ffmpeg.git
7 months agoavfilter/vf_v360: add mitchell interpolation
Paul B Mahol [Sun, 4 Oct 2020 12:36:30 +0000 (14:36 +0200)]
avfilter/vf_v360: add mitchell interpolation

7 months agoavformat/moflex: Check m->size before seeking
Michael Niedermayer [Fri, 2 Oct 2020 12:59:15 +0000 (14:59 +0200)]
avformat/moflex: Check m->size before seeking

Fixes: Infinite loop
Fixes: 26016/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6195663833137152

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>
7 months agoavcodec/dxtory: Fix negative stride shift in dx2_decode_slice_420()
Michael Niedermayer [Fri, 2 Oct 2020 12:59:13 +0000 (14:59 +0200)]
avcodec/dxtory: Fix negative stride shift in dx2_decode_slice_420()

Fixes: left shift of negative value -640
Fixes: 26044/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXTORY_fuzzer-5631057602543616

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>
7 months agoavcodec/av1dec: partially clean state on frame decoding errors
James Almer [Sun, 4 Oct 2020 13:21:59 +0000 (10:21 -0300)]
avcodec/av1dec: partially clean state on frame decoding errors

Fixes: member access within null pointer of type 'TileGroupInfo' (aka 'struct TileGroupInfo')
Fixes: 25725/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-5166692706287616

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavformat: add tri-ACE demuxer
Paul B Mahol [Thu, 24 Sep 2020 15:55:03 +0000 (17:55 +0200)]
avformat: add tri-ACE demuxer

7 months agoavformat/adxdec: demux multiple blocks at once
Paul B Mahol [Fri, 18 Sep 2020 10:08:42 +0000 (12:08 +0200)]
avformat/adxdec: demux multiple blocks at once

Improves decoding speed by 24x

7 months agolibwavpackenc: remove libwavpackenc wrapper
Lynne [Mon, 7 Sep 2020 00:41:19 +0000 (02:41 +0200)]
libwavpackenc: remove libwavpackenc wrapper

The manual states "there is virtually no reason to use that encoder.".

It supports less sample formats than the native encoder, is less efficient
than the native encoder and is also slower and pretty much remains untested.
libwavpack also isn't being fuzzed, which given that we plug the parameters
without any sanitizing them looks concerning.

7 months agoavformat/movenc: handle tracks w/o AVStreams in calculate_mpeg4_bit_rates
Jan Ekström [Mon, 28 Sep 2020 14:23:07 +0000 (17:23 +0300)]
avformat/movenc: handle tracks w/o AVStreams in calculate_mpeg4_bit_rates

The generated text streams for chapters lack an AVStream since they
are but an internal concept within movenc.

Fixes #8910

7 months agoavformat/asfdec_f: Change order or operations slightly
Michael Niedermayer [Sat, 12 Sep 2020 17:44:35 +0000 (19:44 +0200)]
avformat/asfdec_f: Change order or operations slightly

Fixes: signed integer overflow: 20 * 5184056935931942919 cannot be represented in type 'long'
Fixes: 25466/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4798660247552000

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/dxa: Use av_rescale() for duration computation
Michael Niedermayer [Wed, 2 Sep 2020 21:13:00 +0000 (23:13 +0200)]
avformat/dxa: Use av_rescale() for duration computation

Fixes: signed integer overflow: 8224000000 * 1629552639 cannot be represented in type 'long'
Fixes: 24908/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4658478506049536

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/vc1_block: Fix integer overflow in ac value
Michael Niedermayer [Wed, 2 Sep 2020 20:42:05 +0000 (22:42 +0200)]
avcodec/vc1_block: Fix integer overflow in ac value

Fixes: signed integer overflow: 25488 * 87381 cannot be represented in type 'int'
Fixes: 24765/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5108259565076480

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agolibswcale/input: use more accurate rgbf32 yuv conversions
Mark Reid [Tue, 29 Sep 2020 03:44:34 +0000 (20:44 -0700)]
libswcale/input: use more accurate rgbf32 yuv conversions

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agolibswscale/tests: add floatimg_cmp test
Mark Reid [Tue, 29 Sep 2020 03:44:33 +0000 (20:44 -0700)]
libswscale/tests: add floatimg_cmp test

changes since v1:
- made into fate test
- fixed c90 warnings
- tests more intermediate formats
- tested on BE mips too

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/rtsp: fix parse_rtsp_message
Zhao Zhili [Sun, 27 Sep 2020 11:50:27 +0000 (19:50 +0800)]
avformat/rtsp: fix parse_rtsp_message

1. Remove the assumption that the message method is TEARDOWN.
2. Don't ignore the error code of ff_rtsp_parse_streaming_commands.

Signed-off-by: Martin Storsjö <martin@martin.st>
7 months agortsp: Fix infinite loop in listen mode with UDP transport
Martin Storsjö [Wed, 30 Sep 2020 09:27:00 +0000 (12:27 +0300)]
rtsp: Fix infinite loop in listen mode with UDP transport

In listen mode with UDP transport, once the sender has sent
the TEARDOWN and closed the connection, poll will indicate that
one can read from the connection (indicating that the socket has
reached EOF and should be closed by the receiver as well). In this
case, parse_rtsp_message won't try to parse the command (because
it's no longer in state STREAMING), but previously just returned
zero.

Prior to f6161fccf8c5720ceac1ed1df8ba60ff8fed69f5, this caused
udp_read_packet to return zero, which is treated as EOF by
read_packet. But after that commit, udp_read_packet would continue
if parse_rtsp_message didn't return an explicit error code.

To keep the original behaviour from before that commit, more
explicitly return an error in parse_rtsp_message when in the wrong
state.

Fixes: #8840
Signed-off-by: Martin Storsjö <martin@martin.st>
7 months agoavutil/pixdesc: add missing FF_API_PSEUDOPAL check
James Almer [Fri, 2 Oct 2020 03:18:13 +0000 (00:18 -0300)]
avutil/pixdesc: add missing FF_API_PSEUDOPAL check

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavformat/utils: add missing FF_API_LAVF_AVCTX check
James Almer [Fri, 2 Oct 2020 01:47:51 +0000 (22:47 -0300)]
avformat/utils: add missing FF_API_LAVF_AVCTX check

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavformat/sdp: add missing FF_API_LAVF_AVCTX check
James Almer [Fri, 2 Oct 2020 01:45:34 +0000 (22:45 -0300)]
avformat/sdp: add missing FF_API_LAVF_AVCTX check

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavcodec/utils: add missing FF_API_TAG_STRING check
James Almer [Fri, 2 Oct 2020 01:43:28 +0000 (22:43 -0300)]
avcodec/utils: add missing FF_API_TAG_STRING check

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavcodec/options: add missing FF_API_COPY_CONTEXT checks
James Almer [Fri, 2 Oct 2020 01:43:03 +0000 (22:43 -0300)]
avcodec/options: add missing FF_API_COPY_CONTEXT checks

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavcodec/libvpxenc: add missing FF_API_ERROR_FRAME check
James Almer [Fri, 2 Oct 2020 01:42:37 +0000 (22:42 -0300)]
avcodec/libvpxenc: add missing FF_API_ERROR_FRAME check

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavcodec/cuviddec: avoid copy of uninitialized extradata pointer
Timo Rothenpieler [Thu, 1 Oct 2020 19:09:34 +0000 (21:09 +0200)]
avcodec/cuviddec: avoid copy of uninitialized extradata pointer

7 months agoavcodec/cuviddec: use correct type for extradata_size
Timo Rothenpieler [Thu, 1 Oct 2020 18:49:59 +0000 (20:49 +0200)]
avcodec/cuviddec: use correct type for extradata_size

7 months agoavcodec/cuviddec: fix copy&paste error
Timo Rothenpieler [Thu, 1 Oct 2020 18:20:48 +0000 (20:20 +0200)]
avcodec/cuviddec: fix copy&paste error

7 months agoavformat/movenc: Fix stack overflow when remuxing timecode tracks
Andreas Rheinhardt [Wed, 30 Sep 2020 12:36:23 +0000 (14:36 +0200)]
avformat/movenc: Fix stack overflow when remuxing timecode tracks

There are two possible kinds of timecode tracks (with tag "tmcd") in the
mov muxer: Tracks created internally by the muxer and timecode tracks
sent by the user. If any of the latter exists, the former are
deactivated. The former all belong to another track, the source
track; the latter don't have a source track set, but the index of the
source track is initially zeroed by av_mallocz_array(). This is a
problem since 3d894db700cc1e360a7a75ab9ac8bf67ac6670a3: Said commit added
a function that calculates the duration of tracks and the duration of
timecode tracks is calculated by rescaling the duration (calculated by
the very same function) of the source track. This gives an infinite
recursion if the first track (the one that will be treated as source
track for all timecode tracks) is a timecode track itself, leading to a
stack overflow.

This commit fixes this by not using the nonexistent source track
when calculating the duration of timecode tracks not created internally
by the mov muxer.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/utils: Reindentation
Andreas Rheinhardt [Thu, 24 Sep 2020 21:59:15 +0000 (23:59 +0200)]
avcodec/utils: Reindentation

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/utils: Also free encoder extradata on avcodec_open2() error
Andreas Rheinhardt [Sat, 26 Sep 2020 09:18:13 +0000 (11:18 +0200)]
avcodec/utils: Also free encoder extradata on avcodec_open2() error

It is owned by libavcodec for encoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/utils: Don't forget cleaning up when allocating priv_data fails
Andreas Rheinhardt [Thu, 24 Sep 2020 21:54:17 +0000 (23:54 +0200)]
avcodec/utils: Don't forget cleaning up when allocating priv_data fails

Allocating an AVCodecContext's priv_data used to be the first object
allocated in avcodec_open2(), so it was unnecessary to goto free_and_end
(which does the cleanup) upon error here. But this is no longer so since
f3a29b750a5979ae6847879fba758faf1fae88d0.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/utils: Improve check for freeing codec private options
Andreas Rheinhardt [Thu, 24 Sep 2020 21:41:24 +0000 (23:41 +0200)]
avcodec/utils: Improve check for freeing codec private options

Don't check for AVCodec.priv_data_size (which is always true if
AVCodec.priv_class is set). Instead check for AVCodecContext.priv_data
to actually exist.

(Note: av_opt_free(NULL) is a no-op.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/utils: Remove always-true check
Andreas Rheinhardt [Thu, 24 Sep 2020 21:24:20 +0000 (23:24 +0200)]
avcodec/utils: Remove always-true check

The first thing avcodec_open2() allocates is the AVCodecInternal. If
allocating it fails, a jump to end occurs; but if an error happens after
its allocation, a jump to free_and_end happens which frees all
allocations performed so far and then jumps to end. Yet free_and_end
contained a check for AVCodecInternal (after having already dereferenced
it to check whether ff_thread_free() needs to be called) which is of
course always true. So remove it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoopusdec: do not fail when LBRR frames are present
Anton Khirnov [Fri, 11 Sep 2020 17:32:43 +0000 (19:32 +0200)]
opusdec: do not fail when LBRR frames are present

Decode and discard them.

Fixes ticket 4641.

7 months agofate: add scale filters for big-endian architectures.
Nicolas George [Mon, 14 Sep 2020 19:23:20 +0000 (21:23 +0200)]
fate: add scale filters for big-endian architectures.

Filters mostly work in native endianness, but they must output
a specified endianness, usually little: that requires a final
conversion for big endian.

I do not know what's the deal with gif-deal: inserting explicitly
the filters that are implicitly inserted result in less frames in
output. Probably a strange problem of duration.

7 months agoswresample/audioconvert: Fix left shift of negative value
Andreas Rheinhardt [Tue, 29 Sep 2020 14:06:31 +0000 (16:06 +0200)]
swresample/audioconvert: Fix left shift of negative value

Fixes ticket #8219.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/av1dec: call ff_cbs_flush() on decoder flush
James Almer [Thu, 24 Sep 2020 21:54:14 +0000 (18:54 -0300)]
avcodec/av1dec: call ff_cbs_flush() on decoder flush

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavcodec/av1dec: fix check for active sequence header
James Almer [Fri, 25 Sep 2020 14:05:30 +0000 (11:05 -0300)]
avcodec/av1dec: fix check for active sequence header

We clear the AV1RawSequenceHeader pointer on flush, not the relevant AVBufferRef.

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavcodec/av1dec: parse dimensions from the sequence header in extradata
James Almer [Fri, 25 Sep 2020 14:20:41 +0000 (11:20 -0300)]
avcodec/av1dec: parse dimensions from the sequence header in extradata

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavcodec/cbs_vp9: implement a CodedBitstreamType.flush() callback
James Almer [Fri, 25 Sep 2020 03:04:15 +0000 (00:04 -0300)]
avcodec/cbs_vp9: implement a CodedBitstreamType.flush() callback

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavcodec/cbs_h2645: implement CodedBitstreamType.flush() callbacks
James Almer [Thu, 24 Sep 2020 21:19:05 +0000 (18:19 -0300)]
avcodec/cbs_h2645: implement CodedBitstreamType.flush() callbacks

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavcodec/cbs_av1: implement a CodedBitstreamType.flush() callback
James Almer [Thu, 24 Sep 2020 21:06:35 +0000 (18:06 -0300)]
avcodec/cbs_av1: implement a CodedBitstreamType.flush() callback

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavcodec/cbs: add a flush callback to CodedBitstreamType
James Almer [Thu, 24 Sep 2020 20:57:42 +0000 (17:57 -0300)]
avcodec/cbs: add a flush callback to CodedBitstreamType

Used to reset the codec's private internal state.

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavfilter/vf_v360: stop using floats variables in xyz_to_octahedron
Paul B Mahol [Tue, 29 Sep 2020 22:05:02 +0000 (00:05 +0200)]
avfilter/vf_v360: stop using floats variables in xyz_to_octahedron

Use proper integer variables.

7 months agoavcodec/cuviddec: handle arbitrarily sized extradata
Timo Rothenpieler [Tue, 29 Sep 2020 21:19:23 +0000 (23:19 +0200)]
avcodec/cuviddec: handle arbitrarily sized extradata

7 months agoavcodec/utils: Only call codec->close if init has been called
Andreas Rheinhardt [Thu, 24 Sep 2020 21:05:29 +0000 (23:05 +0200)]
avcodec/utils: Only call codec->close if init has been called

avcodec_open2() also called the AVCodec's close function if an error
happened before init had ever been called if the AVCodec has the
FF_CODEC_CAP_INIT_CLEANUP flag set. This is against the documentation of
said flag: "The codec allows calling the close function for deallocation
even if the init function returned a failure."

E.g. the SVQ3 decoder is not ready to be closed if init has never been
called.

Fixes: NULL dereference
Fixes: 25762/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SVQ3_fuzzer-5716279070294016

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoRevert "avfilter/setparams: add FF_FILTER_FLAG_HWFRAME_AWARE"
Mark Thompson [Tue, 29 Sep 2020 16:01:22 +0000 (17:01 +0100)]
Revert "avfilter/setparams: add FF_FILTER_FLAG_HWFRAME_AWARE"

This reverts commit 5bbf58ab876279ca1a5a2f30563f271c99b93e62.

The setparams filters are not hwframe aware, so the default context
passthrough behaviour is needed to allow using them with hardware frames.

7 months agoavfilter/vf_v360: simplify input flipping
Paul B Mahol [Tue, 29 Sep 2020 12:16:32 +0000 (14:16 +0200)]
avfilter/vf_v360: simplify input flipping

7 months agoavfilter/vf_v360: split maps into slices
Paul B Mahol [Tue, 29 Sep 2020 08:48:54 +0000 (10:48 +0200)]
avfilter/vf_v360: split maps into slices

7 months agodnn/native: add native support for dense
Mingyu Yin [Tue, 22 Sep 2020 07:11:09 +0000 (15:11 +0800)]
dnn/native: add native support for dense

Signed-off-by: Mingyu Yin <mingyu.yin@intel.com>
7 months agolibavcodec/videotoolboxenc: Fix crash when frame received after error
Rick Kern [Tue, 29 Sep 2020 01:47:29 +0000 (21:47 -0400)]
libavcodec/videotoolboxenc: Fix crash when frame received after error

Signed-off-by: Rick Kern <kernrj@gmail.com>
7 months agoavcodec/videotoolboxenc: move pthread_cond_signal after add buffer to the queue
Tian Qi [Fri, 28 Aug 2020 01:13:02 +0000 (09:13 +0800)]
avcodec/videotoolboxenc: move pthread_cond_signal after add buffer to the queue

In the VT encoding insertion by FFmpeg,
and vtenc_q_push is callback to add the encoded data
to the singly linked list group in VTEncContext,
and consumers are notified to fetch it.
However, because it first informs consumers of pthread_cond_signal,
and then inserts the data into the tail,
there is a multi-thread safety hazard.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Rick Kern <kernrj@gmail.com>
7 months agoavcodec/videotoolboxenc: don't wait when flushing data
Tian Qi [Thu, 27 Aug 2020 02:53:27 +0000 (10:53 +0800)]
avcodec/videotoolboxenc: don't wait when flushing data

because there is run in thread mode, few times will block
the workflow at the wait, so check the status is flushing data,
don't wait when flushing data.

Signed-off-by: Tian Qi <tianqi@kuaishou.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Rick Kern <kernrj@gmail.com>
7 months agoavcodec/videotoolboxenc: fix use after destroy
Zhao Zhili [Wed, 26 Aug 2020 21:38:45 +0000 (05:38 +0800)]
avcodec/videotoolboxenc: fix use after destroy

The lock is used in clear_frame_queue().

Signed-off-by: Rick Kern <kernrj@gmail.com>
7 months agoavcodec/videotoolboxenc: fix align issue
Zhao Zhili [Wed, 26 Aug 2020 21:38:44 +0000 (05:38 +0800)]
avcodec/videotoolboxenc: fix align issue

bool a53_cc is accessed as int:
src/libavutil/opt.c:129:9: runtime error: store to misaligned
address 0x7fbf454121a3 for type 'int', which requires 4 byte alignment

Signed-off-by: Rick Kern <kernrj@gmail.com>
7 months agoavcodec/videotoolboxenc: Allow full range 10bit pixel format input
Harry Mallon [Mon, 21 Sep 2020 11:16:59 +0000 (12:16 +0100)]
avcodec/videotoolboxenc: Allow full range 10bit pixel format input

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
Signed-off-by: Rick Kern <kernrj@gmail.com>
7 months agoavcodec/videotoolboxenc: Set profile (main/main10) on HEVC encode
Harry Mallon [Mon, 21 Sep 2020 11:16:58 +0000 (12:16 +0100)]
avcodec/videotoolboxenc: Set profile (main/main10) on HEVC encode

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
Signed-off-by: Rick Kern <kernrj@gmail.com>
7 months agoavcodec/mv30: Fix several integer overflows in idct_1d()
Michael Niedermayer [Sat, 25 Jul 2020 21:35:03 +0000 (23:35 +0200)]
avcodec/mv30: Fix several integer overflows in idct_1d()

Fixes: signed integer overflow: -1846510390 + -361755993 cannot be represented in type 'int'
Fixes: 23941/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MV30_fuzzer-5654696631730176

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/pgxdec: Fix invalid shift in write_frame_*
Michael Niedermayer [Sat, 25 Jul 2020 21:14:10 +0000 (23:14 +0200)]
avcodec/pgxdec: Fix invalid shift in write_frame_*

Fixes: left shift of negative value -121
Fixes: 23911/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGX_fuzzer-4986800258154496

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/movenc: Fix segfault upon allocation error
Andreas Rheinhardt [Mon, 28 Sep 2020 14:00:56 +0000 (16:00 +0200)]
avformat/movenc: Fix segfault upon allocation error

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavformat/iff: Check data_size not overflowing int64
Michael Niedermayer [Sun, 27 Sep 2020 20:20:52 +0000 (22:20 +0200)]
avformat/iff: Check data_size not overflowing int64

Fixes: Infinite loop
Fixes: 25844/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5660803318153216

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agopthread_frame: use av_buffer_replace() to simplify code
Anton Khirnov [Fri, 5 Jun 2020 09:24:19 +0000 (11:24 +0200)]
pthread_frame: use av_buffer_replace() to simplify code

7 months agompegvideo: use av_buffer_replace() to simplify code
Anton Khirnov [Fri, 5 Jun 2020 09:24:19 +0000 (11:24 +0200)]
mpegvideo: use av_buffer_replace() to simplify code

7 months agohevcdec: use av_buffer_replace() to simplify code
Anton Khirnov [Fri, 5 Jun 2020 09:24:19 +0000 (11:24 +0200)]
hevcdec: use av_buffer_replace() to simplify code

7 months agolavu/buffer: add a convenience function for replacing buffers
Anton Khirnov [Fri, 5 Jun 2020 09:17:49 +0000 (11:17 +0200)]
lavu/buffer: add a convenience function for replacing buffers

A common pattern e.g. in libavcodec is replacing/updating buffer
references: unref old one, ref new one. This function allows simplifying
such code and avoiding unnecessary refs+unrefs if the references are
already equivalent.

7 months agoavfilter/setparams: add FF_FILTER_FLAG_HWFRAME_AWARE
Pavel Koshevoy [Tue, 22 Sep 2020 03:40:27 +0000 (21:40 -0600)]
avfilter/setparams: add FF_FILTER_FLAG_HWFRAME_AWARE

Allow setparams to be used with hw backed frames and
avoid an assertion failure in avfilter_config_links.

7 months agolavf/hls: add AC-3/EAC-3 to allowed extensions file list
Jun Zhao [Fri, 25 Sep 2020 11:52:14 +0000 (19:52 +0800)]
lavf/hls: add AC-3/EAC-3 to allowed extensions file list

Add AC-3/EAC-3 to allowed extensions file list.

From HTTP Live Streaming 2nd Edition draft-pantos-hls-rfc8216bis-07
section 3.1.3.Packed Audio, HLS demuxer need to support MP3/AC-3/EAC-3.

Reviewd-by: Steven Liu <liuqi05@kuaishou.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
7 months agoexamples/muxing: misc style fixes
Jun Zhao [Fri, 25 Sep 2020 11:23:54 +0000 (19:23 +0800)]
examples/muxing: misc style fixes

misc style fixes.

Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
7 months agoavfilter/vf_v360: add octahedron format
Paul B Mahol [Sun, 27 Sep 2020 20:33:05 +0000 (22:33 +0200)]
avfilter/vf_v360: add octahedron format

7 months agovf_colorspace: Added linear trc.
Andrew Klaassen [Thu, 24 Sep 2020 19:00:52 +0000 (15:00 -0400)]
vf_colorspace: Added linear trc.

This patch adds the coefficients for the linear gamma function (1,0,1,0)
to the colorspace filter.

Signed-off-by: Andrew Klaassen <clawsoon@yahoo.com>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
7 months agoavcodec: add Argonaut Games Video decoder
Paul B Mahol [Fri, 18 Sep 2020 15:43:42 +0000 (17:43 +0200)]
avcodec: add Argonaut Games Video decoder

7 months agotests/fate-run: Always overwrite output files for md5 tests
Andreas Rheinhardt [Sun, 20 Sep 2020 14:39:59 +0000 (16:39 +0200)]
tests/fate-run: Always overwrite output files for md5 tests

Otherwise the result of such tests will not accurately reflect the
current state.

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavformat/argo_brp: use header frame counts
Zane van Iperen [Sat, 26 Sep 2020 02:21:45 +0000 (12:21 +1000)]
avformat/argo_brp: use header frame counts

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
7 months agoavformat/argo_brp: allow v1.1 ASF streams to have a non-22050 sample rate in certain...
Zane van Iperen [Fri, 25 Sep 2020 12:25:42 +0000 (22:25 +1000)]
avformat/argo_brp: allow v1.1 ASF streams to have a non-22050 sample rate in certain circumstances

It seems that in files where the BASF block isn't first, v1.1 ASF streams are
allowed to be non-22050. Either this format is really inconsistent, or
FX Fighter and Croc just ignored the sample rate field, requiring the v1.1
restriction in the first place.

This bumps the version to 1.2 in these streams so they're not "corrected".

Found in Alien Odyssey games files in:
./GRAPHICS/COMMBUNK/{{COMADD1,COMM2_{1,2,3E},COMM3_{2,3,4,5,6}},FADE{1,2}}.BRP

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
7 months agoavformat/argo_brp: cosmetics
Zane van Iperen [Fri, 25 Sep 2020 02:50:53 +0000 (12:50 +1000)]
avformat/argo_brp: cosmetics

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
7 months agoavformat/argo_brp: handle the case where the BASF block isn't the first
Zane van Iperen [Fri, 25 Sep 2020 02:49:58 +0000 (12:49 +1000)]
avformat/argo_brp: handle the case where the BASF block isn't the first

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
7 months agoavformat/argo_brp: support MASK streams
Zane van Iperen [Fri, 25 Sep 2020 12:39:46 +0000 (22:39 +1000)]
avformat/argo_brp: support MASK streams

We can't actually use them though.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
7 months agoavformat/argo_{asf,brp}: fix potential segfault in ff_argo_asf_fill_stream()
Zane van Iperen [Fri, 25 Sep 2020 13:03:46 +0000 (23:03 +1000)]
avformat/argo_{asf,brp}: fix potential segfault in ff_argo_asf_fill_stream()

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
7 months agoavcodec/v4l2_buffers: remove unused function argument
Andriy Gelman [Fri, 28 Aug 2020 03:12:51 +0000 (23:12 -0400)]
avcodec/v4l2_buffers: remove unused function argument

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
7 months agoavfilter/vf_histogram: add slide modes for thistogram
Paul B Mahol [Sat, 26 Sep 2020 19:57:46 +0000 (21:57 +0200)]
avfilter/vf_histogram: add slide modes for thistogram

7 months agoavcodec/fraps: Use cached bitstream reader
Andreas Rheinhardt [Tue, 22 Sep 2020 08:12:15 +0000 (10:12 +0200)]
avcodec/fraps: Use cached bitstream reader

This proved beneficial for performance: For the sample [1] the number
of decicycles in one decode call decreased from 155851561 to 108158037
for Clang 10 and from 168270467 to 128847479 for GCC 9.3. For x86-32
compiled with GCC 9.3 and run on an x64 Haswell the number increased
from 158405517 to 202215769, so that the cached bitstream reader is only
enabled if HAVE_FAST_64BIT is set. These values are the average of 10
runs each looping five times over the input.

[1]: samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2593/fraps_flv1_decoding_errors.avi

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/fraps: Use unchecked bitstream reader
Andreas Rheinhardt [Tue, 22 Sep 2020 06:53:34 +0000 (08:53 +0200)]
avcodec/fraps: Use unchecked bitstream reader

The fraps decoder already checked for overreads manually (and errored
out in this scenario), yet it still enabled implicit checks, leading to
worse performance and more code size.

This commit disables the implicit bitstream reader checks. For the
sample [1] this improves performance from 195105896 to 155851561
decicycles for Clang 10 and from 222801887 to 168270467 decicycles when
compiled with GCC 9.3. These values are the average of 10 runs each
looping ten times over the input.

[1]: samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2593/fraps_flv1_decoding_errors.avi

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/utvideo: Move stuff only used by Ut encoder to Ut encoder
Andreas Rheinhardt [Thu, 24 Sep 2020 16:43:11 +0000 (18:43 +0200)]
avcodec/utvideo: Move stuff only used by Ut encoder to Ut encoder

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/utvideo: Remove unused array
Andreas Rheinhardt [Thu, 24 Sep 2020 16:30:54 +0000 (18:30 +0200)]
avcodec/utvideo: Remove unused array

Unused since 3594788b713e76449eda0bc9d64b38258c86a594.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/utvideodec: Avoid qsort when creating Huffman tables
Andreas Rheinhardt [Thu, 24 Sep 2020 16:29:39 +0000 (18:29 +0200)]
avcodec/utvideodec: Avoid qsort when creating Huffman tables

The Ut video format uses Huffman trees which are only implicitly coded
in the bitstream: Only the lengths of the codes are coded, the rest has
to be inferred by the decoder according to the rule that the longer
codes are to the left of shorter codes in the tree and on each level the
symbols are descending from left to right.

Because longer codes are to the left of shorter codes, one needs to know
how many non-leaf nodes there are on each level in order to know the
code of the next left-most leaf (which belongs to the highest symbol on
that level). The current code does this by sorting the entries to be
ascending according to length and (for entries with the same length)
ascending according to their symbols. This array is then traversed in
reverse order, so that the lowest level is dealt with first, so that the
number of non-leaf nodes of the next higher level is known when
processing said level.

But this can also be calculated without sorting: Simply count how many
leaf nodes there are on each level. Then one can calculate the number of
non-leaf nodes on each level iteratively from the lowest level upwards:
It is just half the number of nodes of the level below.

This improves performance: For the sample from ticket #4044 the amount
of decicycles for one call to build_huff() decreased from 1055489 to
446310 for Clang 10 and from 1080306 to 535155 for GCC 9.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/utvideodec: Remove code duplication when creating Huffman tables
Andreas Rheinhardt [Thu, 24 Sep 2020 14:35:23 +0000 (16:35 +0200)]
avcodec/utvideodec: Remove code duplication when creating Huffman tables

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/utvideodec/enc: Fix edge case of creating Huffman table
Andreas Rheinhardt [Thu, 24 Sep 2020 14:19:03 +0000 (16:19 +0200)]
avcodec/utvideodec/enc: Fix edge case of creating Huffman table

The Ut Video format stores Huffman tables in its bitstream by coding
the length of a given symbol; it does not code the actual code directly,
instead this is to be inferred by the rule that a symbol is to the left
of every shorter symbol in the Huffman tree and that for symbols of the
same length the symbol is descending from left to right. With one
exception, this is also what our de- and encoder did.

The exception only matters when there are codes of length 32, because
in this case the first symbol of this length did not get the code 0,
but 1; this is tantamount to pretending that there is a (nonexistent)
leaf of length 32. This is simply false. The reference software agrees
with this [1].

[1]: https://github.com/umezawatakeshi/utvideo/blob/2700a471a78402e5c340150b38e8a793ef3676f1/utv_core/HuffmanCode.cpp#L280

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/magicyuv: Don't waste stack space
Andreas Rheinhardt [Wed, 23 Sep 2020 14:50:02 +0000 (16:50 +0200)]
avcodec/magicyuv: Don't waste stack space

Now that the HuffEntries are no longer sorted by the MagicYUV decoder,
their symbols are trivial: The symbol of the element with index i is i.
They can therefore be removed. Furthermore, despite the length of the
codes being in the range 1..32 bits, the actual value of the codes is
<= 4096 (for 12 bit content). The reason for this is that the longer
codes are on the left side of the tree, so that the higher bits of
these codes are simply zero. By using an uint16_t for the codes and
removing the symbols entry, the size of each HuffEntry is decreased from
eight to four, saving 16KB of stack space.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/magicyuv: Avoid AV_QSORT when creating Huffman table
Andreas Rheinhardt [Wed, 23 Sep 2020 13:17:33 +0000 (15:17 +0200)]
avcodec/magicyuv: Avoid AV_QSORT when creating Huffman table

The MagicYUV format stores Huffman tables in its bitstream by coding
the length of a given symbol; it does not code the actual code directly,
instead this is to be inferred by the rule that a symbol is to the left
of every shorter symbol in the Huffman tree and that for symbols of the
same length the symbol is ascending from left to right.

Our decoder implemented this by first sorting the array containing
length and symbol of each element according to descending length and
for equal length, according to ascending symbol. Afterwards, the current
state in the tree got encoded in a variable code; if the next array entry
had length len, then the len most significant bits of code contained
the code of this entry. Whenever an entry of the array of length
len was processed, code was incremented by 1U << (32 - len). So two
entries of length len have the same effect as incrementing code by
1U << (32 - (len - 1)), which corresponds to the parent node of length
len - 1 of the two nodes of length len etc.

This commit modifies this to avoid sorting the entries before
calculating the codes. This is done by calculating how many non-leaf
nodes there are on each level of the tree before calculating the codes.
Afterwards every leaf node on this level gets assigned the number of
nodes already on this level as code. This of course works only because
the entries are already sorted by their symbol initially, so that this
algorithm indeed gives ascending symbols from left to right on every
level.

This offers both speed- as well as (obvious) codesize advantages. With
Clang 10 the number of decicycles for build_huffman decreased from
1561987 to 1228405; for GCC 9 it went from 1825096 decicyles to 1429921.
These tests were carried out with a sample with 150 frames that was
looped 13 times; and this was iterated 10 times. The earlier reference
point here is from the point when the loop generating the codes was
traversed in reverse order (as the patch reversing the order led to
performance penalties).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/magicyuv: Fix edge case of building Huffman table
Andreas Rheinhardt [Wed, 23 Sep 2020 12:33:38 +0000 (14:33 +0200)]
avcodec/magicyuv: Fix edge case of building Huffman table

The MagicYUV format stores Huffman tables in its bitstream by coding
the length of a given symbol; it does not code the actual code directly,
instead this is to be inferred by the rule that a symbol is to the left
of every shorter symbol in the Huffman tree and that for symbols of the
same length the symbol is ascending from left to right. With one
exception, this is also what our decoder did.

The exception only matters when there are codes of length 32, because
in this case the first symbol of this length did not get the code 0,
but 1; e.g. if there were exactly two nodes of length 32, then they
would get assigned the codes 1 and 2 and a node of length 31 will get
the 31-bit code 1 which is a prefix of the 32 bit code 2, making the
Huffman table invalid. On the other hand, if there were only one symbol
with the length 32, the earlier code would accept this un-Huffman-tree.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/magicyuv: Don't invert order unnecessarily
Andreas Rheinhardt [Wed, 23 Sep 2020 12:19:03 +0000 (14:19 +0200)]
avcodec/magicyuv: Don't invert order unnecessarily

The MagicYUV decoder currently sets both the length and the symbol field
of an array of HuffEntries; hereby the symbol of the ith entry (0-based)
is just i. Then said array gets sorted so that entries with greater
length are at the end and entries with the same length are ordered so
that those with smaller symbols are at the end. Afterwards the newly
sorted array is traversed in reverse order. This commit instead inverts
the ordering and traverses the array in its ordinary order in order to
simplify understanding.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/magicyuv: Replace implicit checks for overread by explicit ones
Andreas Rheinhardt [Wed, 23 Sep 2020 06:28:59 +0000 (08:28 +0200)]
avcodec/magicyuv: Replace implicit checks for overread by explicit ones

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/magicyuv: Use const uint8_t* for pointer to immutable data
Andreas Rheinhardt [Wed, 23 Sep 2020 06:00:24 +0000 (08:00 +0200)]
avcodec/magicyuv: Use const uint8_t* for pointer to immutable data

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/magicyuv: Don't use GetBit API for byte-aligned reads
Andreas Rheinhardt [Wed, 23 Sep 2020 04:42:24 +0000 (06:42 +0200)]
avcodec/magicyuv: Don't use GetBit API for byte-aligned reads

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/magicyuv: Check early for invalid slices
Andreas Rheinhardt [Wed, 23 Sep 2020 04:24:03 +0000 (06:24 +0200)]
avcodec/magicyuv: Check early for invalid slices

Every plane of each slice has to contain at least two bytes for flags
and the type of prediction used.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/diracdsp: Remove unused variable
Andreas Rheinhardt [Wed, 23 Sep 2020 18:20:12 +0000 (20:20 +0200)]
avcodec/diracdsp: Remove unused variable

Forgotten in ca3c6c981aa5b0af8a5576020b79fdd3cdf9ae9e.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/magicyuv: Improve overread check when parsing Huffman tables
Andreas Rheinhardt [Wed, 23 Sep 2020 03:42:31 +0000 (05:42 +0200)]
avcodec/magicyuv: Improve overread check when parsing Huffman tables

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/bytestream: Add unchecked bytestream2 peek functions
Andreas Rheinhardt [Thu, 28 May 2020 15:43:56 +0000 (17:43 +0200)]
avcodec/bytestream: Add unchecked bytestream2 peek functions

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/photocd: Simplify parsing Huffman tables a bit
Andreas Rheinhardt [Wed, 23 Sep 2020 02:57:53 +0000 (04:57 +0200)]
avcodec/photocd: Simplify parsing Huffman tables a bit

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/dxtory: Fix negative shift in dx2_decode_slice_410()
Michael Niedermayer [Fri, 25 Sep 2020 18:08:37 +0000 (20:08 +0200)]
avcodec/dxtory: Fix negative shift in dx2_decode_slice_410()

Fixes: left shift of negative value -768
Fixes: 25574/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXTORY_fuzzer-6012596027916288

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>
7 months agoavcodec/dxtory: Fix negative shift in dxtory_decode_v1_410()
Michael Niedermayer [Fri, 25 Sep 2020 15:15:29 +0000 (17:15 +0200)]
avcodec/dxtory: Fix negative shift in dxtory_decode_v1_410()

Fixes: left shift of negative value -256
Fixes: 25460/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXTORY_fuzzer-5073252341514240

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>
7 months agoavcodec/dxtory: Fix get_raw_size() for YUV
Michael Niedermayer [Fri, 25 Sep 2020 15:07:24 +0000 (17:07 +0200)]
avcodec/dxtory: Fix get_raw_size() for YUV

Fixes: out of array read
Fixes: 25455/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXTORY_fuzzer-6327985731534848

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>
7 months agolavc/qsvdec: Add QSV AV1 decoder
Haihao Xiang [Wed, 16 Sep 2020 07:07:54 +0000 (15:07 +0800)]
lavc/qsvdec: Add QSV AV1 decoder

AV1 decoder is supported on Tiger Lake+ platforms since libmfx 1.34

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Signed-off-by: Zhong Li <zhongli_dev@126.com>