aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/utils.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/utils: don't return negative values in av_get_audio_frame_duration()James Almer2021-10-091-2/+4
| | | | | | | | | | | | | 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> (cherry picked from commit e01d306c647b5827102260b885faa223b646d2d1) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Use 64bit for intermediate in AV_CODEC_ID_ADPCM_THP* duration ↵Michael Niedermayer2021-10-091-1/+1
| | | | | | | | | | | | 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> (cherry picked from commit 00ae9b77ef757f82660b4b3d2f490374a4f209fd) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: do "calc from frame_bytes, channels, and block_align" in 64bitMichael Niedermayer2021-10-091-9/+17
| | | | | | | | | | 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> (cherry picked from commit 3447979d08d701581a65f7275425cb1a59302319) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: treat PAL8 for jpegs similar to other colorspacesMichael Niedermayer2021-10-091-0/+10
| | | | | | | | | | | | | | 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> (cherry picked from commit f0ce023ddb8863d16ab650fcc0731851a55db084) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Check ima wav duration for overflowMichael Niedermayer2021-10-091-1/+5
| | | | | | | | | | 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> (cherry picked from commit f40e9b13554d88cbdd6cd2b4a3da2cbea9590f5d) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Use more bits for intermediate for AV_CODEC_ID_ADPCM_MSMichael Niedermayer2021-10-091-1/+1
| | | | | | | | | | 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> (cherry picked from commit 0f441b9063281d8ef5d4c30b10379d08aad8924f) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Check for integer overflow in get_audio_frame_duration() for ↵Michael Niedermayer2021-10-091-1/+4
| | | | | | | | | | | | 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> (cherry picked from commit 2488ba85a0fa5ee4125888258d3d95ce3f03bbb6) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Check sample rate before use for AV_CODEC_ID_BINKAUDIO_DCT in ↵Michael Niedermayer2021-10-091-1/+4
| | | | | | | | | | | | 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> (cherry picked from commit ec7e0d42884b40ce93b6b5e94de5f7849310f8a0) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Check close before calling itMichael Niedermayer2021-01-021-1/+1
| | | | | | | | | | Fixes: NULL pointer dereference Fixes: 15733/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IDF_fuzzer-5658616977162240 Reviewed-by: Paul B Mahol <onemda@gmail.com> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 8df6884832ec413cf032dfaa45c23b1c7876670c)
* avcodec/utils: Check block_alignMichael Niedermayer2020-07-011-0/+5
| | | | | | | | | | | | | Fixes: out of array access Fixes: 18432/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAV2_fuzzer-5675574936207360 Fixes: 18326/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAV2_fuzzer-5071752362721280 Fixes: 18384/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAV1_fuzzer-5769439500304384 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> (cherry picked from commit f011572e66c8dd2f0ac3cb147a769e91f24e0202) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Check sample_rate before opening the decoderMichael Niedermayer2020-07-011-0/+5
| | | | | | | | | | | | | | | Fixes: signed integer overflow: 2 * -1306460384 cannot be represented in type 'int' Fixes: 17685/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_fuzzer-5747390337777664 Fixes: 17688/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INTERPLAY_ACM_fuzzer-5739287210885120 Fixes: 17699/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INTERPLAY_ACM_fuzzer-5678394531905536 Fixes: 17738/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-5763415733174272 Fixes: 17746/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINKAUDIO_RDFT_fuzzer-5703008159006720 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> (cherry picked from commit 75fefb1fb7ac8b423e08a8dca19b19884a325ebf) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Optimize ff_color_frame() using memcpy()Michael Niedermayer2020-07-011-6/+12
| | | | | | | | | | | | 4650975 -> 4493240 dezicycles This optimizes lines 2 and later. Line 1 still uses av_memcpy_backptr() This change originally fixed ossfuzz 10790 but this is now fixed by other optimizations already Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 95e5396919b13a00264466b5d766f80f1a4f7fdc) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Use av_memcpy_backptr() in ff_color_frame()Michael Niedermayer2020-07-011-3/+3
| | | | | | | | | | | Fixes: Timeout (191sec -> 53sec) Fixes: 16908/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5711207859748864 Fixes: 10709/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5630617975259136 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 340ab13504dddb71889f518983174d7bac7cfe96) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Check bits_per_coded_sampleMichael Niedermayer2020-07-011-0/+4
| | | | | | | | | | | | | This avoids the need for each decoder separately having to handle this case Fixes: shift exponent -100663046 is negative Fixes: out of array access Fixes: 15270/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5727829913763840 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit d33414d2ad27a5d2193c9ab0948ba7a282c2f910) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Enforce minimum width also for VP5/6Michael Niedermayer2018-07-081-1/+4
| | | | | | | | | | | Fixes: out of array access Fixes: poc_0411 Found-by: GwanYeong Kim <gy741.kim@gmail.com> Tested-by: GwanYeong Kim <gy741.kim@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 544324827e0131e43af1a54fb790a48a25fd7ba4) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Avoid hardcoding duplicated types in sizeof()Michael Niedermayer2018-01-131-2/+2
| | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 860d991fcd715233b5b9eb1f6c7bf0aadefb6061) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Fix signed integer overflow in rc_initial_buffer_occupancy ↵Vitaly Buka2017-09-171-1/+1
| | | | | | | | | | | | initialization Signed integer overflow is undefined behavior. Detected with clang and -fsanitize=signed-integer-overflow Signed-off-by: Vitaly Buka <vitalybuka@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 8c2bb10ddfef1f151b9455d152c9aca91140a4b0) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: fix uninitialized variable readwm42017-05-141-1/+1
| | | | | | | | | | This cna happen if the user tries to call the new decode API for subtitles. Fixes CID 1402071. (cherry picked from commit b4b8ca24f62473528949fe047085eb084364124b) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: correct align value for interplayMichael Niedermayer2017-01-261-1/+6
| | | | | | | | | | Fixes out of array access Fixes: 452/fuzz-1-ffmpeg_VIDEO_AV_CODEC_ID_INTERPLAY_VIDEO_fuzzer Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 2080bc33717955a0e4268e738acf8c1eeddbf8cb) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc/utils: avcodec_string: dump field order when knownRodger Combs2016-10-241-0/+14
|
* avcodec/utils: Move emms_c() before memory allocation functions in ↵Michael Niedermayer2016-10-221-1/+2
| | | | | | avcodec_encode_video2() Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: Clear MMX state before returning from avcodec_default_execute*()Michael Niedermayer2016-10-211-0/+2
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/utils: print Chroma Location string in verbose log levelJames Almer2016-10-161-1/+1
| | | | | | | | It's container level information on some formats (Matroska, MXF, yuv4mpeg), so it should be printed at higher log levels than debug. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* Merge commit '32c8359093d1ff4f45ed19518b449b3ac3769d27'Hendrik Leppkes2016-10-071-4/+20
|\ | | | | | | | | | | | | * commit '32c8359093d1ff4f45ed19518b449b3ac3769d27': lavc: export the timestamps when decoding in AVFrame.pts Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * lavc: export the timestamps when decoding in AVFrame.ptsAnton Khirnov2016-06-211-0/+10
| | | | | | | | | | | | | | | | | | | | | | Currently it's exported as AVFrame.pkt_pts, which is also the only use for that field. The reason it is done like this is that lavc used to export various codec-specific "timing" information in AVFrame.pts, which is not done anymore. Since it is confusing to the callers to have a separate field which is used only for decoder timestamps and nothing else, deprecate pkt_pts and use just AVFrame.pts everywhere.
* | lavc: set best effort timestamp if unset when using new decode APIwm42016-10-051-1/+8
| | | | | | | | | | Some API users (in particular ffmpeg.c) check the best effort timestamp only.
* | lavc/utils: disallow zero sized packets with data set in avcodec_send_packetMarton Balint2016-10-031-0/+3
| | | | | | | | | | | | Reviewed-by: wm4 <nfxjfg@googlemail.com> Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* | ffmpeg: move subframe warning to libavcodecwm42016-10-011-0/+6
| | | | | | | | | | | | | | | | | | | | | | With the new decode API, doing this in ffmpeg.c is impractical. There was resistance against removing the warning, so put it into libavcodec. Not bothering with reducing the warning to verbose log level for subsequent wanrings. The warning should be rare, and only happen when developing new codecs for the old API. Includes a change suggested by Michael Niedermayer.
* | lavc/utils.c: Subtract skip_samples when frame is DISCARDed.Sasi Inguva2016-09-291-9/+7
| | | | | | | | | | Signed-off-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit 'e85f6f7f8d037c0af0f294000718d9ba22753baa'James Almer2016-09-281-0/+15
|\| | | | | | | | | | | | | | | | | | | | | * commit 'e85f6f7f8d037c0af0f294000718d9ba22753baa': lavc: allow using AVCodecContext.hw_frames_ctx for decoding Conflicts: doc/APIchanges libavcodec/version.h Merged-by: James Almer <jamrial@gmail.com>
| * lavc: allow using AVCodecContext.hw_frames_ctx for decodingAnton Khirnov2016-06-211-0/+15
| | | | | | | | | | For now it will only be used by the default get_buffer2 callback for allocating hw frames.
* | avcodec/utils: If using discard frame flag, ignore skip_samples set by the ↵Sasi Inguva2016-09-191-0/+4
| | | | | | | | | | | | decoder Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | lavc: Add a flag in AVPacket to discard packet after decoding. Discard ↵Sasi Inguva2016-09-191-1/+14
| | | | | | | | | | | | | | frames after decoding based on the flag. Signed-off-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/utils: print only the padding values that are setJames Almer2016-09-031-4/+7
| | | | | | | | | | Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* | avcodec/utils: print initial and trailing paddings only in verbose levelsJames Almer2016-09-031-1/+2
| | | | | | | | | | Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* | avcodec: add 64-bit signed pcm codecPaul B Mahol2016-08-181-0/+3
| |
* | lavc: add trailing_padding to AVCodecContext to match AVCodecParameters.Jon Toohill2016-08-161-17/+23
| | | | | | | | | | | | Shows encoder delay/padding in the stream summary if they are set. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/utils: only warn when passed invalid lowres valueAman Gupta2016-08-121-3/+2
| | | | | | | | | | | | | | | | | | This makes it easier to use the lowres option when dealing with input files in different codecs. If the codec doesn't support lowres=1 for instance, it will throw a warning and use lowres=0 instead of erroring out completely. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit 'e62ff72fc1052273deb708ba715f73e5187281d4'Clément Bœsch2016-06-221-0/+7
|\| | | | | | | | | | | | | * commit 'e62ff72fc1052273deb708ba715f73e5187281d4': lavc: make avcodec_open2() fail when the timebase is not set for encoding Merged-by: Clément Bœsch <u@pkh.me>
| * lavc: make avcodec_open2() fail when the timebase is not set for encodingAnton Khirnov2016-05-161-0/+7
| | | | | | | | | | Many encoders use it. There is also a divide by the timebase lower in this function, which would crash when it is not set.
* | libavcodec: factor out SEI generation for A53 captionsAndrey Turkin2016-06-191-0/+43
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/utils: check skip_samples signednessMichael Niedermayer2016-06-071-1/+1
| | | | | | | | | | | | Fixes Ticket5528 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/utils: initialize delay in avcodec_parameters_to_context()Michael Niedermayer2016-06-041-0/+1
| | | | | | | | | | | | | | Fixes lost codec delayy Should fix Ticket5509 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec: add adpcm MTAF decoderPaul B Mahol2016-05-211-0/+2
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | avcodec/utils: Move avctx->codec check before its useMichael Niedermayer2016-05-201-2/+3
| | | | | | | | | | | | Fixes CID1361954 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec: add Direct Stream Transfer (DST) decoderPeter Ross2016-05-151-0/+2
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | Merge commit 'd12b5b2f135aade4099f4b26b0fe678656158c13'Derek Buitenhuis2016-05-111-20/+0
|\| | | | | | | | | | | | | | | * commit 'd12b5b2f135aade4099f4b26b0fe678656158c13': build: Split test programs off into separate files Some conversions done by: James Almer <jamrial@gmail.com> Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * lavc: introduce a new decoding/encoding API with decoupled input/outputwm42016-03-231-2/+279
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, the decoding API was restricted to outputting 0 or 1 frames per input packet. It also enforces a somewhat rigid dataflow in general. This new API seeks to relax these restrictions by decoupling input and output. Instead of doing a single call on each decode step, which may consume the packet and may produce output, the new API requires the user to send input first, and then ask for output. For now, there are no codecs supporting this API. The API can work with codecs using the old API, and most code added here is to make them interoperate. The reverse is not possible, although for audio it might. Signed-off-by: Anton Khirnov <anton@khirnov.net>
| * lavc: factor apply_param_change() AV_EF_EXPLODE handlingwm42016-03-051-13/+15
| | | | | | | | | | | | Remove the duplicated code for handling failure of apply_param_change(). Signed-off-by: Anton Khirnov <anton@khirnov.net>
* | lavc: override decode return value only in case of errorClément Bœsch2016-05-011-1/+3
| | | | | | | | | | | | Fixes Ticket #5350 Regression since 29412821241050c846dbceaad4b9752857659977.