]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoavformat/movenc: Avoid allocation for timecode track
Andreas Rheinhardt [Mon, 28 Sep 2020 17:27:20 +0000 (19:27 +0200)]
avformat/movenc: Avoid allocation for timecode track

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/movenc: Don't forget to free fragment buffers
Andreas Rheinhardt [Mon, 28 Sep 2020 16:36:06 +0000 (18:36 +0200)]
avformat/movenc: Don't forget to free fragment buffers

The buffers used when fragmented output is enabled have up until now not
been freed in the deinit function; they leak e.g. if one errors out of
mov_write_trailer() before one reaches the point where they are normally
written out and freed. This can e.g. happen if allocating new vos_data
fails at the beginning of mov_write_trailer().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/movenc: Free old vos_data before overwriting it
Andreas Rheinhardt [Mon, 28 Sep 2020 16:05:44 +0000 (18:05 +0200)]
avformat/movenc: Free old vos_data before overwriting it

Otherwise the old data leaks whenever extradata needs to be rewritten
(e.g. when encoding FLAC with our encoder that sends an updated
extradata packet at the end).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/movenc: Don't free AVCodecParameters manually
Andreas Rheinhardt [Mon, 28 Sep 2020 11:30:07 +0000 (13:30 +0200)]
avformat/movenc: Don't free AVCodecParameters manually

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qsv: Fix leak of options on error
Andreas Rheinhardt [Sun, 27 Sep 2020 08:06:27 +0000 (10:06 +0200)]
avcodec/qsv: Fix leak of options on error

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/movenc: Make some AVCodecTag tables static
Andreas Rheinhardt [Wed, 30 Sep 2020 16:29:51 +0000 (18:29 +0200)]
avformat/movenc: Make some AVCodecTag tables static

They are not used anywhere else.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/movenc: Fix segfault when remuxing rtp hint stream
Andreas Rheinhardt [Tue, 29 Sep 2020 08:21:34 +0000 (10:21 +0200)]
avformat/movenc: Fix segfault when remuxing rtp hint stream

When remuxing an rtp hint stream (or any stream with the tag "rtp "),
the mov muxer treats this as one of the rtp hint tracks it creates
internally when ordered to do so; yet this track lacks the
AVFormatContext for the hinting rtp muxer, leading to segfaults in
mov_write_udta_sdp() if a "trak" atom is written for this stream; if not,
the stream's codecpar is freed by mov_free() as if the mov muxer owned
it (it does for the internally created "rtp " tracks), but without
resetting st->codecpar, leading to double-frees lateron. This commit
therefore ignores said tag which makes rtp hint streams unremuxable.

This fixes tickets #8181 and #8186.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/dvenc: Fix undefined left shift of negative numbers
Andreas Rheinhardt [Tue, 29 Sep 2020 12:58:24 +0000 (14:58 +0200)]
avcodec/dvenc: Fix undefined left shift of negative numbers

The earlier code was based on the assumption that AVFrame.linesize can
not be negative.

Fixes ticket #8280.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_v360: fix possible out of range values
Paul B Mahol [Sun, 4 Oct 2020 17:06:58 +0000 (19:06 +0200)]
avfilter/vf_v360: fix possible out of range values

3 years 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

3 years 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>
3 years 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>
3 years 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>
3 years agoavformat: add tri-ACE demuxer
Paul B Mahol [Thu, 24 Sep 2020 15:55:03 +0000 (17:55 +0200)]
avformat: add tri-ACE demuxer

3 years 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

3 years 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.

3 years 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

3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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

3 years 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

3 years 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

3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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.

3 years 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.

3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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.

3 years 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

3 years 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>
3 years 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.

3 years 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

3 years 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

3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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

3 years 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

3 years 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

3 years 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.

3 years 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.

3 years 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>
3 years 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>
3 years 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

3 years 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>
3 years 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

3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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

3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>
3 years 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>