ffmpeg.git
4 months agoavformat/dvenc: return error code of dv_assemble_frame()
Limin Wang [Fri, 12 Jun 2020 13:06:25 +0000 (21:06 +0800)]
avformat/dvenc: return error code of dv_assemble_frame()

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoavcodec/av1_parser: initialize avctx->pix_fmt
Manoj Bonda [Fri, 19 Jun 2020 07:01:22 +0000 (12:31 +0530)]
avcodec/av1_parser: initialize avctx->pix_fmt

Initialize avctx->pix_fmt in av1_parser.c
AV1 Chroma format is invalid when quering using below code if no AV1 decoder
is available:

iVideoStream = av_find_best_stream(fmtc, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
eChromaFormat = (AVPixelFormat)fmtc->streams[iVideoStream]->codecpar->format;

Signed-off-by: James Almer <jamrial@gmail.com>
4 months agoavcodec/av1_parser: add missing parsing for RGB pixel format signaling
James Almer [Fri, 19 Jun 2020 13:56:20 +0000 (10:56 -0300)]
avcodec/av1_parser: add missing parsing for RGB pixel format signaling

Signed-off-by: James Almer <jamrial@gmail.com>
4 months agoavcodec/av1_parser: set context values outside the OBU parsing loop
James Almer [Fri, 19 Jun 2020 12:56:49 +0000 (09:56 -0300)]
avcodec/av1_parser: set context values outside the OBU parsing loop

Signed-off-by: James Almer <jamrial@gmail.com>
4 months agofate: add yuv420p10 and yuv422p10 tests for overlay filter
Limin Wang [Fri, 5 Jun 2020 13:58:02 +0000 (21:58 +0800)]
fate: add yuv420p10 and yuv422p10 tests for overlay filter

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoavfilter/vf_overlay: add yuv420p10 and yuv422p10 10bit format support
Limin Wang [Fri, 5 Jun 2020 13:58:01 +0000 (21:58 +0800)]
avfilter/vf_overlay: add yuv420p10 and yuv422p10 10bit format support

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoavfilter/vf_overlay: support for 8bit and 10bit overlay with macro-based function
Limin Wang [Fri, 5 Jun 2020 13:58:00 +0000 (21:58 +0800)]
avfilter/vf_overlay: support for 8bit and 10bit overlay with macro-based function

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoavcodec/libx265: Fix integer overflow in computation of max and avg bitrate
Limin Wang [Mon, 8 Jun 2020 11:51:33 +0000 (19:51 +0800)]
avcodec/libx265: Fix integer overflow in computation of max and avg bitrate

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoavcodec/encode: restructure the old encode API
James Almer [Tue, 9 Jun 2020 21:35:00 +0000 (18:35 -0300)]
avcodec/encode: restructure the old encode API

Following the same logic as 061a0c14bb, this commit turns the old encode API
into a wrapper for the new one.

Signed-off-by: James Almer <jamrial@gmail.com>
4 months agoavcodec/encode: restructure the core encoding code
James Almer [Tue, 9 Jun 2020 21:31:32 +0000 (18:31 -0300)]
avcodec/encode: restructure the core encoding code

This commit follows the same logic as 061a0c14bb, but for the encode API: The
new public encoding API will no longer be a wrapper around the old deprecated
one, and the internal API used by the encoders now consists of a single
receive_packet() callback that pulls frames as required.

amf encoders adapted by James Almer
librav1e encoder adapted by James Almer
nvidia encoders adapted by James Almer
MediaFoundation encoders adapted by James Almer
vaapi encoders adapted by Linjie Fu
v4l2_m2m encoders adapted by Andriy Gelman

Signed-off-by: James Almer <jamrial@gmail.com>
4 months agoavformat: add MCC demuxer
Paul B Mahol [Sat, 13 Jun 2020 13:07:41 +0000 (15:07 +0200)]
avformat: add MCC demuxer

Fixes #7680

4 months agoavformat/sccdec: make splitting more robust
Paul B Mahol [Wed, 17 Jun 2020 08:24:05 +0000 (10:24 +0200)]
avformat/sccdec: make splitting more robust

4 months agolavf/dashdec: Add missed side data/disposition
Jun Zhao [Thu, 4 Jun 2020 14:00:48 +0000 (22:00 +0800)]
lavf/dashdec: Add missed side data/disposition

dash demuxer get the stream info from sub-stream, but missed side
data/disposition part, e,g, missed the DOVI side data when the
stream is Dolby Vision streams

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
4 months agolavf/hls: Add missed side data/disposition
vacingfang [Thu, 4 Jun 2020 13:59:43 +0000 (21:59 +0800)]
lavf/hls: Add missed side data/disposition

hls demuxer get the stream info from sub-stream, but missed side
data/disposition part, e,g, missed the DOVI side data when the
stream is Dolby Vision streams.

Reviewed-by <liuqi05@kuaishou.com>
Signed-off-by: vacingfang <vacingfang@tencent.com>
4 months agofftools/ffmpeg_filter: add -autoscale to disable/enable the default scale
Linjie Fu [Mon, 8 Jun 2020 08:58:05 +0000 (16:58 +0800)]
fftools/ffmpeg_filter: add -autoscale to disable/enable the default scale

Currently, ffmpeg inserts scale filter by default in the filter graph
to force the whole decoded stream to scale into the same size with the
first frame. It's not quite make sense in resolution changing cases if
user wants the rawvideo without any scale.

Using autoscale/noautoscale as an output option to indicate whether auto
inserting the scale filter in the filter graph:
    -noautoscale or -autoscale 0:
    disable the default auto scale filter inserting.

ffmpeg -y -i input.mp4 out1.yuv -noautoscale out2.yuv -autoscale 0 out3.yuv

Update docs.

Suggested-by: Mark Thompson <sw@jkqxz.net>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
4 months agoavformat/apm: check codec tag in probe and add constant
Zane van Iperen [Fri, 12 Jun 2020 11:46:15 +0000 (11:46 +0000)]
avformat/apm: check codec tag in probe and add constant

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavformat/movenc: Write 'av01' as a compatible brand when muxing AV1
Derek Buitenhuis [Wed, 17 Jun 2020 13:43:28 +0000 (14:43 +0100)]
avformat/movenc: Write 'av01' as a compatible brand when muxing AV1

This is a requirement of the AV1-ISOBMFF spec. Section 2.1.
General Requirements & Brands states:

    * It SHALL have the av01 brand among the compatible brands array of the FileTypeBox

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
4 months agomailmap: add entry for myself
Zhong Li [Wed, 17 Jun 2020 14:11:34 +0000 (22:11 +0800)]
mailmap: add entry for myself

Signed-off-by: Zhong Li <zhongli_dev@126.com>
4 months agodnn_backend_native: check operand index
Guo Yejun [Wed, 10 Jun 2020 05:36:11 +0000 (13:36 +0800)]
dnn_backend_native: check operand index

it fixed the issue in https://trac.ffmpeg.org/ticket/8716

4 months agodnn_backend_native.c: refine code for fail case
Guo Yejun [Wed, 10 Jun 2020 02:59:19 +0000 (10:59 +0800)]
dnn_backend_native.c: refine code for fail case

4 months agoavcodec/ccaption_dec: do not modify pkt data and stop removing parity bit twice
Paul B Mahol [Tue, 16 Jun 2020 22:35:37 +0000 (00:35 +0200)]
avcodec/ccaption_dec: do not modify pkt data and stop removing parity bit twice

4 months agoavformat/sccdec: simplify demuxer a little
Paul B Mahol [Tue, 16 Jun 2020 17:13:42 +0000 (19:13 +0200)]
avformat/sccdec: simplify demuxer a little

4 months agoavcodec/ccaption_dec: remove usage of extra buffer
Paul B Mahol [Tue, 16 Jun 2020 15:08:04 +0000 (17:08 +0200)]
avcodec/ccaption_dec: remove usage of extra buffer

4 months agoavcodec/ccaption_dec: fix some small style issues
Paul B Mahol [Tue, 16 Jun 2020 09:16:03 +0000 (11:16 +0200)]
avcodec/ccaption_dec: fix some small style issues

4 months agoavcodec/ccaption_dec: remove pts parameter from handle_char()
Paul B Mahol [Mon, 15 Jun 2020 22:10:57 +0000 (00:10 +0200)]
avcodec/ccaption_dec: remove pts parameter from handle_char()

4 months agoavcodec/tiff: Check stride for dng
Michael Niedermayer [Sun, 14 Jun 2020 21:45:46 +0000 (23:45 +0200)]
avcodec/tiff: Check stride for dng

Fixes: assertion failure
Fixes: 23422/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5746026064642048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavformat/sccdec: unbreak previous commits to this file
Paul B Mahol [Sun, 14 Jun 2020 19:16:57 +0000 (21:16 +0200)]
avformat/sccdec: unbreak previous commits to this file

4 months agoavformat/movenc: fix remuxing eia-608 into mov from other containers
Paul B Mahol [Sun, 14 Jun 2020 16:20:14 +0000 (18:20 +0200)]
avformat/movenc: fix remuxing eia-608 into mov from other containers

4 months agoavformat/mov: fix demuxing of eia-608
Paul B Mahol [Sun, 14 Jun 2020 12:19:56 +0000 (14:19 +0200)]
avformat/mov: fix demuxing of eia-608

Fixes #4616.

4 months agoavcodec/ccaption_dec: add support for colors
Paul B Mahol [Sun, 14 Jun 2020 10:39:31 +0000 (12:39 +0200)]
avcodec/ccaption_dec: add support for colors

4 months agoavformat/mov: Fix reel_name size check
Andreas Rheinhardt [Sun, 14 Jun 2020 18:54:46 +0000 (20:54 +0200)]
avformat/mov: Fix reel_name size check

Only read str_size bytes from offset 30 of extradata if the extradata is
indeed at least 30 + str_size bytes long.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/mov: Fix memleak upon encountering repeating tags
Andreas Rheinhardt [Sun, 14 Jun 2020 07:19:38 +0000 (09:19 +0200)]
avformat/mov: Fix memleak upon encountering repeating tags

mov_read_custom tries to read three strings belonging to three different
tags. When an already encountered tag is encountered again, a new buffer
for the string to be read is allocated and stored in the pointer
destined for this particular tag. But in this scenario, said pointer
already holds the address of the string read earlier, leading to a leak.

This commit therefore aborts the reading process upon encountering
an already encountered tag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/matroskaenc: Don't use NULL for %s format string
Andreas Rheinhardt [Sun, 14 Jun 2020 01:35:41 +0000 (03:35 +0200)]
avformat/matroskaenc: Don't use NULL for %s format string

The argument pertaining to a printf %s conversion specifier must not
be NULL, even if the precision (i.e. the number of characters to write)
is zero. If it is NULL, it is undefined behaviour.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/webvttdec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:29:17 +0000 (03:29 +0200)]
avformat/webvttdec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/vplayerdec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:28:56 +0000 (03:28 +0200)]
avformat/vplayerdec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/tedcaptionsdec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:27:43 +0000 (03:27 +0200)]
avformat/tedcaptionsdec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if allocating the AVStream for the subtitles fails.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/subviewerdec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:27:11 +0000 (03:27 +0200)]
avformat/subviewerdec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/subviewer1dec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:26:40 +0000 (03:26 +0200)]
avformat/subviewer1dec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/stldec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:24:23 +0000 (03:24 +0200)]
avformat/stldec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/srtdec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:23:27 +0000 (03:23 +0200)]
avformat/srtdec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/sccdec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:22:32 +0000 (03:22 +0200)]
avformat/sccdec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/samidec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:21:46 +0000 (03:21 +0200)]
avformat/samidec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle
or when creating extradata.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/pjsdec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:21:03 +0000 (03:21 +0200)]
avformat/pjsdec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/mpsubdec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:20:09 +0000 (03:20 +0200)]
avformat/mpsubdec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon creating an AVStream.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/mpl2dec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:19:32 +0000 (03:19 +0200)]
avformat/mpl2dec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/microdvddec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:16:15 +0000 (03:16 +0200)]
avformat/microdvddec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle
or when allocating extradata.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/lrcdec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:12:00 +0000 (03:12 +0200)]
avformat/lrcdec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/jacosubdec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:09:08 +0000 (03:09 +0200)]
avformat/jacosubdec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/assdec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:07:28 +0000 (03:07 +0200)]
avformat/assdec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle
or if creating the extradata failed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/aqtitledec: Fix memleak upon read header failure
Andreas Rheinhardt [Sun, 14 Jun 2020 01:04:29 +0000 (03:04 +0200)]
avformat/aqtitledec: Fix memleak upon read header failure

The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/mov: Fix memleaks upon read_header failure
Andreas Rheinhardt [Sat, 13 Jun 2020 22:37:40 +0000 (00:37 +0200)]
avformat/mov: Fix memleaks upon read_header failure

By default, a demuxer's read_close function is not called automatically
if an error happens when reading the header; instead it is up to the
demuxer to clean up after itself in this case. The mov demuxer did this
by calling its read_close function when it encountered some errors when
reading the header. Yet for other errors (mostly adding side-data to
streams) this has been forgotten, so that all the internal structures
of the demuxer leak.

This commit fixes this by making sure mov_read_close is called when
necessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/omadec: Fix memleaks upon read_header failure
Andreas Rheinhardt [Sat, 13 Jun 2020 22:24:55 +0000 (00:24 +0200)]
avformat/omadec: Fix memleaks upon read_header failure

Fixes possible leaks of id3v2 metadata as well as an AVDES struct in
case the content is encrypted and an error happens lateron.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/matroskadec: Fix memleaks in WebM DASH manifest demuxer
Andreas Rheinhardt [Sat, 13 Jun 2020 21:58:32 +0000 (23:58 +0200)]
avformat/matroskadec: Fix memleaks in WebM DASH manifest demuxer

In certain error scenarios, the underlying Matroska demuxer was not
properly closed, causing leaks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/matroskadec: Use right number of tracks
Andreas Rheinhardt [Fri, 30 Aug 2019 13:18:29 +0000 (15:18 +0200)]
avformat/matroskadec: Use right number of tracks

When demuxing a Matroska/WebM file, streams are added for tracks and for
attachments, so that the array containing the former can be NULL even
when the corresponding AVFormatContext has streams. So check for there
to be tracks in the MatroskaDemuxContext instead of just streams in the
AVFormatContext before dereferencing the pointer to the tracks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/matroskadec: Fix handling gigantic durations
Andreas Rheinhardt [Tue, 3 Sep 2019 22:50:11 +0000 (00:50 +0200)]
avformat/matroskadec: Fix handling gigantic durations

matroska_parse_block currently asserts that the duration is not equal to
AV_NOPTS_VALUE, but there is nothing that actually guarantees this. It
is easy to create (spec-compliant) files which run into this assert;
so replace it and instead cap the duration to INT64_MAX, as the duration
field of an AVPacket is an int64_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavformat/matroskadec: Move AVBufferRef instead of copying, fix memleak
Andreas Rheinhardt [Sat, 13 Jun 2020 20:34:19 +0000 (22:34 +0200)]
avformat/matroskadec: Move AVBufferRef instead of copying, fix memleak

EBML binary elements are already made reference-counted when read;
so when populating the AVStream.attached_pic, one does not need to
allocate a new buffer for the data; instead the current code just
creates a new reference to the underlying AVBuffer. But this can be
improved even further: Just move the already existing reference.

This also fixes a memleak that happens upon error because
matroska_read_close has not been called in this scenario.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agolavdevice: Add AudioToolbox output device.
Thilo Borgmann [Mon, 15 Jun 2020 13:09:33 +0000 (15:09 +0200)]
lavdevice: Add AudioToolbox output device.

4 months agoavformat/dashenc: Add hls_master_name option
Przemysław Sobala [Wed, 10 Jun 2020 11:14:36 +0000 (13:14 +0200)]
avformat/dashenc: Add hls_master_name option

4 months agoavformat/hlsenc: Always treat numbers as decimal
Andreas Rheinhardt [Mon, 15 Jun 2020 03:09:07 +0000 (05:09 +0200)]
avformat/hlsenc: Always treat numbers as decimal

c801ab43c36e8c4f88121aa09af26c77bcbd671b caused a regression: The stream
number is now parsed with strtoll without a fixed basis; as a
consequence, the "010" in a variant stream mapping like "a:010" is now
treated as an octal number (i.e. as eight, not ten). This was not
intended and may break some scripts, so this commit restores the old
behaviour.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavcodec/iirfilter: Fix memleak
Andreas Rheinhardt [Mon, 15 Jun 2020 01:33:13 +0000 (03:33 +0200)]
avcodec/iirfilter: Fix memleak

Commit 17e88bf0df21906633a7d36d9f2aeeeb5b6d3267 created a memleak by
removing a call to ff_iir_filter_free_coeffsp on error; this has been
found by Coverity (ID 1464159). This commit fixes the memleak by
readding the call to ff_iir_filter_free_coeffsp.

Notice that this is not a simple revert, because several macros that
were used before 17e88bf0df21906633a7d36d9f2aeeeb5b6d3267 were replaced
in commit 44863b2c2d5a31d82aafa71cdbd180d6bfbed5b4 and completely removed
in 2658680df4fc606522e5f65899afb9a98b47d287.

Reviewed-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavcodec/hevc_mp4toannexb_bsf: Check NAL size against available input
Andreas Rheinhardt [Wed, 27 May 2020 17:09:14 +0000 (19:09 +0200)]
avcodec/hevc_mp4toannexb_bsf: Check NAL size against available input

The hevc_mp4toannexb bsf does not explicitly check whether a NAL unit
is so big that it extends beyond the end of the input packet; it does so
only implicitly by using the checked version of the bytestream2 API.
But this has downsides compared to real checks: It can lead to huge
allocations (up to 2GiB) even when the input packet is just a few bytes.
And furthermore it leads to uninitialized data being output.
So add a check to error out early if it happens.

Also check directly whether there is enough data for the length field.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 months agoavcodec/h264: create user data unregistered SEI side data for H.264
Limin Wang [Thu, 11 Jun 2020 04:50:46 +0000 (12:50 +0800)]
avcodec/h264: create user data unregistered SEI side data for H.264

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoavfilter/vf_showinfo: display H.26[45] user data unregistered sei message
Limin Wang [Thu, 11 Jun 2020 23:32:29 +0000 (07:32 +0800)]
avfilter/vf_showinfo: display H.26[45] user data unregistered sei message

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoavcodec/hevc_sei: add support for user data unregistered SEI message
Limin Wang [Thu, 11 Jun 2020 02:25:47 +0000 (10:25 +0800)]
avcodec/hevc_sei: add support for user data unregistered SEI message

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoavcodec/cbs_av1: abort when written inferred values don't match
James Almer [Thu, 11 Jun 2020 16:06:17 +0000 (13:06 -0300)]
avcodec/cbs_av1: abort when written inferred values don't match

If this happens, it's a sign of parsing issues earlier in the process, or
misuse by the calling module.

Prevents writing invalid bitstreams.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
4 months agoavcodec/cbs_h2645: abort when written inferred values don't match
James Almer [Thu, 11 Jun 2020 16:06:10 +0000 (13:06 -0300)]
avcodec/cbs_h2645: abort when written inferred values don't match

If this happens, it's a sign of parsing issues earlier in the process, or
misuse by the calling module.

Prevents writing invalid bitstreams.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
4 months agoavformat/mxfdec: free duplicated utf16 strings
Michael Niedermayer [Sun, 14 Jun 2020 17:45:05 +0000 (19:45 +0200)]
avformat/mxfdec: free duplicated utf16 strings

Fixes: memleak
Fixes: 23415/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5124814510751744

Suggested-by: Marton Balint <cus@passwd.hu>
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavformat/4xm: Check that a video stream was created before returning packets for it
Michael Niedermayer [Sun, 14 Jun 2020 17:51:23 +0000 (19:51 +0200)]
avformat/4xm: Check that a video stream was created before returning packets for it

Fixes: assertion failure
Fixes: 23434/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5227750851084288.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavcodec/libzvbi-teletextdec: fix txt_default_region limits
Marton Balint [Mon, 8 Jun 2020 23:31:00 +0000 (01:31 +0200)]
avcodec/libzvbi-teletextdec: fix txt_default_region limits

Max region ID is 87. Also the region affects not only the G0 charset but G2 and
the national subset as well.

Signed-off-by: Marton Balint <cus@passwd.hu>
4 months agoavcodec/ffwavesynth: Avoid undefined operation on ts overflow
Michael Niedermayer [Sat, 13 Jun 2020 19:47:03 +0000 (21:47 +0200)]
avcodec/ffwavesynth: Avoid undefined operation on ts overflow

Alternatively these conditions could be treated as errors
Fixes: 23147/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-5639254549200896
Fixes: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'int64_t' (aka 'long')

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavcodec/mv30: check mode_size vs. input space
Michael Niedermayer [Sat, 13 Jun 2020 14:03:14 +0000 (16:03 +0200)]
avcodec/mv30: check mode_size vs. input space

Fixes: Timeout (longer than my patience vs 1sec)
Fixes: 22984/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MV30_fuzzer-5630021988515840

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavcodec/mpeg4videodec: Fix 2 integer overflows in get_amv()
Michael Niedermayer [Thu, 11 Jun 2020 20:22:57 +0000 (22:22 +0200)]
avcodec/mpeg4videodec: Fix 2 integer overflows in get_amv()

Fixes: signed integer overflow: -144876608 * 16 cannot be represented in type 'int'
Fixes: 22782/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-6039584977977344

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavcodec/jpeg2000dec: Fix/check for multiple integer overflows
Michael Niedermayer [Thu, 11 Jun 2020 20:45:27 +0000 (22:45 +0200)]
avcodec/jpeg2000dec: Fix/check for multiple integer overflows

Fixes: shift exponent 35 is too large for 32-bit type 'int'
Fixes: 22857/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5202709358837760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavformat/utils: Print analyze duration and probesize when printing a suggestion to...
Michael Niedermayer [Mon, 8 Jun 2020 09:07:27 +0000 (11:07 +0200)]
avformat/utils: Print analyze duration and probesize when printing a suggestion to increase them

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavcodec/lossless_audiodsp: Fix undefined overflows in scalarproduct_and_madd_int16_c()
Michael Niedermayer [Sun, 7 Jun 2020 17:24:10 +0000 (19:24 +0200)]
avcodec/lossless_audiodsp: Fix undefined overflows in scalarproduct_and_madd_int16_c()

Fixes: signed integer overflow: 2142077091 + 6881070 cannot be represented in type 'int'
Fixes: 22737/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMALOSSLESS_fuzzer-5958388889681920

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavcodec/sonic: Fix several integer state overflows
Michael Niedermayer [Sun, 10 May 2020 19:09:45 +0000 (21:09 +0200)]
avcodec/sonic: Fix several integer state overflows

Fixes: signed integer overflow: -234 * -14797801 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5695924975435776
Fixes: 22275/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5695924975435776

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavcodec/sonic: Fix several integer overflows
Michael Niedermayer [Thu, 20 Feb 2020 18:56:39 +0000 (19:56 +0100)]
avcodec/sonic: Fix several integer overflows

Fixes: signed integer overflow: 2129689466 + 2129689466 cannot be represented in type 'int'
Fixes: 20715/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5155263109922816

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavformat/oggdec: Disable mid stream codec changes
Michael Niedermayer [Sat, 13 Jun 2020 10:36:49 +0000 (12:36 +0200)]
avformat/oggdec: Disable mid stream codec changes

Fixes: 22082/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5688619118624768
Fixes: crash from V-codecs/Theora/theora_testsuite_broken/multi2.ogg

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Suggested-by: Lynne on IRC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavcodec/mpeg4videodec: avoid invalid values and reinitialize in format changes for...
Michael Niedermayer [Sat, 13 Jun 2020 09:56:01 +0000 (11:56 +0200)]
avcodec/mpeg4videodec: avoid invalid values and reinitialize in format changes for studio profile

Fixes: out of array access
Fixes: 23327/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5134822992510976

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavcodec/pixlet: Fix log(0) check
Michael Niedermayer [Sat, 13 Jun 2020 09:21:52 +0000 (11:21 +0200)]
avcodec/pixlet: Fix log(0) check

Fixes: passing zero to clz(), which is not a valid argument
Fixes: 23337/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PIXLET_fuzzer-5179131989065728

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavformat/ape: Cleanup after ape_read_header() failure
Michael Niedermayer [Sat, 13 Jun 2020 09:13:21 +0000 (11:13 +0200)]
avformat/ape: Cleanup after ape_read_header() failure

Fixes: memleaks
Fixes: 23306/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5635436931448832

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoavcodec/iff: Fix off by x error
Michael Niedermayer [Sat, 13 Jun 2020 08:48:14 +0000 (10:48 +0200)]
avcodec/iff: Fix off by x error

Fixes: out of array access
Fixes: 23245/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5723121327013888.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 months agoswscale: cosmetic fixes
Nelson Gomez [Sun, 26 Apr 2020 02:37:03 +0000 (19:37 -0700)]
swscale: cosmetic fixes

Signed-off-by: Nelson Gomez <nelson.gomez@microsoft.com>
4 months agoswscale/x86/output: add AVX2 version of yuv2nv12cX
Nelson Gomez [Sun, 26 Apr 2020 02:37:02 +0000 (19:37 -0700)]
swscale/x86/output: add AVX2 version of yuv2nv12cX

256 bits is just wide enough to fit all the operands needed to vectorize
the software implementation, but AVX2 is needed to for a couple of
instructions like cross-lane permutation.

Output is bit-for-bit identical to C.

Signed-off-by: Nelson Gomez <nelson.gomez@microsoft.com>
4 months agoswscale: make yuv2interleavedX more asm-friendly
Nelson Gomez [Sun, 26 Apr 2020 02:37:01 +0000 (19:37 -0700)]
swscale: make yuv2interleavedX more asm-friendly

Extracting information from SwsContext in assembly is difficult, and
rearranging SwsContext just for asm access didn't look good. These
functions only need a couple of fields from it anyway, so just make
them parameters in their own right.

Signed-off-by: Nelson Gomez <nelson.gomez@microsoft.com>
4 months agoavcodec/smvjpegdec: remove uninitialized ret
Limin Wang [Fri, 12 Jun 2020 23:50:22 +0000 (07:50 +0800)]
avcodec/smvjpegdec: remove uninitialized ret

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoavcodec/mpegvideo: remove extra space
Limin Wang [Fri, 12 Jun 2020 23:47:13 +0000 (07:47 +0800)]
avcodec/mpegvideo: remove extra space

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoswscale/utils: return better error code from initFilter()
Limin Wang [Sat, 13 Jun 2020 05:52:20 +0000 (13:52 +0800)]
swscale/utils: return better error code from initFilter()

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoswscale/utils: reindent
Limin Wang [Fri, 12 Jun 2020 23:29:43 +0000 (07:29 +0800)]
swscale/utils: reindent

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agolavf/prompeg: prompeg_write() must report data all was written
David Holroyd [Tue, 9 Jun 2020 13:37:10 +0000 (21:37 +0800)]
lavf/prompeg: prompeg_write() must report data all was written

Previously, prompeg_write() would only report to caller that bytes we
written when a FEC packet was actually created.  Not all RTP packets are
expected to generate a FEC packet however, so this behavior was causing
avio to retry writing the RTP packet, eventually forcing the FEC state
machine to send a FEC packet erroneously (and so breaking out of the
retry loop).

This was resulting in incorrect FEC data being generated, and far too
many FEC packets to be sent (~100% FEC overhead).

fix #7863

Signed-off-by: David Holroyd <david.holroyd@m2amedia.tv>
4 months agolavu/internal: Fix comment for avpriv_dict_set_timestamp
Jun Zhao [Sat, 6 Jun 2020 09:04:58 +0000 (17:04 +0800)]
lavu/internal: Fix comment for avpriv_dict_set_timestamp

Fix comment for avpriv_dict_set_timestamp from b72a7b96f84

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
4 months agolavc/qsv: fix make checkheaders warning
Jun Zhao [Sun, 31 May 2020 08:12:36 +0000 (16:12 +0800)]
lavc/qsv: fix make checkheaders warning

make checkheaders will get warning as follow:

In file included from libavcodec/qsv_internal.h.c:1:
./libavcodec/qsv_internal.h:24:5: warning: "CONFIG_VAAPI" is not defined, evaluates to 0 [-Wundef]
   24 | #if CONFIG_VAAPI
      |     ^~~~~~~~~~~~

include "config.h" to fix the warning

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
4 months agoavformat/sccdec: move pos variables outside of loop
Paul B Mahol [Sat, 13 Jun 2020 10:23:29 +0000 (12:23 +0200)]
avformat/sccdec: move pos variables outside of loop

Ensures that sub->pos is always correct.

4 months agoavcodec/ccaption_dec: switch active screen in end of caption early
Paul B Mahol [Sat, 13 Jun 2020 09:57:33 +0000 (11:57 +0200)]
avcodec/ccaption_dec: switch active screen in end of caption early

Fixes dropping of last caption.

4 months agoavcodec/ccaption_dec: remove unused arguments from function
Paul B Mahol [Sat, 13 Jun 2020 09:48:43 +0000 (11:48 +0200)]
avcodec/ccaption_dec: remove unused arguments from function

4 months agoavcodec/ccaption_dec: check for error codes
Paul B Mahol [Sat, 13 Jun 2020 09:41:53 +0000 (11:41 +0200)]
avcodec/ccaption_dec: check for error codes

4 months agoavutil/internal: remove FF_ALLOCx{_ARRAY}_OR_GOTO macros
Limin Wang [Tue, 2 Jun 2020 11:18:32 +0000 (19:18 +0800)]
avutil/internal: remove FF_ALLOCx{_ARRAY}_OR_GOTO macros

These functions have a terrible design, let us fix them before extending
them.
First design mistake: no error code. A helper function for testing
memory allocation failure where AVERROR(ENOMEM) does not appear is
absurd.

Second design mistake: printing a message. Return the error code, let
the caller print the error message.

Third design mistake: hard-coded use of goto.

http://ffmpeg.org/pipermail/ffmpeg-devel/2020-May/262544.html

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoswscale/utils: remove FF_ALLOC_ARRAY_OR_GOTO macros
Limin Wang [Tue, 2 Jun 2020 13:54:21 +0000 (21:54 +0800)]
swscale/utils: remove FF_ALLOC_ARRAY_OR_GOTO macros

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoavcodec/alac: remove FF_ALLOC_OR_GOTO and gotos label
Limin Wang [Fri, 29 May 2020 14:38:31 +0000 (22:38 +0800)]
avcodec/alac: remove FF_ALLOC_OR_GOTO and gotos label

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 months agoavcodec/mpegvideo_enc: remove FF_ALLOCZ_ARRAY_OR_GOTO and gotos lable
Limin Wang [Tue, 2 Jun 2020 15:59:15 +0000 (23:59 +0800)]
avcodec/mpegvideo_enc: remove FF_ALLOCZ_ARRAY_OR_GOTO and gotos lable

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>