Commit Graph

113606 Commits

Author SHA1 Message Date
Andreas Rheinhardt 5e2b0862eb tests/fate-run: Sanitize test argument
test -z is a binary operator.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-10 08:05:57 +01:00
James Almer 81c2557691 avcodec: remove some references to avcodec_close
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-10 00:04:16 -03:00
Marton Balint dc9d64f794 avformat/mov_chan: never override number of channels based on chan atom
The channel designation metadata should not override the number of channels.
Let's warn the user if it is inconsistent, and keep the channel layout
unspecified.

Before the conversion to the channel layout API the code only set the mask, but
never overridden the channel count, so this restores the old behaviour.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-09 23:47:24 +01:00
Marton Balint 3d3cad7483 avformat/mov_chan: do not assume channels are in native order
Existing code could have caused wrong channel order signalling or reduced
channel count if a channel designation appeared multiple times. This is
actually an old bug, but the conversion to the new channel layout API made it
visible, because now the code overrides the proper channel count with the one
calculated from the mask.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-09 23:47:24 +01:00
Lynne 90adef99ca
avfft: avoid overreads with RDFT API users
The new API requires an extra array member at the very end,
which old API users did not do.

This disables in-place RDFT transforms and instead
does the transform out of place by copying once, there shouldn't
be a significant loss of speed as our in-place FFT requires a reorder
which is likely more expensive in the majority of cases to do.
2024-02-09 23:20:29 +01:00
Andreas Rheinhardt ce7c90ff82 avcodec/dca_core: Remove unneeded emms.h inclusion
Possible since 7ec2354c38.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 23:11:52 +01:00
Martin Storsjö 7ec2354c38 x86: Remove inline MMX assembly that clobbers the FPU state
These inline implementations of AV_COPY64, AV_SWAP64 and AV_ZERO64
are known to clobber the FPU state - which has to be restored
with the 'emms' instruction afterwards.

This was known and signaled with the FF_COPY_SWAP_ZERO_USES_MMX
define, which calling code seems to have been supposed to check,
in order to call emms_c() after using them. See
0b1972d409,
29c4c0886d and
df215e5758 for history on earlier
fixes in the same area.

However, new code can use these AV_*64() macros without knowing
about the need to call emms_c().

Just get rid of these dangerous inline assembly snippets; this
doesn't make any difference for 64 bit architectures anyway.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-02-09 23:55:52 +02:00
Connor Worley d5aaed9d4c lavc/dxv: align to 4x4 blocks instead of 16x16
The previous assumption that DXV needs to be aligned to 16x16 was
erroneous. 4x4 works just as well, and FATE decoder tests pass for all
texture formats.

On the encoder side, we should reject input that isn't 4x4 aligned,
like the HAP encoder does, and stop aligning to 16x16. This both solves
the uninitialized reads causing current FATE tests to fail and produces
smaller encoded outputs.

With regard to correctness, I've checked the decoding path by encoding a
real-world sample with git master, and decoding it with
  ffmpeg -i dxt1-master.mov -c:v rawvideo -f framecrc -
The results are exactly the same between master and this patch.

On the encoding side, I've encoded a real-world sample with both master
and this patch, and decoded both versions with
  ffmpeg -i dxt1-{master,patch}.mov -c:v rawvideo -f framecrc -
Under this patch, results for both inputs are exactly the same.

In other words, the extra padding gained by 16x16 alignment over 4x4
alignment has no impact on decoded video.

Signed-off-by: Connor Worley <connorbworley@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-02-09 23:47:14 +02:00
Niklas Haas c619d20906 fftools/ffplay: constrain supported YUV color spaces
SDL supports only these three matrices. Actually, it only supports these
three combinations: BT.601+JPEG, BT.601+MPEG, BT.709+MPEG, but we have
no way to restrict the specific *combination* of YUV range and YUV
colorspace with the current filter design.

See-Also: https://trac.ffmpeg.org/ticket/10839

Instead of an incorrect conversion result, trying to play a YCgCo file
with ffplay will simply error out with a "No conversion possible" error.
2024-02-09 21:02:08 +01:00
Niklas Haas 75f4cb81de avfilter/buffersink: add color_spaces, color_ranges params
An oversight in my previous series. This omission slipped under the
radar because fftools/ffmpeg_filter.c did not use these options, instead
preferring to insert an explicit format filter.
2024-02-09 21:02:08 +01:00
Timo Rothenpieler 4618b5ebb9 Revert "avutil/mem: limit alignment to maximum simd align"
Patch was not intended to be part of the set it got pushed with.

This reverts commit 6154137b18.
2024-02-09 20:20:03 +01:00
Timo Rothenpieler 21c6d12449 avfilter/ddagrab: only use acquired texture on valid updates 2024-02-09 19:51:48 +01:00
Timo Rothenpieler 6154137b18 avutil/mem: limit alignment to maximum simd align
FFmpeg has instances of DECLARE_ALIGNED(32, ...) in a lot of structs,
which then end up heap-allocated.
By declaring any variable in a struct, or tree of structs, to be 32 byte
aligned, it allows the compiler to safely assume the entire struct
itself is also 32 byte aligned.

This might make the compiler emit code which straight up crashes or
misbehaves in other ways, and at least in one instances is now
documented to actually do (see ticket 10549 on trac).
The issue there is that an unrelated variable in SingleChannelElement is
declared to have an alignment of 32 bytes. So if the compiler does a copy
in decode_cpe() with avx instructions, but ffmpeg is built with
--disable-avx, this results in a crash, since the memory is only 16 byte
aligned.

Mind you, even if the compiler does not emit avx instructions, the code
is still invalid and could misbehave. It just happens not to. Declaring
any variable in a struct with a 32 byte alignment promises 32 byte
alignment of the whole struct to the compiler.

This patch limits the maximum alignment to the maximum possible simd
alignment according to configure.
While not perfect, it at the very least gets rid of a lot of UB, by
matching up the maximum DECLARE_ALIGNED value with the alignment of heap
allocations done by lavu.
2024-02-09 18:11:49 +01:00
Lynne 9af87828bd
x86/tx_init: propely indicate the extended available transform sizes
Forgot to do this with the previous commit.

Actually makes the assembly being used.

Still the fastest FFT in the world, 15% faster than FFTW on the
largest available size.
2024-02-09 18:08:42 +01:00
James Almer 7c873fb298 lavc/refstruct: do not use max_align_t on MSVC
It is not available there, even when C11/17 is requested.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-02-09 16:24:50 +01:00
Anton Khirnov 1cc24d7495 lavc: deprecate avcodec_close()
Its use has been discouraged since 2016, but now is no longer used in
avformat, so there is no reason to keep it public.
2024-02-09 16:14:56 +01:00
Anton Khirnov ca18bb5972 lavf/demux: stop calling avcodec_close()
Replace it with recreating the codec context.

This is the last remaining blocker for deprecating avcodec_close().
2024-02-09 16:14:56 +01:00
Anton Khirnov 88ba22009e lavf/flacdec: stop accessing FFStream.avctx
The demuxer opens an internal parser instance in read_timestamp(), which
requires a codec context. There is no need for it to access the FFStream
one which is used for other purposes, it can allocate its own internal
one.
2024-02-09 16:14:56 +01:00
Anton Khirnov 0d54ae4012 lavf/mpegts: drop a cargo-culted check
This check has survived the transition to AVCodecParameters, but is no
longer relevant after it, since the codec context is no longer updated
or accessed at all from the demuxer.
2024-02-09 16:14:56 +01:00
Anton Khirnov 05fc6d3ce7 fftools/ffmpeg_demux: set stream index right before sending packet to scheduler
This avoids assuming that it survives unchanged through bitstream
filters, if present.
2024-02-09 16:14:24 +01:00
Andreas Rheinhardt 8c2e86ca28 fftools/cmdutils: Don't cast const away
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 12:22:21 +01:00
Andreas Rheinhardt 3371250c32 avformat/rcwtenc: Pass RCWTContext directly in rcwt_init_cluster()
It does not use the AVFormatContext at all.

Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 10:20:42 +01:00
Andreas Rheinhardt a8e55cf118 avformat/rcwtenc: Remove redundant zeroing of buffer
Resetting the counter of used elements is enough as nothing is
ever read from the currently unused elements.

Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 10:20:35 +01:00
Andreas Rheinhardt d30fe36b88 avformat/rcwtenc: Fix potential out-of-bounds write
The rcwt muxer uses several counters for how much data
it has already cached: One byte counter and one counter
for how many complete blocks (of three bytes each).
These counters can become inconsistent when the muxer is
fed incomplete blocks as the muxer presumes that it is
about to write a new block at the start of each write_packet
call. E.g. sending 65535*3+1 1-byte packets (with data[0] e.g. 0x03)
will trigger an out-of-bounds write.

This patch fixes this by processing the data in complete blocks
only. This also allows to simplify the code, e.g. to remove one of
the counters.

Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 10:20:21 +01:00
Andreas Rheinhardt 2b0e9e278a avcodec/h263dec: Remove AVCodec.pix_fmts arrays
They are not intended for decoders (for which there is the get_format
callback in case the user has a choice).

Also note that the list was wrong for MPEG4, because it did not contain
the high bit depth pixel formats used for studio profiles.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 08:16:25 +01:00
Andreas Rheinhardt 39cfd30bf1 avcodec/vc1dec: Remove AVCodec.pix_fmts arrays
They are not intended for decoders (for which there is the get_format
callback in case the user has a choice).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 08:16:25 +01:00
Andreas Rheinhardt ca95863758 avcodec/vc1dec: Don't call ff_get_format() twice
It is currently called once in the codecs' init function
and once when (re)initializing the VC-1 decode context
(which happens upon frame size changes as well as before
decoding the first frame). The first one is unnecessary
now that vc1_decode_frame() no longer requires avctx->hwaccel
to be already set for hwaccel to work properly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 08:16:25 +01:00
Andreas Rheinhardt 38f234c06e avcodec/vc1dec: Set pointers for hwaccel even without hwaccel
VC-1 uses a 0x03 escaping scheme like H.26x and our decoder
unescapes data for this purpose, but hardware accelerations
just want the data as-is and therefore get fed the original
data. The pointers to the actual data are only setcorrectly
if avctx->hwaccel is set (after all, they are only used in
this case).

There are two problems with this: The first is that the branch
is pointless; the second is that it is harmful, because
a hardware acceleration may be added after the packet has been
parsed (in case there is a reconfiguration e.g. due to frame
size changes) in which case decoding the first few frames
won't work.

So delete these branches.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 08:16:25 +01:00
Andreas Rheinhardt 687a287e14 avcodec/mmaldec: Avoid using AVCodec.pix_fmts
It is entirely unnecessary to use it given that all decoders
here share the same set of supported pixel formats. So just
hardcode this list.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 08:16:25 +01:00
Andreas Rheinhardt 89995cfda1 avcodec: Remove redundant pix_fmts from decoders
AVCodec.pix_fmts is only intended for encoders (decoders use
the get_format callback to let the user choose a pix fmt).
So remove them for the decoders for which this is possible
without further complications; keep them for now in the codecs
that actually use them (by passing avctx->codec->pix_fmts to
ff_get_formatt()).

Also notice that some of these lists were wrong; e.g.
317b7b06fd added support for YUV444P16
for cuviddec, but forgot to add it to pix_fmts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 08:16:25 +01:00
Connor Worley 395469c1b0 fate/video: add DXV3 HQ tests
Signed-off-by: Connor Worley <connorbworley@gmail.com>
2024-02-08 20:37:27 +01:00
Connor Worley 5fbb6fc636 fate/video: add DXV3 DXT1 encoding test
Signed-off-by: Connor Worley <connorbworley@gmail.com>
2024-02-08 20:37:27 +01:00
Connor Worley 1eeee68d8e lavc/dxv: fix incorrect back-reference index calculation in DXT5 decoding
This bug causes the DXT5 decoder to produce incorrect block texture data.
After the fix, textures are visually correct and match data decoded by
Resolume Alley (extracted with Nvida Nsight for comparison). Current FATE DXT5
samples did not cover this case.

Signed-off-by: Connor Worley <connorbworley@gmail.com>
2024-02-08 20:36:15 +01:00
Connor Worley 3b6a515c5f lavc/dxv: treat DXT5-tagged files as DXT4
DXV files seem to misnomer DXT5 and really encode DXT4 with
premultiplied alpha. At least, this is what Resolume alley does.

To check, encode some input with alpha as "Normal Quality, With Alpha"
in Alley, then decode the output with this change -- results are true
to the original input compared to git-master.

Signed-off-by: Connor Worley <connorbworley@gmail.com>
2024-02-08 20:36:04 +01:00
Connor Worley c4e9556cf5 lavc/texturedsp: fix premult2straight inversion
This function should convert premultiplied alpha to straight, but does the opposite.

Signed-off-by: Connor Worley <connorbworley@gmail.com>
2024-02-08 20:36:04 +01:00
Andreas Rheinhardt f6ec01147f avfilter/fifo: Remove (a)fifo filters
Obsolete since 4ca1fb9d2a.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-08 14:02:55 +01:00
Andreas Rheinhardt 9ae40f282d avcodec/nvdec: Constify bitstream pointee
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-08 14:00:37 +01:00
Haihao Xiang cd31eac999 lavc/qsvenc: Add workaround for VP9 keyframe
The runtime doesn't set the frame type to MFX_FRAMETYPE_IDR on the
returned mfx bitstream for a keyframe, it set the frame type to
MFX_FRAMETYPE_I only. This patch added workaround for VP9 keyframe to
make the coded stream seekable.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2024-02-08 10:34:02 +08:00
Tong Wu 82e8838165 avcodec/dxva2: fix different 'const' qualifiers warning
Signed-off-by: Tong Wu <tong1.wu@intel.com>
2024-02-08 10:34:02 +08:00
Tong Wu 92ee7461c3 avcodec/d3d12va_decode: fix different 'const' qualifiers warning
Signed-off-by: Tong Wu <tong1.wu@intel.com>
2024-02-08 10:34:02 +08:00
Aleksoid 336d59643a avcodec/d3d12va_vc1: add support for D3D12_VIDEO_DECODE_PROFILE_VC1_D2010 guid.
The VC1_D2010 profile, also known as VC1_VLD2010, has the same functionality
and specification as the VC1_D profile. Support for this profile serves only
as a positive indication that the accelerator has been designed with awareness
of the modifications specified in the August 2010 version of this specification.

Hardware accelerator drivers that expose support for this profile must not
also expose the previously specified VC1_D GUID, unless the accelerator works
properly with existing software decoders that use VC1_D and that do not incorporate
the corrections added to the August 2010 version of this specification.

As a result, we could give VC1_VLD2010 a higher priority and initialize
it first.

Signed-off-by: Aleksoid <Aleksoid1978@mail.ru>
Signed-off-by: Tong Wu <tong1.wu@intel.com>
2024-02-08 10:34:02 +08:00
Wu Jianhua 3372876888 avcodec/x86/vvc/vvcdsp_init: fix unresolved external symbol on ARCH_X86_32
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2024-02-07 22:53:15 +08:00
James Almer 7f92014aca avcodec/nvdec: don't free NVDECContext->bitstream
Ensure all hwaccels that allocate a buffer use NVDECContext->bitstream_internal
instead. Otherwise, if FFHWAccel->end_frame() isn't called before
FFHWAccel->uninit(), an attempt to free a stale pointer to memory not owned by
the hwaccel could take place.

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-07 11:31:33 -03:00
Lynne bd3e71b21e
x86/tx_float: enable SIMD for sizes over 131072
The tables for the new sizes were added last year due
to being required for SDR.
However, the assembly was never updated to use them.
2024-02-07 15:20:48 +01:00
Andreas Rheinhardt e05d3c1a16 avdevice/caca: Allow to list multiple dither option types at once
This can be achieved by using AV_OPT_TYPE_FLAGS instead of
AV_OPT_TYPE_STRING. It also avoids strcmp() when accessing
the option.

Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:25:17 +01:00
Andreas Rheinhardt ed56ca856c avutil/opt: Fix AV_OPT_TYPE_CONST default value
It uses the int64_t instead of the double member.

(This code can currently not be reached: av_opt_get() calls
av_opt_find2() with NULL as unit in which case AV_OPT_TYPE_CONST
options are never returned, leading av_opt_get() to always
return AVERROR_OPTION_NOT_FOUND when searching for AV_OPT_TYPE_CONST*.
For the same reason the code read_number() will never be called
from get_number() when searching for an option of type
AV_OPT_TYPE_CONST. The other callers of read_number() also only
call it with types other than AV_OPT_TYPE_CONST.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:23:00 +01:00
Andreas Rheinhardt 8b83b52d0f avformat/nutenc: Fix indentation
Forgotten after 82beb46e65.
Also use loop-scope for iterators while at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:22:19 +01:00
Andreas Rheinhardt 1a52cbd404 avfilter/ccfifo: Improve included headers
We don't need to include fifo.h, because we don't need AVFifo
as a complete type. Also add the other used headers directly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:22:19 +01:00
Andreas Rheinhardt 9b67c5a684 avfilter/ccfifo: Inline trivial functions
Besides being extremly simple this also avoids including
ff_ccfifo_ccdetected() unnecessarily (it is only used by decklink).
This is possible because this is not avpriv, but duplicated into
lavd if necessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:22:19 +01:00
Andreas Rheinhardt 71e1da4522 avformat/mux: Don't allocate priv_pts separately
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:22:18 +01:00