ffmpeg.git
15 hours agofate/ffmpeg: Fix test requirements master
Andreas Rheinhardt [Wed, 25 May 2022 22:05:32 +0000 (00:05 +0200)]
fate/ffmpeg: Fix test requirements

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
28 hours agomfenc: Use dlopen instead of LoadLibrary for loading mfplat.dll
Martin Storsjö [Wed, 25 May 2022 21:31:05 +0000 (00:31 +0300)]
mfenc: Use dlopen instead of LoadLibrary for loading mfplat.dll

The dlopen wrapper contains code to make loading libraries safer,
to avoid loading a potentially malicious DLL with the same name.

Signed-off-by: Martin Storsjö <martin@martin.st>
28 hours agoswscale/aarch64: add hscale specializations
Swinney, Jonathan [Thu, 26 May 2022 02:02:13 +0000 (02:02 +0000)]
swscale/aarch64: add hscale specializations

This patch adds code to support specializations of the hscale function
and adds a specialization for filterSize == 4.

ff_hscale8to15_4_neon is a complete rewrite. Since the main bottleneck
here is loading the data from src, this data is loaded a whole block
ahead and stored back to the stack to be loaded again with ld4. This
arranges the data for most efficient use of the vector instructions and
removes the need for completion adds at the end. The number of
iterations of the C per iteration of the assembly is increased from 4 to
8, but because of the prefetching, there must be a special section
without prefetching when dstW < 16.

This improves speed on Graviton 2 (Neoverse N1) dramatically in the case
where previously fs=8 would have been required.

before: hscale_8_to_15__fs_8_dstW_512_neon: 1962.8
after : hscale_8_to_15__fs_4_dstW_512_neon: 1220.9

Signed-off-by: Jonathan Swinney <jswinney@amazon.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
28 hours agocheckasm: added additional dstW tests for hscale
Swinney, Jonathan [Thu, 26 May 2022 02:01:58 +0000 (02:01 +0000)]
checkasm: added additional dstW tests for hscale

Signed-off-by: Jonathan Swinney <jswinney@amazon.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
30 hours agoavcodec/libaomenc: Add unmet target level warning
Bohan Li [Tue, 19 Apr 2022 18:18:51 +0000 (11:18 -0700)]
avcodec/libaomenc: Add unmet target level warning

When target levels are set, this patch checks whether they are
satisfied by libaom. If not, a warning is shown. Otherwise the output
levels are also logged.

This patch applies basically the same approach used for libvpx.

Signed-off-by: Bohan Li <bohanli@google.com>
Signed-off-by: James Zern <jzern@google.com>
43 hours agoavfilter/af_biquads: fix low/highshelf 'k' calculation
Paul B Mahol [Fri, 27 May 2022 07:36:19 +0000 (09:36 +0200)]
avfilter/af_biquads: fix low/highshelf 'k' calculation

2 days agoqsv: check for libmfx.pc instead of mfx.pc
Haihao Xiang [Thu, 26 May 2022 02:32:26 +0000 (10:32 +0800)]
qsv: check for libmfx.pc instead of mfx.pc

This fixed the regression caused by commit 478e1a98a

Reported-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2 days agoavfilter/vf_vpp_qsv: set outlink to EOF correctly
Fei Wang [Thu, 12 May 2022 01:18:21 +0000 (09:18 +0800)]
avfilter/vf_vpp_qsv: set outlink to EOF correctly

1. Return error if filter frame fail before set outlink to EOF in none
pass through mode.
2. Set outlink to EOF before return success in pass through mode.

Fix endless cmd:

ffmpeg -hwaccel qsv -qsv_device /dev/dri/renderD128 -hwaccel_output_format     \
qsv -v debug -c:v hevc_qsv -i 4k.h265                                          \
-filter_complex "vpp_qsv=w=3840:h=2160:async_depth=4[o1];[o1]split=2[s1][s2];
[s2]vpp_qsv=w=1920:h=1080:async_depth=4[o2];[o2]split=2[s3][s4];
[s4]vpp_qsv=w=1920:h=1080:async_depth=4[o3]" \
-map [s1] -c:v hevc_qsv -async 3 -async_depth 3 -b:v 9000k -preset 7 -g 33 -y -f null - \
-map [s3] -c:v hevc_qsv -async 3 -async_depth 3 -b:v 4000k -preset 7 -g 33 -y -f null - \
-map [o3] -c:v hevc_qsv -async 3 -async_depth 3 -b:v 3100k -preset 7 -g 33 -y -f null -

2 days agodoc/protocols: add details and reformat IPFS section
Gyan Doshi [Thu, 26 May 2022 10:48:57 +0000 (16:18 +0530)]
doc/protocols: add details and reformat IPFS section

2 days agodoc/protocols: sort IPFS section alphabetically
Gyan Doshi [Thu, 26 May 2022 10:25:33 +0000 (15:55 +0530)]
doc/protocols: sort IPFS section alphabetically

2 days agoavformat/matroskadec: assert non NULL buf
Michael Niedermayer [Thu, 19 May 2022 22:36:34 +0000 (00:36 +0200)]
avformat/matroskadec: assert non NULL buf

The code is only called if size is > 0 so buf should not be NULL

Helps: CID610554

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 days agoChangelog: Add line for IPFS
Michael Niedermayer [Thu, 19 May 2022 14:49:44 +0000 (16:49 +0200)]
Changelog: Add line for IPFS

Noticed-and-suggested-by: Mark Gaiser <markg85@gmail.com>
Reviewed-by: Mark Gaiser <markg85@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 days agoavformat/act: Check ff_get_wav_header() for failure
Michael Niedermayer [Sun, 15 May 2022 20:55:12 +0000 (22:55 +0200)]
avformat/act: Check ff_get_wav_header() for failure

Fixes: missing error check
Fixes: CID717495

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 days agoavformat/jpegxl_probe: Check init_get_bits8() for failure
Michael Niedermayer [Sun, 15 May 2022 20:46:12 +0000 (22:46 +0200)]
avformat/jpegxl_probe: Check init_get_bits8() for failure

Fixes: missing error check
Fixes: CID1504270

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 days agoavutil/mem: fix doc for reallocs
Zhao Zhili [Fri, 1 Apr 2022 17:05:37 +0000 (01:05 +0800)]
avutil/mem: fix doc for reallocs

The doc says those function are like av_free if size or nmemb is
zero. It doesn't match the code. av_realloc() realloc one byte if
size is zero, which was added by 91ff05f6ac5 ten years ago.
realloc() itself in C is implementation-dependent. Make the doc
match the longstanding behaviour.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2 days agolavc/aarch64: hevc_sao reschedule slightly
J. Dekker [Wed, 25 May 2022 08:55:34 +0000 (10:55 +0200)]
lavc/aarch64: hevc_sao reschedule slightly

Signed-off-by: J. Dekker <jdek@itanimul.li>
3 days agoavcodec/mfenc: Dynamically load MFPlat.DLL
Trystan Mata [Wed, 25 May 2022 10:54:01 +0000 (12:54 +0200)]
avcodec/mfenc: Dynamically load MFPlat.DLL

Allows non-UWP builds of FFmpeg with MediaFoundation to work on
N editions of Windows which are without MediaFoundation by default.

On UWP target, FFmpeg is linked directly against MediaFoundation since
LoadLibrary is not available.

This commit adresses https://trac.ffmpeg.org/ticket/9788

Signed-off-by: Martin Storsjö <martin@martin.st>
3 days agoqsv: add requirement for the mininal version of libmfx
Haihao Xiang [Sun, 22 May 2022 12:19:11 +0000 (20:19 +0800)]
qsv: add requirement for the mininal version of libmfx

libmfx 1.28 was released 3 years ago, it is easy to get a greater
version than 1.28. We may remove lots of compile-time checks if adding
the requirement for the minimal version in the configure script.

Reviewed-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
3 days agolibavcodec/qsvenc: expose only supported options
Dmitry Rogozhkin [Thu, 19 May 2022 19:54:16 +0000 (12:54 -0700)]
libavcodec/qsvenc: expose only supported options

vp9, hevc, avc, mpeg2 QSV encoders inherit common list
of options (QSV_COMMON_OPTS) while bunch of options is not
actually supported by current qsv code. The only codec which
supportes everything is avc, followed by hevc, while vp9 and
mpeg2 significantly fall behind. This creates difficulties
for the users to use qsv encoders. This patch fixes options
list for encoders leaving only those which are actually
supported.

Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
3 days agocheckasm: improve hevc_sao test
J. Dekker [Tue, 17 May 2022 11:48:23 +0000 (13:48 +0200)]
checkasm: improve hevc_sao test

The HEVC decoder can call these functions with smaller widths than the
functions themselves are designed to operate on so we should only check
the relevant output

Signed-off-by: J. Dekker <jdek@itanimul.li>
3 days agolavc/aarch64: add hevc sao edge 8x8
J. Dekker [Thu, 28 Apr 2022 12:57:43 +0000 (14:57 +0200)]
lavc/aarch64: add hevc sao edge 8x8

bench on AWS Graviton:

hevc_sao_edge_8x8_8_c: 516.0
hevc_sao_edge_8x8_8_neon: 81.0

Signed-off-by: J. Dekker <jdek@itanimul.li>
3 days agolavc/aarch64: add hevc sao edge 16x16
J. Dekker [Thu, 28 Apr 2022 12:57:33 +0000 (14:57 +0200)]
lavc/aarch64: add hevc sao edge 16x16

bench on AWS Graviton:

hevc_sao_edge_16x16_8_c: 1857.0
hevc_sao_edge_16x16_8_neon: 211.0
hevc_sao_edge_32x32_8_c: 7802.2
hevc_sao_edge_32x32_8_neon: 808.2
hevc_sao_edge_48x48_8_c: 16764.2
hevc_sao_edge_48x48_8_neon: 1796.5
hevc_sao_edge_64x64_8_c: 32647.5
hevc_sao_edge_64x64_8_neon: 3118.5

Signed-off-by: J. Dekker <jdek@itanimul.li>
3 days agolavc/aarch64: fix hevc sao band filter
J. Dekker [Tue, 26 Apr 2022 07:29:54 +0000 (09:29 +0200)]
lavc/aarch64: fix hevc sao band filter

The SAO band filter can be called with non-multiples of 8, we round up
to the nearest multiple of 8 to account for this.

Signed-off-by: J. Dekker <jdek@itanimul.li>
4 days agoavcodec/mjpegenc: Remove ineffective pred option
Andreas Rheinhardt [Thu, 17 Feb 2022 09:07:24 +0000 (10:07 +0100)]
avcodec/mjpegenc: Remove ineffective pred option

Never did anything, so it is removed immediately.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
4 days agoavcodec/mpegvideoenc: Remove ineffective options
Andreas Rheinhardt [Thu, 17 Feb 2022 08:02:27 +0000 (09:02 +0100)]
avcodec/mpegvideoenc: Remove ineffective options

This commit removes the ineffective FF_MPV_DEPRECATED_ options,
namely mpeg_quant (this is only an option for MPEG-4), a53cc
(this is only an option for MPEG-2), force_duplicated_matrix
(applies only to MJPEG) and b_strategy, b_sensitivity and brd_scale
(these options only make sense for encoders supporting B-frames,
which currently means the MPEG-1/2 and MPEG-4 encoders).
Given that these options never changed the outcome of encoding,
they are removed at once.

Notice that the options for the encoders for which it made sense
are not affected by this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
4 days agoavcodec/mjpegenc: Remove pointless motion-estimation options
Andreas Rheinhardt [Mon, 7 Feb 2022 13:50:34 +0000 (14:50 +0100)]
avcodec/mjpegenc: Remove pointless motion-estimation options

(M)JPEG does not use motion estimation/motion vectors at all.
These options therefore don't affect the output at all.
So remove them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
4 days agoavcodec/mpegvideoenc: Remove ineffective [pb]bias options
Andreas Rheinhardt [Mon, 7 Feb 2022 11:14:33 +0000 (12:14 +0100)]
avcodec/mpegvideoenc: Remove ineffective [pb]bias options

The user-provided value is overwritten in ff_mpv_encode_init()
without having ever been read.
(This has been broken when making these options mpegvideo-specific
in commits 910247f1720c6aae422723c05dac6d0b19f20bec and
cf7d2f2d2134c0854edf2db91e7436ac2bc9874f. No one has ever complained,
so this commit removes these fields.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
4 days agoavcodec/pthread_frame: Don't update the first thread ctx before freeing
Andreas Rheinhardt [Wed, 18 May 2022 20:50:38 +0000 (22:50 +0200)]
avcodec/pthread_frame: Don't update the first thread ctx before freeing

Currently, ff_frame_thread_free() uses the last worker thread
to updates the first worker thread via update_context_from_thread()
immediately before freeing all these worker threads. This is
a remnant of the time in which the first worker was special.
(E.g. the first worker shared its AVCodecInternal with the public
AVCodecContext.)

But these times are over (none of the uses of is_copy matter
for ff_frame_thread_free()); nowadays the only thing that
update_context_from_thread() does is referencing a few
buffers/frames and replacing them with other references instead.
These new references will then be freed immediately thereafter
when the first worker thread is freed. Ensuring that the code is
free of double-frees is achieved by using reference-counted structures
(or in case of AVChannelLayouts: by giving each worker its own copy).

Some archaeology:
a) Updating the first worker thread from the last one used
has been done since frame-threading was added in
37b00b47cbeecd66bb34c5c7c534d016d6e8da24.
b) The precursor to ff_mpv_common_end() checked for is_copy
before freeing pictures (i.e. it only freed them for the first
worker thread).
c) Commits c2dfb1e37cc72bf144545c4410a4621cbff5c4b1 and
e33811bd2686411233cb0eb4a4ee45eb99d7e736 modified the
update_thread_context function of the H.264 decoder
so that it could fail before calling ff_mpeg_update_thread_context().
d) This led to a double free/an assert violation with a H.264
sample for which ff_mpeg_update_thread_context() is not reached
for the final update_context_from_thread(). Commit
a6e4796fbf0aa9b13451a8ef917ecc4e80d1d272 added code to fix this
sample.
e) This issue was fixed (even with the last mentioned commit reverted)
when the H.264 decoder was deMpegEncContextized in commit
b7fe35c9e50e1701274364adf7280bf4a02b092b (merging commit
2c541554076cc8a72e7145d4da30389ca763f32f).
f) mpegvideo.c stopped using is_copy when it was switched to refcounted
frames in 759001c534287a96dc96d1e274665feb7059145d.
g) 1f4cf92cfbd3accbae582ac63126ed5570ddfd37 removed the init_thread_copy
callbacks; now no FFCodec.close callback checks for is_copy at all
any more.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
4 days agoffbuild/common: Fix CPPFLAGS applied for compiling C++ files
Andreas Rheinhardt [Thu, 12 May 2022 22:16:30 +0000 (00:16 +0200)]
ffbuild/common: Fix CPPFLAGS applied for compiling C++ files

Currently, $(CPPFLAGS) and $(CFLAGS) are prepended to CXXFLAGS
(the flags for compiling C++) like this:
CXXFLAGS := $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS)
Using ":=" creates a simply expanded variable, i.e. the values
of the variable at the time of assignment are used and later
modifications to them are ignored (using a recursively expanding
variable (i.e. "=" instead of ":=") is not really possible here,
as there would be an infinite loop when evaluating CXXFLAGS).

Yet we perform later additions to CPPFLAGS: HAVE_AV_CONFIG_H and
BUILDING_libfoo are defined. These do not reach C++ compilations.

To fix this a trick is employed to prepend to a recursively
expanded variable while keeping it recursively expanded.

There are two practical consequences of this: C++ files now no longer
include the version.h header, but only the version_major.h header
of their library, saving some recompilations. Furthermore, they
now get some optimized math functions (namely the ones from
lavu/intmath.h instead of the ones from lavu/common.h).
(av_parity() is the only one for which it makes a difference.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
4 days agofftools/ffmpeg: move processing AV_PKT_DATA_QUALITY_STATS to do_video_stats()
Anton Khirnov [Thu, 16 Dec 2021 18:10:12 +0000 (19:10 +0100)]
fftools/ffmpeg: move processing AV_PKT_DATA_QUALITY_STATS to do_video_stats()

This is a more appropriate place for this code, since the values we read
from AV_PKT_DATA_QUALITY_STATS side data are primarily written into
video stats. This ensures that the values written into stats actually
apply to the right packet.

Rename the function to update_video_stats() to better reflect its new
purpose.

4 days agofftools/ffmpeg: merge variable declaration and initialization
Anton Khirnov [Thu, 16 Dec 2021 10:59:21 +0000 (11:59 +0100)]
fftools/ffmpeg: merge variable declaration and initialization

4 days agofftools/ffmpeg: stop using av_stream_get_end_pts() in do_video_stats()
Anton Khirnov [Thu, 16 Dec 2021 10:16:11 +0000 (11:16 +0100)]
fftools/ffmpeg: stop using av_stream_get_end_pts() in do_video_stats()

It retrieves libavformat's internal dts value (contrary to the
function's name), which is not only incorrect in general, but also
unnecessary because we can access the packet directly.

4 days agofftools/ffmpeg: stop using AVStream.nb_frames in do_video_stats()
Anton Khirnov [Thu, 16 Dec 2021 10:10:58 +0000 (11:10 +0100)]
fftools/ffmpeg: stop using AVStream.nb_frames in do_video_stats()

Its use for muxing is not documented, in practice it is incremented per
each packet successfully passed to the muxer's write_packet(). Since
there is a lot of indirection between ffmpeg receiving a packet from the
encoder and it actually being written (e.g. bitstream filters, the
interleaving queue), using nb_frames here is incorrect.

Add a new counter for packets received from encoder instead.

4 days agofftools/ffmpeg: move do_video_stats() to avoid a forward declaration
Anton Khirnov [Wed, 11 May 2022 07:53:09 +0000 (09:53 +0200)]
fftools/ffmpeg: move do_video_stats() to avoid a forward declaration

4 days agofftools/ffmpeg: drop a useless check and reduce indentation
Anton Khirnov [Thu, 16 Dec 2021 09:31:35 +0000 (10:31 +0100)]
fftools/ffmpeg: drop a useless check and reduce indentation

do_video_stats() is only ever called for video.

4 days agofftools/ffmpeg: reindent after previous commit
Anton Khirnov [Wed, 30 Mar 2022 15:06:25 +0000 (17:06 +0200)]
fftools/ffmpeg: reindent after previous commit

4 days agofftools/ffmpeg: reuse the encoding code for flushing encoders
Anton Khirnov [Wed, 30 Mar 2022 15:05:48 +0000 (17:05 +0200)]
fftools/ffmpeg: reuse the encoding code for flushing encoders

4 days agofftools/ffmpeg: share the code encoding a single frame between video and audio
Anton Khirnov [Wed, 30 Mar 2022 11:10:34 +0000 (13:10 +0200)]
fftools/ffmpeg: share the code encoding a single frame between video and audio

Call do_video_stats() for every video packet produced by the encoder,
rather than for every frame sent to the encoder.

4 days agolavfi/vf_v360: implement output mask for barrelsplit
Anton Khirnov [Thu, 19 May 2022 13:36:44 +0000 (15:36 +0200)]
lavfi/vf_v360: implement output mask for barrelsplit

The top/bottom of the barrel are each coded as two semicircles inside a
square block in the frame. Mask out the parts of the square that lie
outside of these semicircles, so they are made transparent when
alpha_mask=1.

Fixes the other part of #9725.

4 days agolavfi/vf_v360: fix barrelsplit transform with padding
Anton Khirnov [Thu, 19 May 2022 13:36:44 +0000 (15:36 +0200)]
lavfi/vf_v360: fix barrelsplit transform with padding

Make it match Facebook's transform360
(https://github.com/facebook/transform360)

Fixes one part of #9725.

4 days agolavfi/vf_v360: factorize vector computation for barrelsplit
Anton Khirnov [Wed, 18 May 2022 09:39:02 +0000 (11:39 +0200)]
lavfi/vf_v360: factorize vector computation for barrelsplit

4 days agolavfi/vf_v360: drop nonsense inline specifier
Anton Khirnov [Tue, 17 May 2022 09:20:46 +0000 (11:20 +0200)]
lavfi/vf_v360: drop nonsense inline specifier

This function is always called indirectly, it cannot be inlined.

4 days agotests/fate/vcodec: add tests for ffv1 2pass mode
Anton Khirnov [Fri, 20 May 2022 09:33:03 +0000 (11:33 +0200)]
tests/fate/vcodec: add tests for ffv1 2pass mode

4 days agofftools/ffmpeg: fix 2pass log file names
Anton Khirnov [Fri, 20 May 2022 09:06:20 +0000 (11:06 +0200)]
fftools/ffmpeg: fix 2pass log file names

Use the global stream index rather than an unrelated variable in the
filename.

Broken in 6d5d9246042.

4 days agotests/fate-run: give consistent names to enc_dec() arguments
Anton Khirnov [Fri, 20 May 2022 08:37:26 +0000 (10:37 +0200)]
tests/fate-run: give consistent names to enc_dec() arguments

enc_dec() performs two ffmpeg runs - the first one encoding a source
file into a specified output format, the second one decoding previously
encoded file.

The arguments to this function currently have confusing names - e.g.
dec_opt contains _output_ (i.e. encoding) options for the second
(decoding) ffmpeg invocation. It is also possible to supply _input_
(i.e. decoding) options for the second ffmpeg run, but the argument
is currently unnamed and referred to by number.

Add an _in/_out suffix to argument names to make it clear what they are
used for. Give a name to input options for the decoding ffmpeg run.

4 days agotests/fate/vcodec: drop unnecessary options
Anton Khirnov [Thu, 12 May 2022 07:36:05 +0000 (09:36 +0200)]
tests/fate/vcodec: drop unnecessary options

jpeg2000 will be chosen by default, there is no reason to prescribe it
explicitly. No other test does so.

4 days agoavcodec/libdavs2: export has_b_frames info
Zhao Zhili [Fri, 13 May 2022 09:40:49 +0000 (17:40 +0800)]
avcodec/libdavs2: export has_b_frames info

More precisely, we should use picture_reorder_delay, but it's
unavailable yet.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
4 days agoavcodec/libuavs3d: use output_reorder_delay as has_b_frames
Zhao Zhili [Fri, 13 May 2022 09:40:48 +0000 (17:40 +0800)]
avcodec/libuavs3d: use output_reorder_delay as has_b_frames

has_b_frames is more than a bool, it's the size of the frame
reordering buffer in the decoder.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
4 days agoavcodec/avs3_parser: set has_b_frames properly
Zhao Zhili [Fri, 13 May 2022 10:12:25 +0000 (18:12 +0800)]
avcodec/avs3_parser: set has_b_frames properly

has_b_frames should be output_reorder_delay field in AVS3 sequence
header and larger than 1. The parser implementation doesn't parse
that field. Decoder can set has_b_frames properly, so use FFMAX
here to avoid resetting has_b_frames from output_reorder_delay to 1.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
4 days agoavfilter: Add blockdetect filter
Thilo Borgmann [Tue, 24 May 2022 09:20:14 +0000 (11:20 +0200)]
avfilter: Add blockdetect filter

4 days agoavcodec/dvdsubdec: use avpriv_fopen_utf8() instead of plain fopen()
softworkz [Mon, 23 May 2022 11:26:10 +0000 (11:26 +0000)]
avcodec/dvdsubdec: use avpriv_fopen_utf8() instead of plain fopen()

Unify file access operations by replacing usages of direct calls
to posix fopen() to prepare for long filename support on Windows.

Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
4 days agoavfilter: use avpriv_fopen_utf8() instead of plain fopen()
softworkz [Mon, 23 May 2022 11:26:09 +0000 (11:26 +0000)]
avfilter: use avpriv_fopen_utf8() instead of plain fopen()

Unify file access operations by replacing usages of direct calls
to posix fopen() to prepare for long filename support on Windows.

Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
4 days agoavfilter/af_afftfilt: add threads support
Paul B Mahol [Tue, 24 May 2022 06:52:25 +0000 (08:52 +0200)]
avfilter/af_afftfilt: add threads support

5 days agoSwitch uses of av_fopen_utf8 to avpriv_fopen_utf8
Martin Storsjö [Fri, 20 May 2022 11:55:46 +0000 (14:55 +0300)]
Switch uses of av_fopen_utf8 to avpriv_fopen_utf8

The former has been deprecated.

Signed-off-by: Martin Storsjö <martin@martin.st>
5 days agolibavutil: Deprecate av_fopen_utf8, provide an avpriv version
Martin Storsjö [Fri, 20 May 2022 11:45:21 +0000 (14:45 +0300)]
libavutil: Deprecate av_fopen_utf8, provide an avpriv version

Since every DLL can use an individual CRT on Windows, having
an exported function that opens a FILE* won't work if that
FILE* is going to be used from a different DLL (or from user
application code).

Internally within the libraries, the issue can be worked around
by duplicating the function in all libraries (this already happened
implicitly because the function resided in file_open.c) and renaming
the function to ff_fopen_utf8 (so that it doesn't end up exported from
the DLLs) and duplicating it in all libraries that use it.

This makes the avpriv_fopen_utf8 / ff_fopen_utf8 function work in
the exact same way as the existing avpriv_open / ff_open, with the
same setup as introduced in e743e7ae6ee7e535c4394bec6fe6650d2b0dbf65.

That mechanism doesn't work for external users, thus deprecate the
existing function.

Signed-off-by: Martin Storsjö <martin@martin.st>
5 days agofftools: Stop using av_fopen_utf8
Martin Storsjö [Fri, 20 May 2022 20:37:15 +0000 (23:37 +0300)]
fftools: Stop using av_fopen_utf8

Provide a header based inline reimplementation of it.

Using av_fopen_utf8 doesn't work outside of the libraries when built
with MSVC as shared libraries (in the default configuration, where
each DLL gets a separate statically linked CRT).

Signed-off-by: Martin Storsjö <martin@martin.st>
5 days agoavutil/hwcontext_qsv: fix mapping issue between QSV frames and D3D11VA frames
Tong Wu [Sat, 7 May 2022 06:24:41 +0000 (06:24 +0000)]
avutil/hwcontext_qsv: fix mapping issue between QSV frames and D3D11VA frames

Fixes:
$ ffmpeg.exe -init_hw_device d3d11va=d3d11 -init_hw_device \
qsv=qsv@d3d11 -s:v WxH -pix_fmt nv12 -i input.yuv -vf \
"hwupload=extra_hw_frames=16,hwmap=derive_device=d3d11va,format=d3d11,\
hwmap=derive_device=qsv,format=qsv" -f null -

Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
5 days agoavutil/hwcontext_d3d11va: pass the format value from outside for staging texture
Tong Wu [Sat, 7 May 2022 06:24:40 +0000 (06:24 +0000)]
avutil/hwcontext_d3d11va: pass the format value from outside for staging texture

In d3d11va_create_staging_texture(), during the hwmap process, the
ctx->internal->priv is not initialized, resulting in the
texDesc.Format not initialized. Now pass the format value from
d3d11va_transfer_data() to fix it.

$ ffmpeg.exe -y -hwaccel qsv -init_hw_device d3d11va=d3d11 \
-init_hw_device qsv=qsv@d3d11 -c:v h264_qsv \
-i input.h264 -vf "hwmap=derive_device=d3d11va,format=d3d11,hwdownload,format=nv12" \
-f null -

Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
5 days agoavutil/hwcontext_qsv: derive QSV frames to D3D11VA frames
Tong Wu [Sat, 7 May 2022 06:24:39 +0000 (06:24 +0000)]
avutil/hwcontext_qsv: derive QSV frames to D3D11VA frames

Fixes:
$ ffmpeg.exe -y -hwaccel qsv -init_hw_device d3d11va=d3d11 \
-init_hw_device qsv=qsv@d3d11 -c:v h264_qsv -i input.h264 \
-vf "hwmap=derive_device=d3d11va,format=d3d11" -f null -

Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
5 days agoavfilter/avf_showfreqs: fix memleak in plot_freqs
Steven Liu [Fri, 13 May 2022 02:19:24 +0000 (10:19 +0800)]
avfilter/avf_showfreqs: fix memleak in plot_freqs

plot_freqs should free colors before return error when
ff_get_video_buffer failed

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
6 days agoavcodec/libuavs3d: fix access uninitialized variable when draining
Zhao Zhili [Thu, 12 May 2022 09:55:31 +0000 (17:55 +0800)]
avcodec/libuavs3d: fix access uninitialized variable when draining

buf_ptr is uninitialized and accessed when function return.

8 days agox86/tx_float: replace fft_sr_avx with fft_sr_fma3
Lynne [Fri, 20 May 2022 23:39:12 +0000 (01:39 +0200)]
x86/tx_float: replace fft_sr_avx with fft_sr_fma3

When the SLOW_GATHER flag was added to the AVX2 version, this
made FMA3-features not enabled on Zen CPUs.
As FMA3 adds 6-7% across all platforms that support it, in
the interest of saving space, this commit removes the AVX
version and replaces it with an FMA3 version.
The only CPUs affected are Sandy Bridge and Bulldozer, which
have AVX support, but no FMA3 support.
In the future, if there's a demand for it, a version of the
function duplicated for AVX can be added.

8 days agox86/tx_float: improve temporary register allocation for loads
Lynne [Fri, 20 May 2022 22:50:09 +0000 (00:50 +0200)]
x86/tx_float: improve temporary register allocation for loads

On Zen 3:

Before:
1484285 decicycles in           av_tx (fft),  131072 runs,      0 skips

After:
1415243 decicycles in           av_tx (fft),  131072 runs,      0 skips

8 days agolavu/tx: make slow ISA extension penalties smarter
Lynne [Fri, 20 May 2022 22:04:11 +0000 (00:04 +0200)]
lavu/tx: make slow ISA extension penalties smarter

Instead of having a fixed -64 prio penalty, make the penalties
more granular.
As the prio is based on the register size in bits, decrementing
it by 129 makes AVX SLOW functions be avoided in favor of any
SSE versions.

8 days agox86/tx_float: add AV_CPU_FLAG_AVXSLOW/SLOW_GATHER flags where appropriate
Lynne [Fri, 20 May 2022 22:11:45 +0000 (00:11 +0200)]
x86/tx_float: add AV_CPU_FLAG_AVXSLOW/SLOW_GATHER flags where appropriate

8 days agoRevert "x86/tx_float: remove vgatherdpd usage"
Lynne [Fri, 20 May 2022 22:05:58 +0000 (00:05 +0200)]
Revert "x86/tx_float: remove vgatherdpd usage"

This reverts commit 82a68a8771ca39564f6a74e0f875d6852e7a0c2a.

Smarter slow ISA penalties makes gathers still useful.
The intention is to use gathers with the final stage of non-ptwo iMDCTs,
where they give benefit.

8 days agoopt_common: note D and T type streams for completeness.
Gyan Doshi [Thu, 19 May 2022 13:48:45 +0000 (19:18 +0530)]
opt_common: note D and T type streams for completeness.

Addresses #9784

8 days agotests/fate: Remove intermediate file of flv-add_keyframe_index test
Andreas Rheinhardt [Wed, 18 May 2022 13:57:17 +0000 (15:57 +0200)]
tests/fate: Remove intermediate file of flv-add_keyframe_index test

Do this by making this test a transcode test.
Also fix the test requirements and don't add this test to FATE_AFILTER;
instead use a new variable and a new target for flvenc-tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
8 days agofate/filter-video: Fix requirements of tests
Andreas Rheinhardt [Wed, 18 May 2022 08:50:02 +0000 (10:50 +0200)]
fate/filter-video: Fix requirements of tests

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
8 days agofate/filter-video: Avoid duplication for fate-filter-overlay tests
Andreas Rheinhardt [Tue, 17 May 2022 17:31:08 +0000 (19:31 +0200)]
fate/filter-video: Avoid duplication for fate-filter-overlay tests

Also add a fate-filter-overlays target containing all these tests
and fix the requirements of the tests; furthermore, remove
unnecessary scale filters from filter-overlay-rgba?_rgba.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
8 days agofate/filter-video: Avoid duplication for filter-removegrain tests
Andreas Rheinhardt [Mon, 16 May 2022 21:39:54 +0000 (23:39 +0200)]
fate/filter-video: Avoid duplication for filter-removegrain tests

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
8 days agofate/filter-video: Avoid duplication for fate-filter-stereo3d tests
Andreas Rheinhardt [Mon, 16 May 2022 21:21:38 +0000 (23:21 +0200)]
fate/filter-video: Avoid duplication for fate-filter-stereo3d tests

Also fix the requirements of these tests: Only the anaglyph
tests need a scale filter, yet it has been inserted for all tests
without any check for its presence.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
8 days agotests/Makefile: Add FRAMECRC variants for filtering
Andreas Rheinhardt [Tue, 17 May 2022 12:50:59 +0000 (14:50 +0200)]
tests/Makefile: Add FRAMECRC variants for filtering

Lots of tests use the framecrc command together with some filters,
so adding a special function for it seems worthwhile. This commit
adds one new one and modifies an already existing one:
All users of FILTERDEMDEC already use framecrc and the more general
FILTERDEMDECENCMUX can be used in scenarios where more control over
the used encoders/muxers is needed, so use this in cases where
an actual input file is involved.
Furthermore, add FILTERFRAMECRC for the cases where no demuxing/decoding
occurs, because the input is generated via lavfi.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
8 days agotests/Makefile: Remove FILTERDEMDECMUX
Andreas Rheinhardt [Tue, 17 May 2022 12:20:52 +0000 (14:20 +0200)]
tests/Makefile: Remove FILTERDEMDECMUX

It is unused and given that one needs an encoder to produce
packets from AVFrames (as output by filters) this is likely
to remain so, because FILTERDEMDECENCMUX is better for these
scenarios.
The only case where one can use filters without encoders is
with the lavfi input device: It outputs AVPackets which could
be copied without another conversion to AVFrames. Yet the variable
to check for this is CONFIG_LAVFI_INDEV, but FILTERDEMDECMUX
is designed to work with demuxers (i.e. CONFIG_*_DEMUXER).
So there is no usecase for FILTERDEMDECMUX.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
8 days agox86/tx_float: remove vgatherdpd usage
Lynne [Fri, 20 May 2022 08:00:43 +0000 (10:00 +0200)]
x86/tx_float: remove vgatherdpd usage

Its performance loss ranges from either being just as fast as individual loads
(Skylake), a few percent slower (Alderlake), 8% slower (Zen 3), to completely
disasterous (older/other CPUs).

Sadly, gathers never panned out fast on x86, even with the benefit of time and
implementation experience.

This also saves a register, as there's no need to fill out an additional
register mask.

Zen 3 (16384-point transform):
Before: 1561050 decicycles in           av_tx (fft),  131072 runs,      0 skips
After:  1449621 decicycles in           av_tx (fft),  131072 runs,      0 skips

Alderlake:
2% slower on big transforms (65536), to 1% (131072), to a few percent for smaller
sizes.

9 days agoavfilter/formats: Constify channel_layout in ff_add_channel_layout()
Andreas Rheinhardt [Mon, 16 May 2022 09:35:20 +0000 (11:35 +0200)]
avfilter/formats: Constify channel_layout in ff_add_channel_layout()

It copies, not moves the channel layout.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
9 days agoavcodec/mpegvideo: Move float.h inclusion to mpegvideoenc.h
Andreas Rheinhardt [Mon, 16 May 2022 16:15:37 +0000 (18:15 +0200)]
avcodec/mpegvideo: Move float.h inclusion to mpegvideoenc.h

It is only needed for the options in mpegvideoenc.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
9 days agoavcodec/mss2: Remove write-only QpelDSPContext
Andreas Rheinhardt [Thu, 24 Mar 2022 23:58:07 +0000 (00:58 +0100)]
avcodec/mss2: Remove write-only QpelDSPContext

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
9 days agoavcodec/error_resilience: Only keep what is needed from MECmpContext
Andreas Rheinhardt [Fri, 25 Mar 2022 17:39:16 +0000 (18:39 +0100)]
avcodec/error_resilience: Only keep what is needed from MECmpContext

ERContext currently has an embedded MECmpContext, despite only
needing exactly one function from it. This is wasteful because
MECmpContext is pretty large (135 pointers, 1080 B for eight byte
pointers). So keep only what is needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
9 days agoavcodec/dvdsubenc: return error if canvas_size is too small for subtitle render
Limin Wang [Sun, 8 May 2022 14:52:14 +0000 (22:52 +0800)]
avcodec/dvdsubenc: return error if canvas_size is too small for subtitle render

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
9 days agoavformat/sccenc: avoid potential invalid access
Limin Wang [Sun, 10 Apr 2022 14:20:04 +0000 (22:20 +0800)]
avformat/sccenc: avoid potential invalid access

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
9 days agoMakefile: remove sccenc dependency on subtitles
Limin Wang [Sun, 10 Apr 2022 12:33:09 +0000 (20:33 +0800)]
Makefile: remove sccenc dependency on subtitles

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
9 days agoavformat/img2: Add support for AVIF mux in image2
Vignesh Venkatasubramanian [Mon, 16 May 2022 17:40:21 +0000 (10:40 -0700)]
avformat/img2: Add support for AVIF mux in image2

Add support for AVIF muxing in the image2 muxer.

Tested with this example:
ffmpeg -lavfi testsrc=duration=1:size=320x320 -g 1 -flags global_header -c:v libaom-av1 -f image2 img-%2d.avif

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
10 days agofftools/opt_common: add includes of avf headers for clarity
softworkz [Sun, 15 May 2022 19:23:22 +0000 (19:23 +0000)]
fftools/opt_common: add includes of avf headers for clarity

Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
12 days agoavformat/hls, dashdec: Don't use AV_OPT flags in av_dict_set()
Andreas Rheinhardt [Sun, 15 May 2022 17:32:44 +0000 (19:32 +0200)]
avformat/hls, dashdec: Don't use AV_OPT flags in av_dict_set()

av_dict_set() expects a different set of flags, namely the AV_DICT_*
flags. Using AV_OPT_FLAG_DECODING_PARAM (or any AV_OPT_FLAG_*) ic
av_dict_set() is therefore completely wrong and given that av_dict_set()
just doesn't care about whether the string it receives has anything
to do with a decoding parameter or not, it should just be removed
without replacement.
(The numerical value of AV_OPT_FLAG_DECODING_PARAM currently coincides
with AV_DICT_IGNORE_SUFFIX. Given that the dictionaries we are dealing
with here are always empty (i.e. NULL) before the calls to
av_dict_set(), this flag changes nothing. It would be different if
it were equal to one of the AV_DICT_DONT_STRDUP_* values.)

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
12 days agodoc/muxers: note write_btrt option for MOV/MP4
Gyan Doshi [Mon, 16 May 2022 08:22:48 +0000 (13:52 +0530)]
doc/muxers: note write_btrt option for MOV/MP4

13 days agoavcodec/wrapped_avframe: Don't attach FrameDecodeData unnecessarily
Andreas Rheinhardt [Wed, 11 May 2022 12:12:00 +0000 (14:12 +0200)]
avcodec/wrapped_avframe: Don't attach FrameDecodeData unnecessarily

It is unneeded, as this decoder does not call ff_get_buffer().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
13 days agoavcodec/ac3: Move non-(de|en)coder-only parts out of ac3.h
Andreas Rheinhardt [Thu, 12 May 2022 11:44:21 +0000 (13:44 +0200)]
avcodec/ac3: Move non-(de|en)coder-only parts out of ac3.h

Move AC3HeaderInfo into ac3_parser_internal.h and the rest
into a new header ac3defs.h.

This also breaks an include cycle of ac3.h and ac3tab.h
(the latter now only needs ac3defs.h).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
13 days agoavcodec/ac3tab: Move some tables only used by ac3.c to it
Andreas Rheinhardt [Thu, 12 May 2022 10:19:22 +0000 (12:19 +0200)]
avcodec/ac3tab: Move some tables only used by ac3.c to it

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
13 days agoavcodec/ac3: Remove declaration of inexistent function
Andreas Rheinhardt [Thu, 12 May 2022 08:52:20 +0000 (10:52 +0200)]
avcodec/ac3: Remove declaration of inexistent function

Removed in 7b11eead1b4e08728561595e6b610cf8fe2b7122.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
13 days agoavfilter/af_afir: add support for double sample format
Paul B Mahol [Sat, 14 May 2022 08:28:49 +0000 (10:28 +0200)]
avfilter/af_afir: add support for double sample format

2 weeks agoavfilter/af_acrossover: add precision option
Paul B Mahol [Sat, 14 May 2022 12:10:07 +0000 (14:10 +0200)]
avfilter/af_acrossover: add precision option

2 weeks agoavformat/dashdec: accept and relay CENC decryption key
Gyan Doshi [Sat, 14 May 2022 09:08:56 +0000 (14:38 +0530)]
avformat/dashdec: accept and relay CENC decryption key

Allows to process CENC-encrypted media segments.
Option arg syntax is same as that for option decryption_key in MOV demuxer

2 weeks agoavfilter/af_asubboost: add channels option
Paul B Mahol [Fri, 13 May 2022 20:00:08 +0000 (22:00 +0200)]
avfilter/af_asubboost: add channels option

2 weeks agoavfilter/vf_zscale: active region use doubles so use that type here too
Paul B Mahol [Fri, 13 May 2022 13:15:41 +0000 (15:15 +0200)]
avfilter/vf_zscale: active region use doubles so use that type here too

2 weeks agoavfilter/af_asubboost: add boost option
Paul B Mahol [Fri, 13 May 2022 12:19:43 +0000 (14:19 +0200)]
avfilter/af_asubboost: add boost option

2 weeks agoavfilter/af_crossfeed: always return same number of samples with block processing
Paul B Mahol [Fri, 13 May 2022 09:04:36 +0000 (11:04 +0200)]
avfilter/af_crossfeed: always return same number of samples with block processing

2 weeks agoavfilter/vf_zscale: improve slice processing
Paul B Mahol [Fri, 13 May 2022 08:02:14 +0000 (10:02 +0200)]
avfilter/vf_zscale: improve slice processing

2 weeks agoavformat/movenc: Add support for AVIF muxing
Vignesh Venkatasubramanian [Thu, 12 May 2022 16:23:28 +0000 (09:23 -0700)]
avformat/movenc: Add support for AVIF muxing

Add an AVIF muxer by re-using the existing the mov/mp4 muxer.

AVIF Specification: https://aomediacodec.github.io/av1-avif

Sample usage for still image:
ffmpeg -i image.png -c:v libaom-av1 -still-picture 1 image.avif

Sample usage for animated AVIF image:
ffmpeg -i video.mp4 animated.avif

We can re-use any of the AV1 encoding options that will make
sense for image encoding (like bitrate, tiles, encoding speed,
etc).

The files generated by this muxer has been verified to be valid
AVIF files by the following:
1) Displays on Chrome (both still and animated images).
2) Displays on Firefox (only still images, firefox does not support
   animated AVIF yet).
3) Verified to be valid by Compliance Warden:
   https://github.com/gpac/ComplianceWarden

Fixes the encoder/muxer part of Trac Ticket #7621

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
2 weeks agoavformat/av1: Add a parameter to av1c to omit seq header
Vignesh Venkatasubramanian [Mon, 2 May 2022 21:36:28 +0000 (14:36 -0700)]
avformat/av1: Add a parameter to av1c to omit seq header

Add a parameter to omit seq header when generating the av1C atom.

For now, this does not change any behavior. This will be used by a
follow-up patch to add AVIF support.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>