ffmpeg.git
7 months agoavfilter/vf_geq: Relicense to LGPL
Michael Niedermayer [Mon, 16 Dec 2019 22:17:11 +0000 (23:17 +0100)]
avfilter/vf_geq: Relicense to LGPL

All authors who have code in this under GPL agreed.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/atrac9dec: Clamp band_ext_data to max that can be read if skipped.
Michael Niedermayer [Mon, 16 Dec 2019 23:19:42 +0000 (00:19 +0100)]
avcodec/atrac9dec: Clamp band_ext_data to max that can be read if skipped.

Fixes: out of array read
Fixes: 19327/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ATRAC9_fuzzer-5679823087468544

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/agm: Include block size in the MV check for flags == 3
Michael Niedermayer [Mon, 16 Dec 2019 22:09:04 +0000 (23:09 +0100)]
avcodec/agm: Include block size in the MV check for flags == 3

Fixes: out of array read
Fixes: 19331/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5644115983466496

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/wmadec: Keep track of exponent initialization per channel
Michael Niedermayer [Sat, 30 Nov 2019 15:46:46 +0000 (16:46 +0100)]
avcodec/wmadec: Keep track of exponent initialization per channel

Fixes: division by 0
Fixes: 19123/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAV2_fuzzer-5655493121146880

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/iff: Check that video_size is large enough for the read parameters
Michael Niedermayer [Sat, 30 Nov 2019 11:22:25 +0000 (12:22 +0100)]
avcodec/iff: Check that video_size is large enough for the read parameters

video is allocated before parameters like bpp are read.

Fixes: out of array access
Fixes: 19084/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5718556033679360
Fixes: 19465/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5759908398235648

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on device
Andriy Gelman [Fri, 27 Dec 2019 23:38:35 +0000 (18:38 -0500)]
avcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on device

Fixes #8079

During initialization of a v4l2m2m device, the configured pix_fmt can be
different to the pix_fmt of the encoder (i.e. avctx->pix_fmt).

For example on the Odroid XU4:
./ffmpeg -f lavfi -i yuvtestsrc -codec:v h264_v4l2m2m out.h264

will configure the v4l2 encoder to pix_fmt nv21, whereas the input
frames will be yuv444p.

This commit checks that the configured v4l2 pix_fmt on device is the
same as avctx->pix_fmt. If they are different the initialization fails
and an error is returned. Tested on RPI4 and Odroid XU4.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
7 months agoavutil/tests/opt: add av_opt_get/av_opt_set tests
Marton Balint [Wed, 25 Dec 2019 20:07:41 +0000 (21:07 +0100)]
avutil/tests/opt: add av_opt_get/av_opt_set tests

Signed-off-by: Marton Balint <cus@passwd.hu>
7 months agoavutil/tests/opt: add tests for AV_OPT_TYPE_DICT
Marton Balint [Wed, 25 Dec 2019 18:35:34 +0000 (19:35 +0100)]
avutil/tests/opt: add tests for AV_OPT_TYPE_DICT

Signed-off-by: Marton Balint <cus@passwd.hu>
7 months agoavutil/opt: add full support for AV_OPT_TYPE_DICT
Marton Balint [Mon, 23 Dec 2019 23:19:47 +0000 (00:19 +0100)]
avutil/opt: add full support for AV_OPT_TYPE_DICT

Now it is possible to set them from a string, to serialize them and to use a
default value.

Signed-off-by: Marton Balint <cus@passwd.hu>
7 months agoavfilter/vf_vibrance: add support for commands
Paul B Mahol [Fri, 27 Dec 2019 20:31:04 +0000 (21:31 +0100)]
avfilter/vf_vibrance: add support for commands

7 months agoavfilter/vf_il: add support for commands
Paul B Mahol [Fri, 27 Dec 2019 20:17:00 +0000 (21:17 +0100)]
avfilter/vf_il: add support for commands

7 months agoavfilter/af_stereowiden: add support for commands
Paul B Mahol [Fri, 27 Dec 2019 20:03:29 +0000 (21:03 +0100)]
avfilter/af_stereowiden: add support for commands

7 months agoavfilter/af_extrastereo: add support for commands
Paul B Mahol [Fri, 27 Dec 2019 19:57:06 +0000 (20:57 +0100)]
avfilter/af_extrastereo: add support for commands

7 months agoavfilter/vf_neighbor: add support for commands
Paul B Mahol [Fri, 27 Dec 2019 19:21:20 +0000 (20:21 +0100)]
avfilter/vf_neighbor: add support for commands

7 months agoavformat/dashdec: propagate icy to child AVIOContexts
Marvin Scholz [Tue, 17 Dec 2019 00:45:04 +0000 (01:45 +0100)]
avformat/dashdec: propagate icy to child AVIOContexts

When the user decides they do not want to to send the Icy-MetaData
header, this should be respected for all requests, not just the first
one.

Fix #5578

Reviewed-by: Liu Steven <lq@chinaffmpeg.org>
Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavformat/hls: propagate icy to child AVIOContexts
Marvin Scholz [Tue, 17 Dec 2019 00:17:42 +0000 (01:17 +0100)]
avformat/hls: propagate icy to child AVIOContexts

When the user decides they do not want to to send the Icy-MetaData
header, this should be respected for all requests, not just the first
one.

Fix #5578

Reviewed-by: Liu Steven <lq@chinaffmpeg.org>
Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavcodec/mvha: fix warning: variable 'size' set but not used
Limin Wang [Fri, 27 Dec 2019 15:58:35 +0000 (23:58 +0800)]
avcodec/mvha: fix warning: variable 'size' set but not used

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavformat/microdvdenc: Use avio_w8 to write a char
Andreas Rheinhardt [Thu, 12 Dec 2019 15:53:18 +0000 (16:53 +0100)]
avformat/microdvdenc: Use avio_w8 to write a char

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/microdvd: Use \n instead of \0 to end file header
Andreas Rheinhardt [Thu, 12 Dec 2019 15:53:17 +0000 (16:53 +0100)]
avformat/microdvd: Use \n instead of \0 to end file header

Up until now, the microdvd demuxer uses av_strdup() to allocate the
extradata from a string; its length is set to strlen() + 1, i.e.
including the \0 at the end. Upon remuxing, the muxer would simply copy
the extradata at the beginning, including the \0.

This commit changes this by not adding the \0 to the size of the
extradata; the muxer now delimits extradata by inserting a \n. This
required to change the subtitles-microdvd-remux FATE-test.

Furthermore, the extradata is now allocated with zeroed padding.

The microdvd decoder is not affected by this, as it didn't use the size
of the extradata at all, but treated it as a C-string.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/flvenc: Fix leak of oversized packets
Andreas Rheinhardt [Thu, 26 Dec 2019 10:53:35 +0000 (11:53 +0100)]
avformat/flvenc: Fix leak of oversized packets

Might happen for annex B H.264.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/flvenc: Forward errors from allocating keyframe index
Andreas Rheinhardt [Thu, 26 Dec 2019 10:53:34 +0000 (11:53 +0100)]
avformat/flvenc: Forward errors from allocating keyframe index

While the function adding a new element to the keyframe index checked
the allocation, the caller didn't check the return value. This has been
changed. To do so, the return value has been changed to an ordinary ret
instead of pb->error. This doesn't pose a problem, as write_packet() in
mux.c already checks for write errors (since 9ad1e0c1).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/wavenc: Add deinit function
Andreas Rheinhardt [Thu, 26 Dec 2019 10:53:27 +0000 (11:53 +0100)]
avformat/wavenc: Add deinit function

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/spdifenc: Replace write_trailer by deinit
Andreas Rheinhardt [Thu, 26 Dec 2019 10:53:26 +0000 (11:53 +0100)]
avformat/spdifenc: Replace write_trailer by deinit

The write_trailer function doesn't write anything anyway. It only frees
memory.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/vc1dec: remove the unneeded ()
Limin Wang [Thu, 26 Dec 2019 01:31:04 +0000 (09:31 +0800)]
avcodec/vc1dec: remove the unneeded ()

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/ass: remove the unneeded ()
Limin Wang [Thu, 26 Dec 2019 01:31:03 +0000 (09:31 +0800)]
avcodec/ass: remove the unneeded ()

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavfilter/vf_histogram: use the name 's' for the pointer to the private context
Paul B Mahol [Thu, 26 Dec 2019 19:45:20 +0000 (20:45 +0100)]
avfilter/vf_histogram: use the name 's' for the pointer to the private context

This is consistent across filters.

7 months agoavcodec/cbs_vp9: Check data_size
Michael Niedermayer [Wed, 25 Dec 2019 23:57:07 +0000 (00:57 +0100)]
avcodec/cbs_vp9: Check data_size

Fixes: out of array access
Fixes: 19542/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5659498341728256

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>
7 months agoavfilter/buffersrc: Remove unused variables
Andreas Rheinhardt [Wed, 25 Dec 2019 11:59:07 +0000 (12:59 +0100)]
avfilter/buffersrc: Remove unused variables

Unused since f09ae730.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavdevice/xcbgrab: use a buffer pool for shared memory segments
Marton Balint [Sat, 7 Dec 2019 19:41:44 +0000 (20:41 +0100)]
avdevice/xcbgrab: use a buffer pool for shared memory segments

Also by wrapping the SHM buffer in an AVBufferRef we eliminate yet another
possible memcpy improving performance.

Signed-off-by: Marton Balint <cus@passwd.hu>
7 months agoavutil/buffer: add av_buffer_pool_buffer_get_opaque
Marton Balint [Sat, 7 Dec 2019 00:56:56 +0000 (01:56 +0100)]
avutil/buffer: add av_buffer_pool_buffer_get_opaque

In order to access the original opaque parameter of a buffer in the buffer
pool. (The buffer pool implementation overrides the normal opaque parameter but
also saves it so it is accessible).

v2: add assertion check before dereferencing the BufferPoolEntry.

Signed-off-by: Marton Balint <cus@passwd.hu>
7 months agoavformat/dhav: improve seeking
Paul B Mahol [Wed, 25 Dec 2019 18:35:27 +0000 (19:35 +0100)]
avformat/dhav: improve seeking

7 months agoavcodec/cbs_vp9: Check index_size
Michael Niedermayer [Fri, 13 Dec 2019 23:27:09 +0000 (00:27 +0100)]
avcodec/cbs_vp9: Check index_size

Fixes: out of array read
Fixes: 19300/clusterfuzz-testcase-minimized-ffmpeg_BSF_VP9_METADATA_fuzzer-5653911730126848

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>
7 months agoavfilter/vf_yadif: cosmetics in the pix_fmts[] array
Limin Wang [Thu, 28 Nov 2019 01:34:17 +0000 (09:34 +0800)]
avfilter/vf_yadif: cosmetics in the pix_fmts[] array

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavfilter/drawtext: log why input pad failed to be configured
Gyan Doshi [Mon, 23 Dec 2019 16:10:02 +0000 (21:40 +0530)]
avfilter/drawtext: log why input pad failed to be configured

7 months agoavformat/sccdec: only change duration for last subtitle
Paul B Mahol [Mon, 23 Dec 2019 21:47:27 +0000 (22:47 +0100)]
avformat/sccdec: only change duration for last subtitle

7 months agoavformat/sccdec: fix sub->pos values
Paul B Mahol [Mon, 23 Dec 2019 21:39:46 +0000 (22:39 +0100)]
avformat/sccdec: fix sub->pos values

7 months agoavformat/sccdec: fix timestamp of last subtitle
Paul B Mahol [Mon, 23 Dec 2019 21:15:23 +0000 (22:15 +0100)]
avformat/sccdec: fix timestamp of last subtitle

Fixes -c:s copy case.

7 months agoavfilter/vf_fade: reindent after previous commit
Paul B Mahol [Mon, 23 Dec 2019 19:24:36 +0000 (20:24 +0100)]
avfilter/vf_fade: reindent after previous commit

7 months agoavfilter/vf_fade: add support for gbrp/gbrap formats
Paul B Mahol [Tue, 19 Nov 2019 13:09:42 +0000 (14:09 +0100)]
avfilter/vf_fade: add support for gbrp/gbrap formats

7 months agolavc/midivid: check return value of init_get_bits8()
Zhong Li [Mon, 23 Dec 2019 14:14:09 +0000 (14:14 +0000)]
lavc/midivid: check return value of init_get_bits8()

Fix CID 1456088

Signed-off-by: Zhong Li <zhongli_dev@126.com>
7 months agoavfilter/vf_readeia608: factor some constants out
Paul B Mahol [Mon, 23 Dec 2019 19:07:49 +0000 (20:07 +0100)]
avfilter/vf_readeia608: factor some constants out

7 months agoavfilter/vf_readeia608: check if gaps between clock bits are big enough
Paul B Mahol [Mon, 23 Dec 2019 18:56:05 +0000 (19:56 +0100)]
avfilter/vf_readeia608: check if gaps between clock bits are big enough

Should help finding less false positives.

7 months agoavfilter/vf_readeia608: use special struct to hold line items
Paul B Mahol [Mon, 23 Dec 2019 11:28:30 +0000 (12:28 +0100)]
avfilter/vf_readeia608: use special struct to hold line items

7 months agoavfilter/avfilter: update documentation of avfilter_graph_create_filter
Zhao Zhili [Fri, 6 Dec 2019 07:06:18 +0000 (15:06 +0800)]
avfilter/avfilter: update documentation of avfilter_graph_create_filter

7 months agoavfilter/buffersink: deprecate AVBufferSinkParams and AVABufferSinkParams
Zhao Zhili [Fri, 6 Dec 2019 07:06:17 +0000 (15:06 +0800)]
avfilter/buffersink: deprecate AVBufferSinkParams and AVABufferSinkParams

7 months agoavfilter/buffersink: replace init_opaque by init
Zhao Zhili [Fri, 6 Dec 2019 07:06:16 +0000 (15:06 +0800)]
avfilter/buffersink: replace init_opaque by init

The argument 'opaque' is always NULL since 0acf7e2 (2013),
and avfilter_init_filter() was removed in 52067b3c0e (2016).

7 months agoavfilter/buffersink: remove unused macros
Zhao Zhili [Fri, 6 Dec 2019 07:06:15 +0000 (15:06 +0800)]
avfilter/buffersink: remove unused macros

7 months agoavfilter/buffersrc: remove redundant flag
Zhao Zhili [Wed, 4 Dec 2019 13:41:07 +0000 (21:41 +0800)]
avfilter/buffersrc: remove redundant flag

!(c->pix_fmt != AV_PIX_FMT_NONE || c->got_format_from_params)

equals

(c->pix_fmt == AV_PIX_FMT_NONE) && !c->got_format_from_params

1. When (c->pix_fmt == AV_PIX_FMT_NONE) is true, got_format_from_params is
always false, the flag doesn't contribute to the result.

2. When the first part is false, the second part doesn't matter, the flag
doesn't contribute to the result.

The result only depends on c->pix_fmt.

7 months agoavformat/mpegtsenc: warn users if codec isn't supported
Gyan Doshi [Fri, 20 Dec 2019 11:09:32 +0000 (16:39 +0530)]
avformat/mpegtsenc: warn users if codec isn't supported

The MPEG-TS muxer will mux streams with unsupported codec id
as a private data stream; this usually makes the stream
not recognizable by ffmpeg and likely other tools.

7 months agoavcodec/noise_bsf: remove superfluous fail label
James Almer [Mon, 23 Dec 2019 14:43:57 +0000 (11:43 -0300)]
avcodec/noise_bsf: remove superfluous fail label

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoChangelog: Fix typo of comments
Steven Liu [Sat, 21 Dec 2019 06:32:21 +0000 (14:32 +0800)]
Changelog: Fix typo of comments

Signed-off-by: Steven Liu <lq@onvideo.cn>
Reviewed-by: Lou Logan <lou@lrcd.com>
7 months agolavfi/buffersrc: push frame directly.
Nicolas George [Mon, 2 Dec 2019 16:01:50 +0000 (17:01 +0100)]
lavfi/buffersrc: push frame directly.

This allows to remove the queued frame entirely.

7 months agolavfi: remove AVFilterPad.poll_frame().
Nicolas George [Mon, 2 Dec 2019 15:46:11 +0000 (16:46 +0100)]
lavfi: remove AVFilterPad.poll_frame().

This design is no longer used and was replaced a long time ago.

7 months agolavfi/buffersrc: remove poll_frame.
Nicolas George [Mon, 2 Dec 2019 15:42:59 +0000 (16:42 +0100)]
lavfi/buffersrc: remove poll_frame.

7 months agolavfi: remove ff_poll_frame().
Nicolas George [Mon, 2 Dec 2019 15:41:07 +0000 (16:41 +0100)]
lavfi: remove ff_poll_frame().

It is never used.

7 months agolavfi/buffersrc: remove fifo.
Nicolas George [Mon, 2 Dec 2019 15:38:19 +0000 (16:38 +0100)]
lavfi/buffersrc: remove fifo.

The frame is immediately pushed, the fifo has never more than one.

7 months agoavfilter/vf_readeia608: fix check for failed av_calloc
Limin Wang [Mon, 23 Dec 2019 04:55:58 +0000 (12:55 +0800)]
avfilter/vf_readeia608: fix check for failed av_calloc

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavformat/hls: Use av_packet_move_ref() for packet ownership transfer
Andreas Rheinhardt [Tue, 3 Dec 2019 10:27:38 +0000 (11:27 +0100)]
avformat/hls: Use av_packet_move_ref() for packet ownership transfer

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavformat/hlsenc: Fix check for presence of webvtt muxer
Andreas Rheinhardt [Mon, 16 Dec 2019 00:04:15 +0000 (01:04 +0100)]
avformat/hlsenc: Fix check for presence of webvtt muxer

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Steven Liu <lq@onvideo.cn>
7 months agoavformat/hlsenc: Fix memleaks with repeating parameters
Andreas Rheinhardt [Mon, 16 Dec 2019 00:04:13 +0000 (01:04 +0100)]
avformat/hlsenc: Fix memleaks with repeating parameters

When a parameter like e.g. language is contained more than once in the
part of var_stream_map pertaining to a single VariantStream, the later
one just overwrites the pointer to the earlier one, leading to a
memleak. This commit changes this by handling the situation gracefully:
The earlier string is silently freed first, so that the last one wins.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Steven Liu <lq@onvideo.cn>
7 months agoavformat/hlsenc: Fix return value from localtime_r failure
Andreas Rheinhardt [Mon, 16 Dec 2019 00:04:12 +0000 (01:04 +0100)]
avformat/hlsenc: Fix return value from localtime_r failure

"If an error is detected, localtime_r() shall return a null pointer
and set errno to indicate the error." Yet in case this happened in
hls_init(), AVERROR(ENOMEM) has been returned.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Steven Liu <lq@onvideo.cn>
7 months agoavformat/hlsenc: Fix potential segfault upon allocation failure
Andreas Rheinhardt [Mon, 16 Dec 2019 00:04:09 +0000 (01:04 +0100)]
avformat/hlsenc: Fix potential segfault upon allocation failure

The hls muxer allocates an array of VariantStreams, a structure that
contains pointers to objects that need to be freed on their own. This
means that the number of allocated VariantStreams needs to be correct
when they are freed; yet the number of VariantStreams is set in
update_variant_stream_info() resp. parse_variant_stream_mapstring()
before the allocation has been checked for success, so that upon error
an attempt would be made to free the objects whose pointers are
positioned at position NULL (the location of VariantStreams) +
offsetof(VariantStream, the corresponding pointer).

Furthermore d1fe1344 added another possibility for the first function
to leave an inconsistent state behind: If an allocation of one of the
objects referenced by the VariantStream fails, the VariantStream will be
freed, but the number of allocated VariantStreams isn't reset, leading
to the same problem as above. (This was done in the mistaken belief that
the VariantStreams array would leak otherwise.)

Essentially the same also happens for the number of cc-streams. It has
been fixed, too.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Steven Liu <lq@onvideo.cn>
7 months agoavformat/hlsenc: Fix leak of options when writing packets
Andreas Rheinhardt [Mon, 16 Dec 2019 00:04:07 +0000 (01:04 +0100)]
avformat/hlsenc: Fix leak of options when writing packets

Under certain circumstances hls_write_packet() would add options to an
AVDictionary. Said dictionary was never explicitly freed, instead it was
presumed that these options would be consumed when opening a new
IO-context. This left several possibilities for memleaks:

a) When no new IO-context would be opened at all. This is possible when
using both the flags temp_file and single_file together with a file
output.
b) When an error happens before one actually tries to open the new
IO-context.
c) When the new IO-context does not consume all options.

All three have been fixed; furthermore, the AVDictionary has been put
into a smaller scope (namely the only part of hls_write_packet() where
it is actually used).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Steven Liu <lq@onvideo.cn>
7 months agoavformat/hlsenc: Fix leak of options when initializing muxing fails
Andreas Rheinhardt [Mon, 16 Dec 2019 00:04:06 +0000 (01:04 +0100)]
avformat/hlsenc: Fix leak of options when initializing muxing fails

hls_mux_init() currently leaks an AVDictionary if opening a dynamic
buffer fails or if avformat_init_output fails. This has been fixed by
moving the initialization resp. the freeing of the dictionary around:
In the former case to a place after opening the dynamic buffer, in the
latter to a place before the check for initialization failure so that it
is done unconditionally.

Furthermore, the dictionary is now only copied and freed if the options
in it are actually used (namely when in SEGMENT_TYPE_FMP4 mode).

Finally, a similar situation in hls_start() has been fixed, too.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Steven Liu <lq@onvideo.cn>
7 months agoavformat/hlsenc: Only allocate when data is known to be needed
Andreas Rheinhardt [Mon, 16 Dec 2019 00:04:05 +0000 (01:04 +0100)]
avformat/hlsenc: Only allocate when data is known to be needed

hls_init() would allocate a buffer, although it is only needed in one of
two branches that follow. This commit moves the allocation to the branch
that actually needs the buffer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Steven Liu <lq@onvideo.cn>
7 months agoavformat/hlsenc: Fix typo in error message
Andreas Rheinhardt [Mon, 16 Dec 2019 00:04:04 +0000 (01:04 +0100)]
avformat/hlsenc: Fix typo in error message

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Steven Liu <lq@onvideo.cn>
7 months agoavformat/hlsenc: Fix leak of child AVFormatContext
Andreas Rheinhardt [Mon, 16 Dec 2019 00:04:03 +0000 (01:04 +0100)]
avformat/hlsenc: Fix leak of child AVFormatContext

Before ed897633, the hls muxer would free its child AVFormatContexts
and reset the pointer to these contexts to NULL immediately afterwards;
ed897633 moved the former to later (into a separate function), but kept
the resetting, ensuring that the child context leaks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Steven Liu <lq@onvideo.cn>
7 months agofftools/cmdutils: Fix break command dump for -map option
Jun Zhao [Thu, 12 Dec 2019 08:02:53 +0000 (16:02 +0800)]
fftools/cmdutils: Fix break command dump for -map option

Before this fix, ffmpeg -h full | grep map get the command dump
like:

-map [-]input_file_id[:stream_specifier][,sync_file_id[:stream_s  set input stream mapping
                                                               ^
                                                               |
    truncated
after this fix, we can get full option dump.

Found-by: vacingfang <vacingfang@tencent.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
7 months agoavcodec/hevcdec: keep closed captions in sync between multiple thread contexts
James Almer [Fri, 20 Dec 2019 17:05:42 +0000 (14:05 -0300)]
avcodec/hevcdec: keep closed captions in sync between multiple thread contexts

Based on h264 code.

Reviewed-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavfilter/af_adeclick: implement timeline support
Paul B Mahol [Sat, 21 Dec 2019 19:02:04 +0000 (20:02 +0100)]
avfilter/af_adeclick: implement timeline support

7 months agoavformat/movenc: use iso6 major brand when signed CTS offsets are used in trun boxes
James Almer [Sun, 1 Dec 2019 16:11:28 +0000 (13:11 -0300)]
avformat/movenc: use iso6 major brand when signed CTS offsets are used in trun boxes

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavformat/movenc: ensure we don't write the major brand as a compatible brand more...
James Almer [Sun, 1 Dec 2019 16:10:48 +0000 (13:10 -0300)]
avformat/movenc: ensure we don't write the major brand as a compatible brand more than once

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavformat/movenc: write the major brand also as the first compatible brand
James Almer [Wed, 27 Nov 2019 17:15:34 +0000 (14:15 -0300)]
avformat/movenc: write the major brand also as the first compatible brand

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agofftools/ffmpeg: Reindent after last commit
Nicolas Gaullier [Thu, 19 Dec 2019 16:43:22 +0000 (17:43 +0100)]
fftools/ffmpeg: Reindent after last commit

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/icecast: Use AV_DICT_DONT_STRDUP_VAL to save an av_strdup
Andreas Rheinhardt [Sun, 10 Nov 2019 04:07:30 +0000 (05:07 +0100)]
avformat/icecast: Use AV_DICT_DONT_STRDUP_VAL to save an av_strdup

This will probably also fix CID 1452559, a false positive where Coverity
claims a double-free occurs, because it thinks that av_dict_set() frees
its key and value arguments even when the AV_DICT_DONT_STRDUP_* flags
aren't used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Marvin Scholz <epirat07@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agofftools/ffmpeg: Fix forward CPB props in to out
Nicolas Gaullier [Thu, 19 Dec 2019 16:43:21 +0000 (17:43 +0100)]
fftools/ffmpeg: Fix forward CPB props in to out

CPB side_data is copied when stream-copying (see init_output_stream_streamcopy()),
but it shall not be copied when the stream is decoded.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavfilter/vf_readeia608: if parity bit check fails, set correct value
Paul B Mahol [Sat, 21 Dec 2019 11:11:38 +0000 (12:11 +0100)]
avfilter/vf_readeia608: if parity bit check fails, set correct value

As described in U.S. Federal Register, Volume 56, Number 114, June 13, 1991, pages 27204-27205.

7 months agoavcodec/h264_sei: fix the size of user data unregistered
Limin Wang [Thu, 19 Dec 2019 05:09:06 +0000 (13:09 +0800)]
avcodec/h264_sei: fix the size of user data unregistered

According to the specifications, the payloadSize includes the 16-byte size of UUID.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
7 months agodoc/encoders: correct the description for ts_target_bitrate
Wonkap Jang [Wed, 18 Dec 2019 21:17:00 +0000 (13:17 -0800)]
doc/encoders: correct the description for ts_target_bitrate

ts_target_bitrate is in kbps, not bps. This commit clarifies the unit
and modifies the example to match the description.

Signed-off-by: James Zern <jzern@google.com>
7 months agoavfilter/vf_readeia608: rewrite processing, make extracting more robust
Paul B Mahol [Tue, 17 Dec 2019 18:47:55 +0000 (19:47 +0100)]
avfilter/vf_readeia608: rewrite processing, make extracting more robust

Lots of options are now obsolete.

7 months agoavcodec/hevc_sei: switch to AVBufferRef buffer for a53 caption
Limin Wang [Fri, 20 Dec 2019 01:17:21 +0000 (09:17 +0800)]
avcodec/hevc_sei: switch to AVBufferRef buffer for a53 caption

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavformat/icecast: Free the right buffer on error
Andreas Rheinhardt [Sun, 10 Nov 2019 04:07:29 +0000 (05:07 +0100)]
avformat/icecast: Free the right buffer on error

In case an AVBPrint was not complete, icecast_open() would free some
buffers that have not been allocated yet instead of freeing the data of
the AVBPrint (if they have been allocated). Because this error does not
trigger a jump to the general cleanup section any more, one can moreover
remove a (now unnecessary) initialization of a pointer.

Furthermore, finalizing an AVBPrint can fail (namely when the string
inside the AVBPrint has not been allocated yet) and so this needs to be
checked.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/tls_openssl: don't use libcrypto locking functions with newer OpenSSL versions
James Almer [Wed, 11 Dec 2019 16:11:59 +0000 (13:11 -0300)]
avformat/tls_openssl: don't use libcrypto locking functions with newer OpenSSL versions

They have been removed altogether without a compat implementation, and are
either no-ops or return NULL.
This fixes compiler warnings about checks always evaluating to false, and leaks
of allocated mutexes.

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavcodec/cbs_av1: add missing valid range of values for num_cb_points and num_cr_points
James Almer [Thu, 12 Dec 2019 01:39:56 +0000 (22:39 -0300)]
avcodec/cbs_av1: add missing valid range of values for num_cb_points and num_cr_points

It is a requirement of bitstream conformance that num_cr_points is less than or equal to 10.
It is a requirement of bitstream conformance that num_cb_points is less than or equal to 10.

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agocheckasm: aacpsdsp: Tolerate extra intermediate precision in stereo_interpolate
Martin Storsjö [Wed, 4 Dec 2019 11:04:41 +0000 (13:04 +0200)]
checkasm: aacpsdsp: Tolerate extra intermediate precision in stereo_interpolate

The stereo_interpolate functions add h_step to the values h
BUF_SIZE times. Within the stereo_interpolate C functions, the
values h (h0-h3, h00-h13) are declared as local float variables,
but the compiler is free to keep them in a register with extra
precision.

If the accumulation is rounded to 32 bit float precision after
each step, the less significant bits of h_step end up ignored
and the sum can deviate, affecting the end result more than
the currently set EPS.

By clearing the log2(BUF_SIZE) lower bits of h_step, we make sure
that the accumulation shouldn't differ significantly, regardless
of any extra precision in the accmulating register/variable.

This fixes the aacpsdsp checkasm test when built with clang for
mingw/x86_32.

Signed-off-by: Martin Storsjö <martin@martin.st>
7 months agoffprobe: Fix fate tests for ffprobe in cases where TARGET_PATH differs from the curre...
Martin Storsjö [Mon, 2 Dec 2019 09:16:25 +0000 (11:16 +0200)]
ffprobe: Fix fate tests for ffprobe in cases where TARGET_PATH differs from the current path

In these cases, we must pass the full path of the file to ffprobe
(as the current working dir on the remote system, e.g. when invoked
with "ssh remote ffprobe ..." isn't the wanted one).

The input filename passed to ffprobe is also included in the output,
which is part of the reference test data. Add a new option to
ffprobe to allow overriding what path is printed, to keep the
original relative path in the tests.

An alternative approach could be an option to allow requesting omitting
the file name from the dumped data, and updating the test references
accordingly.

Signed-off-by: Martin Storsjö <martin@martin.st>
7 months agoswscale/aarch64: use multiply accumulate and increase vector factor to 4
Sebastian Pop [Sun, 17 Nov 2019 20:13:13 +0000 (14:13 -0600)]
swscale/aarch64: use multiply accumulate and increase vector factor to 4

This patch implements ff_hscale_8_to_15_neon with NEON fused multiply accumulate
and bumps the vectorization factor from 2 to 4.
The speedup is of 25% on Graviton1 A1 instances based on A-72 cpus:

$ ffmpeg -nostats -f lavfi -i testsrc2=4k:d=2 -vf bench=start,scale=1024x1024,bench=stop -f null -
before: t:0.040303 avg:0.040287 max:0.040371 min:0.039214
after:  t:0.032168 avg:0.032215 max:0.033081 min:0.032146

The speedup is of 39% on Graviton2 m6g instances based on Neoverse-N1 cpus:
$ ffmpeg -nostats -f lavfi -i testsrc2=4k:d=2 -vf bench=start,scale=1024x1024,bench=stop -f null -
before: t:0.019446 avg:0.019423 max:0.019493 min:0.019181
after:  t:0.014015 avg:0.014096 max:0.015018 min:0.013971

Tested with `make check` on aarch64-linux.

Signed-off-by: Sebastian Pop <spop@amazon.com>
Reviewed-by: Jean-Baptiste Kempf <jb@videolan.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agolavc/h264dec.h: remove unused ff_h264_decode_slice_header
Linjie Fu [Tue, 17 Dec 2019 08:57:33 +0000 (16:57 +0800)]
lavc/h264dec.h: remove unused ff_h264_decode_slice_header

Once removed in 4a9bab3db0d9ec449ebc8b5e823374d1d1df7761.

Introduced again in b25cd7540e7.

Signed-off-by: Linjie Fu <fulinjie@zju.edu.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoFATE/hevc.mak: cosmetic for fate-hevc-paired-fields
Linjie Fu [Fri, 13 Dec 2019 17:55:31 +0000 (01:55 +0800)]
FATE/hevc.mak: cosmetic for fate-hevc-paired-fields

Adjust the order of fate-hevc-paired-fields.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoFATE: add test for hevc files with 4 TUDepth(0..4) of cbf_cb/cbf_cr
Linjie Fu [Fri, 13 Dec 2019 17:54:13 +0000 (01:54 +0800)]
FATE: add test for hevc files with 4 TUDepth(0..4) of cbf_cb/cbf_cr

5 cabac states for cbf_cb and cbf_cr are supported according to
Table 9-4.

Add a test for 64x64 4:4:4 8bit HEVC clips with TUDepth = 4, cbf_cr > 0.

Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: James Almer <jamrial@gmail.com>
7 months agolavc/hevc_cabac: fix cbf_cb and cbf_cr for transform depth 4
Linjie Fu [Wed, 11 Dec 2019 08:47:38 +0000 (16:47 +0800)]
lavc/hevc_cabac: fix cbf_cb and cbf_cr for transform depth 4

The max transform depth is 5(from 0 to 4), so we need 5 cabac states for
cbf_cb and cbf_cr.

See Table 9-4 for details.

Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: James Almer <jamrial@gmail.com>
7 months agovc2enc: zero padding of the coefficient buffer
Lynne [Tue, 17 Dec 2019 14:56:33 +0000 (14:56 +0000)]
vc2enc: zero padding of the coefficient buffer

Wavelet types with large amounts of overreading/writing like 9_7 would
write into the padding at high wavelet depths, which would remain and be
read by the next frame's transform and quickly cause artifacts to appear
for subsequent frames.
This fix affects all frames encoded with a non-power-of-two width, with
the artifacts varying between non-observable to very noticeable,
depending on encoder settings, so reencoding is advisable.

7 months agoavfilter/vf_stack: set framerate to VFR when inputs frame rates differs
Paul B Mahol [Tue, 17 Dec 2019 12:28:27 +0000 (13:28 +0100)]
avfilter/vf_stack: set framerate to VFR when inputs frame rates differs

7 months agofate: Add an option for disabling the 2k/4k tests
Martin Storsjö [Mon, 2 Dec 2019 21:57:11 +0000 (23:57 +0200)]
fate: Add an option for disabling the 2k/4k tests

When testing on a memory limited system, these tests consume a
significant amount of memory and can often fail if testing by running
multiple processes in parallel.

Signed-off-by: Martin Storsjö <martin@martin.st>
7 months agolavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers
Linjie Fu [Fri, 31 May 2019 00:34:31 +0000 (20:34 -0400)]
lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

Currently, assigning new buffer for pkt when multiple buffers were returned
from vaMapBuffer will overwrite the previous encoded pkt data and lead
to encode issues.

Iterate through the buf_list first to find out the total buffer size
needed for the pkt, allocate the whole pkt to avoid repeated reallocation
and memcpy, then copy data from each buf to pkt.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
7 months agoavfilter: Add tonemap vaapi filter for H2S
Xinpeng Sun [Mon, 2 Dec 2019 07:17:29 +0000 (15:17 +0800)]
avfilter: Add tonemap vaapi filter for H2S

It performs HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion
with tone-mapping. It only supports HDR10 as input temporarily.

An example command to use this filter with vaapi codecs:
FFMPEG -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi \
-i INPUT -vf 'tonemap_vaapi=format=p010' -c:v hevc_vaapi -profile 2 OUTPUT

Signed-off-by: Xinpeng Sun <xinpeng.sun@intel.com>
Signed-off-by: Zachary Zhou <zachary.zhou@intel.com>
Signed-off-by: Ruiling Song <ruiling.song@intel.com>
7 months agolavc/allcodecs: Add mpeg4 omx encoder, missed in 0e387232
Carl Eugen Hoyos [Mon, 16 Dec 2019 21:45:34 +0000 (22:45 +0100)]
lavc/allcodecs: Add mpeg4 omx encoder, missed in 0e387232

7 months agolavu/log: Also print the log level for level trace.
Carl Eugen Hoyos [Mon, 16 Dec 2019 12:08:40 +0000 (13:08 +0100)]
lavu/log: Also print the log level for level trace.

7 months agolavc/cbs_h2645_syntax_template: Fix memleak
Andriy Gelman [Fri, 6 Dec 2019 19:22:14 +0000 (14:22 -0500)]
lavc/cbs_h2645_syntax_template: Fix memleak

payload_count is used to track the number of SEI payloads. It is also
used to free the SEIs in cbs_h264_free_sei()/cbs_h265_free_sei().

Currently, payload_count is set after for loop is completed. Hence if
there is an error and the function exits, the payload remains zero
causing a memleak.

This commit keeps track of payload_count inside the for loop to fix the
issue. Note that that the contents of current are initialized with
av_mallocz() so there is no need to zero initialize payload_count.

Found-by: libFuzzer
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
7 months agoh264_mp4toannexb: Remove unnecessary check
Andreas Rheinhardt [Sat, 14 Dec 2019 22:19:13 +0000 (23:19 +0100)]
h264_mp4toannexb: Remove unnecessary check

There can be at most 31 SPS and 255 PPS in the mp4/Matroska extradata.
Given that each has a size of at most 2^16-1, the length of the output
derived from these parameter sets can never overflow an ordinary 32 bit
integer. So use a simple uint32_t instead of uint64_t and replace the
unnecessary check with an av_assert1.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>