]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoffprobe: drop code accessing deprecated AVStream.codec
Anton Khirnov [Mon, 8 Feb 2021 11:05:55 +0000 (12:05 +0100)]
ffprobe: drop code accessing deprecated AVStream.codec

3 years agoffprobe: do not use deprecated AVStream.codec for max bitrate
Anton Khirnov [Mon, 8 Feb 2021 11:03:00 +0000 (12:03 +0100)]
ffprobe: do not use deprecated AVStream.codec for max bitrate

Use the decoder context instead.

3 years agoffprobe: remove an unnecessary deprecation guard
Anton Khirnov [Mon, 8 Feb 2021 11:00:13 +0000 (12:00 +0100)]
ffprobe: remove an unnecessary deprecation guard

The code it is guarding is not accessing anything deprecated
(disregarding the fact that a library caller must not use FF_API
deprecation guards).

3 years agoavformat/mov: fix timecode with counter mode flag set
Mark Reid [Sun, 17 Jan 2021 01:48:45 +0000 (17:48 -0800)]
avformat/mov: fix timecode with counter mode flag set

The current behaviour ends up squaring the avg_frame_rate if the conter mode flag is set.
This messes up the timecode calculation, and looks to me as a regression that
seems to have been introduced 428b4aac.

Upon further testing is seems that no special case is need for having the counter flag set.
av_timecode_init appears to handles the timecode correctly, at least in the sample files
I have.

Here is a sample mov file with the counter flag set
https://www.dropbox.com/s/5l4fucb9lhq523s/timecode_counter_mode.mov

before the patch ffmpeg will report the timecode as:
00:37:11:97 and warns that the timecode framerate is 576000000/1002001

after patch:
14:50:55:02

Signed-off-by: Anton Khirnov <anton@khirnov.net>
3 years agolavc/ac3enc: rename variable to avoid shadowing
Anton Khirnov [Wed, 3 Feb 2021 15:16:37 +0000 (16:16 +0100)]
lavc/ac3enc: rename variable to avoid shadowing

Harmless, but confusing.

3 years agoavutil/tx: Fix declaration after statement
Andreas Rheinhardt [Mon, 22 Feb 2021 04:57:14 +0000 (05:57 +0100)]
avutil/tx: Fix declaration after statement

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agofate/matroska: Add fate-matroska target
Andreas Rheinhardt [Wed, 17 Feb 2021 08:07:33 +0000 (09:07 +0100)]
fate/matroska: Add fate-matroska target

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agofate/matroska: Add test for remuxing VP8 with alpha
Andreas Rheinhardt [Wed, 17 Feb 2021 00:12:41 +0000 (01:12 +0100)]
fate/matroska: Add test for remuxing VP8 with alpha

This provides coverage for writing BlockGroups with BlockAdditional
and ReferenceBlock elements. It also tests setting the hearing impaired
disposition (it fits given that this video has no audio so one needs to
be able to read lips to understand anything).

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskaenc: Add support for FlagTextDescriptions
Andreas Rheinhardt [Tue, 16 Feb 2021 18:49:16 +0000 (19:49 +0100)]
avformat/matroskaenc: Add support for FlagTextDescriptions

This is the Matroska equivalent of D_WEBVTT_DESCRIPTIONS and is
therefore only enabled for subtitles.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskadec: Add support for FlagTextDescriptions
Andreas Rheinhardt [Tue, 16 Feb 2021 18:38:19 +0000 (19:38 +0100)]
avformat/matroskadec: Add support for FlagTextDescriptions

This is the equivalent of the WebM "D_WEBVTT/DESCRIPTIONS" and is
therefore only exported for subtitles.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskaenc: Add support for FlagHearing/VisualImpaired
Andreas Rheinhardt [Tue, 16 Feb 2021 18:14:06 +0000 (19:14 +0100)]
avformat/matroskaenc: Add support for FlagHearing/VisualImpaired

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskadec: Add support for FlagHearing/VisualImpaired
Andreas Rheinhardt [Tue, 16 Feb 2021 18:08:51 +0000 (19:08 +0100)]
avformat/matroskadec: Add support for FlagHearing/VisualImpaired

Given that our disposition flags provide no way to distinguish the
cases of "track is unsuitable for hearing impaired users" and "it is
unknown whether the track is suitable for hearing impaired users" we do
not need to use a CountedElement for these flags.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskaenc: Add support for FlagCommentary
Andreas Rheinhardt [Tue, 16 Feb 2021 17:32:23 +0000 (18:32 +0100)]
avformat/matroskaenc: Add support for FlagCommentary

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskadec: Add support for FlagCommentary
Andreas Rheinhardt [Tue, 16 Feb 2021 17:23:59 +0000 (18:23 +0100)]
avformat/matroskadec: Add support for FlagCommentary

Hint: Matroska actually provides a way to distinguish the cases of
"track is no commentary track" and "it is unknown whether the track
is a commentary track", but our disposition flags do not. Therefore
we need not use a CountedElement.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskadec: Beautify setting default values
Andreas Rheinhardt [Tue, 16 Feb 2021 16:21:14 +0000 (17:21 +0100)]
avformat/matroskadec: Beautify setting default values

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskadec: Reindent after the previous commit
Andreas Rheinhardt [Tue, 16 Feb 2021 16:14:03 +0000 (17:14 +0100)]
avformat/matroskadec: Reindent after the previous commit

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskadec: Make reading zero-length elements spec-compliant
Andreas Rheinhardt [Tue, 16 Feb 2021 15:51:40 +0000 (16:51 +0100)]
avformat/matroskadec: Make reading zero-length elements spec-compliant

For a very long time, the payload of integer and float elements had to
have a length > 0. Our parser treated such invalid elements as having a
value zero. But now it has been defined what an EBML element with length
zero means: It is a shorthand for the default value. This has also been
defined for strings (both ASCII and UTF-8). This commit modifies our
parser to support this.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskadec: Don't use fake default value for ReferenceBlock
Andreas Rheinhardt [Tue, 16 Feb 2021 15:18:02 +0000 (16:18 +0100)]
avformat/matroskadec: Don't use fake default value for ReferenceBlock

This has been done in order to find out whether this element is present
at all; but this can now be done in a cleaner way by using a CountedElement
for it.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskaenc: Don't write empty language
Andreas Rheinhardt [Tue, 16 Feb 2021 14:53:25 +0000 (15:53 +0100)]
avformat/matroskaenc: Don't write empty language

According to the new EBML specifications, a string element of length
zero would be read as the default value by a compliant parser.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskadec: Check min_luminance more thoroughly
Andreas Rheinhardt [Tue, 16 Feb 2021 14:34:06 +0000 (15:34 +0100)]
avformat/matroskadec: Check min_luminance more thoroughly

In the absence of an explicitly coded minimal luminance, the current
code inferred it to be -1, an invalid value. Yet it did not check the
value lateron at all, so that if a valid maximum luminance is
encountered, but no minimal luminance, an invalid minimal luminance of
-1 is exported. If an minimal luminance element with a negative value is
present, it is exported, too. This can be simply fixed by adding a check
for the value of the element.

Yet given that a minimal luminance of zero Cd/m² is legal and can be
coded with a length of zero, we must not use a fake default value to
find out whether the element is present or not. Therefore this patch
uses an explicit counter for it.

While just at it, also check for max_luminance > min_luminance.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskadec: Allow to count the number of element occurences
Andreas Rheinhardt [Tue, 16 Feb 2021 13:33:51 +0000 (14:33 +0100)]
avformat/matroskadec: Allow to count the number of element occurences

Up until now, the generic EBML reader used by the Matroska demuxer did
not have the capability to record whether an element was actually
present or not; instead, in cases where it mattered one typically added
an invalid default value and checked whether the value is valid (in
which case it is guaranteed to be present). This worked pretty well so
far, yet the EBML specifications have evolved: It is now legal to use
zero-length elements for floats, ints, uints and strings (both ASCII and
UTF-8); the value of these elements is the default value of the element
(if it has one) or zero for scalar types and an empty string for
strings. Furthermore, having a default value does no longer imply that
the element may be presumed to be present (with its default value) if it
is absent; this is only true if the element is mandatory, too.

These rules are designed to allow size savings as follows: Consider the
newly added FlagOriginal: It being zero means the track is not in its
original language, it being one means it is. For backward compatibility
reasons, neither of the two values may be inferred automatically in the
absence of the element. But one can still save a byte when one wants to
write the element with a value of zero, as one can write the integer with
a length of zero: 0x55AE 80 instead of 0x55AE 81 00. In the former case,
a parser has to infer the value of the element to be zero (which is the
element's default value).

When encountering an element with length zero, our parser always infers
a value of zero (or an empty string); this is wrong for values with
a different default value. It needs to infer the default value (or zero
in its absence) and this precludes using an invalid default value for
elements like FlagOriginal. Ergo one needs to be able to record whether
an element is present or not by other means. This patch allows to use a
simple counter for this. While just at it, some invalid and unnecessary
default values have been removed (mastering metadata elements used
default values of -1.0, despite these elements only being used if they
are > 0).

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agofate/matroska: Add test for mastering display metadata
Andreas Rheinhardt [Wed, 17 Feb 2021 06:32:47 +0000 (07:32 +0100)]
fate/matroska: Add test for mastering display metadata

The FATE suite already contains a file containing mastering display
and content light level metadata: Meridian-Apple_ProResProxy-HDR10.mxf
This file is used to test both the Matroska muxer and demuxer.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/microdvddec: use 64bit for durations
Michael Niedermayer [Fri, 11 Dec 2020 00:06:46 +0000 (01:06 +0100)]
avformat/microdvddec: use 64bit for durations

Fixes: signed integer overflow: 7 - -2147483647 cannot be represented in type 'int'
Fixes: 28036/clusterfuzz-testcase-minimized-ffmpeg_dem_MICRODVD_fuzzer-5171698751766528
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 agoarm/aarch64: Use mach_absolute_time as timer on apple platforms
Martin Storsjö [Fri, 12 Feb 2021 10:27:03 +0000 (12:27 +0200)]
arm/aarch64: Use mach_absolute_time as timer on apple platforms

This is much less precise than the cycle counter register, but
the cycle counter register is not available on apple platforms
(and on linux, it requires a kernel module for allowing user mode
access).

Signed-off-by: Martin Storsjö <martin@martin.st>
3 years agolavu/tx: support in-place FFT transforms
Lynne [Wed, 10 Feb 2021 16:58:22 +0000 (17:58 +0100)]
lavu/tx: support in-place FFT transforms

This commit adds support for in-place FFT transforms. Since our
internal transforms were all in-place anyway, this only changes
the permutation on the input.

Unfortunately, research papers were of no help here. All focused
on dry hardware implementations, where permutes are free, or on
software implementations where binary bloat is of no concern so
storing dozen times the transforms for each permutation and version
is not considered bad practice.
Still, for a pure C implementation, it's only around 28% slower
than the multi-megabyte FFTW3 in unaligned mode.

Unlike a closed permutation like with PFA, split-radix FFT bit-reversals
contain multiple NOPs, multiple simple swaps, and a few chained swaps,
so regular single-loop single-state permute loops were not possible.
Instead, we filter out parts of the input indices which are redundant.
This allows for a single branch, and with some clever AVX512 asm,
could possibly be SIMD'd without refactoring.

The inplace_idx array is guaranteed to never be larger than the
revtab array, and in practice only requires around log2(len) entries.

The power-of-two MDCTs can be done in-place as well. And it's
possible to eliminate a copy in the compound MDCTs too, however
it'll be slower than doing them out of place, and we'd need to dirty
the input array.

3 years agolavu/tx: space out enum AVTXType values with newlines
Lynne [Sun, 21 Feb 2021 16:03:57 +0000 (17:03 +0100)]
lavu/tx: space out enum AVTXType values with newlines

Makes separation clearer.

3 years agoavfilter/af_afade: remove uneeded '.' from durations in options
Paul B Mahol [Sun, 21 Feb 2021 12:38:14 +0000 (13:38 +0100)]
avfilter/af_afade: remove uneeded '.' from durations in options

3 years agoavformat: add Simbiosis IMX demuxer
Paul B Mahol [Wed, 17 Feb 2021 16:19:55 +0000 (17:19 +0100)]
avformat: add Simbiosis IMX demuxer

3 years agoavcodec: add Simbiosis IMX video decoder
Paul B Mahol [Wed, 17 Feb 2021 16:32:57 +0000 (17:32 +0100)]
avcodec: add Simbiosis IMX video decoder

3 years agoavcodec/cpia: Mark decoder as init-threadsafe
Andreas Rheinhardt [Mon, 30 Nov 2020 12:59:27 +0000 (13:59 +0100)]
avcodec/cpia: Mark decoder as init-threadsafe

Reviewed-by: Stephan Hilb <stephan@ecshi.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/dirac_vlc: Make ff_dirac_golomb_lut static
Andreas Rheinhardt [Sat, 20 Feb 2021 04:12:21 +0000 (05:12 +0100)]
avcodec/dirac_vlc: Make ff_dirac_golomb_lut static

Only used here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ac3tab: Move ff_ac3_enc_channel_map to its only user
Andreas Rheinhardt [Sat, 20 Feb 2021 03:30:30 +0000 (04:30 +0100)]
avcodec/ac3tab: Move ff_ac3_enc_channel_map to its only user

and make it static.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/hapdec: Change compressed_offset to unsigned 32bit
Michael Niedermayer [Fri, 19 Feb 2021 20:16:25 +0000 (21:16 +0100)]
avcodec/hapdec: Change compressed_offset to unsigned 32bit

Fixes: out of array access
Fixes: 29345/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5401813482340352
Fixes: 30745/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5762798221131776
Suggested-by: Anton
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/libvpxenc: optimize parsing vpx_svc_ref_frame_config
Wonkap Jang [Thu, 18 Feb 2021 19:01:31 +0000 (11:01 -0800)]
avcodec/libvpxenc: optimize parsing vpx_svc_ref_frame_config

Getting rid of unnecessary use of AVDictionary object in parsing
vpx_svc_ref_frame_config.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: James Zern <jzern@google.com>
3 years agofftools/ffplay: reindent and some minor cosmetics
Marton Balint [Sun, 7 Feb 2021 17:55:31 +0000 (18:55 +0100)]
fftools/ffplay: reindent and some minor cosmetics

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agofftools/ffplay: use av_packet_alloc() to allocate packets
Marton Balint [Sun, 7 Feb 2021 17:48:11 +0000 (18:48 +0100)]
fftools/ffplay: use av_packet_alloc() to allocate packets

Heavily based on a patch by James Almer.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agofftools/ffplay: use context AVPacket in decoder_decode_frame()
Marton Balint [Sun, 7 Feb 2021 14:47:09 +0000 (15:47 +0100)]
fftools/ffplay: use context AVPacket in decoder_decode_frame()

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agofftools/ffplay: get rid of flush_pkt
Marton Balint [Sun, 7 Feb 2021 12:39:18 +0000 (13:39 +0100)]
fftools/ffplay: get rid of flush_pkt

The packet serial can be used instead to detect when a flush is needed.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavcodec/cfhdenc: use pts instead of frame number
Paul B Mahol [Fri, 19 Feb 2021 19:58:41 +0000 (20:58 +0100)]
avcodec/cfhdenc: use pts instead of frame number

Makes encodes bitexact with different number of threads.

3 years agoavfilter/vf_ssim: add slice threading
Paul B Mahol [Tue, 16 Feb 2021 22:00:03 +0000 (23:00 +0100)]
avfilter/vf_ssim: add slice threading

3 years agoavfilter/vf_psnr: add support for slice threading
Paul B Mahol [Fri, 12 Feb 2021 23:53:16 +0000 (00:53 +0100)]
avfilter/vf_psnr: add support for slice threading

3 years agoavcodec/indeo3: add support for more dimensions
Paul B Mahol [Sun, 14 Feb 2021 18:14:45 +0000 (19:14 +0100)]
avcodec/indeo3: add support for more dimensions

Fixes #6581

3 years agotests/checkasm/sw_scale: use memset() to fill dither
James Almer [Fri, 19 Feb 2021 19:19:11 +0000 (16:19 -0300)]
tests/checkasm/sw_scale: use memset() to fill dither

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agocheckasm/sw_scale: properly initialize src_pixer and filter_coeff buffers
Alan Kelly [Fri, 19 Feb 2021 13:55:39 +0000 (14:55 +0100)]
checkasm/sw_scale: properly initialize src_pixer and filter_coeff buffers

Fixes valgrind uninitialised value warnings.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavfilter/vf_vif: Remove superfluous ';'
Andreas Rheinhardt [Fri, 19 Feb 2021 07:34:57 +0000 (08:34 +0100)]
avfilter/vf_vif: Remove superfluous ';'

Inside a function a superfluous ';' is just a null-statement; yet
outside it is invalid, even though compilers happen to accept them.
They (at least GCC and Clang) only warn about this when on -pedantic.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/mpegenc: Forward error code
Andreas Rheinhardt [Mon, 15 Feb 2021 12:55:07 +0000 (13:55 +0100)]
avformat/mpegenc: Forward error code

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/mpegenc: Avoid adding invalid packet to queue
Andreas Rheinhardt [Mon, 15 Feb 2021 02:44:52 +0000 (03:44 +0100)]
avformat/mpegenc: Avoid adding invalid packet to queue

Do this by moving the check before the allocation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/mpegenc: Fix leak in case trailer is never written
Andreas Rheinhardt [Mon, 15 Feb 2021 02:41:20 +0000 (03:41 +0100)]
avformat/mpegenc: Fix leak in case trailer is never written

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/mpegenc: Ensure packet queue stays valid
Andreas Rheinhardt [Mon, 15 Feb 2021 02:26:04 +0000 (03:26 +0100)]
avformat/mpegenc: Ensure packet queue stays valid

The MPEG-PS muxer uses a custom queue of custom packets. To keep track
of it, it has a pointer (named predecode_packet) to the head of the
queue and a pointer to where the next packet is to be added (it points
to the next-pointer of the last element of the queue); furthermore,
there is also a pointer that points into the queue (called premux_packet).

The exact behaviour was as follows: If premux_packet was NULL when a
packet is received, it is taken to mean that the old queue is empty and
a new queue is started. premux_packet will point to the head of said
queue and the next_packet-pointer points to its next pointer. If
predecode_packet is NULL, it will also made to point to the newly
allocated element.

But if premux_packet is NULL and predecode_packet is not, then there
will be two queues with head elements premux_packet and
predecode_packet. Yet only elements reachable from predecode_packet are
ever freed, so the premux_packet queue leaks.
Worse yet, when the predecode_packet queue will be eventually exhausted,
predecode_packet will be made to point into the other queue and when
predecode_packet will be freed, the next pointer of the preceding
element of the queue will still point to the element just freed. This
element might very well be still reachable from premux_packet which
leads to use-after-frees lateron. This happened in the tickets mentioned
below.

Fix this by never creating two queues in the first place by checking for
predecode_packet to know whether the queue is empty. If premux_packet is
NULL, then it is set to the newly allocated element of the queue.

Fixes tickets #6887, #8188 and #8266.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavutil/video_enc_params: Check for truncation before creating buffer
Andreas Rheinhardt [Sun, 14 Feb 2021 18:47:45 +0000 (19:47 +0100)]
avutil/video_enc_params: Check for truncation before creating buffer

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavutil/video_enc_params: Combine overflow checks
Andreas Rheinhardt [Sun, 14 Feb 2021 18:43:56 +0000 (19:43 +0100)]
avutil/video_enc_params: Combine overflow checks

This patch also fixes a -Wtautological-constant-out-of-range-compare
warning from Clang and a -Wtype-limits warning from GCC on systems
where size_t is 64bits and unsigned 32bits. The reason for this seems
to be that variable (whose value derives from sizeof() and can therefore
be known at compile-time) is used instead of using sizeof() directly in
the comparison.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoswscale/x86/yuv2yuvX: use the movsxdifnidn helper macro
James Almer [Thu, 18 Feb 2021 15:09:27 +0000 (12:09 -0300)]
swscale/x86/yuv2yuvX: use the movsxdifnidn helper macro

Simplifies code

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoswscale/x86/yuv2yuvX: use movq to load 8 bytes in all non-AVX2 functions
James Almer [Thu, 18 Feb 2021 15:09:11 +0000 (12:09 -0300)]
swscale/x86/yuv2yuvX: use movq to load 8 bytes in all non-AVX2 functions

mova expands to movq on non-XMM functions

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoswscale/x86/yuv2yuvX: use the SPLATW helper macro
James Almer [Thu, 18 Feb 2021 15:07:45 +0000 (12:07 -0300)]
swscale/x86/yuv2yuvX: use the SPLATW helper macro

Simplifies code

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoswscale/x86/swscale: fix mix of inline and external function definitions
James Almer [Thu, 18 Feb 2021 14:35:08 +0000 (11:35 -0300)]
swscale/x86/swscale: fix mix of inline and external function definitions

This includes removing pointless static function forward declarations.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agolavc/aarch64: add HEVC sao_band NEON
Josh Dekker [Thu, 7 Jan 2021 11:55:44 +0000 (11:55 +0000)]
lavc/aarch64: add HEVC sao_band NEON

Only works for 8x8.

Signed-off-by: Josh Dekker <josh@itanimul.li>
3 years agolavc/aarch64: add HEVC idct_dc NEON
Josh Dekker [Mon, 1 Feb 2021 10:30:52 +0000 (10:30 +0000)]
lavc/aarch64: add HEVC idct_dc NEON

Signed-off-by: Josh Dekker <josh@itanimul.li>
3 years agolavc/aarch64: port HEVC add_residual NEON
Reimar Döffinger [Sun, 10 Jan 2021 10:27:00 +0000 (10:27 +0000)]
lavc/aarch64: port HEVC add_residual NEON

Speedup is fairly small, around 1.5%, but these are fairly simple.

Signed-off-by: Josh Dekker <josh@itanimul.li>
3 years agolavc/aarch64: port HEVC SIMD idct NEON
Reimar Döffinger [Sat, 16 Jan 2021 01:03:45 +0000 (02:03 +0100)]
lavc/aarch64: port HEVC SIMD idct NEON

Makes SIMD-optimized 8x8 and 16x16 idcts for 8 and 10 bit depth
available on aarch64.
For a UHD HDR (10 bit) sample video these were consuming the most time
and this optimization reduced overall decode time from 19.4s to 16.4s,
approximately 15% speedup.
Test sample was the first 300 frames of "LG 4K HDR Demo - New York.ts",
running on Apple M1.

Signed-off-by: Josh Dekker <josh@itanimul.li>
3 years agoavcodec: add initial exr image encoder
Paul B Mahol [Sun, 14 Feb 2021 22:11:59 +0000 (23:11 +0100)]
avcodec: add initial exr image encoder

3 years agodnn_backend_openvino.c: allow out_frame as NULL for analytic case
Ting Fu [Mon, 8 Feb 2021 02:44:58 +0000 (10:44 +0800)]
dnn_backend_openvino.c: allow out_frame as NULL for analytic case

3 years agodnn: add color conversion for analytic case
Guo, Yejun [Sun, 7 Feb 2021 07:03:43 +0000 (15:03 +0800)]
dnn: add color conversion for analytic case

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agodnn_interface.h: add enum DNNColorOrder
Guo, Yejun [Mon, 8 Feb 2021 01:53:39 +0000 (09:53 +0800)]
dnn_interface.h: add enum DNNColorOrder

the data type and order together decide the color format, we could
not use AVPixelFormat directly because not all the possible formats
are covered by it.

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agodnn: add function type for model
Guo, Yejun [Sun, 7 Feb 2021 06:35:22 +0000 (14:35 +0800)]
dnn: add function type for model

So the backend knows the usage of model is for frame processing,
detect, classify, etc. Each function type has different behavior
in backend when handling the input/output data of the model.

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agodnn: extract common functions used by different filters
Guo, Yejun [Tue, 26 Jan 2021 05:35:30 +0000 (13:35 +0800)]
dnn: extract common functions used by different filters

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agodnn_backend_openvino.c: fix multi-thread issue for async execution
Guo, Yejun [Mon, 8 Feb 2021 10:46:27 +0000 (18:46 +0800)]
dnn_backend_openvino.c: fix multi-thread issue for async execution

once we mark done for the task in function infer_completion_callback,
the task is possible to be release in function ff_dnn_get_async_result_ov
in another thread just after it, so we need to record request queue
first, instead of using task->ov_model->request_queue later.

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agodnn_backend_openvino.c: fix mismatch between ffmpeg(NHWC) and openvino(NCHW)
Guo, Yejun [Mon, 8 Feb 2021 01:22:23 +0000 (09:22 +0800)]
dnn_backend_openvino.c: fix mismatch between ffmpeg(NHWC) and openvino(NCHW)

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agoswscale/x86/swscale: fix compilation with old yasm
James Almer [Thu, 18 Feb 2021 00:05:41 +0000 (21:05 -0300)]
swscale/x86/swscale: fix compilation with old yasm

Where AVX2 may not be supported.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agocheckasm/sw_scale: use av_free() instead of free()
James Almer [Wed, 17 Feb 2021 23:57:33 +0000 (20:57 -0300)]
checkasm/sw_scale: use av_free() instead of free()

Fixes crashes on Win64

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavfilter/vf_pseudocolor: Add missing braces
Mark Thompson [Tue, 2 Feb 2021 21:50:37 +0000 (21:50 +0000)]
avfilter/vf_pseudocolor: Add missing braces

The array inside a structure needs two levels of braces.

3 years agoswscale: move yuv2yuvX_sse3 to yasm, unrolls main loop
Alan Kelly [Thu, 14 Jan 2021 14:47:03 +0000 (15:47 +0100)]
swscale: move yuv2yuvX_sse3 to yasm, unrolls main loop

And other small optimizations for ~20% speedup.

3 years agox86/vf_gblur: fix reg name in UNIX64 prologue
James Almer [Wed, 17 Feb 2021 18:51:28 +0000 (15:51 -0300)]
x86/vf_gblur: fix reg name in UNIX64 prologue

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavfilter/vf_gblur: add missing arch check
James Almer [Wed, 17 Feb 2021 18:45:40 +0000 (15:45 -0300)]
avfilter/vf_gblur: add missing arch check

Removed by mistake in 2b4da1cb8c2984b37e5c912e103a1b8b734e7c1f where it
should have been replaced instead.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agocheckasm/vf_gblur: add a test for postscale_slice
James Almer [Wed, 17 Feb 2021 15:05:12 +0000 (12:05 -0300)]
checkasm/vf_gblur: add a test for postscale_slice

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agocheckasm/vf_gblur: split off the horiz_slice test into its own function
James Almer [Wed, 17 Feb 2021 15:04:23 +0000 (12:04 -0300)]
checkasm/vf_gblur: split off the horiz_slice test into its own function

Will come in handy for the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agox86/vf_gblur: fix postscale_slice prologue
James Almer [Wed, 17 Feb 2021 13:46:36 +0000 (10:46 -0300)]
x86/vf_gblur: fix postscale_slice prologue

x86_32 ABI does not pass float arguments directly on xmm regs, and the Win64
ABI uses only the first four regs for this purpose.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agolavfi/drawtext: ignore final LF of textfile.
Nicolas George [Mon, 30 Nov 2020 18:28:36 +0000 (19:28 +0100)]
lavfi/drawtext: ignore final LF of textfile.

A standard text file ends with a final LF.
Without this change, it is interpreted as an empty final line,
and visible with the box option.
The current behavior can be achieved by actually having
an empty line at the end of the file.

Fix trac ticket #7948.

3 years agoavformat/ircamdec: use lrintf() for rounding
Paul B Mahol [Tue, 16 Feb 2021 22:35:11 +0000 (23:35 +0100)]
avformat/ircamdec: use lrintf() for rounding

3 years agolavc/aacdec_template: Fix 7.1 decoding with default strictness.
KM [Tue, 16 Feb 2021 22:19:19 +0000 (23:19 +0100)]
lavc/aacdec_template: Fix 7.1 decoding with default strictness.

Broken in 4d9b9c5e
Fixes ticket #9057.

3 years agoavformat/mxfenc: Discard audio until valid video has been received
Andreas Rheinhardt [Fri, 4 Dec 2020 23:39:28 +0000 (00:39 +0100)]
avformat/mxfenc: Discard audio until valid video has been received

Normally, video packets are muxed before audio packets for mxf (there is
a dedicated interleave function for this); furthermore the first (video)
packet triggers writing the actual header. Yet when the first video packet
fails the checks performed on it, it will be an audio packet that leads
to writing the header and codec_ul (a value set based upon
properties of the bitstream which necessitates actually inspecting
packets) may be wrong. Therefore this commit discards audio packets until
a valid video packet has been received.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agotests/fate-run.sh: Don't overlook errors from md5 tests
Andreas Rheinhardt [Fri, 4 Dec 2020 22:42:55 +0000 (23:42 +0100)]
tests/fate-run.sh: Don't overlook errors from md5 tests

The md5 test up until now ignored errors from ffmpeg (the cli) and just
md5'ed whatever ffmpeg has output; while testing scenarios in which
ffmpeg fails has its merits, errors should not be overlooked by default;
doing so also reduces the effectiveness of sanitizers as errors from
them are ignored. This has happened with a memleak in the AV1 decoder.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agofate/mxf: Fix d10-user-comments test
Andreas Rheinhardt [Fri, 4 Dec 2020 22:11:00 +0000 (23:11 +0100)]
fate/mxf: Fix d10-user-comments test

The mxf_d10 muxer is very picky regarding the input it accepts:
The only video accepted is MPEG-2 with absolutely constant bitrate,
i.e. all packets need to have exactly the same size; and only a few
bitrates are accepted.

The sample file used did not abide by this: Writing the first packet
(a video packet) errors out and afterwards an audio packet from the
muxing queue has been written. That's all besides metadata (which this
test is about). The FFmpeg cli returned an error, but said error has
been ignored by the md5 test.

This commit changes the test to actually send a compliant stream to the
muxer, so that it does not error out; furthermore, the test is changed
to explicitly check the metadata instead of it only being implicitly
included in the md5 checksum. The compliant stream is created by our
encoder at runtime.

Finally, the test now also covers writing user-specified
product/company/version identification.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/mxfenc: Fix typo
Andreas Rheinhardt [Mon, 15 Feb 2021 15:58:44 +0000 (16:58 +0100)]
avformat/mxfenc: Fix typo

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/mxfenc: Use user-specified version even when bitexact
Andreas Rheinhardt [Mon, 15 Feb 2021 15:54:59 +0000 (16:54 +0100)]
avformat/mxfenc: Use user-specified version even when bitexact

Doing so is still bitexact.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/mxfenc: Never set codec_ul UID to NULL
Andreas Rheinhardt [Fri, 28 Feb 2020 03:48:22 +0000 (04:48 +0100)]
avformat/mxfenc: Never set codec_ul UID to NULL

mxf distinguishes codec profiles by different UIDs and therefore needs
to check that the input is actually compatible with mxf (i.e. if there
is a defined UID for it). If not, then sometimes the UID would be set to
NULL and writing the (video) packet would fail. Yet the following audio
packet would trigger writing the header (which has been postponed because
the UID is not known at the start) and if the UID is NULL, this can lead
to segfaults. This commit therefore stops setting the UID to NULL if the
input is incompatible with mxf (it has initially been set to a generic
value in mxf_write_header()).

Fixes #7993.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vif: Include avfilter.h
Andreas Rheinhardt [Tue, 16 Feb 2021 21:26:56 +0000 (22:26 +0100)]
avfilter/vif: Include avfilter.h

Fixes checkheaders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/frame_thread_encoder: Use more natural types
Andreas Rheinhardt [Sun, 7 Feb 2021 19:35:09 +0000 (20:35 +0100)]
avcodec/frame_thread_encoder: Use more natural types

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/frame_thread_encoder: Reduce amount of code guarded by mutex
Andreas Rheinhardt [Sun, 7 Feb 2021 18:59:11 +0000 (19:59 +0100)]
avcodec/frame_thread_encoder: Reduce amount of code guarded by mutex

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/frame_thread_encoder: Avoid FIFO
Andreas Rheinhardt [Sun, 7 Feb 2021 14:08:13 +0000 (15:08 +0100)]
avcodec/frame_thread_encoder: Avoid FIFO

It can be replaced by a simple counter.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/frame_thread_encoder: Avoid allocations of AVFrames
Andreas Rheinhardt [Sun, 7 Feb 2021 13:30:28 +0000 (14:30 +0100)]
avcodec/frame_thread_encoder: Avoid allocations of AVFrames

Up until now, when using frame threaded encoding, an AVFrame would be
allocated for every frame to be encoded. These AVFrames would reach the
worker threads via a FIFO of tasks, a structure which contained the
AVFrame as well as an index into an array which gives the place where
the worker thread shall put the returned packet; in addition to that,
said structure also contained several unused fields.

This commit changes this: The AVFrames are now allocated during init in
the array that is up until now only used to return the packets. The
contents to be encoded are put into the AVFrame in the same array
element that is also used to return the packets.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/frame_thread_encoder: Avoid creating reference to frame
Andreas Rheinhardt [Sun, 7 Feb 2021 12:46:11 +0000 (13:46 +0100)]
avcodec/frame_thread_encoder: Avoid creating reference to frame

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/frame_thread_encoder: Avoid allocations of AVPackets, fix deadlock
Andreas Rheinhardt [Sun, 7 Feb 2021 12:36:52 +0000 (13:36 +0100)]
avcodec/frame_thread_encoder: Avoid allocations of AVPackets, fix deadlock

Up until now, when doing frame thread encoding, each worker thread
tried to allocate an AVPacket for every AVFrame to be encoded; said
packets would then be handed back to the main thread, where the content
of said packet is copied into the packet actually destined for output;
the temporary AVPacket is then freed.

Besides being wasteful this also has another problem: There is a risk of
deadlock, namely if no AVPacket can be allocated at all. The user
doesn't get an error at all in this case and the worker threads will
simply try to allocate a packet again and again. If the user has
supplied enough frames, the user's thread will block until a task has
been completed, which just doesn't happen if no packet can ever be
allocated.

This patch instead modifies the code to allocate the packets during
init; they are then reused again and again.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/frame_thread_encoder: Fix segfault on allocation error
Andreas Rheinhardt [Sun, 7 Feb 2021 09:58:25 +0000 (10:58 +0100)]
avcodec/frame_thread_encoder: Fix segfault on allocation error

Fixes a segfault from av_fifo_size(NULL) that happens in
ff_frame_thread_encoder_free if the fifo couldn't be allocted;
furthermore the mutexes and conditions that are destroyed in
ff_frame_thread_encoder_free are not even initialized at this point,
so don't call said function.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/frame_thread_encoder: Improve type safety
Andreas Rheinhardt [Sun, 7 Feb 2021 09:48:17 +0000 (10:48 +0100)]
avcodec/frame_thread_encoder: Improve type safety

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/x86/vf_gblur: add postscale SIMD
Paul B Mahol [Sat, 13 Feb 2021 11:09:47 +0000 (12:09 +0100)]
avfilter/x86/vf_gblur: add postscale SIMD

3 years agoavfilter/vf_gblur: factor out postscale function
Paul B Mahol [Sat, 13 Feb 2021 10:15:22 +0000 (11:15 +0100)]
avfilter/vf_gblur: factor out postscale function

3 years agotools/target_dec_fuzzer: Adjust threshold for wavpack
Michael Niedermayer [Wed, 20 Jan 2021 23:32:51 +0000 (00:32 +0100)]
tools/target_dec_fuzzer: Adjust threshold for wavpack

Fixes: Timeout (long -> 4sec)
Fixes: 29064/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVPACK_fuzzer-5104450901508096
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_dec_fuzzer: Adjust threshold for MSA1
Michael Niedermayer [Wed, 20 Jan 2021 22:50:54 +0000 (23:50 +0100)]
tools/target_dec_fuzzer: Adjust threshold for  MSA1

Fixes: Timeout (too long to wait -> 1ms)
Fixes: 29048/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSA1_fuzzer-5733703473037312
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_dec_fuzzer: adjust threshold for cook
Michael Niedermayer [Sat, 23 Jan 2021 18:42:23 +0000 (19:42 +0100)]
tools/target_dec_fuzzer: adjust threshold for cook

Fixes: Timeout (long -> 3ms)
Fixes: 29134/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_COOK_fuzzer-5192822695264256
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_dec_fuzzer: Adjust threshold for theora
Michael Niedermayer [Fri, 29 Jan 2021 23:46:26 +0000 (00:46 +0100)]
tools/target_dec_fuzzer: Adjust threshold for theora

Fixes: Timeout
Fixes: 29226/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-6195092572471296
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>