1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-18 03:19:31 +02:00
Commit Graph

105991 Commits

Author SHA1 Message Date
Andreas Rheinhardt
10e520f1f1 avcodec/pngdec: Cleanup generically on init failure
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-11 06:52:12 +01:00
Jiasheng Jiang
c4d63dbc94 avcodec/vp6: return value check for av_mallocz
As the potential failure of the av_mallocz(), the 's->alpha_context'
could be NULL and be dereferenced later.
Therefore, it should be better to check it and deal with it if fails
in order to prevent memory leak, same as the av_frame_alloc() in
ff_vp56_init().

Fixes: 39a3894ad5 ("lavc/vp6: Implement "slice" threading for VP6A decode")
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
2022-02-11 16:29:50 +11:00
Gyan Doshi
b6bb6b9f22 avformat/mpegts: initialize max_packet_size when sub-demuxer
bca30570d2 added a user option to set max_packet_size replacing
a hardcoded value. This had a side-effect of leaving the field
set to 0 when packet demuxing is carried out from another demuxer
using avpriv functions, which could lead to demux failure.

Hardcoded max_packet_size inside avpriv_mpegts_parse_open to
2048000 to avoid this. Value chosen to be 10x that of default value
to accommodate large payloads.
2022-02-10 16:57:59 +05:30
Paul B Mahol
9bdb476c40 avfilter/vf_avgblur: fix memory leaks if config_input() is called again 2022-02-10 09:22:36 +01:00
Paul B Mahol
9809f318ea avfilter/vf_dblur: fix memory leaks if config_input() is called again 2022-02-10 09:22:36 +01:00
Paul B Mahol
f89cd457ca avfilter/vf_gblur: fix memory leaks if config_input() is called again 2022-02-10 09:22:36 +01:00
Paul B Mahol
a0ede3cb56 avfilter/vf_gblur: use av_freep() 2022-02-10 09:22:36 +01:00
Andreas Rheinhardt
e1edfe6416 avcodec/pthread_frame: Properly unref frame in case of decoding failure
Use ff_thread_release_buffer() instead of av_frame_unref(),
as the former handles the case of non-thread-safe callbacks
properly. (This is possible now that ff_thread_release_buffer()
no longer requires a ThreadFrame.)

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-09 17:22:51 +01:00
Andreas Rheinhardt
02220b88fc avcodec/thread: Don't use ThreadFrame when unnecessary
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>
2022-02-09 17:22:35 +01:00
Andreas Rheinhardt
f025b8e110 avcodec/threadframe: Add ff_thread_(get|release)_ext_buffer()
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>
2022-02-09 17:22:23 +01:00
Andreas Rheinhardt
b3551b6072 avcodec/thread: Move ff_thread_(await|report)_progress to new header
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>
2022-02-09 17:22:16 +01:00
Andreas Rheinhardt
7fc10e273b avcodec/hapdec: Remove always-false check
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-09 17:22:05 +01:00
Andreas Rheinhardt
7bf38eb000 avcodec/pthread_frame: Don't prematurily presume frame-threading
Several of our decoders support both frame- as well as slice-threading;
in case of the latter avctx->internal->thread_ctx points to
a SliceThreadContext, not to a frame-thread PerThreadContext.
So only treat avctx->internal->thread_ctx as the latter after
having checked that frame-threading is active.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-09 17:18:43 +01:00
Michael Niedermayer
ce43e1c581 avcodec/motion_est: fix indention of ff_get_best_fcode()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-02-09 10:54:30 +01:00
Michael Niedermayer
634312a70f avcodec/motion_est: Fix xy indexing on range violation in ff_get_best_fcode()
This codepath seems untested, no testcases change

Found-by: <mkver>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-02-09 10:54:30 +01:00
Michael Niedermayer
bf33a38499 avformat/hls: Use unsigned for iv computation
Fixes: signed integer overflow: 9223372036854775748 + 60 cannot be represented in type 'long'
Fixes: 44417/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-5802443881971712

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-02-09 10:50:35 +01:00
Michael Niedermayer
6ee283d7d0 avcodec/jpeglsdec: Increase range for N in ls_get_code_runterm() by using unsigned
Fixes: left shift of 32768 by 16 places cannot be represented in type 'int'
Fixes: Timeout
Fixes: 44219/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-4679455379947520
Fixes: 44088/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-4885976600674304

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-02-09 10:50:35 +01:00
Michael Niedermayer
5038933977 avformat/matroskadec: Check desc_bytes
Fixes: Division by 0
Fixes: 44035/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-4826721386364928

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-02-09 10:50:35 +01:00
Michael Niedermayer
59328aabd2 avformat/utils: Fix invalid NULL pointer operation in ff_parse_key_value()
Fixes: pointer index expression with base 0x000000000000 overflowed to 0xffffffffffffffff
Fixes: 44012/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-5670607746891776

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-02-09 10:50:35 +01:00
Michael Niedermayer
9c3d2cbb51 avformat/matroskadec: Fix infinite loop with bz decompression
The same check is added to zlib too, it seems not needed there though

Fixes: Infinite loop
Fixes: 43932/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-6175167573786624

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-02-09 10:49:05 +01:00
Michael Niedermayer
948c262099 avformat/utils: keep chapter monotonicity on chapter updates
Updating a chapter with the same id does not break monotonicity
Fixes: Timeout
Fixes: 43727/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4960623367159808

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-02-09 10:26:35 +01:00
Anton Khirnov
aeaefc3728 lavfi/qsvpp: fix after 85c938fa28 2022-02-09 09:40:33 +01:00
Andreas Rheinhardt
8b49436452 avcodec/vp8: Remove always-false check
Since e9b6617579 a codec's close
function is never ever called for a codec whose init function has not
been called; in particular, it is never ever called if the
AVCodecContext's private data has not been allocated.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-09 06:52:41 +01:00
Andreas Rheinhardt
42140010a2 avcodec/hcadec: Mark decoder as init-threadsafe
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-09 06:52:41 +01:00
Andreas Rheinhardt
2c7f25d460 avcodec/hcadec: Fix memleak upon allocation error
An AVFloatDSPContext would leak upon av_tx_init() failure.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-09 06:52:41 +01:00
Gustav Grusell
e78d0810d1 avformat/hls: Implement support for using AVSEEK_FLAG_BACKWARD when seeking
Before, seeking in hls streams would always seek to the next keyframe
after the given timestamp. With this fix, if seeking in videostream and
AVSEEK_FLAG_BACKWARD is set, seeking will be to the first keyframe of
the segment containing the given timestamp. This fixes #7485.

Signed-off-by: Gustav Grusell <gustav.grusell@gmail.com>
2022-02-09 13:49:23 +08:00
Haihao Xiang
2727ff069e lavu/fifo: fix regression
offset_w might be updated after growing the FIFO

Fix ticket #9630

Tested-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
Reviewed-by: mkver
Reviewed-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-02-09 11:04:47 +08:00
Alexander Kanavin
91326dc942 libavutil: include assembly with full path from source root
Otherwise nasm writes the full host-specific paths into .o
output, which breaks binary reproducibility.

Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-02-08 10:42:26 +01:00
Andreas Rheinhardt
67e1013a96 avcodec/cbs_mpeg2: Use smaller scope for variables
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-08 07:11:14 +01:00
Andreas Rheinhardt
70a90fb73e avcodec/internal.h: Move avpriv_find_start_code() to startcode.h
This is by definition the appropriate place for it.
Remove all the now unnecessary libavcodec/internal.h inclusions;
also remove other unnecessary headers from the affected files.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-08 06:22:14 +01:00
Andreas Rheinhardt
27f22f3383 all: Remove unnecessary libavcodec/internal.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-08 06:16:26 +01:00
Andreas Rheinhardt
115ac90ec9 avcodec/cbs_mpeg2: Simplify splitting fragment
avpriv_find_start_code() supports non-contiguous buffers
by maintaining a state that allows to find start codes
that span across multiple buffers; a consequence thereof
is that avpriv_find_start_code() is given a zero-sized
buffer, it does not modify this state, so that it appears
as if a start code was found if the state contained a start code.

This can e.g. happen with Sequence End units in MPEG-2 and
to counter this, cbs_mpeg2_split_fragment() reset the state
when it has already encountered the end of the fragment
in order to add the last unit (if it is only of the form 00 00 01 xy)
only once; it also used a flag to set whether this is the final unit.

Yet this can be improved by simply resetting state unconditionally
(thereby avoiding a branch); the flag can be removed by just checking
whether we have a valid start code (of the next unit to add)
at the end.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-08 06:10:08 +01:00
Andreas Rheinhardt
66d7a21132 avcodec/cbs: Make ff_cbs_insert_unit_data() always append the new unit
All split functions (the only users of this function) only
append units.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-08 06:02:05 +01:00
Andreas Rheinhardt
f183ae787a avcodec/cbs_jpeg: Remove redundant counter
Use -1 as the position in ff_cbs_insert_unit_data()
which implicitly reuses frag->nb_units as the counter.

Also switch to a do-while-loop, as it is more natural
than a for-loop now that the counter is gone.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-08 04:30:02 +01:00
Andreas Rheinhardt
d64e27f521 avcodec/cbs_mpeg2: Remove redundant counter
Use -1 as the position in ff_cbs_insert_unit_data()
which implicitly reuses frag->nb_units as the counter.

Also switch to a do-while-loop, as it is more natural
than a for-loop now that the counter is gone.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-08 04:00:30 +01:00
Aman Karmani
2f299c0b8b avutil: use getauxval(3) for CPU capabilities on linux/android ARM
getauxval is marginally faster, and works even when procfs is not mounted

support on Linux was added in glibc 2.16
support on Android was added in 4.4 (API 20)
fixes #6578

Signed-off-by: Aman Karmani <aman@tmm1.net>
2022-02-07 13:42:40 -08:00
Lynne
04cc7a5548
lavu/tx: wrap missed string in NULL_IF_CONFIG_SMALL
It's the only one that isn't defined through the macros used elsewhere.
2022-02-07 04:23:31 +01:00
Lynne
eac4c3574b
lavu/tx: disable debugging information when CONFIG_SMALL 2022-02-07 03:56:47 +01:00
Lynne
3bbe9c5e38
lavu/tx: refactor assembly codelet definition
This commit does some refactoring to make defining assembly codelets
smaller, and fixes compiler redefinition warnings. It also allows
for other assembly versions to reuse the same boilerplate code as
x86.

Finally, it also adds the out_of_place flag to all assembly codelets.
This changes nothing, as out-of-place operation was assumed to be
available anyway, but this makes it more explicit.
2022-02-07 03:56:45 +01:00
Anton Khirnov
a10f1aec1f avutil/fifo: Deprecate old FIFO API
Users should switch to the superior AVFifo API.

Unfortunately AVFifoBuffer fields cannot be marked as deprecated because
it would trigger a warning wherever fifo.h is #included, due to
inlined av_fifo_peek2().
2022-02-07 00:31:49 +01:00
Anton Khirnov
e6469e68cc ffmpeg: switch to new FIFO API 2022-02-07 00:31:23 +01:00
Anton Khirnov
bdf9ed41fe ffplay: switch to new FIFO API 2022-02-07 00:31:23 +01:00
Anton Khirnov
c65c2ed01d lavfi/vf_deshake_opencl: switch to new FIFO API 2022-02-07 00:31:23 +01:00
Anton Khirnov
85c938fa28 lavfi/qsvvpp: switch to new FIFO API 2022-02-07 00:31:23 +01:00
Anton Khirnov
90eef1c3de lavu/threadmessage: switch to new FIFO API 2022-02-07 00:31:23 +01:00
Anton Khirnov
d1bd189c63 lavu/audio_fifo: switch to new FIFO API 2022-02-07 00:31:23 +01:00
Anton Khirnov
082136209c lavu/audio_fifo: drop an unnecessary include
Nothing in audio_fifo.h uses anything from fifo.h
2022-02-07 00:31:23 +01:00
Anton Khirnov
d46fd9640f lavd/jack: switch to the new FIFO API 2022-02-07 00:31:23 +01:00
Anton Khirnov
36117968ad lavf/async: switch to new FIFO API 2022-02-07 00:31:23 +01:00
Anton Khirnov
70a1774f1a lavf/udp: switch to new FIFO API 2022-02-07 00:31:23 +01:00