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

119345 Commits

Author SHA1 Message Date
6ecdbcc454 avcodec/mpeg12enc: Merge ff_mpeg1_encode_init() into ordinary init
Everything except setting the dc_scale_tables can be done
before calling ff_mpv_encode_init(); setting the dc_scale_tables
unfortunately still has to be performed via a (now inlined)
callback performed by ff_mpv_encode_init() as it relies
on intra_dc_precision having been sanitized.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:12:38 +01:00
34557b1d30 avcodec/mpeg12enc: Move encode_init() to the end of the file
Will avoid forward declarations later.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:12:14 +01:00
edebd1d9a4 avcodec/mpegvideo_enc: Only set fcode_tab if unset
This is in preparation for merging ff_mpeg1_encode_init()
into the MPEG-1/2 encoder's init function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:11:49 +01:00
24dbc4c2e8 avcodec/mjpegenc: Simplify allocating huffman table
Reuse the already computed value of macroblocks; use an array
instead of a switch, evaluate 64 * sizeof(MJpegHuffmanCode)
at compile-time.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:11:26 +01:00
dcd4daee8c avcodec/mjpegenc: Make mjpeg_encode_init() call ff_mpv_encode_init()
Right now, ff_mpv_encode_init() is set as FFCodec.init and
calls ff_speedhq_encode_init(). The opposite is more natural,
avoids a non-static function and allows to reuse e.g.
slice_context_count instead of duplicating the logic from
ff_mpv_common_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:11:00 +01:00
9928b9e9fa avcodec/speedhqenc: Avoid indirection
Namely use avctx directly instead of s->avctx. While just at it,
also move the switch to the other checks involving avctx.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:10:37 +01:00
565e57ea87 avcodec/speedhqenc: Make speedhq_encode_init() call ff_mpv_encode_init()
Right now, ff_mpv_encode_init() is set as FFCodec.init and
calls ff_speedhq_encode_init(). The opposite is more natural
and avoids a non-static function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:10:12 +01:00
c757f948d1 avcodec/mpegvideo: Don't initialize [yc]_dc_scale_table by default
Only the H.263-based decoders as well as the encoders need it;
so move it to ff_h263_decode_init() as well as ff_mpv_encode_init().
Also for the latter make it only set these tables if none are
already set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:09:47 +01:00
b7ee7994cc avcodec/h261enc: Make h261_encode_init() call ff_mpv_encode_init()
Right now, ff_mpv_encode_init() is set as FFCodec.init and
calls ff_h261_encode_init(). The opposite is more natural
and avoids a non-static function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:09:23 +01:00
3275d788ec avcodec/mpegvideo: Move frame_skip_* fields to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:08:52 +01:00
4d79175b9a avcodec/mpegvideo_enc: Precalculate which frames to reconstruct
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:08:22 +01:00
d8c7925e32 avcodec/mpegvideoenc: Move ratecontrol to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:07:52 +01:00
bb0a72b100 avcodec/mpegvideoenc: Move tmp bframes to MPVMainEncContext
Also move b_frame_strategy and b_sensitivity and brd_scale;
they are all only used by an encoder's main thread when
b_frame_strategy == 2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:07:22 +01:00
f507f26e47 avcodec/mpegvideoenc: Add MPVMainEncContext
This is in preparation for moving all the elements from
MpegEncContext that are only used by the main encoder thread
to MPVMainEncContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:06:54 +01:00
ad4f6a3d6e avcodec/mpegvideo(_enc)?: Mark init, close functions as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:06:10 +01:00
08e334e462 avformat/movenccenc: add support for CENC AV1 encryption
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-25 20:59:18 -03:00
5631704d83 avcodec/cbs: allow fine tunning selection of features
Core framework and AV1 only for now.
This will be useful in an upcoming commit, where CBS will be utilized by
a module outside libavcodec.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-25 20:38:29 -03:00
3e0b38ed7f avcodec/cbs_av1: also store a pointer to the start of the tile group data
This will be useful a following commit, where the offset of the Tile Group
inside a Frame OBU needs to be known.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-25 11:09:16 -03:00
d435b641a2 MAINTAINERS: Add myself
will move to specific areas once they are there.

Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:38:21 +01:00
8af28d2eb1 avcodec/ffv1enc: Eliminate index_stack and delta_stack
This reduces stack space requirements my 1.5 mb and should fix fate

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:38:20 +01:00
051fd03f6c avcodec/ffv1enc: Heuristic to select fixed in float multipliers
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:32:14 +01:00
a33908d051 avcodec/ffv1enc: Factorize s.last_val update out
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:32:14 +01:00
836add03a8 avcodec/ffv1enc: Simplify last_val update
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:32:11 +01:00
4b24c5ba69 avcodec/ffv1enc: introduce step to simplify code
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:31:08 +01:00
e9cfed35a5 avcodec/ffv1enc: eliminate if()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:13 +01:00
522fc389e8 avcodec/ffv1dec: replace literal 65535 by what it is
should make the code easier to understand

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:13 +01:00
5ca14b23f1 avcodec/ffv1dec: compute end instead of hardcoding it and test for fltmap correctly
A step toward supporting remap for integer formats less than 16 bit

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:12 +01:00
3813559660 avcodec/ffv1enc: remap table size is 1<<bits_per_raw_sample not fixed 65536
not a bugfix as this path was only used for float16 but it makes sense
to allow using this for integers too

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:12 +01:00
e619b0d817 avcodec/ffv1enc: remap mode 2 is for floats only
(you could use it for others but it makes no sense)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:12 +01:00
8b2372cac7 ffmpeg-filter: check for initialized graph
Don't drop frame if graph hasn't been initialized yet!
2025-03-25 01:06:03 +05:30
044664ac3b avcodec/ffv1enc: remove mixed declarations and code
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 16:34:24 -03:00
a4cf0979a4 avcodec/ffv1enc: update missing Unit accesses inside av_assert2
Fixes compilation with assert-level=2.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 16:32:47 -03:00
702239bc50 avcodec/ffv1enc: reduce stack usage
Fixes failures in some systems since 171060d5dc.
This can be further improved by only allocating the arrays when needed.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 13:55:56 -03:00
fee5b0a383 fftools/ffmpeg_filter: ensure ifp is set before dereferencing it
Fixes segfaults since cbbc927a67.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 10:10:19 -03:00
5dcf566f69 avcodec/ffv1: Implement 2D RLE for remap
ATM this performs as well or better as any other algorithm tried.
Its simple for the decoder.
On the encoder side complexity depends on how parameters are
chosen. But with a fixed mul_count of 1 and basic heuristic
it performs as well as any more complex choice i tried so far.

The encoder code here is flexible and allows mul_count > 1
and also can easily be used to exactly test various parameters.

With mul_count=512 we can gain another 6% in remap table size
for fixed point in float data. (this is not implemented in this
patch though)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-24 13:46:59 +01:00
0538b4c569 avcodec/ffv1dec: remove unused var 2025-03-24 13:46:58 +01:00
e19496fe71 avcodec/ffv1enc: remap allows using rice golomb with more bits
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-24 13:46:58 +01:00
171060d5dc avcodec/ffv1: 32-bit float sample support
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-24 13:46:58 +01:00
62c7d08947 avcodec/ffv1: Fix remap ordering
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-24 13:46:57 +01:00
cbbc927a67 ffmpeg: add per-stream input option drop_changed
This is a replacement in ffmpeg for the deprecated avcodec flag AV_CODEC_FLAG_DROPCHANGED.

This option is meant to be used when the filtergraph should not be
reinited upon input parameter changes as that leads to loss of state
in the filtergraph potentially leading to broken or aborted output,
e.g. inserting of silence with first_pts specified in aresample.

Generally useful to avoid corrupted yet decodable packets in live
streaming inputs.

This option when enabled takes precedence over reinit_filters
2025-03-24 16:18:17 +05:30
323cb8c61e ffmpeg_demux: set default for readrate_catchup to be 5% faster
The existing default value is the same as the primary readrate.
This maintains the flow rate as best as possible but does not
reduce the lag. This new value allows catchup to gradually happen
without overwhelming the receiver.

Addresses a concern brought up in #11469
2025-03-24 16:17:47 +05:30
6fb1bbd73c avfilter/scale: remove duplicate block
Added in bb80445813
2025-03-24 16:17:13 +05:30
51b61ec35d avcodec/libuavs3d: pixel format should be native endian
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-24 14:54:46 +08:00
2a189d44b5 avcodec/avs3_parser: pixel format should be native endian
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-24 14:54:40 +08:00
1731eba20d avformat/mov: generalize sgpd_sync index lookup
The function has a nal_unit_type parameter but unused before.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-24 14:53:41 +08:00
c6214b0d69 avcodec/vt: Don't restart decoder when confronted with ReferenceMissingErr
Otherwise the decoder may enter an loop of repeated state resets.
This can happen for streams with CRA but no IDR.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-24 14:53:27 +08:00
26f2f03e0d swscale/x86/rgb2rgb: optimize AVX2 version of uyvytoyuv422
Currently the AVX2 version of uyvytoyuv422 in the SIMD loop does the following:
4 vinsertq to have interleaving of the vector lanes during load from memory.
4 vperm2i128 inside 4 RSHIFT_COPY calls to achieve the desired layout.

This patch replaces the above 8 instructions with 2 vpermq and
2 vpermd with a vector register similar to AVX512ICL version.

Observed the following numbers on various microarchitectures:

On AMD Zen3 laptop:
Before:
uyvytoyuv422_c:                                      51979.7 ( 1.00x)
uyvytoyuv422_sse2:                                    5410.5 ( 9.61x)
uyvytoyuv422_avx:                                     4642.7 (11.20x)
uyvytoyuv422_avx2:                                    4249.0 (12.23x)

After:
uyvytoyuv422_c:                                      51659.8 ( 1.00x)
uyvytoyuv422_sse2:                                    5420.8 ( 9.53x)
uyvytoyuv422_avx:                                     4651.2 (11.11x)
uyvytoyuv422_avx2:                                    3953.8 (13.07x)

On Intel Macbook Pro 2019:
Before:
uyvytoyuv422_c:                                     185014.4 ( 1.00x)
uyvytoyuv422_sse2:                                   22800.4 ( 8.11x)
uyvytoyuv422_avx:                                    19796.9 ( 9.35x)
uyvytoyuv422_avx2:                                   13141.9 (14.08x)

After:
uyvytoyuv422_c:                                     185093.4 ( 1.00x)
uyvytoyuv422_sse2:                                   22795.4 ( 8.12x)
uyvytoyuv422_avx:                                    19791.9 ( 9.35x)
uyvytoyuv422_avx2:                                   12043.1 (15.37x)

On AMD Zen4 desktop:
Before:
uyvytoyuv422_c:                                      29105.0 ( 1.00x)
uyvytoyuv422_sse2:                                    3888.0 ( 7.49x)
uyvytoyuv422_avx:                                     3374.2 ( 8.63x)
uyvytoyuv422_avx2:                                    2649.8 (10.98x)
uyvytoyuv422_avx512icl:                               1615.0 (18.02x)

After:
uyvytoyuv422_c:                                      29093.4 ( 1.00x)
uyvytoyuv422_sse2:                                    3874.4 ( 7.51x)
uyvytoyuv422_avx:                                     3371.6 ( 8.63x)
uyvytoyuv422_avx2:                                    2174.6 (13.38x)
uyvytoyuv422_avx512icl:                               1625.1 (17.90x)

Signed-off-by: Shreesh Adiga <16567adigashreesh@gmail.com>
2025-03-23 15:25:48 +00:00
fc44ccd981 configure: Add EXR decoder->bswapdsp dependency
Needed on BE systems.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-23 14:14:43 +01:00
9f0970ee35 tests/checkasm/videodsp: Don't use declare_func_emms
It allows the callee to clobber the MMX state,
yet since 1e3dc705df this is no longer
done. So use the stricter declare_func instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-22 03:45:03 +01:00
c94143350f avutil/libm: Only include intfloat.h when needed
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-22 03:35:28 +01:00