]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoavformat/url: fix ff_make_absolute_url with Windows file paths
Marton Balint [Fri, 2 Apr 2021 15:07:54 +0000 (17:07 +0200)]
avformat/url: fix ff_make_absolute_url with Windows file paths

Ugly, but a lot less broken than it was.

Fixes ticket #9166.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/utils: add helper functions to retrieve index entries from an AVStream
James Almer [Tue, 23 Mar 2021 18:36:22 +0000 (15:36 -0300)]
avformat/utils: add helper functions to retrieve index entries from an AVStream

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agodoc/muxers: fix alphabetical sorting of entries
Gyan Doshi [Wed, 7 Apr 2021 09:11:44 +0000 (14:41 +0530)]
doc/muxers: fix alphabetical sorting of entries

3 years agomov: Skip computing SAR from invalid display matrix elements
Vittorio Giovara [Tue, 30 Mar 2021 14:47:39 +0000 (16:47 +0200)]
mov: Skip computing SAR from invalid display matrix elements

3 years agoavcodec/bsf: Simplify getting codec name
Andreas Rheinhardt [Fri, 2 Apr 2021 13:21:51 +0000 (15:21 +0200)]
avcodec/bsf: Simplify getting codec name

All codec ids on BSF whitelists have a codec descriptor, so one can just
use avcodec_get_name() without worrying about the case of what happens
when no codec descriptor is found.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/mov: check offset for overflow in mov_probe()
Michael Niedermayer [Sun, 4 Apr 2021 19:01:46 +0000 (21:01 +0200)]
avformat/mov: check offset for overflow in mov_probe()

Fixes: Invalid read of size 4
Fixes: ASAN_Deadlysignal.zip
Found-by: Hardik Shah <hardik05@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/options: Remove always-true check
Andreas Rheinhardt [Thu, 1 Apr 2021 21:16:37 +0000 (23:16 +0200)]
avcodec/options: Remove always-true check

Every codec has a name.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavutil/frame: Return 0 on success in av_frame_ref()
Andreas Rheinhardt [Thu, 1 Apr 2021 21:04:19 +0000 (23:04 +0200)]
avutil/frame: Return 0 on success in av_frame_ref()

av_frame_copy() is allowed to return values >= 0 on success, whereas
the documentation of av_frame_ref() states that the return value is 0 on
success. Ergo the latter must not just return the former's return value.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/dss: Return 0 on success
Andreas Rheinhardt [Thu, 1 Apr 2021 21:02:18 +0000 (23:02 +0200)]
avformat/dss: Return 0 on success

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/dss: Avoid using intermediate buffer
Andreas Rheinhardt [Thu, 1 Apr 2021 20:55:31 +0000 (22:55 +0200)]
avformat/dss: Avoid using intermediate buffer

All one needs is one byte beyond the end of the normal data; and because
the packet is padded, one already has it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/dss: Set values known during read_header in read_header
Andreas Rheinhardt [Thu, 1 Apr 2021 20:31:13 +0000 (22:31 +0200)]
avformat/dss: Set values known during read_header in read_header

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/mpegtsenc: Preserve disposition in the absence of language
Andreas Rheinhardt [Sat, 3 Apr 2021 05:14:40 +0000 (07:14 +0200)]
avformat/mpegtsenc: Preserve disposition in the absence of language

Implements ticket #9113.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavfilter/vf_find_rect: Use correct format specifier
Andreas Rheinhardt [Sun, 4 Apr 2021 09:26:47 +0000 (11:26 +0200)]
avfilter/vf_find_rect: Use correct format specifier

Fixes the following GCC warning:
warning: format ‘%lld’ expects argument of type ‘long long int’,
but argument 4 has type ‘int64_t’ {aka ‘long int’} [-Wformat=]

Reviewed-by: Gyan Doshi <ffmpeg@gyani.pro>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoatomics: Fix the win32 atomic_exchange function
Martin Storsjö [Sat, 3 Apr 2021 21:04:46 +0000 (00:04 +0300)]
atomics: Fix the win32 atomic_exchange function

This fixes building with MSVC after
a2a38b160620d91bc3f895dadc4501c589998b9c.

Remove the stray semicolon, and add casts for the input argument
(which is an intptr_t*) to the right type (PVOID volatile *).

Signed-off-by: Martin Storsjö <martin@martin.st>
3 years agoavfilter/find_rect: write score to metadata
Gyan Doshi [Thu, 1 Apr 2021 13:16:20 +0000 (18:46 +0530)]
avfilter/find_rect: write score to metadata

3 years agoavfilter/find_rect: add option to discard non-matching frames
Gyan Doshi [Thu, 1 Apr 2021 12:52:03 +0000 (18:22 +0530)]
avfilter/find_rect: add option to discard non-matching frames

Default is disabled.

3 years agoavfilter/find_rect: improve logging
Gyan Doshi [Thu, 1 Apr 2021 12:39:25 +0000 (18:09 +0530)]
avfilter/find_rect: improve logging

Log now indicates timestamps of frames where a match is made.
Loglevel is changed to INFO since the user specifically wants this info.

3 years agoavcodec/wmavoice: Check operations that can fail
Andreas Rheinhardt [Sat, 3 Apr 2021 15:45:17 +0000 (17:45 +0200)]
avcodec/wmavoice: Check operations that can fail

There might be segfaults on failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mjpegdec: Fix leak in case ICC array allocations fail partially
Andreas Rheinhardt [Sat, 3 Apr 2021 13:39:35 +0000 (15:39 +0200)]
avcodec/mjpegdec: Fix leak in case ICC array allocations fail partially

If only one of the two arrays used for the ICC profile could be
successfully allocated, it might be overwritten and leak when
the next ICC entry is encountered. Fix this by using a common struct,
so that one has only one array to allocate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/cfhd: Keep track of which subbands have been read
Michael Niedermayer [Sat, 3 Apr 2021 14:04:48 +0000 (16:04 +0200)]
avcodec/cfhd: Keep track of which subbands have been read

This avoids use of uninitialized data
also several checks are inside the band reading code
so it is important that it is run at least once

Fixes: out of array accesses
Fixes: 28209/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5684714694377472
Fixes: 32124/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5425980681355264
Fixes: 30519/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4558757155700736
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/cfhd: Require valid setup before Lowpass coefficients, BandHeader and BandSec...
Michael Niedermayer [Sat, 3 Apr 2021 13:19:22 +0000 (15:19 +0200)]
avcodec/cfhd: Require valid setup before Lowpass coefficients, BandHeader and BandSecondPass

Previously the code skipped all security checks when these where encountered but prior data was incorrect.
Also replace an always true condition by an assert

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/cfhd: Check transform_type consistently
Michael Niedermayer [Sat, 3 Apr 2021 12:40:50 +0000 (14:40 +0200)]
avcodec/cfhd: Check transform_type consistently

Fixes: out of array accesses
Fixes: 29754/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-6333598414274560
Fixes: 30519/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-6298424511168512
Fixes: 30739/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5011292836462592
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/mjpegdec: Check initializing Huffman tables
Andreas Rheinhardt [Sat, 3 Apr 2021 14:00:56 +0000 (16:00 +0200)]
avcodec/mjpegdec: Check initializing Huffman tables

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mjpegdec: Fix leak in case of invalid external Huffman tables
Andreas Rheinhardt [Sat, 3 Apr 2021 12:12:44 +0000 (14:12 +0200)]
avcodec/mjpegdec: Fix leak in case of invalid external Huffman tables

When using external Huffman tables fails during init, the decoder
reverts back to using the default Huffman tables; and when doing so,
the current VLC tables leak because init_default_huffman_tables()
doesn't free them before overwriting them.

Sample:
samples.ffmpeg.org/archive/all/avi+mjpeg+pcm_s16le++mjpeg-interlace.avi

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/a64multienc: Don't use static buffers, fix potential races
Andreas Rheinhardt [Sat, 3 Apr 2021 11:07:43 +0000 (13:07 +0200)]
avcodec/a64multienc: Don't use static buffers, fix potential races

render_charset() used static buffers that are always completely
initialized before every use, so that it is unnecessary for the
values in these arrays to be kept after leaving the function.
Given that this is not only unnecessary, but harmful due to the
possibility of data races if several instances of a64multi/a64multi5
run simultaneously these buffers have been replaced by ordinary buffers
on the stack (they are small enough for this).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/rawdec: Free bitstream_buf
Andreas Rheinhardt [Sat, 3 Apr 2021 09:54:12 +0000 (11:54 +0200)]
avcodec/rawdec: Free bitstream_buf

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agodoc/ffmpeg: clarify what -hwaccels list indicates
Gyan Doshi [Sat, 3 Apr 2021 05:25:12 +0000 (10:55 +0530)]
doc/ffmpeg: clarify what -hwaccels list indicates

Fixes #8204

3 years agoavformat/vividas: Fix crash when seeking without audio stream
Andreas Rheinhardt [Fri, 2 Apr 2021 19:03:39 +0000 (21:03 +0200)]
avformat/vividas: Fix crash when seeking without audio stream

The current code tries the access the codecpar of a nonexistent
audio stream when seeking. Stop that. Fixes ticket #9121.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavutil/cpu: Fix race condition in av_cpu_count()
Andreas Rheinhardt [Wed, 2 Dec 2020 22:57:16 +0000 (23:57 +0100)]
avutil/cpu: Fix race condition in av_cpu_count()

av_cpu_count() intends to emit a debug message containing the number of
logical cores when called the first time. The check currently works with
a static volatile int; yet this does not help at all in case of
concurrent accesses by multiple threads. So replace this with an
atomic_int.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ass_split: Don't presume strlen to be >= 2
Andreas Rheinhardt [Tue, 1 Dec 2020 13:24:10 +0000 (14:24 +0100)]
avcodec/ass_split: Don't presume strlen to be >= 2

Fixes potential heap-buffer-overflow.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/binkaudio: Check return value of functions that can fail
Andreas Rheinhardt [Mon, 30 Nov 2020 21:30:49 +0000 (22:30 +0100)]
avcodec/binkaudio: Check return value of functions that can fail

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/binkaudio: Fix memleak upon init failure
Andreas Rheinhardt [Mon, 30 Nov 2020 21:24:10 +0000 (22:24 +0100)]
avcodec/binkaudio: Fix memleak upon init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/flacenc: Fix memleak upon init error
Andreas Rheinhardt [Sun, 29 Nov 2020 21:28:37 +0000 (22:28 +0100)]
avcodec/flacenc: Fix memleak upon init error

An AVMD5 struct would leak if an error happened after its allocation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/proresenc_anatoliy: Fix memleak upon init error
Andreas Rheinhardt [Fri, 27 Nov 2020 14:08:00 +0000 (15:08 +0100)]
avcodec/proresenc_anatoliy: Fix memleak upon init error

A buffer may leak in case of YUVA444P10 with dimensions that are not
both divisible by 16.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/bsf: Fix segfault when freeing half-allocated BSF
Andreas Rheinhardt [Fri, 2 Apr 2021 12:17:56 +0000 (14:17 +0200)]
avcodec/bsf: Fix segfault when freeing half-allocated BSF

When allocating a BSF fails, it could happen that the BSF's close
function has been called despite a failure to allocate the private data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/av1_metadata_bsf: Check for the existence of units
Andreas Rheinhardt [Fri, 2 Apr 2021 15:16:39 +0000 (17:16 +0200)]
avcodec/av1_metadata_bsf: Check for the existence of units

Fixes a crash with ISOBMFF extradata containing no OBUs.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/h264_metadata_bsf: Don't add AUD to extradata
Andreas Rheinhardt [Fri, 2 Apr 2021 14:59:42 +0000 (16:59 +0200)]
avcodec/h264_metadata_bsf: Don't add AUD to extradata

This is a regression since switching to the generic CBS BSF code.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/tiff: Don't use separate temporary buffer for fax
Andreas Rheinhardt [Tue, 30 Mar 2021 06:26:43 +0000 (08:26 +0200)]
avcodec/tiff: Don't use separate temporary buffer for fax

Also don't unnecessarily copy the input data around if it needn't be
reversed; and remove a redundant memset -- av_fast_padded_malloc()
already does this for us.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/msmpeg4enc: Don't use code for static init that can fail
Andreas Rheinhardt [Thu, 10 Dec 2020 05:01:45 +0000 (06:01 +0100)]
avcodec/msmpeg4enc: Don't use code for static init that can fail

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dss: Don't prematurely modify context variable
Andreas Rheinhardt [Thu, 1 Apr 2021 20:07:40 +0000 (22:07 +0200)]
avformat/dss: Don't prematurely modify context variable

The DSS demuxer currently decrements a counter that should be positive
at the beginning of read_packet; should it become negative, it means
that the data to be read can't be read contiguosly, but has to be read
in two parts. In this case the counter is incremented again after the
first read if said read succeeded; if not, the counter stays negative.

This can lead to problems in further read_packet calls; in tickets #9020
and #9023 it led to segfaults if one tries to seek lateron if the seek
failed and generic seek tried to read from the beginning. But it could
also happen when av_new_packet() failed and the user attempted to read
again afterwards.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/utils: Check allocations for failure
Andreas Rheinhardt [Thu, 1 Apr 2021 16:18:13 +0000 (18:18 +0200)]
avformat/utils: Check allocations for failure

There would be leaks in case of failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/ac3enc: Simplify AC-3 bit counting
Andreas Rheinhardt [Thu, 1 Apr 2021 14:47:11 +0000 (16:47 +0200)]
avcodec/ac3enc: Simplify AC-3 bit counting

When encoding E-AC-3, whether coupling is on or not determines whether
an additional frame based coupling exponent strategy element frmcplexpstr
(of size five bits) is present in the bitstream. So just add five to the
number of bits when counting them instead of adding 5*s->cpl_on (the
latter field is currently only 0 or 1, so it doesn't make a difference).

Furthermore, move some parts of the bit allocation that doesn't change
per-frame to count_frame_bits_fixed() (which is only run once during
init).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/[e]ac3enc: Fix indentation
Andreas Rheinhardt [Tue, 30 Mar 2021 18:01:17 +0000 (20:01 +0200)]
avcodec/[e]ac3enc: Fix indentation

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/ac3enc: Avoid needlessly copying encoded packets around
Andreas Rheinhardt [Mon, 29 Mar 2021 16:54:46 +0000 (18:54 +0200)]
avcodec/ac3enc: Avoid needlessly copying encoded packets around

AC-3 and EAC-3 are codecs whose packet sizes are known in advance,
so one can use the min_size parameter of ff_alloc_packet2() to
allocate exactly this amount. This avoids a memcpy later in
av_packet_make_refcounted() in encode_simple_internal().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/ac3enc: Use actual size of buffer in init_put_bits()
Andreas Rheinhardt [Mon, 29 Mar 2021 16:19:43 +0000 (18:19 +0200)]
avcodec/ac3enc: Use actual size of buffer in init_put_bits()

Since the very beginning (since de6d9b6404bfd1c589799142da5a95428f146edd)
the AC-3 encoder used AC3_MAX_CODED_FRAME_SIZE (namely 3840) for the
size of the output buffer (without any check at all).
This causes problems when encoding EAC-3 for which the maximum is too small,
smaller than the actual size of the buffer: One can run into asserts used
by the PutBits API. Ticket #8513 is about such a case and this commit
fixes it by using the real size of the buffer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agodoc/muxers: add entry for A64 muxer
Gyan Doshi [Fri, 2 Apr 2021 06:34:56 +0000 (12:04 +0530)]
doc/muxers: add entry for A64 muxer

3 years agodoc/encoders: add entry for a64 encoders
Gyan Doshi [Fri, 2 Apr 2021 09:43:39 +0000 (15:13 +0530)]
doc/encoders: add entry for a64 encoders

3 years agoavcodec/adpcmenc: don't share a single AVClass between multiple AVCodecs.
Zane van Iperen [Thu, 1 Apr 2021 10:31:35 +0000 (20:31 +1000)]
avcodec/adpcmenc: don't share a single AVClass between multiple AVCodecs.

Temporary fix until AVClass::child_class_next is gone.

Reviewed-By: James Almer <jamrial@gmail.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agolibswscale/x86/yuv2yuvX: Removes unrolling for mmx and mmxext
Alan Kelly [Thu, 1 Apr 2021 10:00:15 +0000 (12:00 +0200)]
libswscale/x86/yuv2yuvX: Removes unrolling for mmx and mmxext

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolibswscale/x86/swscale: Only call ff_yuv2yuvX functions if the input size is > 0
Alan Kelly [Thu, 1 Apr 2021 10:00:16 +0000 (12:00 +0200)]
libswscale/x86/swscale: Only call ff_yuv2yuvX functions if the input size is > 0

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agotests/checkasm/sw_scale: adds additional tests sizes for yux2yuvX
Alan Kelly [Thu, 1 Apr 2021 10:00:17 +0000 (12:00 +0200)]
tests/checkasm/sw_scale: adds additional tests sizes for yux2yuvX

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/asf: Use ff_add_attached_pic() to read attached pics
Andreas Rheinhardt [Mon, 29 Mar 2021 07:01:50 +0000 (09:01 +0200)]
avformat/asf: Use ff_add_attached_pic() to read attached pics

Also removes a stack packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/utils: Free new streams in ff_add_attached_pic on error
Andreas Rheinhardt [Mon, 29 Mar 2021 06:50:18 +0000 (08:50 +0200)]
avformat/utils: Free new streams in ff_add_attached_pic on error

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat: Add and use helper function to add attachment streams
Andreas Rheinhardt [Mon, 29 Mar 2021 05:58:56 +0000 (07:58 +0200)]
avformat: Add and use helper function to add attachment streams

All instances of adding attached pictures to a stream or adding
a stream and an attached packet to said stream have several things
in common like setting the index and flags of the packet, setting
the stream disposition etc. This commit therefore factors this out.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/flashsv2enc: Fix undefined NULL + 0
Andreas Rheinhardt [Fri, 26 Mar 2021 17:35:25 +0000 (18:35 +0100)]
avcodec/flashsv2enc: Fix undefined NULL + 0

Affected the vsynth*-flashsv2 FATE-tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavutil/pixdesc: Fix 1 << 32
Andreas Rheinhardt [Fri, 26 Mar 2021 17:22:24 +0000 (18:22 +0100)]
avutil/pixdesc: Fix 1 << 32

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/motion_est: Fix invalid left shift of negative numbers
Andreas Rheinhardt [Fri, 26 Mar 2021 17:18:05 +0000 (18:18 +0100)]
avcodec/motion_est: Fix invalid left shift of negative numbers

Affected many FATE-tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_codecview: Fix undefined left shifts of negative numbers
Andreas Rheinhardt [Fri, 26 Mar 2021 15:24:59 +0000 (16:24 +0100)]
avfilter/vf_codecview: Fix undefined left shifts of negative numbers

Affected the filter-codecview-mvs FATE-test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/g2meet: Fix undefined NULL + 0
Andreas Rheinhardt [Fri, 26 Mar 2021 15:17:04 +0000 (16:17 +0100)]
avcodec/g2meet: Fix undefined NULL + 0

Affected the g2m4 FATE-test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavutil/base64: Fix undefined NULL + 0
Andreas Rheinhardt [Fri, 26 Mar 2021 15:03:27 +0000 (16:03 +0100)]
avutil/base64: Fix undefined NULL + 0

Affected the base64 FATE test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/vmdvideo: Fix NULL + 0
Andreas Rheinhardt [Fri, 26 Mar 2021 14:12:10 +0000 (15:12 +0100)]
avcodec/vmdvideo: Fix NULL + 0

Affected the FATE tests filter-gradfun-sample and sierra-vmd-video.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mss12: Don't apply non-zero offset to null pointer
Andreas Rheinhardt [Fri, 26 Mar 2021 13:40:40 +0000 (14:40 +0100)]
avcodec/mss12: Don't apply non-zero offset to null pointer

Affected the FATE tests mss2-wmv and mss1-pal.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/lcldec: Fix undefined NULL + 0
Andreas Rheinhardt [Fri, 26 Mar 2021 13:11:18 +0000 (14:11 +0100)]
avcodec/lcldec: Fix undefined NULL + 0

Affected the FATE tests vsynth*-zlib, mszh and zlib.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qtrleenc: Fix negative linesizes, don't use NULL + offset
Andreas Rheinhardt [Fri, 26 Mar 2021 12:37:43 +0000 (13:37 +0100)]
avcodec/qtrleenc: Fix negative linesizes, don't use NULL + offset

Before commit f1e17eb446577180ee9976730aacb46563766518, the qtrle
encoder had undefined pointer arithmetic: Outside of a loop, two
pointers were set to point to the ith element (with index i-1) of
a line of a frame. At the end of each loop iteration, these pointers
were decremented, so that they pointed to the -1th element of the line
after the loop. Furthermore, one of these pointers can be NULL (in which
case all pointer arithmetic is automatically undefined behaviour).

Commit f1e17eb44 added a check in order to ensure that the elements
never point to the -1th element of the array: The pointers are only
decremented if they are bigger than the frame's base pointer
(i.e. AVFrame.data[0]). Yet this check does not work at all in case of
negative linesizes; furthermore in case the pointer that can be NULL is
NULL initializing it still involves undefined pointer arithmetic.

This commit fixes both of these issues: First, non-NULL pointers are
initialized to point to the element after the ith element and
decrementing is moved to the beginning of the loop. Second, if a pointer
is NULL, it is just made to point to the other pointer, as this allows
to avoid checks before decrementing it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qtrleenc: Use keyframe when no previous frame is available
Andreas Rheinhardt [Fri, 26 Mar 2021 11:42:21 +0000 (12:42 +0100)]
avcodec/qtrleenc: Use keyframe when no previous frame is available

If keeping a reference to an earlier frame failed, the next frame must
be an I frame for lack of reference frame. This commit implements this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agolibswresample/audioconvert: Fix undefined NULL + 0
Andreas Rheinhardt [Fri, 26 Mar 2021 08:43:22 +0000 (09:43 +0100)]
libswresample/audioconvert: Fix undefined NULL + 0

Affected 26 FATE tests like swr-resample_async-s16p-44100-8000.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/proresdec2: Don't apply non-zero offset to null pointer
Andreas Rheinhardt [Fri, 26 Mar 2021 08:21:22 +0000 (09:21 +0100)]
avcodec/proresdec2: Don't apply non-zero offset to null pointer

Affected ProRes without alpha; affected 32 FATE tests, e.g. prores-422,
prores-422_proxy, prores-422_lt or matroska-prores-header-insertion-bz2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegvideo_enc: Don't apply non-zero offset to null pointer
Andreas Rheinhardt [Fri, 26 Mar 2021 06:15:56 +0000 (07:15 +0100)]
avcodec/mpegvideo_enc: Don't apply non-zero offset to null pointer

Affected many FATE tests (mostly vsynth ones).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_hdcd: Fix undefined shifts
Andreas Rheinhardt [Fri, 26 Mar 2021 05:22:24 +0000 (06:22 +0100)]
avfilter/af_hdcd: Fix undefined shifts

Affected the filter-hdcd-* FATE tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/dcaenc: Fix undefined left shift of negative numbers
Andreas Rheinhardt [Fri, 26 Mar 2021 05:03:49 +0000 (06:03 +0100)]
avcodec/dcaenc: Fix undefined left shift of negative numbers

Affected the acodec-dca and acodec-dca2 FATE tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agotests/matroska: Add test for remuxing annex B H.264 into Matroska
Andreas Rheinhardt [Wed, 31 Mar 2021 18:25:04 +0000 (20:25 +0200)]
tests/matroska: Add test for remuxing annex B H.264 into Matroska

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/pnm_parser: Check image size addition for overflow
Michael Niedermayer [Tue, 30 Mar 2021 11:22:14 +0000 (13:22 +0200)]
avcodec/pnm_parser: Check image size addition for overflow

Fixes: assertion failure
Fixes: out of array access
Fixes: 32664/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGMYUV_fuzzer-6533642202513408.fuzz
Fixes: 32669/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGMYUV_fuzzer-6001928875147264
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/lscrdec: Check length in decode_idat()
Michael Niedermayer [Tue, 30 Mar 2021 11:17:09 +0000 (13:17 +0200)]
avcodec/lscrdec: Check length in decode_idat()

Fixes: out of array access
Fixes: 32264/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LSCR_fuzzer-6684504010915840
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agotools/target_dem_fuzzer: Fix packet leak
Michael Niedermayer [Mon, 22 Mar 2021 20:58:30 +0000 (21:58 +0100)]
tools/target_dem_fuzzer: Fix packet leak

Fixes: 32121/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-4512973109460992
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/imx: Check palette chunk size
Michael Niedermayer [Tue, 30 Mar 2021 10:47:22 +0000 (12:47 +0200)]
avformat/imx: Check palette chunk size

Fixes: out of array write
Fixes: 32116/clusterfuzz-testcase-minimized-ffmpeg_dem_SIMBIOSIS_IMX_fuzzer-6702533894602752
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/h265_metadata_bsf: Check nb_units before accessing the first in h265_metadata...
Michael Niedermayer [Tue, 30 Mar 2021 10:36:08 +0000 (12:36 +0200)]
avcodec/h265_metadata_bsf: Check nb_units before accessing the first in h265_metadata_update_fragment()

Fixes: null pointer dereference
Fixes: 32113/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-4803262287052800
Same as 0c48c332eeb2866d9353125f701e099c48889463

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/rmdec: use larger intermediate type for audio_framesize * sub_packet_h check
Michael Niedermayer [Tue, 30 Mar 2021 09:03:56 +0000 (11:03 +0200)]
avformat/rmdec: use larger intermediate type for audio_framesize * sub_packet_h check

Fixes: signed integer overflow: 65535 * 65535 cannot be represented in type 'int'
Fixes: 31406/clusterfuzz-testcase-minimized-ffmpeg_dem_IVR_fuzzer-5024692843970560
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/exr: Check oe in huf_decode() before use
Michael Niedermayer [Tue, 30 Mar 2021 07:15:27 +0000 (09:15 +0200)]
avcodec/exr: Check oe in huf_decode() before use

Fixes: out of array access
Fixes: 31386/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5773234709594112
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agotls_gnutls: Print the underlying IO error message and pass the error code through
Martin Storsjö [Fri, 26 Mar 2021 13:41:07 +0000 (15:41 +0200)]
tls_gnutls: Print the underlying IO error message and pass the error code through

Signed-off-by: Martin Storsjö <martin@martin.st>
3 years agotls_openssl: Improve quality of printed error messages, pass IO error codes through
Martin Storsjö [Fri, 26 Mar 2021 13:39:53 +0000 (15:39 +0200)]
tls_openssl: Improve quality of printed error messages, pass IO error codes through

Print every error in the stack, if more than one, and don't print
bogus errors if there's none logged within OpenSSL.

Retain the underlying IO error code, print an error message out of
it, and pass the error code on to the caller.

Signed-off-by: Martin Storsjö <martin@martin.st>
3 years agortpenc_mpegts: add AVClass to the muxer context
Gyan Doshi [Wed, 31 Mar 2021 13:10:48 +0000 (18:40 +0530)]
rtpenc_mpegts: add AVClass to the muxer context

3 years agoavcodec/h264_slice: Check input SPS in ff_h264_update_thread_context()
Michael Niedermayer [Sat, 20 Mar 2021 13:36:28 +0000 (14:36 +0100)]
avcodec/h264_slice: Check input SPS in ff_h264_update_thread_context()

Fixes: crash
Fixes: check_pkt.mp4
Found-by: Rafael Dutra <rafael.dutra@cispa.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/mpegpicture: Keep ff_mpeg_framesize_alloc() failure state consistent
Michael Niedermayer [Thu, 18 Mar 2021 18:19:54 +0000 (19:19 +0100)]
avcodec/mpegpicture: Keep ff_mpeg_framesize_alloc() failure state consistent

Fixes: null pointer dereference
Fixes: ff_put_pixels16_sse2.mp4
Found-by: Rafael Dutra <rafael.dutra@cispa.de>
Regression-since: 4b2863ff01b1fe93d9a518523c9098d17a9d8c6f
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/mpc8: check for size overflow in mpc8_get_chunk_header()
Michael Niedermayer [Wed, 17 Mar 2021 20:58:53 +0000 (21:58 +0100)]
avformat/mpc8: check for size overflow in mpc8_get_chunk_header()

Fixes: signed integer overflow: -9223372036854775760 - 50 cannot be represented in type 'long'
Fixes: 31673/clusterfuzz-testcase-minimized-ffmpeg_dem_MPC8_fuzzer-580134751869337
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/mov: Do not zero memory that is written too or unused
Michael Niedermayer [Sun, 21 Mar 2021 17:08:43 +0000 (18:08 +0100)]
avformat/mov: Do not zero memory that is written too or unused

Fixes: OOM
Fixes: 31220/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6033383962574848
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/mpegvideo: Update chroma_?_shift in ff_mpv_common_frame_size_change()
Michael Niedermayer [Mon, 22 Mar 2021 14:22:35 +0000 (15:22 +0100)]
avcodec/mpegvideo: Update chroma_?_shift in ff_mpv_common_frame_size_change()

Fixes: out of array access
Fixes: 31201/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-4627865612189696.fuzz
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/mov: Ignore multiple STSC / STCO
Michael Niedermayer [Wed, 24 Mar 2021 16:03:08 +0000 (17:03 +0100)]
avformat/mov: Ignore multiple STSC / STCO

Fixes: STSC / STCO inconsistency and assertion failure
Fixes: crbug1184666.mp4
Found-by: Chromium ASAN fuzzer
Reviewed-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/utils: Extend overflow check in dts wrap in compute_pkt_fields()
Michael Niedermayer [Tue, 2 Feb 2021 16:29:23 +0000 (17:29 +0100)]
avformat/utils: Extend overflow check in dts wrap in compute_pkt_fields()

Fixes: signed integer overflow: -9223372032574480351 - 4294967296 cannot be represented in type 'long long'
Fixes: 30022/clusterfuzz-testcase-minimized-ffmpeg_dem_KUX_fuzzer-5568610275819520
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavfilter/vf_scale: Fix adding 0 to NULL (which is UB) in scale_slice()
Michael Niedermayer [Fri, 19 Feb 2021 20:43:45 +0000 (21:43 +0100)]
avfilter/vf_scale: Fix adding 0 to NULL (which is UB) in scale_slice()

Found-by: Jeremy Leconte <jleconte@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavutil/common: Add FF_PTR_ADD()
Michael Niedermayer [Mon, 15 Mar 2021 08:47:43 +0000 (09:47 +0100)]
avutil/common: Add FF_PTR_ADD()

Suggested-by: Andreas Rheinhardt
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/asf: Factor common code out
Andreas Rheinhardt [Mon, 29 Mar 2021 06:31:36 +0000 (08:31 +0200)]
avformat/asf: Factor common code out

Both functions to read attached pictures coincide since
e83f27a21a6d2f602b55e541ef66e365400e9827 (save for some log messages
in case av_dict_set failed).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mjpegenc: Fix segfault when freeing incomplete context
Andreas Rheinhardt [Tue, 30 Mar 2021 21:20:49 +0000 (23:20 +0200)]
avcodec/mjpegenc: Fix segfault when freeing incomplete context

When allocating the MJpegContext fails (or if the dimensions run afoul
of the 65500x65500 limit), an attempt to free a subbuffer of said
context leads to a segfault in ff_mjpeg_encode_close().
Seems to be a regression since 467d9e27e0cb2bf74f41dc832f2f8d191ba58ec9.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/tiff: Avoid forward declarations
Andreas Rheinhardt [Tue, 30 Mar 2021 05:53:50 +0000 (07:53 +0200)]
avcodec/tiff: Avoid forward declarations

In this case it also fixes a potential for compilation failures:
Not all compilers can handle the case in which a function with
a forward declaration declared with an attribute to always inline it
is called before the function body appears. E.g. GCC 4.2.1 on OS X 10.6
doesn't like it.

Reviewed-by: Pavel Koshevoy <pkoshevoy@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agotests/matroska: Add test for WebVTT in WebM
Andreas Rheinhardt [Mon, 29 Mar 2021 13:09:26 +0000 (15:09 +0200)]
tests/matroska: Add test for WebVTT in WebM

Specifically test that the WebVTT flavour is correctly mapped to
the Matroska/WebM CodecID and back; and test that dispositions
unsupported by WebM are discarded even when they would be supported
by Matroska.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agofftools/ffprobe: Add missing dispositions
Andreas Rheinhardt [Mon, 29 Mar 2021 12:18:47 +0000 (14:18 +0200)]
fftools/ffprobe: Add missing dispositions

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agodoc/demuxers: note support for flv variant KUX
Gyan Doshi [Wed, 31 Mar 2021 09:46:12 +0000 (15:16 +0530)]
doc/demuxers: note support for flv variant KUX

3 years agoavcodec/dv_profile: PAL DV files with dsf flag 0 - detect via pal flag and buf_size
Mark Plomer [Thu, 18 Mar 2021 12:19:16 +0000 (13:19 +0100)]
avcodec/dv_profile: PAL DV files with dsf flag 0 - detect via pal flag and buf_size

Some old DV AVI files have the DSF-Flag of frames set to 0, although it
is PAL (maybe rendered with an old Ulead Media Studio Pro) ... this causes
ffmpeg/VLC-player to produce/play corrupted video (other players/editors
like VirtualDub work fine).

Fixes ticket #8333 and replaces/extends hack for ticket #2177

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/rtpdec: Fix prft wallclock time.
Alok Priyadarshi [Thu, 25 Mar 2021 04:46:36 +0000 (21:46 -0700)]
avformat/rtpdec: Fix prft wallclock time.

Timestamp difference is available in media timebase (1/90K) where as
rtcp time is in the default microseconds timebase. This patch fixes
the calculated prft wallclock time by rescaling the timestamp delta
to the microseconds timebase.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/put_bits: Don't set size_in_bits, fix overflow
Andreas Rheinhardt [Thu, 25 Mar 2021 13:17:10 +0000 (14:17 +0100)]
avcodec/put_bits: Don't set size_in_bits, fix overflow

A PutBitContext has a field called size_in_bits which is set to the
context's bitsize init_put_bits(); but it isn't used at all (the PutBits
API uses pointers directly and not bit indexes), so remove it (due to
ABI concerns the actual element is only removed at the next bump).

Furthermore, the multiplication inherent in setting this field can lead
to undefined integer overflows. This is particularly true for FFV1,
which uses a very big worst-case buffer (37*4*width*height; even
ordinary 1080p triggers an overflow). Ticket #8350 is about this
overflow which this commit fixes.

This means that the effective range of the PutBits API is no longer
restricted by the /8 as long as one isn't using put_bits_(count|left).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoAvoid intermediate bitcount for number of bytes in PutBitContext
Andreas Rheinhardt [Thu, 25 Mar 2021 11:52:56 +0000 (12:52 +0100)]
Avoid intermediate bitcount for number of bytes in PutBitContext

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>