summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
Commit message (Collapse)AuthorAge
* avcodec/utils: don't return negative values in av_get_audio_frame_duration()James Almer2021-08-06
| | | | | | | | | | | In some extrme cases, like with adpcm_ms samples with an extremely high channel count, get_audio_frame_duration() may return a negative frame duration value. Don't propagate it, and instead return 0, signaling that a duration could not be determined. Fixes ticket #9312 Signed-off-by: James Almer <jamrial@gmail.com>
* Remove obsolete version.h inclusionsAndreas Rheinhardt2021-07-22
| | | | | | | These have mostly been added because of FF_API_*; yet when these were removed, removing the header has been forgotten. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/avcodec: Stop including channel_layout.h in avcodec.hAndreas Rheinhardt2021-07-22
| | | | | | Also include channel_layout.h directly wherever used. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/utils: Use 64bit for intermediate in AV_CODEC_ID_ADPCM_THP* duration ↵Michael Niedermayer2021-06-29
| | | | | | | | | | calculation Fixes: signed integer overflow: 486539264 * 14 cannot be represented in type 'int' Fixes: 35281/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-6068262742917120 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: do "calc from frame_bytes, channels, and block_align" in 64bitMichael Niedermayer2021-06-12
| | | | | | | | Fixes: signed integer overflow: 104962766 * 32 cannot be represented in type 'int' Fixes: 33614/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-6252129036664832 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: don't use ff_fast_mallocz() in av_fast_padded_malloc()James Almer2021-05-27
| | | | | | It will be removed in the next commit. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: Implement Acorn Replay IMA ADPCM decoderCameron Cawley2021-05-09
| | | | Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avcodec/utils: treat PAL8 for jpegs similar to other colorspacesMichael Niedermayer2021-05-04
| | | | | | | | | | | | Fixes: out of array access Fixes: 33713/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-5778775641030656 Fixes: 33717/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-4960397238075392 Fixes: 33718/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-5314270096130048.fuzz Fixes: 33719/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-5352721864589312 Fixes: 33721/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-5938892055379968 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: Remove remnants of user-visiable HW acceleration APIAndreas Rheinhardt2021-04-27
| | | | | | | Disabled and deprecated in 3536a3efb9fde88d34d526a51b1080247326cd6e. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: Remove deprecated av_codec_get_tag_stringAndreas Rheinhardt2021-04-27
| | | | | | | Deprecated in f156d35321bb600b2309b78185d600b2fa64d84a. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: Remove unneeded getters and settersAndreas Rheinhardt2021-04-27
| | | | | | | Deprecated in c4131a0613c4b2c30c01b2550b41068815d27799. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/utils: Check ima wav duration for overflowMichael Niedermayer2021-04-20
| | | | | | | | Fixes: signed integer overflow: 44331634 * 65 cannot be represented in type 'int' Fixes: 32120/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-5760221223583744 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: move core AVCodecContext functions from util.c to a new fileJames Almer2021-03-19
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: move AVCodecParameters related functions from util.c to a new fileJames Almer2021-03-19
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* 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: 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: 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/utils: free last_pkt_props on avcodec_open2() failureJames Almer2021-03-03
| | | | | | Regression since b34d1de8dc Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: port last_pkt_props to AVFifoBufferJames Almer2021-03-03
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: add SGA PCM decoderPaul B Mahol2021-03-01
|
* avcodec/utils: unbreak BINKAUDIO_DCT duration calculationPaul B Mahol2021-02-04
|
* lavc: shedule old encoding/decoding API for removalAnton Khirnov2021-01-26
| | | | | | | | It has been deprecated for 4 years and certain new codecs do not work with it. Also include AVCodecContext.refcounted_frames, as it has no effect with the new API.
* avcodec/utils: Check for integer overflow in get_audio_frame_duration() for ↵Michael Niedermayer2021-01-23
| | | | | | | | | | ADPCM_DTK Fixes: signed integer overflow: 131203586 * 28 cannot be represented in type 'int' Fixes: 26817/clusterfuzz-testcase-minimized-ffmpeg_dem_MSF_fuzzer-6296902548848640 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Check bitrate for overflow in get_bit_rate()Michael Niedermayer2020-12-19
| | | | | | | | Fixes: signed integer overflow: 617890810133996544 * 16 cannot be represented in type 'long' Fixes: 26565/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5092054700654592 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Remove ff_codec_open2_recursive()Andreas Rheinhardt2020-12-04
| | | | | | | | | | | | | | | This function existed to enable codecs with non-threadsafe init functions to initialize other codecs despite the fact that normally no two codecs with non-threadsafe init functions can be initialized at the same time (there is a mutex guarding this). Yet there are no users of this function any more as all users have been made thread-safe (switching away from ff_codec_open2_recursive() was required for this as said function requires the caller to hold the lock to the mutex guarding the initializations and this is only true for codecs with the FF_CODEC_CAP_INIT_THREADSAFE flag unset); so remove it. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utils: Require a non zero channels unless AV_CODEC_CAP_CHANNEL_CONF ↵Michael Niedermayer2020-11-28
| | | | | | | | | | | | | | | | is set This avoids per codec checks for channels not being 0 Fixes: division by 0 Fixes: 25419/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FASTAUDIO_fuzzer-5632544761184256 Fixes: 25433/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FASTAUDIO_fuzzer-6215671900536832 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Suggested-by: Paul B Mahol <onemda@gmail.com> See: [FFmpeg-devel] [PATCH 1/3] avcodec/fastaudio: Check channel Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: deprecate thread_safe_callbacksAnton Khirnov2020-11-27
| | | | | | | | | They add considerable complexity to frame-threading implementation, which includes an unavoidably leaking error path, while the advantages of this option to the users are highly dubious. It should be always possible and desirable for the callers to make their get_buffer2() implementation thread-safe, so deprecate this option.
* avcodec/utils: clear the packet props queue on flushingJames Almer2020-11-09
| | | | | | | This ensures no queued timestamps or side data are kept and used after seeking, preventing potential desyncs. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: add adpcm_ima_amv encoderZane van Iperen2020-11-09
| | | | | | Fixes ticket #747. Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avcodec/adpcm_ima_amv: restrict to 1 channelZane van Iperen2020-11-09
| | | | | | The format doesn't allow for anything else. Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avcodec/utils: add adpcm_ima_alp to av_get_exact_bits_per_sample()Zane van Iperen2020-11-03
| | | | Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avcodec/utils: Check sample rate before use for AV_CODEC_ID_BINKAUDIO_DCT in ↵Michael Niedermayer2020-10-29
| | | | | | | | | | get_audio_frame_duration() Fixes: shift exponent 95 is too large for 32-bit type 'int' Fixes: 26590/clusterfuzz-testcase-minimized-ffmpeg_dem_SMACKER_fuzzer-5120609937522688 Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc: un-avpriv avpriv_bprint_to_extradata()Anton Khirnov2020-10-28
| | | | | | It has not been used outside of lavc since 6f69f7a8bf6. Also, move it to the only place where it is used.
* avcodec/utils: Check for overflow with ATRAC* in get_audio_frame_duration()Michael Niedermayer2020-10-17
| | | | | | | | Fixes: signed integer overflow: 1024 * 13129048 cannot be represented in type 'int' Fixes: 26378/clusterfuzz-testcase-minimized-ffmpeg_dem_CODEC2RAW_fuzzer-5634018353348608 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: add missing FF_API_TAG_STRING checkJames Almer2020-10-01
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/utils: ReindentationAndreas Rheinhardt2020-10-01
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utils: Also free encoder extradata on avcodec_open2() errorAndreas Rheinhardt2020-10-01
| | | | | | It is owned by libavcodec for encoders. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utils: Don't forget cleaning up when allocating priv_data failsAndreas Rheinhardt2020-10-01
| | | | | | | | | Allocating an AVCodecContext's priv_data used to be the first object allocated in avcodec_open2(), so it was unnecessary to goto free_and_end (which does the cleanup) upon error here. But this is no longer so since f3a29b750a5979ae6847879fba758faf1fae88d0. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utils: Improve check for freeing codec private optionsAndreas Rheinhardt2020-10-01
| | | | | | | | | | Don't check for AVCodec.priv_data_size (which is always true if AVCodec.priv_class is set). Instead check for AVCodecContext.priv_data to actually exist. (Note: av_opt_free(NULL) is a no-op.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utils: Remove always-true checkAndreas Rheinhardt2020-10-01
| | | | | | | | | | | | The first thing avcodec_open2() allocates is the AVCodecInternal. If allocating it fails, a jump to end occurs; but if an error happens after its allocation, a jump to free_and_end happens which frees all allocations performed so far and then jumps to end. Yet free_and_end contained a check for AVCodecInternal (after having already dereferenced it to check whether ff_thread_free() needs to be called) which is of course always true. So remove it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utils: Only call codec->close if init has been calledAndreas Rheinhardt2020-09-29
| | | | | | | | | | | | | | | | | | | | avcodec_open2() also called the AVCodec's close function if an error happened before init had ever been called if the AVCodec has the FF_CODEC_CAP_INIT_CLEANUP flag set. This is against the documentation of said flag: "The codec allows calling the close function for deallocation even if the init function returned a failure." E.g. the SVQ3 decoder is not ready to be closed if init has never been called. Fixes: NULL dereference Fixes: 25762/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SVQ3_fuzzer-5716279070294016 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol <onemda@gmail.com> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: use a packet list to store packet propertiesJames Almer2020-09-15
| | | | | | | | | Keeping only the latest packet fed to the decoder works only for decoders that return a frame immediately after every consumed packet. Decoders that consume several packets before they return a frame will fill said frame with properties taken from the last consumed packet instead of the earliest. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/utils: make the src paramater for ff_thread_ref_frame constJames Almer2020-09-11
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* fftools, libavcodec, libavfilter: Add const to some AVCodec *Andreas Rheinhardt2020-09-11
| | | | | | | | The user has no business modifying the underlying AVCodec. Reviewed-by: Paul B Mahol <onemda@gmail.com> Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec: add FastAudio decoderPaul B Mahol2020-09-03
|
* avcodec: add ADPCM IMA MOFLEX decoderPaul B Mahol2020-09-03
|