1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

97383 Commits

Author SHA1 Message Date
Paul B Mahol
4457f75c65 avfilter: add maskedthreshold filter 2020-04-18 12:34:49 +02:00
Paul B Mahol
9987f6d01e avfilter: add tmedian filter 2020-04-18 12:34:49 +02:00
Peter Ross
55d830f69a avcodec/pngdec: set return value on av_stereo3d_create_side_data() failure
Signed-off-by: Peter Ross <pross@xvid.org>
Reviewed-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2020-04-18 10:16:55 +10:00
Andreas Rheinhardt
1d15e4208f avformat/flacenc: Don't allocate updated streaminfo separately
It is a small buffer of a known, fixed size and so it should simply be
put into the muxer's context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-18 01:53:31 +02:00
Andreas Rheinhardt
9311ece7d3 avformat/flacenc: Only update streaminfo if it has changed
An AVStream's codecpar is supposed to be filled by the caller before
avformat_write_header(); if the CodecParameters change, the caller
should signal this via packet side data, but not touch the AVStream's
codecpar.

The FLAC muxer checks for packet side data containing updated extradata,
yet if nothing has arrived by the time the trailer is written, the
already written extradata is overwritten by the very same extradata
again, unless the output is unseekable, in which case a warning that the
FLAC header can't be rewritten is emitted.

This commit changes this by only trying to rewrite the extradata if a
new streaminfo arrived via packet side data. Only then is a warning
emitted in case the output is unseekable.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-18 01:39:53 +02:00
Andreas Rheinhardt
e79309fde6 libavformat/mux, mxfenc: Don't initialize unnecessarily
When no packet could be output, the interleavement functions
nevertheless initialized the packet destined for output (with the
exception of the data and size fields, making the initialization
pointless), although it will not be used at all. So remove the
initializations.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-18 01:24:56 +02:00
Andreas Rheinhardt
148bcc0bc5 avformat/mux: Remove pointless timestamp backups
write_packet() currently saves the original timestamps of the packet it
got and restores them in case writing fails. This is unnecessary as we
are no longer working directly with the user-supplied AVPacket here; and
it is also pointless because the timestamps may already have been
altered before write_packet().

So remove this and add a general comment to the function that timestamps
may be modified; also remove a long outdated comment about side data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-18 01:09:58 +02:00
Andreas Rheinhardt
fe251f77c8 avformat/mux: Don't modify packets we don't own
The documentation of av_write_frame() explicitly states that the function
doesn't take ownership of the packets sent to it; while av_write_frame()
does not directly unreference the packets after having written them, it
nevertheless modifies the packet in various ways:
1. The timestamps might be modified either by prepare_input_packet() or
compute_muxer_pkt_fields().
2. If a bitstream filter gets applied, it takes ownership of the
reference and the side-data in the packet sent to it.
In case of do_packet_auto_bsf(), the end result is that the returned packet
contains the output of the last bsf in the chain. If an error happens,
a blank packet will be returned; a packet may also simply not lead to
any output (vp9_superframe).
This also implies that side data needs to be really copied and can't be
shared with the input packet.
The method choosen here minimizes copying of data: When the input isn't
refcounted and no bitstream filter is applied, the packet's data will
not be copied.

Notice that packets that contain uncoded frames are exempt from this
because these packets are not owned by and returned to the user. This
also moves unreferencing the packets containing uncoded frames to
av_write_frame() in the noninterleaved codepath; in the interleaved
codepath, these packets are already freed in av_interleaved_write_frame(),
so that unreferencing the packets in write_uncoded_frame_internal() is
no longer needed. It has been removed.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-18 00:56:35 +02:00
Andreas Rheinhardt
00aa6dea3f avformat/mux: Remove redundant resetting
Now that ff_interleave_add_packet() always returns blank packets, the
input packet to ff_interleave_packet_per_dts() will always be blank on
return as well (if supplied) and the same goes for interleave_packet()
in mux.c. Document these facts and remove the redundant resetting that
happened in av_interleaved_write_frame().

The last reference to the (long removed) destruct field that AVPackets
once had has been removed as well when updating the documentation of
ff_interleave_packet_per_dts().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-18 00:41:27 +02:00
Andreas Rheinhardt
a43120b609 avformat/mux: Fix leak when adding packet to interleavement queue fails
When an error happened in ff_interleave_add_packet() when adding
a packet to the packet queue, said packet would not be unreferenced
in ff_interleave_add_packet(), but would be zeroed in
av_interleaved_write_frame(), which results in a memleak.

This has been fixed: ff_interleave_add_packet() now always unreferences
the input packet on error; as a result, it always returns blank packets
which has been documented. Relying on this a call to av_packet_unref()
in ff_audio_rechunk_interleave() can be removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-18 00:22:22 +02:00
Andreas Rheinhardt
1004a92cd4 avformat/mux: Fix leaks on error when writing noninterleaved uncoded frames
If writing uncoded frames in noninterleaved mode fails at the preparatory
steps (i.e. before it reaches write_packet()), the packet would not be
unreferenced and the frame would leak. This is fixed by unreferencing
the packet in write_uncoded_frame_internal() instead.

This also makes it possible to remove the unreferencing in
write_packet() itself: In noninterleaved mode frames are now freed in
write_uncoded_frame_internal(), while they are freed in interleaved
mode when their containing packet gets unreferenced (like normal
packets).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-18 00:14:05 +02:00
Andreas Rheinhardt
ad1dc918a0 avformat/mux: Make uncoded frames av_packet_unref() compatible
Currently uncoded frames (i.e. packets whose data actually points to an
AVFrame) are not refcounted. As a consequence, calling av_packet_unref()
on them will not free them, but may simply make sure that they leak by
losing the pointer to the frame.

This commit changes this by actually making uncoded frames refcounted.
In order not to rely on sizeof(AVFrame) (which is not part of the public
API and so must not be used here in libavformat) the packet's data is
changed to a (padded) buffer containing just a pointer to an AVFrame.
Said buffer is owned by an AVBuffer with a custom free function that
frees the frame as well as the buffer. Thereby the pointer/the AVBuffer
owns the AVFrame.

Said ownership can actually be transferred by copying and resetting
the pointer, as might happen when actually writing the uncoded frames
in AVOutputFormat.write_uncoded_frame() (although currently no muxer
makes use of this possibility).

This makes packets containing uncoded frames compatible with
av_packet_unref(). This already has three advantages in interleaved mode:
1. If an error happens at the preparatory steps (before the packet is
put into the interleavement queue), the frame is properly freed.
2. If the trailer is never written, the frames still in the
interleavement queue will now be properly freed by
ff_packet_list_free().
3. The custom code for moving the packet to the packet list in
ff_interleave_add_packet() can be removed.

It will also simplify fixing further memleaks in future commits.

Suggested-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-18 00:04:04 +02:00
Marton Balint
7d89445473 avcodec/bsf: use simplified algorithm for bsf_list chained filtering
Based on the one in ffmpeg.c and it is not using an extra flush_idx variable.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-17 21:26:55 +02:00
Limin Wang
403bee30a5 avfilter/af_acrossover: Check sscanf() return value
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-04-17 16:56:13 +02:00
Paul B Mahol
24db9372eb avfilter/af_astats: add noise floor count stat 2020-04-17 13:28:01 +02:00
Paul B Mahol
715da29501 avfilter/af_astats: add slice threading support 2020-04-17 13:26:44 +02:00
Paul B Mahol
87b4fb65a8 avfilter/af_astats: measure noise floor 2020-04-17 13:26:30 +02:00
Peter Ross
1b59f3f844 avcodec/mv30: use aandcttables 2020-04-17 19:34:02 +10:00
Peter Ross
06dab51e68 avcodec/mv30: remove unused table elements 2020-04-17 19:34:02 +10:00
Peter Ross
3e5f0cf271 avcodec/vp3: fix indentation 2020-04-17 19:33:43 +10:00
Andreas Rheinhardt
889ad93c88 fftools/ffmpeg_opt: Check attachment filesize
The data of an attachment file is put into an AVCodecParameter's
extradata. The corresponding size field has type int, yet there was no
check for the size to fit into an int. As a consequence, it was possible
to create extradata with negative size (by using a big enough max_alloc).

Other errors were also possible: If SIZE_MAX < INT64_MAX (e.g. on 32bit
systems) then the file size might be truncated before the allocation;
and avio_read() takes an int, too, so one would not have read as much
as one desired.

Furthermore, the extradata is now padded as is required.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-17 01:34:07 +02:00
Marton Balint
d1e52e396b avutil/log: update text requesting samples
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-17 00:08:56 +02:00
Marton Balint
2a118a71cf avdevice/opengl: add support of wrapped avframe codec
Also change the default to that.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-16 23:52:12 +02:00
Marton Balint
e4ce40d25b avdevice/xv: add support of wrapped avframe codec
Also change the default to that.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-16 23:52:12 +02:00
James Almer
fccd6c2be0 avcodec: add a WebP parser
Based on code from the BMP parser.

Addresses ticket #8574

Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-16 15:05:07 -03:00
Michael Niedermayer
8e30502abe avcodec/ac3dec_fixed: Fix several invalid left shifts in scale_coefs()
Fixes: left shift of negative value -14336
Fixes: 20298/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AC3_FIXED_fuzzer-5675484201615360

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-16 00:56:49 +02:00
Michael Niedermayer
55f9683cf6 avcodec/flac_parser: Do not lose header count in find_headers_search()
Fixes: Timeout
Fixes: out of array access
Fixes: 20274/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-5649631988154368
Fixes: 19275/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-5757535722405888

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-16 00:56:49 +02:00
Michael Niedermayer
abb5762e98 avcodec/audiodsp: Fix integer overflow in scalarproduct_int16_c()
Fixes: signed integer overflow: 2145417478 + 76702564 cannot be represented in type 'int'
Fixes: 20313/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RA_144_fuzzer-5734487724130304

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-16 00:56:49 +02:00
Philip Langdale
22b25b3ea5 avcodec: Add explicit capability flag for encoder flushing
Previously, there was no way to flush an encoder such that after
draining, the encoder could be used again. We generally suggested
that clients teardown and replace the encoder instance in these
situations. However, for at least some hardware encoders, the cost of
this tear down/replace cycle is very high, which can get in the way of
some use-cases - for example: segmented encoding with nvenc.

To help address that use case, we added support for calling
avcodec_flush_buffers() to nvenc and things worked in practice,
although it was not clearly documented as to whether this should work
or not. There was only one previous example of an encoder implementing
the flush callback (audiotoolboxenc) and it's unclear if that was
intentional or not. However, it was clear that calling
avocdec_flush_buffers() on any other encoder would leave the encoder in
an undefined state, and that's not great.

As part of cleaning this up, this change introduces a formal capability
flag for encoders that support flushing and ensures a flush call is a
no-op for any other encoder. This allows client code to check if it is
meaningful to call flush on an encoder before actually doing it.

I have not attempted to separate the steps taken inside
avcodec_flush_buffers() because it's not doing anything that's wrong
for an encoder. But I did add a sanity check to reject attempts to
flush a frame threaded encoder because I couldn't wrap my head around
whether that code path was actually safe or not. As this combination
doesn't exist today, we'll deal with it if it ever comes up.
2020-04-15 14:54:42 -07:00
James Almer
e6fb3aba42 avformat/dashenc: fix typo in ProducerReferenceTime elements
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-15 17:09:34 -03:00
Carl Eugen Hoyos
d727fea4da lavc/jpeg2000dec: Cosmetics, re-indent after last commit. 2020-04-15 20:03:33 +02:00
Carl Eugen Hoyos
cbe3f1b1fb lavc/jpeg2000dec: Allow to force a compatible pix_fmt.
This copies the behaviour of the libopenjpeg decoder.
Fixes ticket #5919.
2020-04-15 20:00:51 +02:00
Carl Eugen Hoyos
d5bf704f50 ffmpeg: Do not clip timestamps at LONG_MAX.
Fixes ticket #8612.
2020-04-15 19:59:13 +02:00
James Almer
e7eb379d98 avformat/movenc: remove call to av_copy_packet_side_data() when concatenating eac3 syncframes
This generates a potential memory leak, and mixes side data from the last
packet with other properties from the first.

Keep all the properties from the first packet only in the output packet
instead.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-15 14:12:38 -03:00
Michael Niedermayer
18f5256c0d avcodec/cbs_jpeg_syntax_template: Check array index in huffman_table()
Fixes: index 224 out of bounds for type 'uint8_t [224]'
Fixes: 21534/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-6291612167831552

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-15 18:48:23 +02:00
Michael Niedermayer
d31862c2b1 avcodec/cbs_jpeg_syntax_template: Check table index before use in dht()
Fixes: out of array access
Fixes: 21515/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5766121576988672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-15 18:48:23 +02:00
Josh de Kock
07ecc4615c configure: fix clang on macOS 10.15
Works around a bug in the newer Xcode 11's clang with -fstack-check
emitting bad code with misaligned call instructions.

This fixes Trac #8073
2020-04-15 15:45:31 +01:00
Matthieu Bouron
5216edbc54 avcodec/mediacodec_wrapper: fix {input,output}_buffers global reference leak
Fixes ticket #8607.

Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
2020-04-15 09:43:16 +02:00
Steven Liu
51db0a472a avformat/dashdec: add attribute lang for audio and subtitle streams
There should have language in the metadata of streams which show to user

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2020-04-15 12:45:23 +08:00
Steven Liu
152f61e29b avformat/hlsenc: add hls_fmp4_init_resend option
add option for resend init file after m3u8 refresh everytime.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2020-04-15 12:45:16 +08:00
Ming Qian
8ac8e905e9 avcodec/v4l2_m2m: handle v4l2 end of stream event
When flushing the capture buffers, the driver may send a V4L2_EVENT_EOS
to notify that draining is completed. Currently, v4l2_m2m does not
subscribe to this event, which can cause some devices (i.e. imx8qm) to
hang at the end of encoding/decoding. Support for handling the event is
added in this commit.

Some devices may not signal V4L2_EVENT_EOS. This is logged as a warning
message during initialization and not treated as a fatal error.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-04-14 23:42:05 -04:00
Paul B Mahol
0607f1bcb0 avfilter/af_amix: unbreak FATE, increase iterator when breaking from loop 2020-04-14 19:21:23 +02:00
Andreas Rheinhardt
40a9363033 avformat/filmstripenc: Use ff_raw_write_packet()
The only difference of the currently used write_packet()-function to
ff_raw_write_packet() is that the former also counts the number of
frames. Yet doing so in the muxer itself is unnecessary as this is
already done generically in write_packet() in libavformat/mux.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-14 19:01:27 +02:00
Andreas Rheinhardt
2cae3f60bf avformat/rso: Don't reimplement ff_raw_write_packet()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-14 18:57:59 +02:00
Andreas Rheinhardt
b5985ce44d avformat/amr: Don't reimplement ff_raw_write_packet()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-14 18:52:44 +02:00
Andreas Rheinhardt
c16611ad69 avformat/Makefile: Don't add dependency twice
as has happened with flac_picture.o and the Matroska demuxer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-14 18:50:54 +02:00
Andreas Rheinhardt
0c0a1d73c2 avformat/Makefile: Remove false dependencies of WebM and Matroska muxer
These muxers don't depend on the WebM Chunk or the WebM DASH Manifest
muxers.

Furthermore, remove some #if checks in webm_chunk.c and webmdashenc.c.
They are always true now that webm_chunk.c and webmdashenc.c are only
compiled when their corresponding muxers are enabled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-14 18:43:44 +02:00
Andreas Rheinhardt
a51d1b3634 avformat/Makefile: Remove false dependency of WebM DASH manifest muxer
It does not use anything from libavformat/matroska.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-14 18:41:28 +02:00
Andreas Rheinhardt
8744f973ab avformat/webmdashenc: Remove unnecessary header
avio_internal.h has been included in this muxer since the beginning and
was never needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-14 18:37:49 +02:00
Andreas Rheinhardt
d8e63ed70e avformat/webm_chunk: Remove superfluous headers
libavutil/avstring.h is unnecessary since 8a632b3e. The other
unnecessary headers were never used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-14 18:33:14 +02:00