1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00
Commit Graph

120009 Commits

Author SHA1 Message Date
dee4edfa63 avformat/riff: G.728 muxing and demuxing 2025-06-23 17:19:18 +10:00
52f62468aa avformat/g728dec: raw G.728 demuxer 2025-06-23 17:19:18 +10:00
a107340035 avcodec/g728dec: G.728 decoder 2025-06-23 17:16:42 +10:00
a3c900a0c4 avcodec/lpc_functions: compute_lpc_coefs: add starting lpc order and err cache parameters 2025-06-23 17:11:09 +10:00
a0b9d61faf avcodec/g728_template: make hist parameter constant 2025-06-23 17:11:07 +10:00
93368029e3 avcodec/g728_template: do_hybrid_window() template
intended for use by RealAudio 2.0 (28.8k) and G.728 decoders.
2025-06-23 17:11:03 +10:00
b1172b8cc6 avcodec/mss2dsp: use FF_PTR_ADD to add offsets to a pointer
Fixes: libavcodec/mss2dsp.c:59:14: runtime error: applying zero offset to null pointer

Tested-by: Kacper Michajlow <kasper93@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-06-22 17:50:26 -03:00
f789d60e11 avformat/mov: add more sanity checks when reading clap boxes
If the apperture window is bigger than the canvas, then the clap box is invalid
and there's no point calculating cropping values.

Fixes: libavformat/mov.c:1295:14: runtime error: -256 is outside the range of representable values of type 'unsigned long'

Signed-off-by: James Almer <jamrial@gmail.com>
2025-06-22 10:30:03 -03:00
dbe94e1110 avfilter/x86/f_ebur128: replace AVX2 instruction with AVX equivalent
Using vpbroadcastq in an AVX function will result in SIGILL errors on pre
Haswell/Zen processors.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-06-22 09:31:44 -03:00
27590d8653 avutil/hwcontext_vulkan: disable host transfers if ReBAR is disabled
This feature fundamentally relies on host-visible VRAM, which restricts the
set of available memory types to (typically) host-visible device-local ones.

When resizable BAR is disabled, this memory type is usually limited to
e.g. 256 MiB in size, which is just plain insufficient for allocation of
general purpose GPU images, causing OOM errors on even the simplest of
commands.

The easiest solution is to disable host transfers entirely on machines
without host-addressable VRAM. In theory, we could try and recover the use
of host transfers for images which are *not* restricted to device-local
memory types, but this is rarely the case in practice, and the effort
required would exceed the benefit, especially since ReBAR is a standard
feature on all platforms recent enough to have Vulkan drivers, and only
occasionally disabled in the UEFI for by default for some hare-brained
notion of "backwards compatibiility" with ancient software.
2025-06-22 12:13:09 +02:00
baad40bdd1 avcodec/mips: fix build failure when specific decoder/encoder enabled
acelp_kelvin, g729, qcelp, sipr and wmavoice decoders all depend upon
mips/{acelp_filters_mips,celp_filters_mips,acelp_vectors_mips}.o when
arch is mips.

g723_1 depends on mips/{celp_filters_mips,acelp_vectors_mips}.o.

comfortnoise, evrc, ra144 and ra288 depend on mips/celp_filters_mips.o.
2025-06-22 09:15:56 +10:00
b49c4d1034 configure: h264_vulkan_encoder depends on atsc_a53 2025-06-22 09:15:56 +10:00
08943c82c6 configure: cbs_apv depends on cbs 2025-06-22 09:15:56 +10:00
34953e195f avcodec/mpeg4videoenc: Fix data race when using AC prediction
The check for whether we can use the fast path to process
AC coefficients used the qscale value belonging to a different
slice; this worked in practice, because the predicted AC values
are zero in this case, so it does not matter whether we use
the fast or the slow path.

Fix this by checking for first_slice_line instead. This fixes all
the races in the encoding part of the vsynth*-mpeg4-thread tests
(and fixes them if no frame threading is in use for the decoding part).

(The left prediction check may use data from a different slice, too,
but said slice is always processed by the same thread, so that no race
can happen. Given that out-of-slice AC values are zero, it does not
matter whether we use the fast path or the slow path either.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
5cdce56a79 avcodec/mpegvideo: Reduce stack usage when copying MpegEncContext
(GCC did not perform this on its own; Clang did.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
f8c0ac9984 avcodec/ituh263enc: Simplify encoding umotion vectors
There is no need to use two loops.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
689cde75ee avcodec/mpeg4video: Move ff_mpeg4_pred_dc() to decoder
Only used by the decoder now that the encoder solves
out-of-slice predictions by setting the out-of-slice
values appropriately.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
56fd45d2a9 avcodec/{ituh263,mpeg4video}enc: Simplify out-of-slice DC prediction
Now that every slice (and therefore every thread) uses its own
DC array, one can simply set the out-of-slice DC values to its
expected values (this is not possible for the decoders due
to error resilience).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
c84a03d752 avcodec/mpegvideo: Allocate dc_val for each encoder slice
This fixes data races (which are UB) in the MPEG-4 and H.263+
encoder when predicting DC values; these encoders unconditionally
read values from the line above the current line and only check
lateron (via first_slice_line) whether said prediction can be used
at all. It will also allow to remove said checks (by setting the
entries to 1024 upon opening a new slice).

The vsynth{1,2,3,_lena}-mpeg4-thread FATE tests were affected by this:
https://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-tsan-slices&time=20250613002615

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
eb597d9a1e avcodec/vc1: Only keep mb_type[0]
The chroma mb_type[1] and mb_type[2] pointers are unused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
81ab1106c8 avcodec/mpegvideo: Only keep MpegEncContext.dc_val[0]
The chroma dc_val pointers are mostly unused (accesses use
dc_val[0] and block_index), so remove them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
c4fd33a951 avcodec/mpegvideo: Zero-init mbintra_table
Up until now, they are marked as dirty (filled with 1), meaning that
the entries are in need of a reset via ff_clean_intra_table_entries();
but actually, the entries are initialized to the state that
ff_clean_intra_table_entries() produces, so they can be marked
as non-dirty (i.e. filled with 0).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
c4ebe55f94 avcodec/mpegvideo: Allocate ac_val jointly
They are currently allocated separately per slice; allocating them
jointly allows to avoid saving them in ff_update_duplicate_context().

The way it is done also avoids allocating ac_val for encoders that
don't need it (e.g. H.263 or H.263+ with AIC).

This entailed moving setting nb_slices to ff_mpv_init_context_frame()
which is called from ff_mpv_common_frame_size_change(). The resultant
nb_slices will always be one when called from a decoder using
ff_mpv_common_frame_size_change().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
dba1061ba4 avcodec/mpegvideo: Only use a single ac_val pointer
The chroma pointers ac_val[1] and ac_val[2] are no longer used anywhere.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
4aca6b19ac avcodec/mpeg4video: Don't use ac_val[1], ac_val[2] when cleaning buffers
This is in preparation for removing removing ac_val[1]
and ac_val[2]. ff_mpeg4_clean_buffers() was the last user of them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
b2661569b1 avcodec/mpegvideo: Combine stores
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
70ce68d021 avcodec/mpegvideo: Don't reset AC values of upper-left luma block
Said block will only be referenced by blocks from the same macroblock,
which will read the new AC values instead of the reset values
from this function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
dcd7408c92 avcodec/mpegvideo: Provide alignment hint to compiler
The underlying element type has always a size of 32B,
so that the pointer is always at least 16B aligned.
Clang uses this to upgrade the (inlined) memset to
aligned stores. GCC doesn't (it does it only when
the alignment hint is provided via __builtin_assume_aligned).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
32cbadcd74 avcodec/mpegvideo: Avoid {a,d}c_val[{1,2}]
These are already mostly unused; not using them here is in
preparation for removing them altogether. Use block_index[4..5]
instead for addressing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
13527b39bb avcodec/mpegvideo: Redo resetting intra table entry
All callers check the corresponding entry of MpegEncContext.mbintra_table
and if set (indicating that the intra tables might have been written to
when decodeing a intra MB, so that they are "dirty"), call
ff_clean_intra_table_entries(), which resets them to default values
and resets the mbintra_table entry. Move resetting to the callers
(via an inline function that also performs the checks). This currently
has the advantage that the additional load of the mbintra_table ptr
can be avoided. It will also allow to simplify
ff_clean_intra_table_entries() (by using block_index[4] and [5]).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
514e5ea0db avcodec/flvenc: Move ff_flv2_encode_ac_esc() to ituh263enc.c
This is the only place where it is used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
61d34c2b8e avcodec/flvenc: Combine writing bits
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
7643269ec2 avcodec/ituh263enc: Simplify AIC handling
Namely with block_index and block_wrap.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
950137a7c8 avcodec/ituh263dec: Simplify AIC handling
Possible by using block_index.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
822be72f0a avcodec/mpegvideo_enc: Simplify allocating non-slice buffers
Allocate them before the slice contexts, so that they are automatically
copied to the slice contexts. This avoids having to set them in a loop.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
8f92885b1f avcodec/mpegvideo: Defer init of enc slice ctxs in ff_mpv_common_init()
This will allow to perform initializations between ff_mpv_common_init()
and ff_mpv_init_duplicate_contexts() that will be automatically
copied to the slice contexts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
85692e5da1 avcodec/mpegvideo: Don't zero unnecessarily
The whole dc_val array is initialized (to 1024) immediately
after the allocation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
b4e7135986 avcodec/mpegvideo: Don't reset thread_context ptrs unnecessarily
They are freed with av_freep(), so the pointers are already consistent.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
6f84160b82 configure: Relax snowenc->mpegvideoenc dependency
It only needs mpegvideoencdsp, motion_est.o and ratecontrol.o.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
da22ee281e configure: Relax diracdec->mpegvideoenc dependency
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
8764b21048 configure: Relax svq1enc->mpegvideoenc dependency
It only needs mpegvideoencdsp, motion_est.o and
some H.263 specific parts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
9b409ea1e6 configure: Factor mpegvideoencdsp out of mpegvideoenc
This will allow to relax the dependency on mpegvideoenc
for several codecs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
2583c7abcf avcodec/svq1enc: Don't initialize unneeded block_index
The motion estimation code only uses block_index[0..3],
so only initialize that (just like estimate_motion_thread()
in mpegvideo_enc.c).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
83ddf99267 avcodec/svq1enc: Set MpegEncContext.avctx only once
It is already set during init.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
4b7f1595cc avcodec/svq1enc: Remove write-only c_block_{width,height}
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
58a222f561 avcodec/svq1enc: Stop calling ff_mpv_common_init()
It is not really needed, as none of the buffers allocated
in ff_mpv_common_init() are used lateron; in fact, ff_mpv_common_init()
is called with MpegEncContext.width and height equal to zero
(as well as encoding equal to zero, so that the error resilience
parts are initialized...), so that all the buffers are too small
anyway.

The call to ff_mpv_common_init() has been added in commit
f6774f905f in order to allocate
{current,last,new}_picture.f (an AVFrame). Yet this is unnecessary
since 7814dd77aa.

The only task that ff_mpv_common_init() does that may be used
is initializing the HpelDSPContext embedded in the MpegEncContext.
In fact, it was not initialized before
f6774f905f and not initializing
it passes FATE, yet I can't prove that it is indeed unnecessary.
Therefore it is still initialized and used instead of
SVQ1EncContext.hdsp.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
fbb8e605ed avcodec/svq1enc: Allocate motion_val{8,16} during init
It only depends upon the dimensions (which do not change).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
1fe08d629a avcodec/svq1enc: Don't free scratchbuf upon error
Forgotten in 65015003f5c4b83a8202abfa7420ccf37cde6ce3;
after said commit, freeing scratchbuf on error in svq1_encode_frame()
could lead to segfaults lateron, because the buffer will not
be allocated again.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00
109bf099d5 avcodec/motion_est: Fix indentation
Forgotten after 919e749772.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00
5b1e805653 avcodec/mpegvideo_enc: Remove always-true branch
Always-true since 1c40a17922
which made 4863671d88 superfluous.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00