Commit Graph

96126 Commits

Author SHA1 Message Date
Andreas Rheinhardt
5946243fa8 avformat/flac_picture: Return directly if nothing has been allocated
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-01 17:17:04 +01:00
Andreas Rheinhardt
84a4261cd8 avformat/flac_picture: Switch to bytestream2 API
ff_flac_parse_picture() parses a buffer containing a flac metadata
picture block by wrapping it in an AVIOContext and using the AVIOContext
API. Consequently, when not enough data could be read AVERROR(EIO) was
returned although reading didn't really fail: A block that contains a
subfield whose size field indicates that it is so big as to extend
beyond the buffer is just invalid.

This commit changes this by using the bytestream2 API instead;
furthermore, the checks for whether there is enough data left are
performed before allocating a buffer for said data.

Finally, if the length of the picture description is bigger than
INT_MAX, it will now raise an error.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-01 17:17:04 +01:00
Andreas Rheinhardt
35005a4af1 avformat/flac_picture: Simplify checks
During parsing a flac picture metadata block, the mimetype is read as
follows: Its 32b size field is read and checked for being in the range
1..63; afterwards, the actual mimetype-string is read into a buffer of
size 64, where the length to read is the minimum of the length field and
the size of the destination buffer -1. Then an assert guards that length
is indeed < the size of the destination buffer before the string in the
buffer is zero-terminated.

The FFMIN as well as the assert are actually redundant, as it has
been checked that the string (even after terminating) fits into the
buffer. In order to make this clear, reword the check "len >= 64" to
"len >= sizeof(mimetype)" and drop the FFMIN as well as the assert.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-01 17:17:04 +01:00
Steven Liu
9cc88ed4b7 avformat/smoothstreamingenc: removed unused check of avformat_free_context
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Jun Zhao <barryjzhao@tencent.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-12-02 00:08:31 +08:00
Steven Liu
0f79a71353 avformat/rtpenc_mpegts: removed unused check of avformat_free_context
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Jun Zhao <barryjzhao@tencent.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-12-02 00:08:21 +08:00
Steven Liu
e880f4fb38 avformat/hdsenc: removed unused check of avformat_free_context
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Jun Zhao <barryjzhao@tencent.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-12-02 00:08:14 +08:00
Steven Liu
b26225a3c7 avformat/dashenc: remove unused check of avformat_free_context
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Jun Zhao <barryjzhao@tencent.com>
Reviewed-by: Jeyapal, Karthick <kjeyapal@akamai.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-12-02 00:08:07 +08:00
James Almer
e5db2e96c0 avformat/avc: add missing return error value
Signed-off-by: James Almer <jamrial@gmail.com>
2019-11-30 11:34:58 -03:00
Andriy Gelman
99d78e4f42 lavc/extract_extradata: Use bytestream api
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-11-30 11:34:51 -03:00
Andreas Rheinhardt
76e0ecec0b avcodec/extract_extradata_bsf: Don't unref uninitialized buffers
This happens if allocating extradata fails and s->remove is unset.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-11-30 09:59:30 -03:00
James Almer
18507b4882 avformat/avc: fix sps buffer offset when calling ff_avc_decode_sps()
Skip the avcC specific size bytes and the NAL header bits.

Signed-off-by: James Almer <jamrial@gmail.com>
2019-11-29 23:17:43 -03:00
James Almer
0d67af34c2 fate/demux: add an AV1 Annex B test
Signed-off-by: James Almer <jamrial@gmail.com>
2019-11-29 18:58:42 -03:00
James Almer
378065f08f avcodec/av1_parser: export stream dimensions in avctx
This is required to demux annexb samples when a decoder isn't available.

Signed-off-by: James Almer <jamrial@gmail.com>
2019-11-29 18:58:34 -03:00
James Almer
13ed243594 fate/lavf-container: add an H264 mp4 remux test
This uses a raw h264 bitstream as source, in order to test the avcC
generation code.

Signed-off-by: James Almer <jamrial@gmail.com>
2019-11-29 18:24:01 -03:00
James Almer
de557eb191 fate/lavf-container: add an AV1 mp4 remux test
Signed-off-by: James Almer <jamrial@gmail.com>
2019-11-29 18:23:49 -03:00
Zhao Zhili
19956d01cc libavdevice/lavfi: check avfilter_graph_dump return value
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-29 19:58:35 +01:00
Andreas Rheinhardt
2205fb2810 avformat/avio: Use ffurl_closep
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-29 19:58:35 +01:00
Paul B Mahol
8c2f81a17a avfilter/vf_hqdn3d: add support for commands 2019-11-29 17:28:59 +01:00
Paul B Mahol
3a61297a67 avfilter/vf_hqdn3d: add support for 12bit and 14bit yuv formats 2019-11-29 17:28:59 +01:00
Jun Zhao
2952d9c5dc lavc/mvha: Check init_get_bits8() for failure
fix potential null pointer dereference

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-11-29 10:10:52 +08:00
Jun Zhao
d965589022 lavf/vividas: check avformat_new_stream() return
check avformat_new_stream() return.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-11-29 10:09:29 +08:00
Limin Wang
c1ed00fd18 avfilter/vf_yadif: rename config_props -> config_output, link -> outlink
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-29 00:03:28 +01:00
Andreas Rheinhardt
ff5c8e57e7 avformat/vividas: Avoid allocation of AVIOContext
Put an AVIOContext whose lifetime doesn't extend beyond the function where
it is allocated on the stack instead of allocating and freeing it. This
also avoids the need to free it, which in this case fixes possible
memleaks on error.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-29 00:03:28 +01:00
James Almer
16fa513392 avformat/avc: write the missing bits in the AVC Decoder Configuration Box
Signed-off-by: James Almer <jamrial@gmail.com>
2019-11-28 15:20:37 -03:00
Andreas Rheinhardt
4d97b2ad2f avformat/movenc: Avoid allocation for small dynamic buffers
By using avio_get_dyn_buf() + ffio_free_dyn_buf() instead of
avio_close_dyn_buf() + av_free() one can avoid an allocation + copy for
small dynamic buffers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-11-28 15:20:37 -03:00
Andreas Rheinhardt
3a58ec7c77 avformat/matroskaenc: Avoid allocation for small dynamic buffers
By using avio_get_dyn_buf() + ffio_free_dyn_buf() instead of
avio_close_dyn_buf() + av_free() one can avoid an allocation + copy for
small dynamic buffers (i.e. small master elements).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-11-28 15:20:37 -03:00
Andreas Rheinhardt
aad82270b6 avformat/id3v2enc: Avoid allocation for small tags
By using avio_get_dyn_buf() + ffio_free_dyn_buf() instead of
avio_close_dyn_buf() + av_free() one can avoid an allocation + copy for
small tags. Furthermore, it simplifies freeing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-11-28 15:20:37 -03:00
Andreas Rheinhardt
c36a3df676 avformat/avc: Avoid allocation for small SPS/PPS arrays
By using avio_get_dyn_buf() + ffio_free_dyn_buf() instead of
avio_close_dyn_buf() + av_free() one can avoid an allocation + copy for
small extradata. Furthermore, it simplifies freeing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-11-28 15:20:37 -03:00
Andreas Rheinhardt
a31f68fb44 avformat/av1: Avoid allocation for small headers
By using avio_get_dyn_buf() + ffio_free_dyn_buf() instead of
avio_close_dyn_buf() + av_free() one can avoid an allocation + copy for
small headers. Furthermore, it simplifies freeing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-11-28 15:20:37 -03:00
Andreas Rheinhardt
67ce9e0463 avformat/apetag: Avoid allocation for small tags
By using avio_get_dyn_buf() + ffio_free_dyn_buf() instead of
avio_close_dyn_buf() + av_free() one can avoid an allocation + copy for
small tags. Furthermore, it simplifies freeing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-11-28 15:20:36 -03:00
Andreas Rheinhardt
163bb9ac0a avformat/aviobuf: Avoid allocating buffer when using dynamic buffer
Up until now, using a dynamic buffer entailed at least three
allocations: One for the AVIOContext, one for the AVIOContext's opaque
(which, among other things, contains the small write buffer), and one
for the big buffer that is independently allocated that is returned when
calling avio_close_dyn_buf().

It is possible to avoid the third allocation if one doesn't use a
packetized dynamic buffer, if all the data written so far fit into the
write buffer and if one does not require the actual (big) buffer to have
an indefinite lifetime. This is done by making avio_get_dyn_buf() return
a pointer to the data in the write buffer if nothing has been written to
the main buffer yet. The dynamic buffer will then be freed using
ffio_free_dynamic_buffer (which needed to be modified not to call
avio_close_dyn_buf() internally).

So a typical use-case like:

size = avio_close_dyn_buf(dyn_pb, &buf);
do something with buf
av_free(buf);

can be converted to:

size = avio_get_dyn_buf(dyn_pb, &buf);
do something with buf
ffio_free_dynamic_buffer(&dyn_pb);

In more complex scenarios this can simplify freeing as well, because it
is now clear that freeing always has to be performed via
ffio_free_dynamic_buffer().

Of course, in case this saves an allocation it also saves a memcpy.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-11-28 15:20:36 -03:00
Limin Wang
8aa143eaa8 avfilter/vf_libvmaf: Check for av_frame_alloc failure
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-28 18:44:01 +01:00
Andreas Rheinhardt
df912bbc5f avformat/flacenc: Add const to ff_flac_write_header() parameter
The extradata is not changed at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-28 18:44:01 +01:00
Zhao Zhili
ed5cdf3d5a avcodec/vp8: fix multiple ff_thread_finish_setup() calls
webp decoder doesn't set update_thread_context field

$ ffmpeg -i rgb_q80.webp -f null -
[webp @ 0x7ffbd5823200] Multiple ff_thread_finish_setup() calls

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-28 18:44:01 +01:00
Limin Wang
3a6ec10d90 avfilter/vf_colorconstancy: av_frame_free(&in) in case of error or direct flag is false
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-28 18:44:01 +01:00
Linjie Fu
df625057af lavc/qsvenc: Fix some code indentations
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2019-11-28 23:34:40 +08:00
Zhong Li
1b831bc729 doc/encoder: add the missing qsv encoders
Reviewed-by: Gyan Doshi <ffmpeg@gyani.pro>
Signed-off-by: Zhong Li <zhongli_dev@126.com>
2019-11-28 23:30:31 +08:00
Zhong Li
846e26b8c9 lavc/rav1e: log and doc updated for const quantizer mode
Signed-off-by: Zhong Li <zhongli_dev@126.com>
2019-11-28 23:27:46 +08:00
Thierry Foucu
eaf566ce0b Add options for spatial layers.
Disable by default to output all the layers, to match libaomdec wrapper.
Add option to select the operating point for the spatial layers.
Update the documentation with the new options.

Signed-off-by: James Almer <jamrial@gmail.com>
2019-11-28 10:21:20 -03:00
Paul B Mahol
ed58f8475f avcodec: add mvha video decoder 2019-11-27 23:54:20 +01:00
Paul B Mahol
61dc7add30 avcodec: add mvdv video decoder 2019-11-27 23:53:43 +01:00
Steven Liu
afee801276 avformat/hls: correct grammatical errors of m3u8_hold_counters option
Suggested-by: Gyan <ffmpeg@gyani.pro>
Suggested-by: Rodney Baker <rodney.baker@iinet.net.au>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-11-27 19:04:00 +08:00
Carl Eugen Hoyos
a2fbdc6898 lavc/qsvenc: Fix compilation for some build environments.
Reported and tested by Sean Darcy.
2019-11-27 00:03:33 +01:00
Oleg Dobkin
32ba563cfc avutil/hwcontext_cuda: allow using primary CUDA device context
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2019-11-26 16:24:40 +01:00
Steven Liu
59d264b0a1 avformat/hlsenc: set strict_std_compliance from the parent AVFormatContext
fix ticket: 8388

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-11-26 11:32:03 +08:00
Limin Wang
d07d1c1dd0 avcodec/v210dec: add support for frame and slice threading
1, Test server configure:
[root@localhost ~]# cat /proc/cpuinfo  |grep "model name"
 model name      : Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz
 model name      : Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz
 ...

[root@localhost ~]# free -h
              total        used        free      shared  buff/cache   available
              Mem:           102G        1.1G        100G         16M        657M        100G
              Swap:          4.0G          0B        4.0G

2, Test result:
encode the v210 input data for testing:
./ffmpeg -y -i 4k_422.ts  -c:v v210 -vframes 10 test.avi

master:
./ffmpeg -y -threads 1 -stream_loop 1000 -i ./test.avi -benchmark -f null -
frame=10010 fps= 60 q=-0.0 Lsize=N/A time=00:38:26.30 bitrate=N/A speed=13.7x
video:5240kB audio:432432kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
bench: utime=101.869s stime=66.181s rtime=167.996s
bench: maxrss=186552kB

patch applied:
./ffmpeg -y -threads 2 -thread_type slice -stream_loop 1000 -i ./test.avi -benchmark -f null -
frame=10010 fps= 72 q=-0.0 Lsize=N/A time=00:38:26.30 bitrate=N/A speed=16.5x
video:5240kB audio:432432kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
bench: utime=103.562s stime=74.858s rtime=139.599s
bench: maxrss=188616kB

./ffmpeg -y -threads 2 -thread_type frame -stream_loop 1000 -i ./test.avi -benchmark -f null -
frame=10010 fps= 85 q=-0.0 Lsize=N/A time=00:38:26.30 bitrate=N/A speed=19.6x
video:5240kB audio:432432kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
bench: utime=114.310s stime=92.685s rtime=117.693s
bench: maxrss=231896kB

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-25 09:54:27 +01:00
Limin Wang
f0dbeb5eaa avcodec/v410dec: add support for frame and slice threading
1, Test server configure:
[root@localhost ~]# cat /proc/cpuinfo  |grep "model name"
model name	: Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz
model name	: Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz
...

[root@localhost ~]# free -h
              total        used        free      shared  buff/cache   available
              Mem:           102G        1.1G        100G         16M        657M        100G
              Swap:          4.0G          0B        4.0G

2, Test result:
encode the v410 input data for testing:
 ./ffmpeg -y -i 4k_422.ts  -c:v v410 -vframes 10 test.avi

master:
./ffmpeg -y -stream_loop 1000 -i ./test.avi -benchmark -f null -
frame=10010 fps= 37 q=-0.0 Lsize=N/A time=00:38:26.30 bitrate=N/A speed= 8.6x
video:5240kB audio:432432kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
bench: utime=166.016s stime=102.192s rtime=268.120s
bench: maxrss=273400kB

patch applied:
./ffmpeg -y -threads 2 -thread_type slice -stream_loop 1000 -i ./test.avi -benchmark -f null -
frame=10010 fps= 53 q=-0.0 Lsize=N/A time=00:38:26.30 bitrate=N/A speed=12.3x
video:5240kB audio:432432kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
bench: utime=165.135s stime=100.456s rtime=187.994s
bench: maxrss=275476kB

./ffmpeg -y -threads 2 -thread_type frame -stream_loop 1000 -i ./test.avi -benchmark -f null -
frame=10010 fps= 61 q=-0.0 Lsize=N/A time=00:38:26.30 bitrate=N/A speed=14.1x
video:5240kB audio:432432kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
bench: utime=171.386s stime=122.102s rtime=163.637s
bench: maxrss=340308kB

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-25 09:54:27 +01:00
Steven Liu
d5e3d8e2f7 avformat/hls: add option for the m3u8 list load max times
set max times for load m3u8 when the m3u8 list refresh do not with new
segments any times.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-11-25 11:12:20 +08:00
Michael Niedermayer
1ca978d636 avcodec/nuv: Use ff_set_dimensions()
Fixes: OOM
Fixes: 18956/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NUV_fuzzer-5766505644163072

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>
2019-11-25 00:07:07 +01:00
Michael Niedermayer
d83002179f avformat/vividas: Error out on audio packets in the absence of audio streams
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-25 00:07:07 +01:00