1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

108165 Commits

Author SHA1 Message Date
Paul B Mahol
9c05f178a6 avformat/ape: fix overflow in total_blocks 2022-09-16 18:04:20 +02:00
Paul B Mahol
8f11512273 avformat/ape: set packet duration 2022-09-16 18:04:20 +02:00
Andreas Rheinhardt
2c23cd0181 avformat/bonk: Don't set data_offset to what it would be set to anyway
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 17:49:40 +02:00
Andreas Rheinhardt
aaf6d85283 avcodec/Makefile: Remove obsolete adx_parser->adx.c dependency
Obsolete since b024209b1f.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 11:21:22 +02:00
Andreas Rheinhardt
b15a2f2504 avcodec/adx: Move ff_adx_decode_header() to adxdec.c
Possible since 9325d88eba.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 11:14:32 +02:00
Paul B Mahol
53523ed530 avcodec/tak*: use cached bitstream reader on !x86_32
Increases single thread decoding speed in one example from 85x to 90x
2022-09-16 10:02:19 +02:00
Paul B Mahol
dd2a01ef5c avformat: add LAF demuxer 2022-09-16 10:02:19 +02:00
Paul B Mahol
e91bc521af avcodec: add Micronas SC-4 parser 2022-09-16 10:02:19 +02:00
Paul B Mahol
ea93943bee avcodec: add MI-SC4 audio decoder 2022-09-16 10:02:19 +02:00
Rémi Denis-Courmont
6df3ad9687 lavu/riscv: fix off-by-one in bit-magnitude clip 2022-09-15 18:11:12 -03:00
Andreas Rheinhardt
a2c6bf2314 avcodec/intrax8: Remove reference to inexistent parameter
Forgotten in eb5c5ae658.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:34:59 +02:00
Andreas Rheinhardt
4cd1d3e3b7 avcodec/iff: Use unsigned to avoid compiler warning
GCC 12 apparently believes that negative palette sizes are
possible (they are not, as this has already been checked during
init) and therefore emits a -Wstringop-overflow= for the memcpy.
Using unsigned avoids this.
(To be honest, there might be a compiler bug involved.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
487fc61cb2 avcodec/iff: Remove transient objects from the context
This avoids keeping invalid pointers in the context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
828a0c4254 avcodec/iff: Reindent after the previous commits
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
8612b26202 avcodec/iff: Pass extradata and extradata_size explicitly
This might be useful in case this decoder were changed to support
new extradata passed via side-data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
d0df74553b avcodec/iff: Return early when possible
It allows to save one level of indentation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
46b586e5b2 avcodec/iff: Avoid redundant frees
This code is only called once during init, so none of the buffers
here have been allocated already.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
f0be9129ad avcodec/iff: Split extract_header into extradata and packet part
183132872a made the iff demuxer
output extradata and made the decoder parse said extradata.
To make this extradata extensible, it came with its own internal
length field (containing the offset of the palette at the end
of the extradata). Furthermore, in order to support mid-stream
extradata changes, the packets returned by the demuxer also have
such a length field (containing the offset of the actual packet
data). Therefore the packet parsing the extradata accepted its
input from both AVPackets as well as from ordinary extradata.

Yet the demuxer never made use of this "feature": The packet's
length field always indicated that the packet data starts
immediately after the length field.

Later, commit cb928fc448 stopped
appending the length field to the packets' data; of course,
it also stopped searching for extradata in this data.

Instead it added code to parse the packet's header to the function
that parses extradata. This made this function consist of two disjoint
parts, one of which is only reachable if this function is called
from init (when parsing extradata) and one of which is reachable
when parsing packet headers.

Therefore this commit splits this function into two.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
bffc8f9af1 avcodec/adpcmenc: Round up required buffer size
Otherwise the buffer might be too small. Fixes assert violations
when encoding mono audio with exactly one sample.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:15:27 +02:00
Timo Rothenpieler
c9bd6ee5cb avfilter/vf_colorspace_cuda: mark fall-through 2022-09-15 19:35:30 +02:00
Rémi Denis-Courmont
a90e5335b3 avutil/lfg: fix comment typo 2022-09-15 20:56:23 +05:30
James Almer
0e0f74b632 avfilter/vf_drawbox: use the correct macro to fill rgb plane pointers
Fixes ticket #9924

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-15 09:13:29 -03:00
Wang Yaqiang
3f0fac9303 fftools/ffplay: fix rotation incorrect when frame contains the displaymatrix
For example, if the jpeg contains exif information
and the rotation direction is included in the exif,
the displaymatrix will be set on the side_data of the frame when decoding.
However, when ffplay is used to play the image,
only the side data in the stream will be determined.
It does not check whether the frame also contains rotation information,
causing it to play in the wrong direction

Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Wang Yaqiang <wangyaqiang03@kuaishou.com>
2022-09-15 16:16:16 +08:00
Andreas Rheinhardt
859b31de50 avfilter/video: Fix newline in trace output
Forgotten in 7e350379f8.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 21:49:00 +02:00
Andreas Rheinhardt
e10774a8cc avfilter/avfilter: #if ff_tlog_link() away when empty
It is currently calling av_channel_layout_describe()
unnecessarily.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 21:48:48 +02:00
Andreas Rheinhardt
f4af504a1f avfilter/avfilter: Don't use AVFrame.channel_layout
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 21:48:11 +02:00
Christian Feldmann
8357d4790f avfilter/vf_libvmaf: copy all values also for 10 bit input 2022-09-14 19:42:59 +02:00
Jyrki Vesterinen
8fc2dedfe6 avcodec/vorbisdec: don't use a flag to determine if frames have been output
If a developer using FFmpeg libraries seeks into an earlier position and calls
avcodec_flush_buffers() afterwards as recommended, the Vorbis decoder will drop
the next frame, since buffer flushing clears the first_frame flag. As a result,
the audio samples the calling code receives may be ahead of the requested seek
position, which is unacceptable in some use cases such as playing a looping
sound effect.

This commit records the presentation timestamp of the first frame and
determines after that if the new frame is the first frame (possible after
seeking to the start) by comparing its pts to the stored pts.
2022-09-14 19:42:59 +02:00
Rémi Denis-Courmont
a5ce44f301 lavu/riscv: fix av_clip_int16
Some serious copy-paste / squash / rebase mismanipulation here.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-14 14:37:21 -03:00
Andreas Rheinhardt
e867a29ec1 avutil/dict: Improve appending values
When appending two values (due to AV_DICT_APPEND), the earlier code
would first zero-allocate a buffer of the required size and then
copy both parts into it via av_strlcat(). This is problematic,
as it leads to quadratic performance in case of frequent enlargements.
Fix this by using av_realloc() (which is hopefully designed to handle
such cases in a better way than simply throwing the buffer we already
have away) and by copying the string via memcpy() (after all, we already
calculated the strlen of both strings).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 19:01:02 +02:00
Andreas Rheinhardt
c15dd31d2a avutil/dict: Fix memleak when using AV_DICT_APPEND
If a key already exists in an AVDictionary and the AV_DICT_APPEND flag
is set, the old entry is at first discarded from the dictionary, but
a pointer to the value is kept. Lateron enough memory to store the
appended string is allocated; should this allocation fail, the old string
is not freed and hence leaks. This commit changes this by moving
creating the combined value to an earlier point in the function,
which also ensures that the AVDictionary is unchanged in case of errors.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 19:00:44 +02:00
Andreas Rheinhardt
f976ed7fcf avutil/dict: Avoid check whose result is known in advance
We know that an AVDictionary is not empty if we have just added
an entry to it, so only check for it being empty on the branch
that does not do so.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 15:03:59 +02:00
Andreas Rheinhardt
62af385b91 avformat/dump: Avoid unnecessary implicit calculation of strlen
av_strlcpy() returns the length of the src string to enable
the caller to check for truncation. It is currently used in
the following way in dump_metadata(): Every metadata value
is searched for \b, \n, \v, \f, \r and then the data up to
the first of these characters found is copied to a small
temporary buffer via av_strlcpy() (but of course not more
than fits into said buffer) and then printed; all characters up
to the character found earlier are then treated as consumed.

But this is bad performance-wise if the while string is big
and contains many of these characters, because av_strlcpy()
will unnecessarily calculate the length of the whole remaining string.
(dump_metadata() actually ignored the return value of av_strlcpy().)

Fix this by not copying the data to a temporary buffer at all.
Instead just use %.*s to bound the number of characters output.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 15:03:59 +02:00
James Almer
130483449e fftools/opt_common: check the return value of av_hwdevice_get_type_name before printing it
It may be NULL, as is the case for D3D11VA_VLD.

Running "ffmpeg -h decoder=h264" on a Windows build

Before:
Decoder h264 [H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10]:
    Supported hardware devices: dxva2 (null) d3d11va cuda

After:
Decoder h264 [H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10]:
    Supported hardware devices: dxva2 d3d11va cuda

Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-14 09:54:19 -03:00
James Almer
9903ba28c2 swsresample/swresample: error out on invalid layouts
If it's unsupported or invalid, then there's no point trying to rebuild it
using a value that may have been derived from the same layout to begin with.

Move the checks before the attempts at copying the layout while at it.

Fixes ticket #9908.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-14 09:52:33 -03:00
Andreas Rheinhardt
e402bd65b1 Revert "avcodec/loongarch/h264chroma, vc1dsp_lasx: Add wrapper for __lasx_xvldx"
This reverts commit 2c8dc7e953.
The loongarch headers have been fixed, so that this wrapper
is no longer necessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 14:09:26 +02:00
Andreas Rheinhardt
1234df7501 Revert "avcodec/loongarch: Add wrapper for __lsx_vldx"
This reverts commit 6c9a60ada4.
The loongarch headers have been fixed, so that this workaround
is no longer necessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 14:09:26 +02:00
Roman Arzumanyan
cc81ab283c libavfilter: add vf_colorrange_cuda, CUDA-accelerated color conversion filter
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2022-09-13 22:59:30 +02:00
Rémi Denis-Courmont
c177108ae1 lavu/riscv: add <intmath.h> optimisations
This provides some micro-optimisations for signed integer clipping, and
support for bit weight with the Zbb extension.
2022-09-13 16:50:43 -03:00
Rémi Denis-Courmont
df2057041b lavu/riscv: byte-swap operations
If the target supports the Basic bit-manipulation (Zbb) extension, then
the REV8 instruction is available to reverse byte order.

Note that this instruction only exists at the "XLEN" register size,
so we need to right shift the result down to the data width.

If Zbb is not supported, then this patchset does nothing. Support for
run-time detection is left for the future. Currently, there are no
bits in auxv/ELF HWCAP for Z-extensions, so there are no clean ways to
do this.
2022-09-13 16:50:43 -03:00
Rémi Denis-Courmont
ff14e37393 configure/riscv: detect fast CLZ
RISC-V defines the CLZ instruction as part of the ratified Zbb subset
of the (not yet ratified) bit mapulation extension (B). We can detect
it from the __riscv_zbb predefined constant. At least GCC 12 already
supports this correctly.

Note that the macro will be non-zero if supported, zero if enabled
in the compiler flags (e.g. -march=rv64gzbb) but not known to the
compiler, and undefined otherwise.
2022-09-13 16:50:43 -03:00
Rémi Denis-Courmont
d808070547 lavu/riscv: AV_READ_TIME cycle counter
This uses the architected RISC-V 64-bit cycle counter from the
RISC-V unprivileged instruction set.

In 64-bit and 128-bit, this is a straightforward CSR read.
In 32-bit mode, the 64-bit value is exposed as two CSRs, which
cannot be read atomically, so a loop is necessary to detect and fix up
the race condition where the bottom half wraps exactly between the two
reads.
2022-09-13 16:50:43 -03:00
Rémi Denis-Courmont
092ce9712f doc: reference the RISC-V specification 2022-09-13 16:50:43 -03:00
James Almer
bda3a9faf4 x86/float_dsp: use three operand form for some instructions
Fixes compilation with old yasm

Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-13 13:50:09 -03:00
Paul B Mahol
37a503ac87 avcodec/x86/audiodsp: add scalarproduct avx2 2022-09-13 17:43:16 +02:00
Paul B Mahol
72acff9f59 avutil/x86/float_dsp: add fma3 for scalarproduct 2022-09-13 17:43:15 +02:00
Paul B Mahol
cf2cf31805 avcodec/flac_parser: avoid returning too negative number
If return value is very small parser code will assert.
2022-09-13 17:43:15 +02:00
Andreas Rheinhardt
9ad3db3ad9 fate/spdif: Add spdif tests
These tests test both the demuxer as well as the muxer
wherever possible. It is not always possible due to the fact
that the muxer supports more codecs than the demuxer.

The spdif demuxer does currently not set the need_parsing flag.
If one were to set this to AVSTREAM_PARSE_FULL, the test results
would change as follows:
- For spdif-aac-remux, the packets are currently padded to 16bits,
i.e. if the actual packet size is odd, there is a padding byte.
The parser splits this byte away into a one byte packet of its own.
Insanely, these one byte packets get the same duration as normal
packets, i.e. timing is ruined.
- The DCA-remux tests get proper duration/timestamps.
- In the spdif-mp2-remux test the demuxer marks the stream as
being MP2; the parser sets it to MP3 and this triggers
the "Codec change in IEC 61937" codepath; this test therefore
returns only two packets with the parser.
- For spdif-mp3-remux some bytes end up in different packets:
Some input packets of this file have an odd length (417B instead
of 418B like all the other packets) and are padded to 418B.
Without a parser, all returned packets from the spdif-demuxer
are 418B. With a parser, the packets that were originally 417B
are 417B again, but the padding byte has not been discarded,
but added to the next packet which is now 419B.
This fixes "Multiple frames in a packet" warning and avoids
an "Invalid data found when processing input" error when decoding.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-13 14:50:01 +02:00
James Cowgill
50a4dff69f avcodec/arm/sbcenc: avoid callee preserved vfp registers
When compiling FFmpeg with GCC-9, some very random segfaults were
observed in code which had previously called down into the SBC encoder
NEON assembly routines. This was caused by these functions clobbering
some of the vfp callee saved registers (d8 - d15 aka q4 - q7). GCC was
using these registers to save local variables, but after these
functions returned, they would contain garbage.

Fix by reallocating the registers in the two affected functions in
the following way:
 ff_sbc_analyze_4_neon: q2-q5 => q8-q11, then q1-q4 => q8-q11
 ff_sbc_analyze_8_neon: q2-q9 => q8-q15

The reason for using these replacements is to keep closely related
sets of registers consecutively numbered which hopefully makes the
code more easy to follow. Since this commit only reallocates
registers, it should have no performance impact.

Signed-off-by: James Cowgill <jcowgill@debian.org>
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-09-13 09:51:51 +03:00
Andreas Rheinhardt
8d12f3de14 avcodec/bonk: Actually clip when using av_clip()
Also fixes a "statement with no effect [-Wunused-value]"
warning from GCC.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-12 23:51:51 +02:00