Commit Graph

107896 Commits

Author SHA1 Message Date
Andreas Rheinhardt 61fa1e14e4 avformat/imf_cpl: Check the right variable
Fixes Coverity issue #1512407.

Reviewed-by: Pierre-Anthony Lemieux <pal@sandflow.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-25 23:19:57 +02:00
James Almer adc38738cb avcodec/libaomenc: fix the check for presence of encoder interface
ctx->encoder is not a pointer.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-08-25 16:25:55 -03:00
James Almer 9f323cb04c avcodec/libaomenc: check return value of queue_frames()
Signed-off-by: James Almer <jamrial@gmail.com>
2022-08-25 14:28:27 -03:00
James Almer 5bab794e4a avcodec/libaomenc: add init cleanup flag
Signed-off-by: James Almer <jamrial@gmail.com>
2022-08-25 14:28:27 -03:00
Lynne f932b89ea3
lavu/tx: implement aarch64 NEON SIMD FFT
The fastest fast Fourier transform in not just the west, but the world,
now for the most popular toy ISA.

On a high level, it follows the design of the AVX2 version closely,
with the exception that the input is slightly less permuted as we don't have
to do lane switching with the input on double 4pt and 8pt.

On a low level, the lack of subadd/addsub instructions REALLY penalizes
any attempt at writing an FFT. That single register matters a lot,
and reloading it simply takes unacceptably long.
In x86 land, vendors would've noticed developers need this.
In ARM land, you get a badly designed complex multiplication instruction
we cannot use, that's not present on 95% of devices. Because only
compilers matter, right?

Future optimization options are very few, perhaps better register
management to use more ld1/st1s.

All timings below are in cycles:
A53:
Length | C           | New (lavu)  | Old (lavc)  | FFTW
------ |-------------|-------------|-------------|-----
4      |         842 | 420         | 1210        | 1460
8      |        1538 | 1020        | 1850        | 2520
16     |        3717 | 1900        | 3700        | 3990
32     |        9156 | 4070        | 8289        | 8860
64     |       21160 | 9931        | 18600       | 19625
128    |       49180 | 23278       | 41922       | 41922
256    |      112073 | 53876       | 93202       | 101092
512    |      252864 | 122884      | 205897      | 207868
1024   |      560512 | 278322      | 458071      | 453053
2048   |     1295402 | 775835      | 1038205     | 1020265
4096   |     3281263 | 2021221     | 2409718     | 2577554
8192   |     8577845 | 4780526     | 5673041     | 6802722

Apple M1
New  - Total for len 512 reps 2097152 = 1.459141 s
Old  - Total for len 512 reps 2097152 = 2.251344 s
FFTW - Total for len 512 reps 2097152 = 1.868429 s

New  - Total for len 1024 reps 4194304 = 6.490080 s
Old  - Total for len 1024 reps 4194304 = 9.604949 s
FFTW - Total for len 1024 reps 4194304 = 7.889281 s

New  - Total for len 16384 reps 262144 = 10.374001 s
Old  - Total for len 16384 reps 262144 = 15.266713 s
FFTW - Total for len 16384 reps 262144 = 12.341745 s

New  - Total for len 65536 reps 8192 = 1.769812 s
Old  - Total for len 65536 reps 8192 = 4.209413 s
FFTW - Total for len 65536 reps 8192 = 3.012365 s

New  - Total for len 131072 reps 4096 = 1.942836 s
Old  - Segfaults
FFTW - Total for len 131072 reps 4096 = 3.713713 s

Thanks to wbs for some simplifications, assembler fixes and a review
and to jannau for giving it a look.
2022-08-25 17:40:28 +02:00
Paul B Mahol 9bf9d42d01 avcodec/wavpack: fix regression in decoding
Regression introduced in c6831e2a70.
Fix it by using bitreader that reads 0-32 bits, instead of
0-25 bits and asserting on anything higher.
2022-08-25 09:12:17 +02:00
Paul B Mahol b347a05f1f avformat/riff: add support for ICMV files 2022-08-25 09:12:07 +02:00
rcombs 9546b3a1cb lswr: take const AVChannelLayout* in swr_alloc_set_opts2()
This is fully backwards-compatible in both ABI and API,
so it's only a minor bump.
2022-08-24 18:31:05 -05:00
James Almer 22514527d3 avcodec/libaomenc: use av_fast_realloc() to resize the stats buffer
Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-08-24 15:22:15 -03:00
James Almer 57041bb7b5 avcodec/libvpxenc: use av_fast_realloc() to resize the stats buffer
Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-08-24 15:21:44 -03:00
Martin Storsjö 48cb2c7a8a videotoolbox_vp9: Add a missing include
This fixes compilation after 0bb0c26799.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-08-24 15:36:03 +03:00
Wujian(Chin) 76cb899f8a avformat/wavdec: fix the ID3 metadata obtained in WAV format's missing
Fixes ticket #9848.

Signed-off-by: wujian_nanjing <wujian2@huawei.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2022-08-24 10:45:33 +08:00
Andreas Rheinhardt 0b3f09689d avcodec/gif: Remove unnecessary headers
The gif encoder uses the bytestream API, not the PutBit-API.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-24 03:43:52 +02:00
Andreas Rheinhardt 0bb0c26799 avutil/mem_internal: Fix headers
Including avassert.h is unnecessary since commit
786be70e28.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-24 03:43:52 +02:00
Andreas Rheinhardt d09dacc197 avformat/os_support: Include stdint.h for int64_t
Fixes checkheaders for Windows targets.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-24 03:43:52 +02:00
Andreas Rheinhardt 85655bd9da avcodec/loongarch/cabac, vp9dsp_loongarch: Add missing headers
Fixes checkheaders on loongarch.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-24 03:43:52 +02:00
Andreas Rheinhardt 5bf7187327 avcodec/4xm: Remove unnecessary and redundant emms_c()
It is unnecessary since ee551a21ddcbf81afe183d9489c534ee80f263a0;
but it was redundant even before that, because decode_simple_internal()
calls emms_c().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-24 03:43:47 +02:00
Andreas Rheinhardt 145914524b avcodec/apedec: Remove unnecessary emms_c()
Possible since 6feea076e9.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-24 03:42:38 +02:00
Andreas Rheinhardt 4a699858d5 avcodec/ffv1(dec|enc): Remove unnecessary emms_c()
These codecs do not use MMX at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-24 03:42:38 +02:00
Andreas Rheinhardt 73f024aa58 avcodec/jpeglsenc: Remove unnecessary emms_c()
This encoder does not use any MMX anywhere.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-24 03:42:38 +02:00
Andreas Rheinhardt da0e7c3b67 avcodec/takdec: Remove unnecessary emms_c()
Possible since 3d716d38ab.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-24 03:42:38 +02:00
Andreas Rheinhardt 505eaf0e37 avcodec/wmalosslessdec: Remove unnecessary emms_c()
Possible since 6feea076e9.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-24 03:42:38 +02:00
James Almer 9c7a8a8546 avcodec/libvpx: fix assembling vp9 packets with alpha channel
There's no warranty that vpx_codec_encode() will generate a list with the same
amount of packets for both the yuv planes encoder and the alpha plane encoder,
so queueing packets based on what the main encoder returns will fail when the
amount of packets in both lists differ.
Queue all data packets for every vpx_codec_encode() call from both encoders
before attempting to assemble output AVPackets out of them.

Fixes ticket #9884

Reviewed-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-08-23 19:40:03 -03:00
Paul B Mahol 0dff278e5b avfilter/af_silenceremove: do not trim non-silence from start 2022-08-23 22:18:02 +02:00
Michael Niedermayer 104804a718
tools/target_dec_fuzzer: Adjust threshold for ZLIB
Fixes: Timeout
Fixes: 49769/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZLIB_fuzzer-6302938657587200

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-23 20:03:03 +02:00
Michael Niedermayer ca4ff9c21c
avcodec/h263dec: Sanity check against minimal I/P frame size
Fixes: Timeout
Fixes: 49718/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-4874987894341632

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-23 20:03:03 +02:00
Michael Niedermayer 3b51e19922
avcodec/hevcdec: Check s->ref in the md5 path similar to hwaccel
This is somewhat redundant with the is_decoded check. Maybe
there is a nicer solution

Fixes: Null pointer dereference
Fixes: 49584/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5297367351427072

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-23 20:03:03 +02:00
Michael Niedermayer 7086491fa0
avcodec/mpegaudiodec_template: use unsigned shift in handle_crc()
Fixes: left shift of 192 by 24 places cannot be represented in type 'int'
Fixes: 49577/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MP1FLOAT_fuzzer-5205996678545408

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-23 20:03:03 +02:00
Michael Niedermayer 8ab944c4c3
avcodec/4xm: treat AV_LOG_ERROR cases as errors
Fixes: Timeout
Fixes: 49504/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FOURXM_fuzzer-570457772222054

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-23 20:03:03 +02:00
Michael Niedermayer 58a8e739ef
avformat/subviewerdec: Make read_ts() more flexible
Fixes: signed integer overflow: -1948269928 * 10 cannot be represented in type 'int'
Fixes: 49451/clusterfuzz-testcase-minimized-ffmpeg_dem_SUBVIEWER_fuzzer-6344614822412288

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2022-08-23 20:03:03 +02:00
Michael Niedermayer a44f5a5212
avcodec/mjpegdec: bayer and rct are incompatible
Fixes: out of array read
Fixes: 49434/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5208501080686592

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-23 20:03:03 +02:00
Michael Niedermayer 928857099c
tools/target_dec_fuzzer: Adjust threshold for VB
Fixes: Timeout
Fixes: 49372/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VB_fuzzer-5234505337667584

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-23 20:03:03 +02:00
Michael Niedermayer b716ba5029
tools/target_dec_fuzzer: Adjust threshold for VMDVIDEO
Fixes: Timeout
Fixes: 49350/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VMDVIDEO_fuzzer-4554761801695232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-23 20:03:03 +02:00
Michael Niedermayer 6ba9e22f67
tools/target_dec_fuzzer: Adjust threshold for NUV
Fixes: Timeout
Fixes: 49286/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NUV_fuzzer-5856252655173632

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-23 20:03:03 +02:00
James Almer f5a663f2a9 fftools/ffmpeg_opt: try to propagate the requested output channel layout
Don't silently replace it with the default layout for the amount of channels
from the requested layout.

Should fix ticket #9869

Signed-off-by: James Almer <jamrial@gmail.com>
2022-08-23 13:03:56 -03:00
James Almer fb70e0611b avcodec/libsvtav1: properly initialize the flush EbBufferHeaderType struct
Should fix ticket #9834

Signed-off-by: James Almer <jamrial@gmail.com>
2022-08-23 13:03:55 -03:00
Hendrik Leppkes 89ea7a2442 configure: enable the av1_frame_split bsf for the av1 decoder
The BSF is required to make use of the AV1 decoder, thus configure
should also ensure it is built.
2022-08-23 14:30:28 +02:00
Andreas Rheinhardt de33506e4b swscale/x86/rgb_2_rgb: Empty MMX state in ff_shuffle_bytes_2103_mmxext
Fixes FATE-failures with the the filter-2xbr filter-3xbr filter-4xbr
filter-ep2x filter-ep3x filter-hq2x filter-hq3x filter-hq4x
filter-paletteuse-bayer filter-paletteuse-bayer0
filter-paletteuse-nodither and filter-paletteuse-sierra2_4a tests
when using 32bit x86 with CPUFLAGS ranging from "mmx+mmxext" to
"mmx+mmxext+sse+sse2+sse3" (the relevant function is only overwritten
when using SSSE3).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-23 12:21:00 +02:00
Andreas Rheinhardt 72cfc80d7b avcodec/pngdec: Improve decoding text chunks
By checking immediately whether the first allocation was successfull
one can simplify the cleanup code in case of errors.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-23 12:21:00 +02:00
Andreas Rheinhardt eda3abd1ec avcodec/pngdec: Use char* instead of uint8_t* for text
Also stop casting const away.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-23 12:21:00 +02:00
Andreas Rheinhardt 3d4a5ef5c1 avcodec/pngdec: Use internal AVBPrint string when parsing chunks
One saves an allocation in case the string fits into the buffer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-23 12:21:00 +02:00
Andreas Rheinhardt a84087eaf8 avcodec/pngdec: Fix APNG_DISPOSE_OP_BACKGROUND
APNG works with a single reference frame and an output frame.
According to the spec, decoding APNG works by decoding
the current IDAT/fdAT chunks (which decodes to a rectangular
subregion of the whole image region), followed by either
overwriting the region of the output frame with the newly
decoded data or by blending the newly decoded data with
the data from the reference frame onto the current subregion
of the output frame. The remainder of the output frame
is just copied from the reference frame.
Then the reference frame might be left untouched
(APNG_DISPOSE_OP_PREVIOUS), it might be replaced by the output
frame (APNG_DISPOSE_OP_NONE) or the rectangular subregion
corresponding to the just decoded frame has to be reset
to black (APNG_DISPOSE_OP_BACKGROUND).

The latter case is not handled correctly by our decoder:
It only performs resetting the rectangle in the reference frame
when decoding the next frame; and since commit
b593abda6c it does not reset
the reference frame permanently, but only temporarily (i.e.
it only affects decoding the frame after the frame with
APNG_DISPOSE_OP_BACKGROUND). This is a problem if the
frame after the APNG_DISPOSE_OP_BACKGROUND frame uses
APNG_DISPOSE_OP_PREVIOUS, because then the frame after
the APNG_DISPOSE_OP_PREVIOUS frame has an incorrect reference
frame. (If it is not followed by an APNG_DISPOSE_OP_PREVIOUS
frame, the decoder only keeps a reference to the output frame,
which is ok.)

This commit fixes this by being much closer to the spec
than the earlier code: Resetting the background is no longer
postponed until the next frame; instead it is applied to
the reference frame.

Fixes ticket #9602.

(For multithreaded decoding it was actually already broken
since commit 5663301560d77486c7f7c03c1aa5f542fab23c24.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-23 12:21:00 +02:00
David Flater d2b6ec1e27 avfilter/af_alimiter: fix misbehavior when nb_channels != 2
Some code in alimiter assumes that there are 2 channels, resulting in
clipping if the loudest channel is 3 or above and an out-of-bounds read if
the input is monophonic.  Fix that in 2 places.

Signed-off-by: David Flater <dave@flaterco.com>
2022-08-23 12:20:05 +02:00
Haihao Xiang 1adfd28f9e qsvenc_{hevc,h264}: add scenario option
User may get better experience after providing corresponding senario hint
to encoder for the encoding session. See [1] for scenario support in the
SDK

[1]https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#scenarioinfo
2022-08-23 12:42:19 +08:00
Wenbin Chen ae7d19680b libavcodec/qsvenc: Add adaptive_i/b to hevc_qsv
Add adaptive_i/b feature to hevc_qsv. Adaptive_i allows changing of
frame type from P and B to I. Adaptive_b allows changing of frame type
frome B to P.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-08-23 12:42:19 +08:00
Anton Khirnov f23e3ce858 fftools/ffmpeg: call av_guess_frame_rate() when opening the file
It is currently called when configuring the filter, which races with the
demuxer thread.
2022-08-22 11:36:43 +02:00
Anton Khirnov 14726571dd lavf: deprecate av_stream_get_end_pts()
According to its documentation it returns "pts of the last muxed packet
+ its duration", but the value it actually returns right now is
(possibly guessed) dts after muxer-internal bitstream filtering (if
any).

This function was added for ffmpeg.c, but it is not used there anymore.
Since the value it returns is ill-defined and so inappropriate for any
serious use, deprecate it.
2022-08-22 11:35:43 +02:00
Steven Liu 627543f58a avcodec/audiotoolboxenc: return AVERROR_EXTERNAL immediately when encode error
Just return AVERROR_EXTERNAL immediately when encode error.
The other logic should keep the old behavior before commit 7c05b7951.

Suggested-By: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2022-08-22 10:58:13 +08:00
James Almer 4ab04fdfb5 swresample/swresample: fill the correct buffer to print the output layout string
Signed-off-by: James Almer <jamrial@gmail.com>
2022-08-21 17:46:36 -03:00
Andreas Rheinhardt 0154fb43e3 avcodec/mpegvideo: Allocate encoder-only tables in mpegvideo_enc.c
This commit moves the encoder-only allocations of the tables
owned solely by the main encoder context to mpegvideo_enc.c.
This avoids checks in mpegvideo.c for whether we are dealing
with an encoder; it also improves modularity (if encoders are
disabled, this code will no longer be included in the binary).
And it also avoids having to reset these pointers at the beginning
of ff_mpv_common_init() (in case the dst context is uninitialized,
ff_mpeg_update_thread_context() simply copies the src context
into dst which therefore may contain pointers not owned by it,
but this does not happen for encoders at all).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-21 04:48:02 +02:00