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

120284 Commits

Author SHA1 Message Date
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
00926669f7 avcodec/mpeg_er: Mark ff_mpeg_er_init() as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00
01d6235fae avcodec/rv10: Avoid indirection when reading VLC codes
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00
c2e5f7466d avcodec/mpeg12dec: Don't store block_last_index unnecessarily
Given that the MPEG-1/2 decoders unquantize the blocks
on their own, block_last_index is only used to signal
to ff_mpv_reconstruct_mb() whether a block is skipped
or not; but this is only checked for inter macroblocks,
so it is unnecessary to set block_last_index for intra
macroblocks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00
069329ec02 avcodec/ituh263enc: Fix indentation
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00
a2272aff76 avcodec/ituh263enc: Don't use array unnecessarily
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00
d95041dffe avcodec/ituh263dec: Remove redundant store
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00
5507da21e6 avcodec/ituh263dec: Don't process unnecessarily many coefficients
Overriding the number of coefficients is only necessary if
ac_pred is in used, not for h263_aic alone (for which only
the DC coefficient is predicted) as it is done here.

And since d50635cd24
the H.263 unquantize-intra functions override the number of
coefficients in case of ac_pred, so we don't have to do this here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00
ea4b9a121d avcodec/rv10: Perform RV20 check only for RV20
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00
f5fc31acec avcodec/rv10: Perform RV20 initialization during init
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00
8e0f064a11 avcodec/mpeg4videodec: Don't zero blocks twice
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:51 +02:00
204d03c803 configure: Fix a regression when probing link.exe
The version ident is printed on stdout for link.exe and redirecting
stdout to /dev/null will cause the output of link.exe to be paged.

This caused configure to hang for some configurations and by
extension some FATE clients. You might want to check if you run
affected configurations automated in FATE clients or similar setups.

Fixes: 45a30e0361
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-06-21 22:37:44 +03:00
32153fac84 avfilter/af_aresample: rework activate logic to follow the advised flow more strictly
This should prevent the possibility of audio data accumulating.

The commit also cleans up and simplifies the code a bit so all frame producers
(filter_frame(), flush_frame()) functions follow similar logic as
ff_inlink_consume_frame() for the return code.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-06-21 20:24:57 +02:00
a21429e134 avfilter/af_aresample: make aresample return FFERROR_NOT_READY when no progress can be made
FF_FILTER_FORWARD_WANTED() already sets the ready status as needed.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-06-21 20:24:57 +02:00
ffcdd2cdc1 avfilter/af_aresample: merge request_frame into activate function
No functional change.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-06-21 20:24:57 +02:00
28a7b9c863 avfilter/split: consume all frames before forwarding inlink status
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-06-21 20:24:30 +02:00
606efaa2cf fftools/ffmpeg_filter: simplify control flow in read_frames
No functional change.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-06-21 20:24:30 +02:00
daef348574 avfilter/x86/f_ebur128: implement AVX peak calculation
Stereo only, for simplicity. Slightly faster than the C code.
2025-06-21 17:28:39 +02:00
3b26b782ee avfilter/f_ebur128: move peak detection to reusable DSP function
True peak and sample peak share almost the same logic. Define this logic in
a separate function for reusability, and so we can write SIMD versions.
2025-06-21 17:21:58 +02:00
4c046517e7 avfilter/f_ebur128: move variable declarations to usage site
This is actually allowed by non-ancient versions of C.
2025-06-21 17:21:58 +02:00
f362bacd27 avfilter/f_ebur128: lift sample peak calculation out of main loop
This is substantially faster (~55%) than the transposed loop, and also
avoids an unnecessary macro.
2025-06-21 17:21:58 +02:00
229393d8dc avfilter/f_ebur128: move true peak calculation out of main loop
Easier to read, less convoluted, and ~30% faster. Most importantly, this
avoids repeating the redundant recalculation of the true peak on every
single sample, by moving the FIND_PEAK() loop out of the main loop. (Note
that FIND_PEAK() does not depend on the current sample index at all, so
there is no reason for it to ever be recomputed here)
2025-06-21 17:21:58 +02:00
a96175e76f avfilter/f_ebur128: remove pointless macro
This macro is not shortening the code nor aiding readability.
2025-06-21 17:21:58 +02:00
53e03ec8af avfilter/x86/f_ebur128: add x86 AVX implementation
Processes two channels in parallel, using 128-bit XMM registers.

In theory, we could go up to YMM registers to process 4 channels, but this is
not a gain except for relatively high channel counts (e.g. 7.1), and also
complicates the sample load/store operations considerably.

I decided to only add an AVX variant, since the C code is not substantially
slower enough to justify a separate function just for ancient CPUs.
2025-06-21 17:21:36 +02:00
deab15e76a avfilter/f_ebur128: split off C implementation to separate function
I decided to separate out the peak measurement loop to avoid bloating
the signature, and since it's only conditionally used.
2025-06-21 17:19:50 +02:00
c7d2b0a7a1 avfilter/f_ebur128: move weights and cache to EBUR128DSPContext 2025-06-21 17:19:50 +02:00