Compare commits

...

3890 Commits

Author SHA1 Message Date
David Korczynski 444f2cf047 avfilter/boxblur: Fix off by one errors
Fixes: ada-2-poc.mkv

Found-by: Claude and Ada Logics. This issue was found by Anthropic from using agents to study security of open source projects, and I am from Ada Logics helping validate the found issues and report to maintainers.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-16 17:22:45 +00:00
James Almer ef3ff9a73d avformat/iamf_writer: reject unset frame size
The specification states that nb_samples in codec config must not be zero.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:23 -03:00
James Almer 412aa48868 fftools/ffmpeg_mux_init: propagate the muxer request for fixed frame size
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:23 -03:00
James Almer c0bdc3b62a avformat/avformat: add an AVOutputFormat capability flag to signal fixed frame size is needed.
And set it on the IAMF muxer.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:22 -03:00
James Almer 8e162daf9a fftools:/ffmpeg_enc: honor the user request for fixed size frames
And set it also for non-variable frame size encoders.

FATE changes are the result of passing a frame_size to flac and wavenc
encoders, instead of letting them choose one.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:22 -03:00
James Almer 8567345514 tests/fate/lavf-audio: set frame_size on fate-lavf-ogg
Both worksaround a issue the following commit reveals (encoding with 4096
frame_size fails on aarch64 for unknown reasons), and tests setting
frame_size now that it's allowed (and ensuring the CLI doesn't overwrite it).

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:22 -03:00
James Almer 53d46a51fa avcodec/encode: propagate skip samples side data if present
Only for non-delay codecs.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:22 -03:00
James Almer 355d05a784 avcodec/encode: report that the padded samples must be discarded
For encoders where we pad the last frame, actually tag the silent samples as
discardable.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:22 -03:00
James Almer 7c5df8d34d avformat/matroskaenc: use frame_size to write audio DefaultDuration
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:22 -03:00
James Almer b1120b1ed8 avcodec: add a flag to force encoders to use fixed size frames
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:22 -03:00
James Almer bf2695e876 avcodec/pcm-dvdenc: don't allow the user to set frame_size
This is for an upcoming change where the field will become user settable.
Unless a proper check for frame_size is introduced, it's better to just not
allow arbitrary values to be used.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:22 -03:00
David Korczynski 08d7646abf avformat/assenc: Add the missing parentheses
Fixes: ada-1-poc.mkv

Found-by: Claude and Ada Logics. This issue was found by Anthropic from using agents to study security of open source projects, and I am from Ada Logics helping validate the found issues and report to maintainers.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-16 16:53:51 +00:00
Kacper Michajłow 200cbaeb5a avformat/hlsenc: use correct close function for custom io
This is open by s->io_open().

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 18:03:26 +02:00
Kacper Michajłow 06ef9a74ea avformat/hlsenc: respect io_open set in AVFormatContext
io_open_default() will call internal impl if needed, don't call it
directly.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 17:18:51 +02:00
Kacper Michajłow 4cf687b3b1 avformat/dashenc: respect io_open set in AVFormatContext
io_open_default() will call internal impl if needed, don't call it
directly.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 17:18:51 +02:00
Kacper Michajłow fbc4003642 avformat/dashdec: respect io_open set in AVFormatContext
io_open_default() will call internal impl if needed, don't call it
directly.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 17:18:51 +02:00
Michael Niedermayer 37c176a2a2 tests/fate/voice: Add fate-g726le-encode
Co-Authored-by: AI
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-16 15:09:52 +00:00
Thai Duong bbdce45fda avcodec/diracdec: Enlarge mctmp to cover the worst-case blheight·ybsep + yblen rows, and break the MC loop when no output rows remain
Fixes: ffmpeg_ANT-2026-02842_dirac-mctmp-heap-overflow

Discovered by Claude (Anthropic). Confirmed and reported by Thai Duong (Calif.io).

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-16 15:03:50 +00:00
Kacper Michajłow dc74fe70b2 avformat/demux: use correct close function for custom io
You may look and think `AVFMT_FLAG_CUSTOM_IO` check is enough, but this
is not what it seems. This flag means that user provided custom
AVIOContext, before creating AVFormatContext and it should not be
closed. However nested sub-demuxers may still open an temporary io, and
those have to be closed and use correct io_close2 function.

You can see 0dcac9c3f0 and
ef01061225 where this flag is cleared for
nested opens to avoid leaking those.

lavf micro version bumped so API users can know if it is safe to use
custom io.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 11:09:56 +00:00
Stuart Eichert 2aad4fb2e3 Typo: Remove space in 'centiseconds', 'microseconds', and 'nanoseconds'.
According to Chapter 3, Paragraph 2 of the "SI Brochure - 9th ed./version 3.02":

> Prefix symbols are printed in upright typeface, as are unit symbols,
> regardless of the typeface used in the surrounding text and are
> attached to unit symbols without a space between the prefix symbol
> and the unit symbol.

https://www.bipm.org/documents/20126/41483022/SI-Brochure-9-EN.pdf
2026-05-15 18:19:40 -07:00
James Almer 18b83f2d0a tools/zmqsend: close the input FILE
Fixes CVE-2026-30998

Fixes: Resource leak
Found-by: Xinghang Lv
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-15 20:35:56 -03:00
James Almer 144af8f81a tools/zmqsend: free the AVBprint buffer after using it
Fixes CVE-2026-30999

Fixes: memleak
Found-by: Xinghang Lv
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-15 20:32:24 -03:00
Link Mauve b5fc215e2d avformat/mods: Return EOF for packets starting at the index offset
Assuming there is no padding between the last packet and the index, this
prevents the index from being parsed as a normal packet, with non-
sensical data.
2026-05-15 19:30:52 +00:00
Link Mauve c4b7a51d35 avformat/mods: Parse the index entries
This lets us seek in the video properly, based on the table at the end
of the files, and has been tested with Suikoden Tierkreis videos.

While at it I’ve also set the duration of the stream, this makes the
progress bar work correctly in mpv.
2026-05-15 19:30:52 +00:00
Andreas Rheinhardt 00ff728512 avfilter/vf_pp7: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-15 20:29:29 +02:00
Andreas Rheinhardt 7971953d29 avfilter/x86/vf_pp7: Port ff_pp7_dctB_mmx to SSE2
Unfortunately a bit slower than the MMX version due to
the impossibility to use memory operands in paddw.
The situation would reverse if ff_dctB_mmx() would have
to issue emms.

dctB_c:                                                  3.7 ( 1.00x)
dctB_mmx:                                                3.3 ( 1.13x)
dctB_sse2:                                               3.6 ( 1.03x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-15 20:29:29 +02:00
Andreas Rheinhardt fc9e63474f avfilter/vf_pp7dsp: Add restrict
Makes GCC optimize the scalar codepath away.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-15 20:29:29 +02:00
Andreas Rheinhardt 94a49068db tests/checkasm: Add vf_pp7 checkasm test
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-15 20:29:29 +02:00
Andreas Rheinhardt 617a9afeb4 avfilter/vf_pp7: Add proper PP7DSPContext
This is in preparation for checkasm tests for dctB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-15 20:29:29 +02:00
Andreas Rheinhardt 0a1faa7202 avfilter/vf_pp7: Constify
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-15 20:29:29 +02:00
Niklas Haas 76dc83d9be swscale/ops_dispatch: make ff_sws_ops_compile() output optional
Allows the uops macro generation code to not actually compile any passes.
More generally, this could be used to e.g. test if an op list is supported by
a backend without actually creating the passes.

The `bool first` change is needed because the `input == prev` check no longer
works if we don't actually compiled any passes.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas 420b1bf368 swscale/ops_dispatch: allow forcing specific ops backend
This will be used eventually when I rewrite checkasm/sw_ops to re-use the
code in ops_dispatch.c instead of hand-rolling the execution layer.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas 9021448857 swscale/ops_dispatch: merge ff_sws_ops_compile_backend() and compile()
Passing backend == NULL now loops over the backends as before.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas ad17144ce6 swscale/ops_dispatch: move op list print to ff_sws_ops_compile_backend()
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas 90669ab52e swscale/ops: move ff_sws_compile_pass() and friends to ops_dispatch.h
This function actually lives in ops_dispatch.c, and doesn't really make
sense in ops.h anymore. We should also move some stuff out of ops_internal.h,
which doesn't depend on any external ops stuff, here.

This allows the backend/compilation-related stuff to co-exist more nicely.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas 1d841635a4 swscale/ops: also include scaling ops in ff_sws_enum_op_lists()
Using the configured scaler from the SwsContext implicitly. This does affect
the output of libswscale/tests/sws_ops.c, which now prints about 4x as much
data (taking roughly 4x as long, but still within a second on my machine).

We can make this process a lot faster by forcing SWS_SCALE_POINT as the
scaler, which skips calculating any actual filter weights in favor of
generating a trivial 1-tap filter.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas eec9f712f5 swscale/ops: re-use ff_sws_op_list_generate() in ff_sws_enum_op_lists()
The only difference here is an extra ff_sws_add_filters() call, which is
a no-op because src w/h = dst w/h = 16.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas cac183f46f swscale/ops: don't silently suppress non-ENOTSUP errors
Matches the behavior to the comment.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas dacbf080f3 swscale/ops_chain: simplify ff_sws_op_compile_tables() signature
This no longer accesses prev/next as a result of the `unused` removal, so
the signature can be simplified to just take the op directly.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas 064600585e swscale/ops_chain: remove flexible from SWS_OP_MIN/MAX entries
We have other op types that skip checking the data even in non-flexible mode,
so there is a precedent for just leaving away `flexible` for such kernels.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas 98c1dbafbe swscale/ops_memcpy: don't depend on ops_backend.h
This is private to the C template based backend.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas 62aad4513c swscale/graph: move format conversion logic to formats.c
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas 0611abc1bb swscale/graph: move code for adding filters to format.h
Mirroring the precedent established by the other SwsOp-generating functions.
This allows us to re-use it for the uops macro generator.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas 9fe0ff3d56 swscale/graph: make _reinit() only call _init(), not _create()
This allows us to preserve the same memory allocation when
reinitializing a graph, which is a nice bonus.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas 56305c460c swscale/graph: add ff_sws_graph_alloc() and _init()
As an alternative to the current _create() API.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Niklas Haas 5e0dddef80 swscale/graph: move graph uninit logic to helper function
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-15 18:53:05 +02:00
Ramiro Polla d0a84c660a swscale/unscaled: fix rgbToRgbWrapper for non-native-endian formats
The fix from 5fa2a65c11 introduced a regression for non-native-endian
formats (such as rgb565be on a little-endian system).

Reproducible with:
$ ./libswscale/tests/swscale -unscaled 1 -src rgb565be -dst rgb24

Also:
$ ./ffmpeg_g -i /opt/samples/jpegls/128.jls -vf "scale=size=512x512,format=rgb24,scale=flags=neighbor,format=rgb565be" -f rawvideo -vframes 1 -y rgb565be.raw
$ magick -size 512x512 -endian MSB RGB565:rgb565be.raw output.png
$ ./ffplay_g output.png

(note: don't use ffmpeg to convert from rgb565be.raw to output for the
test above since it will perform the same bug and cancel out the error)
2026-05-15 14:21:50 +00:00
Ramiro Polla d812c8b0eb swscale/tests/swscale: log test parameters on loss error
When running with "-v 0", the test parameters were not being printed,
which made it hard to track down which conversion the error referred
to.

Now the test parameters are logged with av_log() when a loss error
happens.
2026-05-15 14:12:48 +00:00
Ramiro Polla 1cc9b15bab swscale/tests/swscale: fix -p option when -flags and/or -unscaled are used
The -p, -flags, and -unscaled options all affected the decision to
select a subsample of the tests to run. When specifying -p 0.1, about
57% of the tests would run instead of the expect 10%.

This commit fixes this by separating -p from -flags and -unscaled.
2026-05-15 14:12:48 +00:00
Ramiro Polla 24d432e227 swscale/tests/swscale: improve help text for -p option 2026-05-15 14:12:48 +00:00
Andreas Rheinhardt b2867481d9 avformat/avformat: Add AVFMT_EXPERIMENTAL to allowed flags
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-14 22:58:04 +02:00
Marton Balint 43bbd6dbf9 avformat/utils: avoid void pointer arithmetic
Fixes compliation on MSVC.

Regression since cb708d8703.

Based on code by James Almer.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-05-14 20:52:45 +02:00
Ben Kepner a327bc0561 avformat/hlsenc: fix segment duration with mixed stream time bases
When audio and video streams have different time bases (e.g. video at
1/90000 and audio at 1/48000), vs->start_pts was stored as a raw PTS
from whichever stream's packet arrived first. The segment split
comparison then subtracted this value from the current packet's PTS
without accounting for the time base difference, producing incorrect
elapsed time calculations.

This caused segments to be split at wrong points — either too
frequently (on every keyframe) or not at all, depending on the
relative magnitudes of the time bases.

Fix by normalizing vs->start_pts to AV_TIME_BASE_Q at the point of
assignment and converting pkt->pts to the same base before comparison.
This ensures the segment split decision is always unit-consistent
regardless of which stream's packet is being evaluated.

The bug is most easily triggered by HLS muxing with video passthrough
and audio transcode, where the video retains its container time base
while the audio encoder outputs in its native time base.

Signed-off-by: Ben Kepner <u6bkep@gmail.com>
2026-05-13 23:04:46 +00:00
Marton Balint 566ad7869e avformat/hlsenc: remove unused function parameter
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-05-13 22:41:23 +02:00
Marton Balint f20ea3fb22 avformat/hlsenc: dynamically allocate segment uris along with the segment struct
As suggested by Andreas Rheinhardt.

Supersedes: #22536.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-05-13 22:41:23 +02:00
Marton Balint cb708d8703 avformat/utils: add ff_bprint_finalize_as_fam to put bprint strings to flexible array members
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-05-13 22:41:23 +02:00
Kirill Gavrilov 553321d59e libavcodec/hdrdec: accept "#?RGBE" header in addition to "#?RADIANCE"
Some Radiance HDR image files in the wild have "#?RGBE" header,
which other image readers accept.

Also updated hdr_probe() in libavformat/img2dec.
2026-05-13 19:35:33 +00:00
Vignesh Venkat f69aa0cc64 avcodec/aomenc: Handle Smpte2094App5 metadata
If packets contain Smpte2094App5 metadata, pass it to
the libaom encoder.

Signed-off-by: Vignesh Venkat <vigneshv@google.com>
2026-05-13 19:13:23 +00:00
Lynne 2d826f18fb vulkan/prores_raw: don't load the quantization matrix on every invocation 2026-05-14 02:55:53 +09:00
Lynne 13aabf726b vulkan/prores_raw: specify format on image
Unlike other decoders or encoders, prores_raw only has a single
Vulkan format to worry about.
This is a 20% speedup on AMD, since AMD apparently has optimizations
for this.
2026-05-14 02:55:53 +09:00
Lynne a2737497de vulkan/prores_raw: add skip_bits_unchecked and use it
show_bits(gb, 32) is called immediately above. It guarantees that
the following skip_bits call will not need to reload.
2026-05-14 02:55:53 +09:00
Lynne 5dc567a28e vulkan/prores_raw: remove redundant fast golomb parsing path 2026-05-14 02:55:52 +09:00
Lynne 64f848890c vulkan/prores_raw: use 16-bit/32-bit uints where needed
16-bit ints can overflow.
2026-05-14 02:55:52 +09:00
Lynne 74e3d63fb6 vulkan/prores_raw: use get_bits shared memory cache
50% speedup on AMD.
2026-05-14 02:55:52 +09:00
Lynne 67811c2754 vulkan/common: fix get_bit() with SMEM caching
First of all, it uses the wrong data pointer. Second, gb.bits wouldn't
get set if LOAD64 was called after the start of the stream.
2026-05-14 02:55:48 +09:00
jiangjie 8ffaead836 fftools/ffmpeg_filter: fix frame reference leak in fg_output_step
When clone_side_data() fails in fg_output_step(), the function returns
without calling av_frame_unref(frame), leaking the frame reference.
2026-05-13 14:09:06 +00:00
Marvin Scholz 7e045dfbfc ffprobe: implement printing IAMF frame side data 2026-05-13 15:19:11 +02:00
Marvin Scholz 65635453cb avcodec: map IAMF packet side data to frame side data 2026-05-13 15:19:11 +02:00
Marvin Scholz 99908c6e05 avutil: add IAMF frame side data types
These contain the same data as the packet side data equivalents.
2026-05-13 15:19:11 +02:00
jiangjie 22d06b39ce avfilter/avfilter: fix memory leak of filter name in ff_filter_alloc error path
When ff_filter_alloc fails after the name has been allocated (via
av_strdup), the error handling code frees inputs and input_pads but
misses freeing ret->name, causing a memory leak.

Add av_freep(&ret->name) in the error path before freeing inputs.
2026-05-13 20:11:19 +08:00
Marvin Scholz 4851060ccd avutil: hdr_dynamic_metadata: fix error code
When s is NULL in av_dynamic_hdr_smpte2094_app5_from_t35, that's not an
allocation error but just invalid API usage. If there is any allocation
failure beforehand that would lead to this, the caller has to check it,
like is already done in all usages of this function in FFmpeg itself.
2026-05-12 17:18:38 +02:00
Marvin Scholz 37ff8fad47 avutil: hdr_dynamic_metadata: handle allocation failure
Handle allocation failure properly in
av_dynamic_hdr_smpte2094_app5_from_t35.

Fixes Coverity issue #1691448
2026-05-12 17:18:38 +02:00
Marvin Scholz 3dbc3c6954 avcodec/libvorbisenc: conditionally set initial_padding
Only set initial_padding when vorbis_analysis_blockout succeeds,
this avoids passing uninitialized data/garbage pointer to
av_vorbis_parse_frame.

Fix Coverity Issue 1681345
2026-05-12 15:17:28 +00:00
Andreas Rheinhardt c29d1b9df5 avformat/id3v2: Fix indentation
Forgotten after e9c372362c.

Reviewed-by: Romain Beauxis <toots@rastageeks.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-12 16:12:54 +02:00
Andreas Rheinhardt 356e427d5c avformat/id3v2: Use proper logcontext
Otherwise one could not associate log messages with inputs.

Reviewed-by: Romain Beauxis <toots@rastageeks.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-12 16:12:51 +02:00
Andreas Rheinhardt e626b02a01 avformat/id3v2: Avoid temporary buffer
Reviewed-by: Romain Beauxis <toots@rastageeks.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-12 16:11:56 +02:00
Marvin Scholz 18761f9fb5 avformat/rtpdec_av1: fix buffer overflow due to variable confusion
The pktpos denotes the position in the output packet buffer, while
buf_ptr is the position in the input buffer. As this payload is ignored,
nothing is written to the output packet so increasing the pktpos does
not make sense here, instead the buf_ptr has to be increased to advance
the input buffer to the correct position after this OBU.

This incorrect increment here could result in pktpos exceeding the whole
size of the output packet and the later call to memcpy to write to that
buffer would start its write way past the end of the packet buffer.

Fix #22812

Reported-By: fre3dm4n
2026-05-12 16:02:51 +02:00
nyanmisaka d01d18ad71 vulkan: fix using encode caps before querying
Fix using enc_caps.supportedEncodeFeedbackFlags before
calling vkGetPhysicalDeviceVideoCapabilitiesKHR().

Otherwise the check will never pass and will fail with ENOTSUP.

Fixes 3f9e04b

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-05-12 11:28:09 +00:00
David Rosca 6b3e0f903e vulkan_encode: Fix description for quality option
From spec:
  Generally, using higher video encode quality levels may produce
  higher quality video streams at the cost of additional processing time.
2026-05-12 09:14:34 +00:00
Vignesh Venkat 2c1af16872 avformat/matroskaenc: Use correct buffer for smpte2094_app5
In the call to mkv_write_blockadditional, use the correct
buffer for smpte2094_app5.

Commit 38df985fba updated the
buffer usage to prevent incorrect buffer reuse, but left this line
unchanged inadvertently.

Signed-off-by: Vignesh Venkat <vigneshv@google.com>
2026-05-11 14:44:25 -07:00
Vignesh Venkat e1797cdd51 avcodec/libvpxenc: Copy Smpte2094App5 metadata
If incoming packets contain Smpte2094App5 metadata, retain them
so that they are passed through to the output.

Signed-off-by: Vignesh Venkat <vigneshv@google.com>
2026-05-11 20:17:11 +00:00
Niklas Haas c1ff2c24b5 swscale/filters: hard-code radius for trivial kernels
box() and triangle() have well-defined, trivially verifiable numerical
inverses.

We could actually pre-compute and hard-code the numerical inverse of all
non-parametric kernels, but I'm a bit reluctant to do this as I have plans to
adjust the value of SWS_MAX_REDUCE_CUTOFF based on the desired bit depth of the
output, which makes a hard-coding approach unfeasible.

(It would also be a brittle solution that may break whenever we extend the
scaler configuration API, as well as making it harder to add new filters)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-11 19:59:39 +02:00
Nariman-Sayed 837cf8e38f avformat/tls_mbedtls: fix DTLS handshake failure when receiving non-DTLS packets
Some WebRTC servers such as Pion send STUN packets concurrently during
the DTLS handshake. Unlike OpenSSL and GnuTLS which filter non-DTLS
packets internally, mbedtls passes all received UDP packets directly to
its DTLS state machine, causing the handshake to fail.

Fix this by using ff_is_dtls_packet() in mbedtls_recv to discard
non-DTLS packets such as STUN by returning WANT_READ, as specified
by RFC 5764 Section 5.1.2.

Signed-off-by: Nariman-Sayed <narimansayed28@gmail.com>
2026-05-11 12:36:58 +00:00
Nariman-Sayed 094f72748d avformat/tls: move DTLS packet detection into ff_is_dtls_packet()
Move the DTLS packet detection logic from whip.c into a shared
ff_is_dtls_packet() function in tls.c, with its declaration and
related macros in tls.h. Update whip.c to use the new shared function.

Signed-off-by: Nariman-Sayed <narimansayed28@gmail.com>
2026-05-11 12:36:58 +00:00
Kacper Michajłow 17bc88e67f avformat/hls: disable http_persistent/http_multiple with custom io_open
Both rely on the AVIOContext being backed by the builtin URLContext.
When the API user overrides io_open, the keepalive path asserts on the
missing URLContext and the http_multiple auto-detect probe fails on
every read. http_multiple=1 still works even with custom IO.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-11 09:00:31 +00:00
Lynne fd25b35dd2 vulkan_ffv1: support decoding 32-bit float video
Sponsored-by: Sovereign Tech Fund
2026-05-11 05:32:41 +09:00
jiangjie a67c15dfa5 avutil/hwcontext_vulkan: fix resource leak on alloc_mem failure
Fix by using goto fail so that vulkan_frame_free() properly cleans up
all previously created resources.
2026-05-10 20:01:47 +00:00
Andreas Rheinhardt f16ec8913e avcodec/h264_cavlc: Fix indentation
Forgotten after 8d6947bc7d.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-10 17:16:38 +02:00
Dale Curtis 5bbc00c05d [Wave] Fix issues with unaligned metadata chunks.
Fixes corruption issues with the sample in this PR.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
2026-05-10 01:18:09 +00:00
Michael Niedermayer 188461be10 avformat/mpegts: Dont assume fc->priv_data is a MpegTSContext
Fixes: out of array access
Fixes: 508365271/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-6219535958212608

Regression since: b9cb948ec1

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-09 18:35:08 +00:00
James Almer b2dfc14276 avcodec/vvc_parser: properly split PUs when a Prefix SEI NUT is found
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-09 11:44:39 -03:00
James Almer 2948acd528 avformat/nal: take into account removed zero bytes when calculating buffer size in nal_parse_units()
Fixes issue #23010

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-09 11:28:46 -03:00
jiangjie 2f4ad2497e avformat/movenc: fix dynamic buffer leaks on error paths
In mov_write_iacb_tag(), the dynamic buffer dyn_bc was leaked when
ff_iamf_write_descriptors() failed.

In mov_write_track_udta_tag(), the dynamic buffer pb_buf was leaked
when mov_write_track_kinds() failed, as the error path returned
directly instead of going through cleanup.

Fix both by ensuring ffio_free_dyn_buf() is called on all error paths.
2026-05-09 19:27:17 +08:00
Zhao Zhili 180a10647d avformat/tee: clean up local resources on program copy failure
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-05-09 10:46:35 +00:00
Vignesh Venkat 8518599cd1 avformat/matroskaenc: Write additional mappings for webm
The elements written in mkv_write_blockadditionmapping
(MaxBlockAdditionID, BlockAddIDType and BlockAddIDValue) are all
allowed in WebM as well. Move them out of the "if (!IS_WEBM)"
block.

Matroska spec:
https://www.matroska.org/technical/elements.html#MaxBlockAdditionID
(See column with title "W" which shows WebM availability).

WebM spec:
https://www.webmproject.org/docs/container/#MaxBlockAdditionID

Signed-off-by: Vignesh Venkat <vigneshv@google.com>
2026-05-08 13:33:31 -07:00
Andreas Rheinhardt c8a4770599 avcodec/vc1dsp: Consistently use ptrdiff_t for stride
Also do the same in the x86 MMX code and its MIPS MMI clone.

Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-08 13:28:34 +02:00
Andreas Rheinhardt ff0ad0278d avcodec/cbs: Move ff_cbs_all_codec_ids to cbs_bsf
Only used as AVBitStreamFilter.codec_ids. This avoids duplicating
it into lavf.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-08 09:35:38 +02:00
Andreas Rheinhardt b6d2a0fc66 configure: Add missing apv_metadata->cbs_apv dependency
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-08 09:35:35 +02:00
Andreas Rheinhardt 6a59c847b5 configure: Redo enabling cbs in lavf
Right now, the cbs_type_table (the table of all CodedBitstreamTypes
supported by CBS) is empty unless cbs_apv and cbs_av1 is enabled.
The latter are only enabled in configure if they are needed in lavc.
This means that the mov muxers (the only users of cbs-in-lavf)
don't work as they should depending upon the availability of
e.g. the av1_metadata BSF. The table being empty is also illegal C
and according to PR #23038 MSVC warns about this (as does GCC
with -pedantic) and it may even lead to an internal compiler error.

This could be fixed by simply adding a mov_muxer->cbs_av1,cbs_apv
dependency in configure, yet this would have the downside that
it would force cbs_av1 and cbs_apv to be built for lavc, too,
even though it may not be needed there. So add new configure
variables cbs_{apv,av1}_lavf and cbs_lavf to track this correctly.

Reported-by: xiaozhuai <798047000@qq.com>
Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: xiaozhuai <798047000@qq.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-08 09:34:52 +02:00
Manuel Lauss 0f45541e04 avcodec/sanm: extend the codec37 mv table to 3x512 entries
the c37_mv table is 3x 510-entry tables combined.  Extend each
with a coordinate pair for index 0xff, which allows to eliminate
the index check in the code37/48 block handlers.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2026-05-08 05:08:22 +00:00
Manuel Lauss b418da28bf avcodec/sanm: fobj: apply the x/y offsets after size determination
Otherwise a wrong size might be determined.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2026-05-08 05:08:22 +00:00
Manuel Lauss 01d895340c avcodec/sanm: accept fixed dimensions for ANIM at decode_init
This undoes 556cef27d9, which I added to fix a fuzzer-crash,
but there's no reason to expect the decoder can only be invoked
via the smush demuxer.  Instead also accept a range of dimensions
from 2x2 up to 640x480.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2026-05-08 05:08:22 +00:00
Manuel Lauss d1577bc018 avcodec/sanm: fobj codec37+: reject too large frames.
For the diff-buffer codecs, return error for frames that are larger
than the currently configured canvas.  This mimics the behaviour
of the DOS smush engines.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2026-05-08 05:08:22 +00:00
Manuel Lauss cc2f9ff14f avcodec/sanm: fobj: do not use codec-id to determine canvas size.
Codec>=37 with smaller dimensions can be embedded onto larger canvasses;
it makes no sense to trust their dimensions explicitly.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2026-05-08 05:08:22 +00:00
Yong Yu 9ab345b2d1 fftools/graph: Add missing include "libavutil/mem.h" for fftools/graph/graphprint.c
when HAVE_AV_CONFIG_H is defined, include libavutil/mem.h
is skipped in libavutil/common.h.
Need this header file to build successfully.
2026-05-07 22:00:38 +00:00
Romain Beauxis 0f2e693956 tests/fate/id3v2.mak: add new tests for comm, lyrics, txx and wma
comments.

Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-05-07 09:46:53 -05:00
Romain Beauxis 85cc813412 libavformat/tests/id3v2: add test program for raw ID3v2 frame debugging
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-05-07 09:46:37 -05:00
Romain Beauxis 910d796430 libavformat/id3v2: wire FF_FDEBUG_ID3V2 frame debugging
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-05-07 09:46:17 -05:00
Michael Niedermayer b5c7c7d273 avcodec/cbs_h266_syntax_template: tighten sh_num_tiles_in_slice_minus1 upper bound
Fixes: out of array access

Found-by: Vishal Panchani
Fix suggested by: Vishal Panchani
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-07 13:08:34 +00:00
Zhao Zhili a17e96b103 avcodec/hevc: scope missing-ref loop counters locally 2026-05-07 13:01:16 +00:00
Zhao Zhili 3b939ced79 avcodec/hevc: limit missing-ref fill to coded planes
generate_missing_ref walked frame->f->data[] until a NULL slot, which
on alpha-video frames extended to data[3] and read
sps->hshift[3]/vshift[3] out of bounds.

The alpha plane is produced by the alpha layer via
replace_alpha_plane; the base decoder path never reads or writes it.
Bound the fill loop by the SPS coded plane count. This both removes
the out-of-bounds shift access and avoids an unnecessary full-frame
memset of the alpha plane.

Fixes: out of array read
Fixes: 500770604/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6157374833623040

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2026-05-07 13:01:16 +00:00
牟凡 28ecb07e55 avcodec/cbs_h266: fix wrong condition for chroma MTT depth in PH
In the picture header parser, the chroma branch incorrectly tested
sps_max_mtt_hierarchy_depth_intra_slice_chroma to decide whether to
parse ph_log2_diff_max_{bt,tt}_min_qt_intra_slice_chroma.

Per ITU-T H.266 (V4, 01/2026) section 7.3.2.8 "Picture header
structure syntax", the condition is on the just-parsed
ph_max_mtt_hierarchy_depth_intra_slice_chroma, exactly mirroring the
luma branch a few lines above and the inter-slice branch below.
sps_partition_constraints_override_enabled_flag allows the picture
header to override the SPS values, so testing the SPS field is
incorrect and desynchronises the parser whenever the PH override
changes the chroma MTT depth from/to zero.

Signed-off-by: Mou Fan <moufan17@126.com>
2026-05-07 10:42:44 +01:00
Andreas Rheinhardt f2e5eff3ff avcodec/atsc_a53: Avoid GetBits API to parse A53 CC data
This fixes overreads with libdav1d, because it provides
non-padded data in violation to the requirements of
the GetBits API.

Furthermore, using the GetBits API here is wasteful,
as the offsets here are known and the actual data to be copied
is even byte-aligned, allowing to use memcpy.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-06 15:27:21 +02:00
ldm0 17734f6967 doc/examples/demux_decode: update ffplay command for audio and video output
Signed-off-by: ldm0 <liudingming@bytedance.com>
2026-05-05 23:44:42 +00:00
Dale Curtis 256d93413f avformat/mov: Fix negative index given to can_seek_to_key_sample()
The potentially negative return value of av_index_search_timestamp()
wasn't being handled before passing it to can_seek_to_key_sample().

Found by Wongi Lee (@_qwerty_po) of Theori with Xint Code,
Jungwoo Lee (@physicube).

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
2026-05-05 21:26:38 +00:00
Andreas Rheinhardt 5c44245878 avutil/hwcontext_vulkan: Fix shadowing
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-05 12:46:26 +02:00
Andreas Rheinhardt 3fbf5faa3f avutil/hwcontext_vulkan: Add av_fallthrough
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-05 12:46:23 +02:00
Andreas Rheinhardt 310cf06a27 avcodec/av1dec: Avoid implicit fallthrough
Fixes a -Wimplicit-fallthrough warning from Clang;
GCC does not warn about this.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-05 12:46:00 +02:00
Gyan Doshi 7fc335cb27 avformat/tee: relay programs to child muxers 2026-05-05 12:54:40 +05:30
Gyan Doshi 1b82e58a3a avformat/segment: relay programs to child muxers 2026-05-05 12:54:40 +05:30
Gyan Doshi 0005b36eb7 avformat/hlsenc: relay programs to child muxers 2026-05-05 12:54:40 +05:30
Gyan Doshi 5c557dd5d5 avformat: add av_program_copy()
Helper to transfer programs from one muxing context to another.
2026-05-05 12:54:36 +05:30
Gyan Doshi 7623379a77 avformat: add av_program_add_stream_index2()
av_program_add_stream_index() added in 526efa1053
may fail to carry out its purpose but the lack of
a return value stops callers from catching any error.

Fixed in new function.
2026-05-05 12:51:54 +05:30
Andreas Rheinhardt 1c522ffdef avcodec/x86/mpegvideoenc{,_template}: Remove remnants of MMX
Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-04 17:31:05 +02:00
Andreas Rheinhardt d328a02a9a avcodec/x86/vp6dsp_init: Update obsolete comment
Forgotten in 6cb3ee80b3.

Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-04 17:31:01 +02:00
Andreas Rheinhardt 564f610cbf avcodec/x86/vc1dsp_loopfilter: Remove MMXEXT funcs overridden by SSSE3
Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-04 17:28:28 +02:00
Andreas Rheinhardt 6a46ea7da2 avcodec/x86/constants, h263_loopfilter: Move pb_FC to h263_loopfilter
Only used there.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-04 16:57:18 +02:00
Thilo Borgmann aa14727cd5 avcodec/webp: export XMP metadata
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-05-04 12:47:30 +02:00
huanghuihui0904 b40d91cad9 avformat: avoid potential tmp_opts leak in ffurl_connect()
When options is NULL, ffurl_connect() creates a temporary dictionary
(tmp_opts). If the protocol_blacklist av_dict_set() fails after the
whitelist entry was inserted, the function returns without freeing
this dictionary.

Ensure tmp_opts is freed on this error path.

Signed-off-by: Huihui_Huang <hhhuang@smu.edu.sg>

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-03 20:32:16 +00:00
João Neves 2c71a28bf0 avcodec/hdrdec: fix pixel count decrement in RLE decompress loop
The w variable counts pixels, not bytes. The non-RLE path correctly
uses w-- (one pixel = 4 bytes), but the RLE path uses w -= 4, causing
the loop to terminate after roughly 1/4 of the expected pixels.

The w -= 4 was introduced in 14e99cb472 which moved the decrement
inside the loop to fix an OOB write (clusterfuzz-5423041009549312).
The move was correct, but the decrement value should have been 1 to
match the non-RLE path.

Signed-off-by: João Neves <joaocns0@protonmail.com>
2026-05-03 20:19:51 +00:00
João Neves daedf4012d avcodec/exr: check rle() return value in rle_uncompress()
rle_uncompress() silently discards the return value of rle(). When the
compressed data is malformed and rle() returns AVERROR_INVALIDDATA,
processing continues on a partially filled buffer. Propagate the error
to the caller, which already handles it at line 1420.

Signed-off-by: João Neves <joaocns0@protonmail.com>
2026-05-03 20:15:54 +00:00
Alexander Slobodeniuk 1e9dd2b7e9 avformat/mpegts: handle AC-4 descriptor in DVB extension
as defined in ETSI EN 300 468 (Table 109).

This allows ffprobe to recognize that .ts
file has an ac4 stream.

Checked on the files downloaded from
https://ott.dolby.com/OnDelKits/AC-4/Download_v15.html
2026-05-03 20:10:26 +00:00
Alexander Slobodeniuk dd020e1025 avformat/mpegts: simplify ac3/eac3 descriptor handling
those lines are literally the same, so removing the
code duplication
2026-05-03 20:10:26 +00:00
Alexander Slobodeniuk cda069b092 avformat/mpegts: don't check impossible branches
Quit dvb extension handling when the descriptor
have been processed
2026-05-03 20:10:26 +00:00
Jesper Ek d5a913f99f avformat/gxf: return proper errors when reading header/packet
Returning -1 resulted in an "operation not permitted" error which
was incorrect. This changes the error to a correct "invalid data".
2026-05-03 20:03:00 +00:00
James Almer 1a2c16fe51 avcodec/av1dec: check that primary_ref_frame is within range
Fixes CVE-2026-30997

Fixes: Out-of-Bounds Access
Found-by: Xinghang Lv
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-03 15:55:21 -03:00
Romain Beauxis f80431dc4e .forgejo/CODEOWNERS: fix ogg pattern for @toots 2026-05-03 17:05:25 +00:00
James Almer 3393dc3020 avformat/dashdec: propagate parsing requirement from the underlying demuxer
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-03 17:00:17 +00:00
James Almer e76bfba1cf avformat/mov: request parsing for LCEVC streams
Given that no standalone decoder will be present, use a parser to get stream
information that's not reported by the container.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-03 17:00:17 +00:00
Andreas Rheinhardt da195b1e84 avcodec/qsvenc: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:23:10 +02:00
Andreas Rheinhardt e1115751dd avcodec/nvenc: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:23:07 +02:00
Andreas Rheinhardt 095897060a avcodec/libzvbi-teletextdec: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:23:05 +02:00
Andreas Rheinhardt a9b97d070e avcodec/libxvid: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:23:03 +02:00
Andreas Rheinhardt dc12dd82a1 avcodec/libxavs2: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:23:00 +02:00
Andreas Rheinhardt 8881e1a52c avcodec/libvpxenc: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:58 +02:00
Andreas Rheinhardt 64bea20837 avcodec/libopusenc: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:56 +02:00
Andreas Rheinhardt d8b02fdb9f avcodec/libaomenc: Use av_fallthrough to mark fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:53 +02:00
Andreas Rheinhardt 02391996f8 avfilter/vf_stereo3d: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:51 +02:00
Andreas Rheinhardt 5144b51151 avfilter/vf_super2xsai: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:49 +02:00
Andreas Rheinhardt 21c2d38537 avformat/rmdec: Fix shadowing
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:46 +02:00
Andreas Rheinhardt 2fd9d69034 avformat/rmdec: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:44 +02:00
Andreas Rheinhardt 3cf225b5f8 avcodec/aac/aacdec: Fix shadowing
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:42 +02:00
Andreas Rheinhardt d29cbb87c3 avcodec/aac/aacdec: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:39 +02:00
Andreas Rheinhardt cf5191fac7 avcodec/hevc/hevcdec: Fix shadowing
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:37 +02:00
Andreas Rheinhardt 0cbf77e843 avcodec/hevc/hevcdec: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:34 +02:00
Andreas Rheinhardt e61c940654 avcodec/mpegvideo_enc: Fix shadowing
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:31 +02:00
Andreas Rheinhardt 04ba5e7537 avcodec/mpegvideo_enc: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:29 +02:00
Andreas Rheinhardt 7b4b658a87 avcodec/mpegvideo_motion: Add av_unreachable, fix fallthrough warnings
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:27 +02:00
Andreas Rheinhardt 4b58570ff7 avcodec/sga: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:24 +02:00
Andreas Rheinhardt 392ce463a5 avcodec/tiff: Fix shadowing
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:18 +02:00
Andreas Rheinhardt 25b7166fe3 avcodec/tiff: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:16 +02:00
Andreas Rheinhardt 05a8e89474 avcodec/tta: Fix shadowing
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:13 +02:00
Andreas Rheinhardt 5a7558a0a2 avcodec/tta: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:11 +02:00
Andreas Rheinhardt 9eeca76cbe avcodec/vdpau_mpeg12: Use av_fallthrough to mark fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:07 +02:00
Andreas Rheinhardt 2d0d937ed2 swscale/ops_chain: Use av_fallthrough to mark fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:05 +02:00
Andreas Rheinhardt a867648555 swscale/x86/swscale: Fix shadowing
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:03 +02:00
Andreas Rheinhardt e241a45548 swscale/x86/swscale: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:21:45 +02:00
Michael Niedermayer 2e32276872 avcodec/aac/aacdec_usac_mps212: fix attach_lsb() OOB after huff_decode
Fixes: VS-FF-2026-0001/poc.wav

Reported-by: Vuln Seeker Cyber Security Team
2026-05-03 15:11:28 +00:00
Michael Niedermayer 118bddf0ce avcodec/dfpwmdec: Check nb_samples
Fixes: integer overflow

Found-by: Dhiraj Mishra <mishra.dhiraj95@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 16:56:43 +02:00
Michael Niedermayer 7ae36ceba9 avcodec/alsdec: do not set nbits invalidly
note that the spec actually disallows the 0 case too but we are
a little lenient here so the full 24bit twos-complement range can be handled

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 14:54:27 +00:00
Michael Niedermayer 43a0715e30 swscale/swscale_unscaled: adjust last line copy
Fixes: out of array access
Fixes: DFVULN-694

*Reporter: Zhenpeng (Leo) Lin at depthfirst*

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 14:52:32 +00:00
Michael Niedermayer 7d0837a742 swscale/swscale: Check srcSliceY and srcSliceH
Obviously noone should pass negative values, they make no sense, but better to
explicitly check

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 14:52:32 +00:00
Michael Niedermayer 2678bce860 avformat/avidec: check LIST size in avi_load_index()
This avoids an unsigned integer underflow and passing that large value to ff_read_riff_info()
2026-05-03 14:40:49 +00:00
depthfirst-dev[bot] f1c3f1cae1 avformat/avidec: validate INFO list size before parsing
Reject INFO list chunks that are too small to contain the expected
4-byte list type field before calling ff_read_riff_info().

The parser subtracts 4 from the list size when handing the remaining
payload to ff_read_riff_info(). If the chunk is smaller than 4 bytes,
that underflows the expected structure and should be treated as invalid
input.

Fixes: DFVULN-607

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*
2026-05-03 14:40:49 +00:00
Michael Niedermayer f47ca0a5e6 avformat/matroskadec: Check audio.sub_packet_h * audio.frame_size
Fixes: out of array access
Fixes: poc_matroska.mkv

This issue requires manually increasing the malloc limit
(-max_alloc 4294967296)

Found-by: Guanni Qu <qguanni@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 14:39:45 +00:00
Michael Niedermayer 9d9250e5da avformat/pcm: Use 64bit for byte_rate
Fixes: integer overflow

Found-by: Marius Momeu <marius.momeu@berkeley.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 13:26:34 +00:00
Michael Niedermayer b45a6d3f76 avcodec/adpcm: signed integer overflow in ADPCM_N64
Fixes: signed integer overflow

Found-by: Marius Momeu <marius.momeu@berkeley.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 13:26:34 +00:00
Michael Niedermayer 2d4ec46345 libavformat/xwma: fix overflow in seek position
Fixes: signed integer overflow

Found-by: Marius Momeu <marius.momeu@berkeley.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 13:26:34 +00:00
Michael Niedermayer 0f5705959d avcodec/hevc/ps: validate rep_format dimensions in multi-layer SPS
When an SPS uses the multi-layer extension (nuh_layer_id > 0 with
sps_max_sub_layers_minus1 == 7), width and height are taken from the
VPS rep_format without the av_image_check_size() validation that the
direct path performs.  HEVC F.7.4.3.1.1 requires rep_format pic
dimensions to satisfy the constraints in 7.4.3.2.1, including
"pic_width_in_luma_samples shall not be equal to 0".

Run the same av_image_check_size() check in the multi-layer-extension
path so the SPS is rejected before it reaches setup_pps().

Fixes: VS-FF-2026-0003/poc.flv
Fixes: out of array access

Found-by: Vuln Seeker Cyber Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 13:26:06 +00:00
Marius Momeu e32b2c8886 avfilter/vf_kerndeint: Check for minimum height
Fixes: out of array access

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 13:25:48 +00:00
Marius Momeu ff3223b5d6 avcodec/ralf: Add the missing return statement after the error log
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 13:25:30 +00:00
Michael Niedermayer c568f40597 avfilter/vf_codecview: Clamp block to the visible frame region
Fixes: write into the padding area of the frame

Found-by: Marius Momeu <marius.momeu@berkeley.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 13:23:21 +00:00
Michael Niedermayer 2a991a3475 avcodec/zmbv: reject XOR data that overruns the decompression buffer
Add a per-block bounds check at the start of each XOR block so the
read is rejected before src crosses decomp_len, and propagate the
error from decode_frame().

Fixes: out of array read

Found-by: Seung Min Shin
2026-05-03 13:22:37 +00:00
Michael Niedermayer 2f60af465a avcodec/rasc: fix heap use-after-free in decode_move()
Use a separate scratch buffer (s->mv_scratch) for the type-0 pixel
copy so s->delta and mc are not disturbed for the lifetime of
decode_move().  The new buffer is freed in decode_close().

Found-by: Seung Min Shin
Patch based on suggsted fix by Seung Min Shin

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 13:20:27 +00:00
depthfirst-dev[bot] 8010aa2193 avformat/rtpdec_mpeg4: reject zero-length AU header sections
Reject AU header sections with a signaled length of zero in
rtp_parse_mp4_au().

The AU-headers-length field specifies the length in bits of the AU header
section that immediately follows. A zero-length section is not useful input
for this parser and can lead to invalid downstream state, so reject it
up front together with oversized values.

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

Fixes: OOB read
2026-05-03 13:19:55 +00:00
Niels Provos fd5023053a avcodec/hevc/refs: Check multiplication in alloc_frame()
Fixes: integer overflow on 32bit
2026-05-03 13:19:35 +00:00
Michael Niedermayer 89e128224e fftools/ffmpeg_opt: fix mismatching negative maps
Fixes:  -f lavfi -i testsrc2=size=128x128:rate=1:d=1   -filter_complex '[0:v]scale=64:64[vout]'   -map '[vout]'   -map -0:v   -f null -
Previously  -0:v matched [vout] apparently

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 13:19:18 +00:00
depthfirst-dev[bot] 25a98586cc fftools/ffmpeg_opt: validate stream index in negative map handling
Negative -map processing iterates previously parsed stream map entries
and dereferences input_files[m->file_index]->ctx->streams[m->stream_index]
without validating that stream_index is in range.

A malformed earlier map can leave m->stream_index negative, which causes
an out-of-bounds read when a later negative map walks existing entries.
Check that stream_index is non-negative and below nb_streams before
calling stream_specifier_match().

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

Fixes: DFVULN-695
2026-05-03 13:19:18 +00:00
Flavio Milan a45a91b23b avformat/rtmpproto: prevent integer overflow accumulating FLV buffer size
Fixes: out of array access
2026-05-03 13:18:54 +00:00
depthfirst-dev[bot] 52b78cd3fe avformat/rtmpproto: validate compressed SWF header length
Reject truncated compressed SWF input before attempting to read the
8-byte header in rtmp_calc_swfhash().

Compressed SWF data identified by the "CWS" signature must be at least
8 bytes long to contain the fixed header. Bail out early when the input
is shorter to avoid operating on malformed data.

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

Fixes: DFVULN-612
2026-05-03 12:43:21 +00:00
depthfirst-dev[bot] 1a00ea51cb avformat/rtsp: Fix out-of-bounds read in SDP parser when control_url is empty
Guard against empty string before reading the last byte in control_url.
When parsing relative a=control: paths, if no base control URL was set,
the code would access control_url[strlen(control_url)-1] which on an
empty string causes a size_t underflow and out-of-bounds read.

Now compute the length first and check for len == 0 before array access.

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

Fixes: DFVULN-611
2026-05-03 12:43:05 +00:00
depthfirst-dev[bot] 664d44a825 avformat/rtpdec_latm: avoid integer overflow in LATM length parsing
latm_parse_packet() accumulated attacker-controlled AU length bytes in
a signed int and later checked data->pos + cur_len against data->len.
That addition could overflow, allowing malformed packets to bypass the
bounds check and drive memcpy() far past the end of the LATM buffer.

Reject length-byte accumulation that would exceed the remaining packet
size, and compare cur_len against the remaining buffer space using
subtraction so the bounds check cannot overflow.

Fixes: DFVULN-610

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*
2026-05-03 12:42:57 +00:00
Michael Niedermayer 1772386392 avcodec/h264: recompute per-slice direct mode state for every slice
Regression since: 7f05c5cea0
Fixes: poc10
Fixes: null pointer dereference

Reported-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 12:42:47 +00:00
Michael Niedermayer 1886c3269d avcodec/h264_refs: Clear stale pointers from ref_list
Testcase: poc10.bin

Reported-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 12:42:47 +00:00
Michael Niedermayer a780d46d3b avcodec/leaddec: Check input data before allocating buffer
Fixes: Timeout
Fixes: 471636089/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LEAD_fuzzer-6346348464242688

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 12:40:44 +00:00
Michael Niedermayer b801f1fe6d avcodec/pdvdec: Check input space before buffer allocation
this rejects packets whose claimed decompressed frame would require a deflate ratio beyond the format's theoretical 1032:1 limit

Fixes: Timeout
Fixes: 474457186/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PDV_fuzzer-5366108782919680

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 10:25:54 +00:00
Kacper Michajłow 702b0784b7 avformat/concat: guard total_size overflow
Fixes: 466797413/clusterfuzz-testcase-minimized-fuzzer_options_parser-6015183727427584
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-03 07:30:46 +00:00
Kacper Michajłow be207a0d66 avformat/concat: change concat_data::total_size to int64_t
It's both initialized as int64_t in concat_open() and returned as
int64_t in concat_seek().
2026-05-03 07:30:46 +00:00
Gyan Doshi 4a2b643646 avcodec/mediacodecdec: declare correct class for audio decoders
The class for video decoders had been assigned till date.
2026-05-03 05:58:13 +00:00
Michael Niedermayer 016a241102 avformat/iamf_parse.c: Fix potential integer overflow in opus_decoder_config()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 02:36:54 +00:00
Michael Niedermayer 8439e02037 avformat: Fix various extradata padding issues
Reported-by: Kenan Alghythee <kalghy2@uic.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 02:36:54 +00:00
Michael Niedermayer 23227a444d avcodec/wmaenc: Fix missing padding in extradata
Reported-by: Kenan Alghythee <kalghy2@uic.edu>
2026-05-03 02:36:54 +00:00
Michael Niedermayer 242ff799c7 avcodec/tdsc: remove double stride adjustment
Fixes: out of array access

Found-by: Seung Min Shin
Patch based on suggested fix by Seung Min Shin
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-02 23:11:24 +00:00
depthfirst-dev[bot] 5408059eb7 avformat/cafdec: fix negative index use in read_seek
av_index_search_timestamp() returns a negative value when a seek target
cannot be resolved from the stream index. Bail out before using that
result as an index into sti->index_entries to avoid out-of-bounds reads.

Fixes: Buffer underflow

Fixes: DFVULN-608

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*
2026-05-02 21:40:19 +00:00
Michael Niedermayer 05817dc7dd avcodec/notchlc: Check 255 loops
Fixes: integer overflow

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-02 21:39:02 +00:00
Michael Niedermayer 91d29be49a avformat/rtpdec_jpeg: check qtable_len
Fixes: out of array access
Fixes: 605/pc.py

Based-on patch by depthfirst

*Reporter: Zhenpeng (Leo) Lin at depthfirst*
2026-05-02 21:16:51 +00:00
ASTRA 26732641fb avformat/vividas: use-of-uninitialized-value in keybuffer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-02 21:16:19 +00:00
Michael Niedermayer bf4eb194cf avcodec/tdsc: Better input size check
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-02 21:13:01 +00:00
Michael Niedermayer bb69a090a7 avcodec/tdsc: Check jpeg size
Fixes: out of array read
Fixes: tdsc_tile_dim_mismatch.avi

Found-by: Ante Silovic <asilovic155@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-02 21:13:01 +00:00
Michael Niedermayer af87d77514 avcodec/tdsc: Prettier uncompress() check
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-02 21:13:01 +00:00
Michael Niedermayer e9e6fb8798 avcodec/tdsc: Check tile_size
Fixes: out of array read
Fixes: tdsc_war_groom_far4096.avi

Found by: Ante Silovic <asilovic155@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-02 21:13:01 +00:00
Michael Niedermayer 9572ab7f45 avcodec/decode: Better documentation for ff_set_dimensions()
Clarify what is checked and that it avoids explicit generic overflow checks

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-02 21:11:47 +00:00
Nicolas George 571dd04ca2 lavfi/vf_scale: store aspect ratio as a whole 2026-05-02 14:47:00 +02:00
Nicolas George 5f3783005e lavfi/vf_scale: simplify indirections
link is always input[0].
2026-05-02 14:46:59 +02:00
Kacper Michajłow dba0b078c8 avcodec/vaapi_av1: reorder functions to avoid fwd decl 2026-05-01 23:59:06 +00:00
Kacper Michajłow 688f68bffa avcodec/vaapi_av1: fix leak of ref frames on init failure
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-01 23:59:06 +00:00
Kacper Michajłow 1bb12370b0 avformat/httpauth: avoid casting callback functions type
Technically it's is UB to call function of different type.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-01 23:58:40 +00:00
Kacper Michajłow d768bd564e avformat/hls: avoid casting callback functions type
Technically it's is UB to call function of different type.

Fixes:
src/libavformat/utils.c:531:9: runtime error: call to function handle_variant_args through pointer to incorrect function type 'void (*)(void *, const char *, int, char **, int *)'
src/libavformat/hls.c:379: note: handle_variant_args defined here

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-01 23:58:40 +00:00
zhanghongyuan 7e5eb2b65c fftools/opt_common: Use enum for encoder/decoder selection
Replace magic numbers (0 and 1) with SHOW_DECODER and SHOW_ENCODER
enum values throughout the opt_common.c file.
2026-05-01 23:37:55 +00:00
Jun Zhao ea3e09bfb1 fate/filter-video: use run $(FFMPEG) for scale-zero-dim test
$(FFMPEG) expands to "ffmpeg.exe" on Windows/MSYS2, and the bare
$(FFMPEG) call falls through to PATH lookup, picking up an externally
installed ffmpeg instead of the freshly built binary in $target_path.
That stale binary lacked the rejection added in a45fe72c9d, causing
msys2-clang64/clangarm64/ucrt64 slots to silently produce 250x2
instead of failing at 500x0.

Wrap with fate-run.sh's run() so $target_exec and $target_path are
resolved correctly on all platforms, matching the convention used by
e.g. fate-id3v2-invalid-tags, and avoiding the ffmpeg() helper's
unrelated default flags.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-05-01 23:45:30 +08:00
Leo Izen 739fc9249c avcodec/libjxlenc: fix frame->linesize raw pointer read
These should say frame->linesize[0] as it does everywhere else this
variable is referenced. Fixes a typo bug.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-05-01 07:40:25 -04:00
Leo Izen 05b5add006 avcodec/libjxlenc: check orientation tag metadata before reading
We need to check that entry->count is nonzero and that entry->type is
AV_TIFF_SHORT before reading from the buffer, in case a maliciously
constructed IFD uses a zero-count or an unusual type (e.g. IFD) for it.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-05-01 07:40:25 -04:00
Leo Izen f1cab2d018 avcodec/exif_internal.h: improve return docs for ff_exif_get_buffer
This commit improves the documentation for the return value of the
function ff_exif_get_buffer.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-05-01 07:40:25 -04:00
Leo Izen 087ec68451 avcodec/exif.c: synthesize EXIF data from frame metadata and matrix
If the displaymatrix is present, we should synthesize EXIF data from
the values there even if there is no EXIF attached to the frame.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-05-01 07:40:25 -04:00
Leo Izen 1d36c4d8ae avcodec/exif.c: reset ifd->size when freeing ifd->entries
If we free ifd->entries then we need to set ifd->size to 0 so another
call to av_fast_realloc doesn't get confused.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-05-01 07:40:24 -04:00
Leo Izen 326808ad2f avcodec/exif.c: add check for singular displaymatrix data
If av_exif_matrix_to_orientation returns 0, then the display matrix
is singular. In this case we should treat it as 1 and print a warning.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-05-01 07:40:24 -04:00
Leo Izen 317d660281 avcodec/exif.c: account for header_mode difference on rewrite
When determining if we need to rewrite the exif buffer or can pass
through as-is, account for a difference in header_mode requested from
the one that is used internally.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-05-01 07:40:24 -04:00
Leo Izen 4f5dfce5a8 avcodec/exif.c: use less than or equal for max width and height
The max width and height for PIXEL_X_TAG and PIXEL_Y_TAG is 0xFFFFu
because these are unsigned shorts, but we used < instead of <=
erroneously. Fix that.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-05-01 07:40:24 -04:00
Leo Izen 2cddfe7d0c avcodec/exif.c: pop entry off IFD if allocation fails
In av_exif_set_entry, if cloning the entry fails because of an alloc
failed, then we remove the entry from the IFD. If that entry exists
in the middle of ifd->entries we need to shift everything to the left
which this commit implements.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-05-01 07:40:24 -04:00
Leo Izen 0c39b1bccd avcodec/exif.h: fix documentation on av_exif_get_entry and similar
Add additional documentation to av_exif_get_entry and also to
av_exif_set_entry that was already part of the existing ABI but was
insufficiently documented before this commit. Also clarifies that
av_fast_realloc is used, instead of av_realloc on av_exif_set_entry.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-05-01 07:40:24 -04:00
Leo Izen 28e64cad6f avutil/frame.h: re-align dynamic HDR frame data declaration
This is aligned forward by an extra space, because it inheried the
incorrect alignment from the EXIF declaration above it (fixed in the
previous commit).

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-05-01 07:40:24 -04:00
Leo Izen 600a8a5a9c avutil/frame.h: fix AV_EXIF_SIDE_DATA declaration
This commit re-aligns the declaration by removing extra whitespace
and fixes the comment above to have the correct acronym. It also
documents what the four magic bytes indicate.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-05-01 07:40:18 -04:00
Dale Curtis a7d42bfba8 avformat/mov: Limit maximum box size for mov_read_lhvc()
Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
2026-04-30 22:50:51 +00:00
Nil Fons Miret e294b390a0 avfilter/vf_unsharp: fix amount scaling in the high-bit-depth path
The 16-bit kernel is dispatched for every non-8-bit pixel format
(9/10/12/16-bit content, all stored in uint16_t). It's supposed to
undo the Q16 scaling that set_filter_param() applies to `amount`:

    fp->amount = amount * 65536.0;

but the shift written in the kernel is `>> (8+nbits)`, which for the
nbits=16 instantiation of the macro comes out to `>> 24` instead of
`>> 16`. Because of this, on any non-8-bit input, unsharp applies ~1/256
of the user's requested strength and is effectively a no-op. The
8-bit kernel (nbits=8) happens to be correct because 8+8 == 16.

This commit also widens the intermediate product to int64 before the
shift, to avoid a potential overflow. Take a 16-bit pixel at the
edge of a sharp white/black region, with the user-facing `amount`
set to its declared maximum of 5.0.

    *srx       = 65535
    blur       = 32768
    diff       = *srx - blur                  = 32767
    amount_q16 = 5.0 * 65536                  = 327680

Then the kernel computes:

    product    = diff * amount_q16
               = 32767 * 327680               = 10,737,090,560     (~1.07e10)

which overflows INT32_MAX. Widening to int64 keeps the
multiplication in range; the subsequent `>> 16` brings it back to
sample range and the final cast to int32 is then safe. The widening
is a semantic no-op for 8/9/10/12-bit content where the product
always fits in int32 (worst case at 12-bit: 4095 * 327680 ~ 1.34e9).

Introduced by ee792ebe08 (2019-11-08, "avfilter/vf_unsharp: add 10bit
support"). The fate-filter-unsharp-yuv420p10 reference added in the
same series was generated from the broken kernel and is regenerated
here. fate-filter-unsharp (8-bit) is unaffected.

Repro:

    python3 -c "import numpy as np; y=np.tile(np.where(np.arange(128)//8 & 1, 512, 256).astype('<u2'), (128,1)); c=np.full((64,64), 512, '<u2'); open('in.yuv','wb').write(y.tobytes()+c.tobytes()*2)"

    ffmpeg -f rawvideo -pix_fmt yuv420p10le -s 128x128 -i in.yuv \
        -lavfi "split=2[a][b];[b]unsharp=la=1[bs];[a][bs]psnr" \
        -f null - 2>&1 | grep PSNR

Before: `PSNR y:66.50 ...` -- the filter is effectively a no-op,
        so the sharpened output matches the input almost exactly.
After:  `PSNR y:28.27 ...` -- the filter actually sharpens, so
        output and input differ as expected.

Signed-off-by: Nil Fons Miret <nilf@netflix.com>
Made-with: Cursor
2026-04-30 21:15:58 +00:00
depthfirst-dev[bot] 68ea660d83 avformat/mov: reject dimg references with zero entries
Reject dimg entries with a zero reference count in mov_read_iref_dimg().
This is the earliest point where the parser learns how many input images
a derived HEIF item references, so it is the right place to enforce the
invariant.

If entries == 0 is accepted here, the value is stored in HEIFGrid.nb_tiles,
later propagated by read_image_iovl() into AVStreamGroupTileGrid.nb_tiles,
and finally consumed in istg_parse_tile_grid(), which assumes at least one
tile and reads tg->offsets[tg->nb_tiles - 1]. With zero tiles, that
assumption breaks and leads to the out-of-bounds access seen in ASan.

Fixing the problem at the parser boundary is preferable to adding a later
workaround because it prevents creation of an invalid derived-image state
and stops that malformed state from reaching downstream consumers.

This is also consistent with the HEIF specification. Both iovl and grid
derived images are formed from one or more input images, and for grid the
dimg reference count must equal rows * columns; since rows and columns are
encoded as *_minus_one + 1, that count cannot be zero. A zero dimg entry
count is therefore invalid input and should be rejected when parsed.
2026-04-30 19:19:07 +00:00
Romain Beauxis 0f6ba39122 avfilter/vf_frei0r: guard against NULL string fields. 2026-04-30 08:33:31 -05:00
Andreas Rheinhardt cc3ca17127 avcodec/x86/qpeldsp{,_init}: Use proper prefix
E.g. rename ff_put_mpeg4_qpel8_h_lowpass_ssse3 to
ff_mpeg4_put_qpel8_h_lowpass_ssse3.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:33 +02:00
Andreas Rheinhardt ca43bc6202 avcodec/x86/qpeldsp_init: Mark functions as hidden
It allows pic 32bit code to call the underlying
assembly functions directly, without loading
the GOT first; this saves 1245B of .text here
(for 32bit pic code).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:33 +02:00
Andreas Rheinhardt 23d3116af9 avcodec/x86/qpeldsp: Add combination of h_lowpass + l2
If the subpel part of the horizontal component of
the motion vector is 1/4 or 3/4, the MPEG-4 qpel motion compensation
first computes the mc for the corresponding motion vector
with 1/2 horizontal subpel part and then averages this
with the left (for 1/4) or the right (for 3/4) source pixel.
These two stages are currently performed in two different functions,
involving a stack buffer as intermediate.

This means that horizontal prediction for every function with
a 1/4 or 3/4 horizontal subpel mv is more expensive code-size wise
(and also performance-wise) as it involves two calls. Given that
the horizontal lowpass functions are not that long, adding combinations
of h_lowpass+l2 actually reduces binary size: An increase of 1136B
in the asm files is more than offset by size reductions in
the wrappers: 1968B here when not using stack protection,
2256B when using stack protection.

Of course it also improves performance. Old benchmarks:
avg_qpel_pixels_tab[0][1]_ssse3:                       106.9 ( 8.69x)
avg_qpel_pixels_tab[0][3]_ssse3:                       105.5 ( 8.84x)
avg_qpel_pixels_tab[0][5]_ssse3:                       226.9 ( 8.57x)
avg_qpel_pixels_tab[0][7]_ssse3:                       231.1 ( 8.38x)
avg_qpel_pixels_tab[0][9]_ssse3:                       217.8 ( 9.04x)
avg_qpel_pixels_tab[0][11]_ssse3:                      214.9 ( 9.32x)
avg_qpel_pixels_tab[0][13]_ssse3:                      227.1 ( 8.48x)
avg_qpel_pixels_tab[0][15]_ssse3:                      236.1 ( 8.02x)

New benchmarks:
avg_qpel_pixels_tab[0][1]_ssse3:                        96.7 ( 9.65x)
avg_qpel_pixels_tab[0][3]_ssse3:                        96.6 ( 9.73x)
avg_qpel_pixels_tab[0][5]_ssse3:                       225.8 ( 8.61x)
avg_qpel_pixels_tab[0][7]_ssse3:                       228.4 ( 8.51x)
avg_qpel_pixels_tab[0][9]_ssse3:                       217.1 ( 9.05x)
avg_qpel_pixels_tab[0][11]_ssse3:                      217.8 ( 9.32x)
avg_qpel_pixels_tab[0][13]_ssse3:                      227.2 ( 8.54x)
avg_qpel_pixels_tab[0][15]_ssse3:                      220.5 ( 8.72x)

Note: The l2 functions are also used for vertical lowpass
functions, yet given that they are much bigger, duplicating
them would lead to massive code size increase.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:33 +02:00
Andreas Rheinhardt f946cac2d9 avcodec/x86/qpeldsp: Remove horizontal mmxext mc functions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:33 +02:00
Andreas Rheinhardt 1d040c527d avcodec/x86/qpeldsp: Add SSSE3 size 8 horizontal filter
Beats the mmxext version by a lot (in the following,
[1][1-3] refers to horizontal-only size 8 mc;
the _sse2 comparators for the other cases use mmxext
horizontal mc coupled with vertical SSE2 mc):

avg_qpel_pixels_tab[1][1]_c:                           223.9 ( 1.00x)
avg_qpel_pixels_tab[1][1]_mmxext:                       66.2 ( 3.38x)
avg_qpel_pixels_tab[1][1]_ssse3:                        36.8 ( 6.08x)
avg_qpel_pixels_tab[1][2]_c:                           251.0 ( 1.00x)
avg_qpel_pixels_tab[1][2]_mmxext:                       58.5 ( 4.29x)
avg_qpel_pixels_tab[1][2]_ssse3:                        25.5 ( 9.84x)
avg_qpel_pixels_tab[1][3]_c:                           226.9 ( 1.00x)
avg_qpel_pixels_tab[1][3]_mmxext:                       66.3 ( 3.42x)
avg_qpel_pixels_tab[1][3]_ssse3:                        35.8 ( 6.34x)
avg_qpel_pixels_tab[1][5]_c:                           473.9 ( 1.00x)
avg_qpel_pixels_tab[1][5]_sse2:                        110.7 ( 4.28x)
avg_qpel_pixels_tab[1][5]_ssse3:                        76.0 ( 6.24x)
avg_qpel_pixels_tab[1][6]_c:                           440.9 ( 1.00x)
avg_qpel_pixels_tab[1][6]_sse2:                        102.1 ( 4.32x)
avg_qpel_pixels_tab[1][6]_ssse3:                        67.1 ( 6.58x)
avg_qpel_pixels_tab[1][7]_c:                           473.8 ( 1.00x)
avg_qpel_pixels_tab[1][7]_sse2:                        108.0 ( 4.39x)
avg_qpel_pixels_tab[1][7]_ssse3:                        74.6 ( 6.35x)
avg_qpel_pixels_tab[1][9]_c:                           492.9 ( 1.00x)
avg_qpel_pixels_tab[1][9]_sse2:                        102.1 ( 4.83x)
avg_qpel_pixels_tab[1][9]_ssse3:                        67.1 ( 7.35x)
avg_qpel_pixels_tab[1][10]_c:                          465.6 ( 1.00x)
avg_qpel_pixels_tab[1][10]_sse2:                        94.9 ( 4.91x)
avg_qpel_pixels_tab[1][10]_ssse3:                       57.5 ( 8.10x)
avg_qpel_pixels_tab[1][11]_c:                          492.8 ( 1.00x)
avg_qpel_pixels_tab[1][11]_sse2:                       102.4 ( 4.81x)
avg_qpel_pixels_tab[1][11]_ssse3:                       68.7 ( 7.17x)
avg_qpel_pixels_tab[1][13]_c:                          476.6 ( 1.00x)
avg_qpel_pixels_tab[1][13]_sse2:                       108.6 ( 4.39x)
avg_qpel_pixels_tab[1][13]_ssse3:                       74.7 ( 6.38x)
avg_qpel_pixels_tab[1][14]_c:                          434.9 ( 1.00x)
avg_qpel_pixels_tab[1][14]_sse2:                       102.2 ( 4.25x)
avg_qpel_pixels_tab[1][14]_ssse3:                       66.6 ( 6.53x)
avg_qpel_pixels_tab[1][15]_c:                          474.1 ( 1.00x)
avg_qpel_pixels_tab[1][15]_sse2:                       107.9 ( 4.39x)
avg_qpel_pixels_tab[1][15]_ssse3:                       74.3 ( 6.38x)
put_no_rnd_qpel_pixels_tab[1][1]_c:                    222.1 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][1]_mmxext:                66.0 ( 3.37x)
put_no_rnd_qpel_pixels_tab[1][1]_ssse3:                 35.2 ( 6.31x)
put_no_rnd_qpel_pixels_tab[1][2]_c:                    212.2 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][2]_mmxext:                56.8 ( 3.74x)
put_no_rnd_qpel_pixels_tab[1][2]_ssse3:                 25.0 ( 8.48x)
put_no_rnd_qpel_pixels_tab[1][3]_c:                    224.5 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][3]_mmxext:                65.8 ( 3.41x)
put_no_rnd_qpel_pixels_tab[1][3]_ssse3:                 35.8 ( 6.26x)
put_no_rnd_qpel_pixels_tab[1][5]_c:                    460.1 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][5]_sse2:                 114.6 ( 4.01x)
put_no_rnd_qpel_pixels_tab[1][5]_ssse3:                 83.1 ( 5.53x)
put_no_rnd_qpel_pixels_tab[1][6]_c:                    438.6 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][6]_sse2:                 104.2 ( 4.21x)
put_no_rnd_qpel_pixels_tab[1][6]_ssse3:                 67.5 ( 6.50x)
put_no_rnd_qpel_pixels_tab[1][7]_c:                    458.0 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][7]_sse2:                 113.8 ( 4.02x)
put_no_rnd_qpel_pixels_tab[1][7]_ssse3:                 79.9 ( 5.73x)
put_no_rnd_qpel_pixels_tab[1][9]_c:                    439.0 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][9]_sse2:                 103.7 ( 4.23x)
put_no_rnd_qpel_pixels_tab[1][9]_ssse3:                 68.9 ( 6.37x)
put_no_rnd_qpel_pixels_tab[1][10]_c:                   427.0 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][10]_sse2:                 93.2 ( 4.58x)
put_no_rnd_qpel_pixels_tab[1][10]_ssse3:                57.9 ( 7.37x)
put_no_rnd_qpel_pixels_tab[1][11]_c:                   439.9 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][11]_sse2:                104.0 ( 4.23x)
put_no_rnd_qpel_pixels_tab[1][11]_ssse3:                69.2 ( 6.36x)
put_no_rnd_qpel_pixels_tab[1][13]_c:                   459.3 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][13]_sse2:                113.2 ( 4.06x)
put_no_rnd_qpel_pixels_tab[1][13]_ssse3:                83.8 ( 5.48x)
put_no_rnd_qpel_pixels_tab[1][14]_c:                   439.5 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][14]_sse2:                103.3 ( 4.25x)
put_no_rnd_qpel_pixels_tab[1][14]_ssse3:                67.9 ( 6.47x)
put_no_rnd_qpel_pixels_tab[1][15]_c:                   453.6 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][15]_sse2:                113.7 ( 3.99x)
put_no_rnd_qpel_pixels_tab[1][15]_ssse3:                80.0 ( 5.67x)
put_qpel_pixels_tab[1][1]_c:                           229.0 ( 1.00x)
put_qpel_pixels_tab[1][1]_mmxext:                       65.5 ( 3.50x)
put_qpel_pixels_tab[1][1]_ssse3:                        33.8 ( 6.77x)
put_qpel_pixels_tab[1][2]_c:                           212.5 ( 1.00x)
put_qpel_pixels_tab[1][2]_mmxext:                       56.6 ( 3.75x)
put_qpel_pixels_tab[1][2]_ssse3:                        23.4 ( 9.08x)
put_qpel_pixels_tab[1][3]_c:                           227.5 ( 1.00x)
put_qpel_pixels_tab[1][3]_mmxext:                       64.4 ( 3.53x)
put_qpel_pixels_tab[1][3]_ssse3:                        33.5 ( 6.79x)
put_qpel_pixels_tab[1][5]_c:                           466.5 ( 1.00x)
put_qpel_pixels_tab[1][5]_sse2:                        106.8 ( 4.37x)
put_qpel_pixels_tab[1][5]_ssse3:                        71.8 ( 6.50x)
put_qpel_pixels_tab[1][6]_c:                           438.7 ( 1.00x)
put_qpel_pixels_tab[1][6]_sse2:                        102.0 ( 4.30x)
put_qpel_pixels_tab[1][6]_ssse3:                        65.3 ( 6.72x)
put_qpel_pixels_tab[1][7]_c:                           466.0 ( 1.00x)
put_qpel_pixels_tab[1][7]_sse2:                        106.3 ( 4.38x)
put_qpel_pixels_tab[1][7]_ssse3:                        70.9 ( 6.57x)
put_qpel_pixels_tab[1][9]_c:                           456.0 ( 1.00x)
put_qpel_pixels_tab[1][9]_sse2:                        100.1 ( 4.55x)
put_qpel_pixels_tab[1][9]_ssse3:                        64.0 ( 7.13x)
put_qpel_pixels_tab[1][10]_c:                          425.1 ( 1.00x)
put_qpel_pixels_tab[1][10]_sse2:                        92.6 ( 4.59x)
put_qpel_pixels_tab[1][10]_ssse3:                       55.1 ( 7.71x)
put_qpel_pixels_tab[1][11]_c:                          452.7 ( 1.00x)
put_qpel_pixels_tab[1][11]_sse2:                        99.6 ( 4.55x)
put_qpel_pixels_tab[1][11]_ssse3:                       63.8 ( 7.09x)
put_qpel_pixels_tab[1][13]_c:                          471.2 ( 1.00x)
put_qpel_pixels_tab[1][13]_sse2:                       106.4 ( 4.43x)
put_qpel_pixels_tab[1][13]_ssse3:                       71.4 ( 6.60x)
put_qpel_pixels_tab[1][14]_c:                          439.7 ( 1.00x)
put_qpel_pixels_tab[1][14]_sse2:                       101.8 ( 4.32x)
put_qpel_pixels_tab[1][14]_ssse3:                       64.8 ( 6.79x)
put_qpel_pixels_tab[1][15]_c:                          467.8 ( 1.00x)
put_qpel_pixels_tab[1][15]_sse2:                       106.1 ( 4.41x)
put_qpel_pixels_tab[1][15]_ssse3:                       72.6 ( 6.44x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:33 +02:00
Andreas Rheinhardt c0e1c1d6b3 avcodec/x86/qpeldsp: Add SSSE3 size 16 horizontal filter
Beats the mmxext version by a lot (in the following,
[0][1-3] refers to horizontal-only size 16 mc;
the _sse2 comparators for the other cases use mmxext
horizontal mc coupled with vertical SSE2 mc):

avg_qpel_pixels_tab[0][1]_c:                           945.5 ( 1.00x)
avg_qpel_pixels_tab[0][1]_mmxext:                      262.6 ( 3.60x)
avg_qpel_pixels_tab[0][1]_ssse3:                       110.4 ( 8.57x)
avg_qpel_pixels_tab[0][2]_c:                          1042.1 ( 1.00x)
avg_qpel_pixels_tab[0][2]_mmxext:                      245.1 ( 4.25x)
avg_qpel_pixels_tab[0][2]_ssse3:                        91.7 (11.37x)
avg_qpel_pixels_tab[0][3]_c:                           941.8 ( 1.00x)
avg_qpel_pixels_tab[0][3]_mmxext:                      260.1 ( 3.62x)
avg_qpel_pixels_tab[0][3]_ssse3:                       110.1 ( 8.56x)
avg_qpel_pixels_tab[0][5]_c:                          1939.5 ( 1.00x)
avg_qpel_pixels_tab[0][5]_sse2:                        394.3 ( 4.92x)
avg_qpel_pixels_tab[0][5]_ssse3:                       247.4 ( 7.84x)
avg_qpel_pixels_tab[0][6]_c:                          1785.8 ( 1.00x)
avg_qpel_pixels_tab[0][6]_sse2:                        380.6 ( 4.69x)
avg_qpel_pixels_tab[0][6]_ssse3:                       221.1 ( 8.08x)
avg_qpel_pixels_tab[0][7]_c:                          1932.5 ( 1.00x)
avg_qpel_pixels_tab[0][7]_sse2:                        393.4 ( 4.91x)
avg_qpel_pixels_tab[0][7]_ssse3:                       238.8 ( 8.09x)
avg_qpel_pixels_tab[0][9]_c:                          1976.9 ( 1.00x)
avg_qpel_pixels_tab[0][9]_sse2:                        380.8 ( 5.19x)
avg_qpel_pixels_tab[0][9]_ssse3:                       223.3 ( 8.85x)
avg_qpel_pixels_tab[0][10]_c:                         1911.9 ( 1.00x)
avg_qpel_pixels_tab[0][10]_sse2:                       366.9 ( 5.21x)
avg_qpel_pixels_tab[0][10]_ssse3:                      207.0 ( 9.24x)
avg_qpel_pixels_tab[0][11]_c:                         2046.9 ( 1.00x)
avg_qpel_pixels_tab[0][11]_sse2:                       385.5 ( 5.31x)
avg_qpel_pixels_tab[0][11]_ssse3:                      227.9 ( 8.98x)
avg_qpel_pixels_tab[0][13]_c:                         1940.8 ( 1.00x)
avg_qpel_pixels_tab[0][13]_sse2:                       389.7 ( 4.98x)
avg_qpel_pixels_tab[0][13]_ssse3:                      244.2 ( 7.95x)
avg_qpel_pixels_tab[0][14]_c:                         1778.4 ( 1.00x)
avg_qpel_pixels_tab[0][14]_sse2:                       379.2 ( 4.69x)
avg_qpel_pixels_tab[0][14]_ssse3:                      223.5 ( 7.96x)
avg_qpel_pixels_tab[0][15]_c:                         1905.9 ( 1.00x)
avg_qpel_pixels_tab[0][15]_sse2:                       398.9 ( 4.78x)
avg_qpel_pixels_tab[0][15]_ssse3:                      238.3 ( 8.00x)
put_no_rnd_qpel_pixels_tab[0][1]_c:                    922.5 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][1]_mmxext:               275.0 ( 3.35x)
put_no_rnd_qpel_pixels_tab[0][1]_ssse3:                108.4 ( 8.51x)
put_no_rnd_qpel_pixels_tab[0][2]_c:                    889.7 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][2]_mmxext:               236.7 ( 3.76x)
put_no_rnd_qpel_pixels_tab[0][2]_ssse3:                 86.8 (10.25x)
put_no_rnd_qpel_pixels_tab[0][3]_c:                    915.5 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][3]_mmxext:               274.3 ( 3.34x)
put_no_rnd_qpel_pixels_tab[0][3]_ssse3:                108.2 ( 8.46x)
put_no_rnd_qpel_pixels_tab[0][5]_sse2:                 400.0 ( 4.63x)
put_no_rnd_qpel_pixels_tab[0][5]_ssse3:                246.0 ( 7.53x)
put_no_rnd_qpel_pixels_tab[0][6]_c:                   1753.9 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][6]_sse2:                 382.5 ( 4.59x)
put_no_rnd_qpel_pixels_tab[0][6]_ssse3:                226.4 ( 7.75x)
put_no_rnd_qpel_pixels_tab[0][7]_c:                   1854.6 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][7]_sse2:                 393.5 ( 4.71x)
put_no_rnd_qpel_pixels_tab[0][7]_ssse3:                248.6 ( 7.46x)
put_no_rnd_qpel_pixels_tab[0][9]_c:                   1794.3 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][9]_sse2:                 382.2 ( 4.70x)
put_no_rnd_qpel_pixels_tab[0][9]_ssse3:                228.0 ( 7.87x)
put_no_rnd_qpel_pixels_tab[0][10]_c:                  1724.7 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][10]_sse2:                353.8 ( 4.88x)
put_no_rnd_qpel_pixels_tab[0][10]_ssse3:               206.5 ( 8.35x)
put_no_rnd_qpel_pixels_tab[0][11]_c:                  1796.3 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][11]_sse2:                378.1 ( 4.75x)
put_no_rnd_qpel_pixels_tab[0][11]_ssse3:               227.1 ( 7.91x)
put_no_rnd_qpel_pixels_tab[0][13]_c:                  1834.4 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][13]_sse2:                400.7 ( 4.58x)
put_no_rnd_qpel_pixels_tab[0][13]_ssse3:               244.2 ( 7.51x)
put_no_rnd_qpel_pixels_tab[0][14]_c:                  1755.7 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][14]_sse2:                387.2 ( 4.53x)
put_no_rnd_qpel_pixels_tab[0][14]_ssse3:               226.8 ( 7.74x)
put_no_rnd_qpel_pixels_tab[0][15]_c:                  1847.3 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][15]_sse2:                400.6 ( 4.61x)
put_no_rnd_qpel_pixels_tab[0][15]_ssse3:               246.1 ( 7.51x)
put_qpel_pixels_tab[0][1]_c:                           919.6 ( 1.00x)
put_qpel_pixels_tab[0][1]_mmxext:                      255.5 ( 3.60x)
put_qpel_pixels_tab[0][1]_ssse3:                       108.3 ( 8.49x)
put_qpel_pixels_tab[0][2]_c:                           883.9 ( 1.00x)
put_qpel_pixels_tab[0][2]_mmxext:                      238.1 ( 3.71x)
put_qpel_pixels_tab[0][2]_ssse3:                        86.7 (10.19x)
put_qpel_pixels_tab[0][3]_c:                           921.9 ( 1.00x)
put_qpel_pixels_tab[0][3]_mmxext:                      258.9 ( 3.56x)
put_qpel_pixels_tab[0][3]_ssse3:                       108.1 ( 8.53x)
put_qpel_pixels_tab[0][5]_c:                          1907.5 ( 1.00x)
put_qpel_pixels_tab[0][5]_sse2:                        384.2 ( 4.96x)
put_qpel_pixels_tab[0][5]_ssse3:                       234.8 ( 8.13x)
put_qpel_pixels_tab[0][6]_c:                          1757.4 ( 1.00x)
put_qpel_pixels_tab[0][6]_sse2:                        382.8 ( 4.59x)
put_qpel_pixels_tab[0][6]_ssse3:                       217.6 ( 8.08x)
put_qpel_pixels_tab[0][7]_c:                          1927.5 ( 1.00x)
put_qpel_pixels_tab[0][7]_sse2:                        384.6 ( 5.01x)
put_qpel_pixels_tab[0][7]_ssse3:                       231.2 ( 8.34x)
put_qpel_pixels_tab[0][9]_c:                          1832.1 ( 1.00x)
put_qpel_pixels_tab[0][9]_sse2:                        374.8 ( 4.89x)
put_qpel_pixels_tab[0][9]_ssse3:                       219.4 ( 8.35x)
put_qpel_pixels_tab[0][10]_c:                         1710.3 ( 1.00x)
put_qpel_pixels_tab[0][10]_sse2:                       384.5 ( 4.45x)
put_qpel_pixels_tab[0][10]_ssse3:                      202.9 ( 8.43x)
put_qpel_pixels_tab[0][11]_c:                         1825.0 ( 1.00x)
put_qpel_pixels_tab[0][11]_sse2:                       369.6 ( 4.94x)
put_qpel_pixels_tab[0][11]_ssse3:                      216.8 ( 8.42x)
put_qpel_pixels_tab[0][13]_c:                         1898.4 ( 1.00x)
put_qpel_pixels_tab[0][13]_sse2:                       384.9 ( 4.93x)
put_qpel_pixels_tab[0][13]_ssse3:                      238.6 ( 7.96x)
put_qpel_pixels_tab[0][14]_c:                         1779.1 ( 1.00x)
put_qpel_pixels_tab[0][14]_sse2:                       373.3 ( 4.77x)
put_qpel_pixels_tab[0][14]_ssse3:                      218.1 ( 8.16x)
put_qpel_pixels_tab[0][15]_c:                         1918.2 ( 1.00x)
put_qpel_pixels_tab[0][15]_sse2:                       385.3 ( 4.98x)
put_qpel_pixels_tab[0][15]_ssse3:                      236.8 ( 8.10x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:33 +02:00
Andreas Rheinhardt a3d747f344 avcodec/x86/qpeldsp{,_init}: Use SSE2 pixels16x16_l2 functions
put and avg versions have been added and used in H264
in b91081274f. This commit
adds the size 16 version of put_no_rnd and uses all three
of them in the SSE2 size 16 qpel functions (i.e. it uses
them in the ones that have a vertical component); it also
removes the 16x17 MMXEXT versions (which are no longer used).

This is particularly beneficial for put_no_rnd:
avg_qpel_pixels_tab[0][5]_c:                          1910.9 ( 1.00x)
avg_qpel_pixels_tab[0][5]_sse2 (old):                  405.1 ( 4.72x)
avg_qpel_pixels_tab[0][5]_sse2:                        392.9 ( 4.86x)
avg_qpel_pixels_tab[0][6]_c:                          1778.9 ( 1.00x)
avg_qpel_pixels_tab[0][6]_sse2 (old):                  385.5 ( 4.61x)
avg_qpel_pixels_tab[0][6]_sse2:                        374.9 ( 4.75x)
avg_qpel_pixels_tab[0][7]_c:                          1935.3 ( 1.00x)
avg_qpel_pixels_tab[0][7]_sse2 (old):                  403.1 ( 4.80x)
avg_qpel_pixels_tab[0][7]_sse2:                        391.6 ( 4.94x)
avg_qpel_pixels_tab[0][9]_c:                          1969.0 ( 1.00x)
avg_qpel_pixels_tab[0][9]_sse2 (old):                  384.1 ( 5.13x)
avg_qpel_pixels_tab[0][9]_sse2:                        380.3 ( 5.18x)
avg_qpel_pixels_tab[0][11]_c:                         2014.9 ( 1.00x)
avg_qpel_pixels_tab[0][11]_sse2 (old):                 385.6 ( 5.23x)
avg_qpel_pixels_tab[0][11]_sse2:                       380.2 ( 5.30x)
avg_qpel_pixels_tab[0][13]_c:                         1925.7 ( 1.00x)
avg_qpel_pixels_tab[0][13]_sse2 (old):                 406.1 ( 4.74x)
avg_qpel_pixels_tab[0][13]_sse2:                       390.4 ( 4.93x)
avg_qpel_pixels_tab[0][14]_c:                         1793.0 ( 1.00x)
avg_qpel_pixels_tab[0][14]_sse2 (old):                 389.6 ( 4.60x)
avg_qpel_pixels_tab[0][14]_sse2:                       377.1 ( 4.75x)
avg_qpel_pixels_tab[0][15]_c:                         1913.0 ( 1.00x)
avg_qpel_pixels_tab[0][15]_sse2 (old):                 404.2 ( 4.73x)
avg_qpel_pixels_tab[0][15]_sse2:                       390.8 ( 4.89x)
put_no_rnd_qpel_pixels_tab[0][5]_c:                   1864.1 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][5]_sse2 (old):           425.6 ( 4.38x)
put_no_rnd_qpel_pixels_tab[0][5]_sse2:                 396.2 ( 4.71x)
put_no_rnd_qpel_pixels_tab[0][6]_c:                   1767.1 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][6]_sse2 (old):           388.4 ( 4.55x)
put_no_rnd_qpel_pixels_tab[0][6]_sse2:                 377.7 ( 4.68x)
put_no_rnd_qpel_pixels_tab[0][7]_c:                   1874.9 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][7]_sse2 (old):           427.6 ( 4.38x)
put_no_rnd_qpel_pixels_tab[0][7]_sse2:                 400.0 ( 4.69x)
put_no_rnd_qpel_pixels_tab[0][9]_c:                   1759.7 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][9]_sse2 (old):           393.0 ( 4.48x)
put_no_rnd_qpel_pixels_tab[0][9]_sse2:                 379.7 ( 4.63x)
put_no_rnd_qpel_pixels_tab[0][11]_c:                  1820.9 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][11]_sse2 (old):          392.7 ( 4.64x)
put_no_rnd_qpel_pixels_tab[0][11]_sse2:                377.4 ( 4.82x)
put_no_rnd_qpel_pixels_tab[0][13]_c:                  1841.2 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][13]_sse2 (old):          427.1 ( 4.31x)
put_no_rnd_qpel_pixels_tab[0][13]_sse2:                395.9 ( 4.65x)
put_no_rnd_qpel_pixels_tab[0][14]_c:                  1761.3 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][14]_sse2 (old):          392.3 ( 4.49x)
put_no_rnd_qpel_pixels_tab[0][14]_sse2:                375.9 ( 4.69x)
put_no_rnd_qpel_pixels_tab[0][15]_c:                  1869.1 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][15]_sse2 (old):          425.6 ( 4.39x)
put_no_rnd_qpel_pixels_tab[0][15]_sse2:                397.3 ( 4.70x)
put_qpel_pixels_tab[0][5]_c:                          1888.2 ( 1.00x)
put_qpel_pixels_tab[0][5]_sse2 (old):                  396.5 ( 4.76x)
put_qpel_pixels_tab[0][5]_sse2:                        382.5 ( 4.94x)
put_qpel_pixels_tab[0][6]_c:                          1760.4 ( 1.00x)
put_qpel_pixels_tab[0][6]_sse2 (old):                  377.0 ( 4.67x)
put_qpel_pixels_tab[0][6]_sse2:                        372.1 ( 4.73x)
put_qpel_pixels_tab[0][7]_c:                          1927.6 ( 1.00x)
put_qpel_pixels_tab[0][7]_sse2 (old):                  396.5 ( 4.86x)
put_qpel_pixels_tab[0][7]_sse2:                        383.4 ( 5.03x)
put_qpel_pixels_tab[0][9]_c:                          1775.9 ( 1.00x)
put_qpel_pixels_tab[0][9]_sse2 (old):                  377.9 ( 4.70x)
put_qpel_pixels_tab[0][9]_sse2:                        372.3 ( 4.77x)
put_qpel_pixels_tab[0][11]_c:                         1809.0 ( 1.00x)
put_qpel_pixels_tab[0][11]_sse2 (old):                 374.6 ( 4.83x)
put_qpel_pixels_tab[0][11]_sse2:                       380.3 ( 4.76x)
put_qpel_pixels_tab[0][13]_c:                         1893.2 ( 1.00x)
put_qpel_pixels_tab[0][13]_sse2 (old):                 399.2 ( 4.74x)
put_qpel_pixels_tab[0][13]_sse2:                       384.7 ( 4.92x)
put_qpel_pixels_tab[0][14]_c:                         1756.2 ( 1.00x)
put_qpel_pixels_tab[0][14]_sse2 (old):                 377.9 ( 4.65x)
put_qpel_pixels_tab[0][14]_sse2:                       374.4 ( 4.69x)
put_qpel_pixels_tab[0][15]_c:                         1922.8 ( 1.00x)
put_qpel_pixels_tab[0][15]_sse2 (old):                 399.0 ( 4.82x)
put_qpel_pixels_tab[0][15]_sse2:                       387.8 ( 4.96x)

The purely vertical size 16 mc functions now no longer use any MMX.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:33 +02:00
Andreas Rheinhardt dad0c01076 avcodec/x86/qpeldsp: Remove vertical MMXEXT mc functions
Superseded by SSE2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:33 +02:00
Andreas Rheinhardt 9beecb2670 avcodec/x86/qpeldsp: Add SSE2 vertical lowpass functions
Benchmarks ([4], [8] and [12] are pure vertical functions
and therefore show the biggest improvements):

avg_qpel_pixels_tab[0][4]_c:                           844.5 ( 1.00x)
avg_qpel_pixels_tab[0][4]_mmxext:                      225.5 ( 3.74x)
avg_qpel_pixels_tab[0][4]_sse2:                        146.6 ( 5.76x)
avg_qpel_pixels_tab[0][5]_c:                          1915.9 ( 1.00x)
avg_qpel_pixels_tab[0][5]_mmxext:                      499.6 ( 3.83x)
avg_qpel_pixels_tab[0][5]_sse2:                        405.5 ( 4.72x)
avg_qpel_pixels_tab[0][6]_c:                          1775.9 ( 1.00x)
avg_qpel_pixels_tab[0][6]_mmxext:                      484.9 ( 3.66x)
avg_qpel_pixels_tab[0][6]_sse2:                        385.4 ( 4.61x)
avg_qpel_pixels_tab[0][7]_c:                          1937.0 ( 1.00x)
avg_qpel_pixels_tab[0][7]_mmxext:                      501.3 ( 3.86x)
avg_qpel_pixels_tab[0][7]_sse2:                        403.6 ( 4.80x)
avg_qpel_pixels_tab[0][8]_c:                           976.7 ( 1.00x)
avg_qpel_pixels_tab[0][8]_mmxext:                      216.9 ( 4.50x)
avg_qpel_pixels_tab[0][8]_sse2:                        113.1 ( 8.64x)
avg_qpel_pixels_tab[0][9]_c:                          1971.8 ( 1.00x)
avg_qpel_pixels_tab[0][9]_mmxext:                      494.9 ( 3.98x)
avg_qpel_pixels_tab[0][9]_sse2:                        388.3 ( 5.08x)
avg_qpel_pixels_tab[0][10]_c:                         1900.8 ( 1.00x)
avg_qpel_pixels_tab[0][10]_mmxext:                     476.4 ( 3.99x)
avg_qpel_pixels_tab[0][10]_sse2:                       362.4 ( 5.24x)
avg_qpel_pixels_tab[0][11]_c:                         2003.3 ( 1.00x)
avg_qpel_pixels_tab[0][11]_mmxext:                     496.5 ( 4.04x)
avg_qpel_pixels_tab[0][11]_sse2:                       385.9 ( 5.19x)
avg_qpel_pixels_tab[0][12]_c:                          841.8 ( 1.00x)
avg_qpel_pixels_tab[0][12]_mmxext:                     226.7 ( 3.71x)
avg_qpel_pixels_tab[0][12]_sse2:                       143.3 ( 5.87x)
avg_qpel_pixels_tab[0][13]_c:                         1929.0 ( 1.00x)
avg_qpel_pixels_tab[0][13]_mmxext:                     499.6 ( 3.86x)
avg_qpel_pixels_tab[0][13]_sse2:                       412.1 ( 4.68x)
avg_qpel_pixels_tab[0][14]_c:                         1777.9 ( 1.00x)
avg_qpel_pixels_tab[0][14]_mmxext:                     484.8 ( 3.67x)
avg_qpel_pixels_tab[0][14]_sse2:                       385.9 ( 4.61x)
avg_qpel_pixels_tab[0][15]_c:                         1914.8 ( 1.00x)
avg_qpel_pixels_tab[0][15]_mmxext:                     501.8 ( 3.82x)
avg_qpel_pixels_tab[0][15]_sse2:                       405.0 ( 4.73x)
avg_qpel_pixels_tab[1][4]_c:                           203.4 ( 1.00x)
avg_qpel_pixels_tab[1][4]_mmxext:                       64.7 ( 3.14x)
avg_qpel_pixels_tab[1][4]_sse2:                         40.3 ( 5.05x)
avg_qpel_pixels_tab[1][5]_c:                           488.8 ( 1.00x)
avg_qpel_pixels_tab[1][5]_mmxext:                      134.6 ( 3.63x)
avg_qpel_pixels_tab[1][5]_sse2:                        108.5 ( 4.50x)
avg_qpel_pixels_tab[1][6]_c:                           448.2 ( 1.00x)
avg_qpel_pixels_tab[1][6]_mmxext:                      128.8 ( 3.48x)
avg_qpel_pixels_tab[1][6]_sse2:                        102.5 ( 4.37x)
avg_qpel_pixels_tab[1][7]_c:                           489.6 ( 1.00x)
avg_qpel_pixels_tab[1][7]_mmxext:                      134.5 ( 3.64x)
avg_qpel_pixels_tab[1][7]_sse2:                        108.8 ( 4.50x)
avg_qpel_pixels_tab[1][8]_c:                           223.8 ( 1.00x)
avg_qpel_pixels_tab[1][8]_mmxext:                       57.5 ( 3.89x)
avg_qpel_pixels_tab[1][8]_sse2:                         36.3 ( 6.16x)
avg_qpel_pixels_tab[1][9]_c:                           496.6 ( 1.00x)
avg_qpel_pixels_tab[1][9]_mmxext:                      129.8 ( 3.82x)
avg_qpel_pixels_tab[1][9]_sse2:                        105.1 ( 4.72x)
avg_qpel_pixels_tab[1][10]_c:                          466.1 ( 1.00x)
avg_qpel_pixels_tab[1][10]_mmxext:                     123.2 ( 3.78x)
avg_qpel_pixels_tab[1][10]_sse2:                        99.1 ( 4.70x)
avg_qpel_pixels_tab[1][11]_c:                          497.9 ( 1.00x)
avg_qpel_pixels_tab[1][11]_mmxext:                     129.9 ( 3.83x)
avg_qpel_pixels_tab[1][11]_sse2:                       105.4 ( 4.72x)
avg_qpel_pixels_tab[1][12]_c:                          203.5 ( 1.00x)
avg_qpel_pixels_tab[1][12]_mmxext:                      63.8 ( 3.19x)
avg_qpel_pixels_tab[1][12]_sse2:                        38.8 ( 5.25x)
avg_qpel_pixels_tab[1][13]_c:                          487.9 ( 1.00x)
avg_qpel_pixels_tab[1][13]_mmxext:                     134.7 ( 3.62x)
avg_qpel_pixels_tab[1][13]_sse2:                       108.4 ( 4.50x)
avg_qpel_pixels_tab[1][14]_c:                          447.4 ( 1.00x)
avg_qpel_pixels_tab[1][14]_mmxext:                     128.2 ( 3.49x)
avg_qpel_pixels_tab[1][14]_sse2:                       102.4 ( 4.37x)
avg_qpel_pixels_tab[1][15]_c:                          487.5 ( 1.00x)
avg_qpel_pixels_tab[1][15]_mmxext:                     134.0 ( 3.64x)
avg_qpel_pixels_tab[1][15]_sse2:                       109.9 ( 4.44x)

put_no_rnd_qpel_pixels_tab[0][4]_c:                    825.5 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][4]_mmxext:               242.5 ( 3.40x)
put_no_rnd_qpel_pixels_tab[0][4]_sse2:                 136.0 ( 6.07x)
put_no_rnd_qpel_pixels_tab[0][5]_c:                   1837.4 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][5]_mmxext:               542.5 ( 3.39x)
put_no_rnd_qpel_pixels_tab[0][5]_sse2:                 446.5 ( 4.11x)
put_no_rnd_qpel_pixels_tab[0][6]_c:                   1766.3 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][6]_mmxext:               493.6 ( 3.58x)
put_no_rnd_qpel_pixels_tab[0][6]_sse2:                 394.6 ( 4.48x)
put_no_rnd_qpel_pixels_tab[0][7]_c:                   1877.4 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][7]_mmxext:               541.9 ( 3.46x)
put_no_rnd_qpel_pixels_tab[0][7]_sse2:                 447.6 ( 4.19x)
put_no_rnd_qpel_pixels_tab[0][8]_c:                    785.1 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][8]_mmxext:               206.2 ( 3.81x)
put_no_rnd_qpel_pixels_tab[0][8]_sse2:                 101.6 ( 7.73x)
put_no_rnd_qpel_pixels_tab[0][9]_c:                   1772.2 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][9]_mmxext:               489.5 ( 3.62x)
put_no_rnd_qpel_pixels_tab[0][9]_sse2:                 394.8 ( 4.49x)
put_no_rnd_qpel_pixels_tab[0][10]_c:                  1711.5 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][10]_mmxext:              461.2 ( 3.71x)
put_no_rnd_qpel_pixels_tab[0][10]_sse2:                357.9 ( 4.78x)
put_no_rnd_qpel_pixels_tab[0][11]_c:                  1815.9 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][11]_mmxext:              490.8 ( 3.70x)
put_no_rnd_qpel_pixels_tab[0][11]_sse2:                394.0 ( 4.61x)
put_no_rnd_qpel_pixels_tab[0][12]_c:                   824.8 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][12]_mmxext:              242.9 ( 3.40x)
put_no_rnd_qpel_pixels_tab[0][12]_sse2:                135.3 ( 6.10x)
put_no_rnd_qpel_pixels_tab[0][13]_c:                  1843.5 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][13]_mmxext:              545.4 ( 3.38x)
put_no_rnd_qpel_pixels_tab[0][13]_sse2:                444.9 ( 4.14x)
put_no_rnd_qpel_pixels_tab[0][14]_c:                  1758.1 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][14]_mmxext:              497.7 ( 3.53x)
put_no_rnd_qpel_pixels_tab[0][14]_sse2:                393.5 ( 4.47x)
put_no_rnd_qpel_pixels_tab[0][15]_c:                  1861.3 ( 1.00x)
put_no_rnd_qpel_pixels_tab[0][15]_mmxext:              545.0 ( 3.42x)
put_no_rnd_qpel_pixels_tab[0][15]_sse2:                445.7 ( 4.18x)
put_no_rnd_qpel_pixels_tab[1][4]_c:                    198.3 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][4]_mmxext:                64.3 ( 3.08x)
put_no_rnd_qpel_pixels_tab[1][4]_sse2:                  39.8 ( 4.98x)
put_no_rnd_qpel_pixels_tab[1][5]_c:                    460.7 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][5]_mmxext:               137.2 ( 3.36x)
put_no_rnd_qpel_pixels_tab[1][5]_sse2:                 113.5 ( 4.06x)
put_no_rnd_qpel_pixels_tab[1][6]_c:                    441.4 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][6]_mmxext:               126.7 ( 3.49x)
put_no_rnd_qpel_pixels_tab[1][6]_sse2:                 103.7 ( 4.26x)
put_no_rnd_qpel_pixels_tab[1][7]_c:                    465.9 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][7]_mmxext:               137.7 ( 3.38x)
put_no_rnd_qpel_pixels_tab[1][7]_sse2:                 114.0 ( 4.09x)
put_no_rnd_qpel_pixels_tab[1][8]_c:                    193.8 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][8]_mmxext:                52.1 ( 3.72x)
put_no_rnd_qpel_pixels_tab[1][8]_sse2:                  27.8 ( 6.97x)
put_no_rnd_qpel_pixels_tab[1][9]_c:                    450.9 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][9]_mmxext:               126.2 ( 3.57x)
put_no_rnd_qpel_pixels_tab[1][9]_sse2:                 104.3 ( 4.32x)
put_no_rnd_qpel_pixels_tab[1][10]_c:                   436.5 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][10]_mmxext:              118.1 ( 3.69x)
put_no_rnd_qpel_pixels_tab[1][10]_sse2:                 92.4 ( 4.73x)
put_no_rnd_qpel_pixels_tab[1][11]_c:                   453.6 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][11]_mmxext:              128.7 ( 3.52x)
put_no_rnd_qpel_pixels_tab[1][11]_sse2:                103.6 ( 4.38x)
put_no_rnd_qpel_pixels_tab[1][12]_c:                   201.2 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][12]_mmxext:               64.2 ( 3.13x)
put_no_rnd_qpel_pixels_tab[1][12]_sse2:                 39.6 ( 5.08x)
put_no_rnd_qpel_pixels_tab[1][13]_c:                   461.9 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][13]_mmxext:              137.6 ( 3.36x)
put_no_rnd_qpel_pixels_tab[1][13]_sse2:                113.4 ( 4.07x)
put_no_rnd_qpel_pixels_tab[1][14]_c:                   442.6 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][14]_mmxext:              127.0 ( 3.49x)
put_no_rnd_qpel_pixels_tab[1][14]_sse2:                102.2 ( 4.33x)
put_no_rnd_qpel_pixels_tab[1][15]_c:                   462.9 ( 1.00x)
put_no_rnd_qpel_pixels_tab[1][15]_mmxext:              139.5 ( 3.32x)
put_no_rnd_qpel_pixels_tab[1][15]_sse2:                113.3 ( 4.09x)

put_qpel_pixels_tab[0][4]_c:                           824.6 ( 1.00x)
put_qpel_pixels_tab[0][4]_mmxext:                      220.1 ( 3.75x)
put_qpel_pixels_tab[0][4]_sse2:                        137.8 ( 5.98x)
put_qpel_pixels_tab[0][5]_c:                          1892.0 ( 1.00x)
put_qpel_pixels_tab[0][5]_mmxext:                      508.0 ( 3.72x)
put_qpel_pixels_tab[0][5]_sse2:                        408.6 ( 4.63x)
put_qpel_pixels_tab[0][6]_c:                          1758.0 ( 1.00x)
put_qpel_pixels_tab[0][6]_mmxext:                      476.7 ( 3.69x)
put_qpel_pixels_tab[0][6]_sse2:                        381.4 ( 4.61x)
put_qpel_pixels_tab[0][7]_c:                          1924.3 ( 1.00x)
put_qpel_pixels_tab[0][7]_mmxext:                      495.1 ( 3.89x)
put_qpel_pixels_tab[0][7]_sse2:                        417.2 ( 4.61x)
put_qpel_pixels_tab[0][8]_c:                           772.1 ( 1.00x)
put_qpel_pixels_tab[0][8]_mmxext:                      197.5 ( 3.91x)
put_qpel_pixels_tab[0][8]_sse2:                        118.4 ( 6.52x)
put_qpel_pixels_tab[0][9]_c:                          1778.2 ( 1.00x)
put_qpel_pixels_tab[0][9]_mmxext:                      476.7 ( 3.73x)
put_qpel_pixels_tab[0][9]_sse2:                        379.6 ( 4.68x)
put_qpel_pixels_tab[0][10]_c:                         1714.6 ( 1.00x)
put_qpel_pixels_tab[0][10]_mmxext:                     460.7 ( 3.72x)
put_qpel_pixels_tab[0][10]_sse2:                       386.8 ( 4.43x)
put_qpel_pixels_tab[0][11]_c:                         1819.1 ( 1.00x)
put_qpel_pixels_tab[0][11]_mmxext:                     474.9 ( 3.83x)
put_qpel_pixels_tab[0][11]_sse2:                       404.5 ( 4.50x)
put_qpel_pixels_tab[0][12]_c:                          829.7 ( 1.00x)
put_qpel_pixels_tab[0][12]_mmxext:                     221.5 ( 3.75x)
put_qpel_pixels_tab[0][12]_sse2:                       138.7 ( 5.98x)
put_qpel_pixels_tab[0][13]_c:                         1892.8 ( 1.00x)
put_qpel_pixels_tab[0][13]_mmxext:                     494.4 ( 3.83x)
put_qpel_pixels_tab[0][13]_sse2:                       413.9 ( 4.57x)
put_qpel_pixels_tab[0][14]_c:                         1763.1 ( 1.00x)
put_qpel_pixels_tab[0][14]_mmxext:                     473.4 ( 3.72x)
put_qpel_pixels_tab[0][14]_sse2:                       377.8 ( 4.67x)
put_qpel_pixels_tab[0][15]_c:                         1896.4 ( 1.00x)
put_qpel_pixels_tab[0][15]_mmxext:                     492.5 ( 3.85x)
put_qpel_pixels_tab[0][15]_sse2:                       399.0 ( 4.75x)
put_qpel_pixels_tab[1][4]_c:                           198.6 ( 1.00x)
put_qpel_pixels_tab[1][4]_mmxext:                       60.9 ( 3.26x)
put_qpel_pixels_tab[1][4]_sse2:                         40.1 ( 4.95x)
put_qpel_pixels_tab[1][5]_c:                           471.4 ( 1.00x)
put_qpel_pixels_tab[1][5]_mmxext:                      131.8 ( 3.58x)
put_qpel_pixels_tab[1][5]_sse2:                        107.2 ( 4.40x)
put_qpel_pixels_tab[1][6]_c:                           440.3 ( 1.00x)
put_qpel_pixels_tab[1][6]_mmxext:                      126.3 ( 3.49x)
put_qpel_pixels_tab[1][6]_sse2:                        100.6 ( 4.38x)
put_qpel_pixels_tab[1][7]_c:                           469.2 ( 1.00x)
put_qpel_pixels_tab[1][7]_mmxext:                      131.7 ( 3.56x)
put_qpel_pixels_tab[1][7]_sse2:                        106.9 ( 4.39x)
put_qpel_pixels_tab[1][8]_c:                           194.2 ( 1.00x)
put_qpel_pixels_tab[1][8]_mmxext:                       52.9 ( 3.67x)
put_qpel_pixels_tab[1][8]_sse2:                         28.0 ( 6.95x)
put_qpel_pixels_tab[1][9]_c:                           464.6 ( 1.00x)
put_qpel_pixels_tab[1][9]_mmxext:                      125.1 ( 3.71x)
put_qpel_pixels_tab[1][9]_sse2:                        100.9 ( 4.60x)
put_qpel_pixels_tab[1][10]_c:                          433.8 ( 1.00x)
put_qpel_pixels_tab[1][10]_mmxext:                     118.2 ( 3.67x)
put_qpel_pixels_tab[1][10]_sse2:                        94.5 ( 4.59x)
put_qpel_pixels_tab[1][11]_c:                          463.9 ( 1.00x)
put_qpel_pixels_tab[1][11]_mmxext:                     125.5 ( 3.70x)
put_qpel_pixels_tab[1][11]_sse2:                       102.6 ( 4.52x)
put_qpel_pixels_tab[1][12]_c:                          199.2 ( 1.00x)
put_qpel_pixels_tab[1][12]_mmxext:                      63.7 ( 3.12x)
put_qpel_pixels_tab[1][12]_sse2:                        36.2 ( 5.50x)
put_qpel_pixels_tab[1][13]_c:                          475.6 ( 1.00x)
put_qpel_pixels_tab[1][13]_mmxext:                     139.5 ( 3.41x)
put_qpel_pixels_tab[1][13]_sse2:                       107.3 ( 4.43x)
put_qpel_pixels_tab[1][14]_c:                          441.9 ( 1.00x)
put_qpel_pixels_tab[1][14]_mmxext:                     126.9 ( 3.48x)
put_qpel_pixels_tab[1][14]_sse2:                       101.3 ( 4.36x)
put_qpel_pixels_tab[1][15]_c:                          475.9 ( 1.00x)
put_qpel_pixels_tab[1][15]_mmxext:                     131.9 ( 3.61x)
put_qpel_pixels_tab[1][15]_sse2:                       107.0 ( 4.45x)

The new functions (in qpeldsp.asm) occupy 8244B (the MMXEXT functions
which they will replace occupy only 6720B).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:33 +02:00
Andreas Rheinhardt 405465700c avcodec/x86/qpeldsp: Don't allocate stack unnecessarily
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:33 +02:00
Andreas Rheinhardt 188df9549c avcodec/x86/qpeldsp: Don't use too much stack
We only need (SIZE+1)*SIZE words.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:33 +02:00
Andreas Rheinhardt bcf7293a21 avcodec/x86/qpeldsp: Remove unused declaration
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:33 +02:00
Andreas Rheinhardt 7b56259dd5 avcodec/x86/constants: Move ff_pw_{15,20} to qpeldsp.asm
Only used there.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:32 +02:00
Andreas Rheinhardt c2685234a6 avcodec/x86/qpeldsp_init: Deduplicate 8x8 and 16x16 code
Also split the big macro into smaller ones for the pure horizontal vs
the pure vertical and the mixed directions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:32 +02:00
Andreas Rheinhardt cf79d8052d avcodec/x86/qpeldsp_init: Specify alignment properly
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:32 +02:00
Andreas Rheinhardt 69906d31c5 avcodec/x86/qpeldsp_init: Don't use unnecessarily big stack buffer
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:32 +02:00
Andreas Rheinhardt d3bd1318b3 avcodec/x86/qpeldsp: Don't zero unnecessarily
This value is write-only.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:32 +02:00
Andreas Rheinhardt d46414b46b avcodec/x86/qpeldsp: Simplify resetting output pointer
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-30 10:39:32 +02:00
Stefan Breunig 9172ab1245 fate/filter-video: add frei0r_src test
An installation of frei0r-plugins is required to run the tests,
which is usually seperate from the build headers. Some systems
have it packaged (e.g. apt install frei0r-plugins). An upstream
release extracted to FREI0R_PATH also works.

Signed-off-by: Stefan Breunig <stefan-ffmpeg-devel@breunig.xyz>
2026-04-30 03:46:18 +00:00
Nicolas Dato 3aa5d957d1 avformat/dashdec: fix previous commit where I inadvertently removed the case when calc_next_seg_no_from_timelines returned -1 and move_timelines wasn't called
Signed-off-by: Nicolas Dato <nicolas.dato@gmail.com>
2026-04-29 23:54:37 +00:00
Nicolas Dato 8a8bde6a54 avformat/dashdec: fix calculation and usage of cur_seq_no, fixing issue 22335
Functions like calc_cur_seg_no, calc_min_seg_no, and calc_max_seg_no calculated
the segment number taking into account the first_seq_no.
However, functions like get_segment_start_time_based_on_timeline and
calc_cur_seg_no didn't take first_seq_no into account.
This made dashdec believe that the cur_seq_no was always less than min_seq_no,
logging 'old fragment' and calling calc_cur_seq_no.

In live dash streams with some startNumber, that call to calc_cur_seq_no after
the 'old fragment' log made ffmpeg reposition itself 60 seconds before the
current time whenever the manifest reloaded.
This made ffmpeg skip segments, specially when the manifest reloaded slower
than the segments duration, resulting in a new manifest with more than one new
segment.

Signed-off-by: Nicolas Dato <nicolas.dato@gmail.com>
2026-04-29 23:54:37 +00:00
Michael Niedermayer c25673fe70 avformat/mpegts: Fix memleak of pes_filter.opaque
Fixes: 490257166/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGTS_fuzzer-4815675538604032

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-29 20:50:21 +00:00
James Almer 2e6af10481 avformat/dashdec: copy stream groups from input representations
Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-29 14:00:03 +00:00
James Almer 8fad6dcfd9 avformat/dashdec: support more than one underlying stream per Representation
Some Dash manifests contain Representations within an Adaptation Set that
reference an underlying mp4 context that contain more than the stream it
describes, as is the case of LCEVC enhancements.

Despite the fact open_demux_for_component() loops through all streams in the
underlying context, the rest of the demuxer is writen assuming only the
stream described by the corresponding representation will be present, which
results in completely wrong stream index assignments.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-29 14:00:03 +00:00
Martin Storsjö 397c7c7524 tools/check_arm_indent: Run formatting on arm, in addition to aarch64
Add exceptions for files that aren't handled well (or that would
require more manual cleanups to make the output look good).
2026-04-29 13:53:07 +03:00
Martin Storsjö f6b21eca5e tools/check_arm_indent: Add missing ;; in switch case, fix indentation 2026-04-29 13:53:07 +03:00
Martin Storsjö 963ea707e3 arm/rv40dsp: Add * on comment continuation lines in prototypes
This avoids that the assembly indenter script tries to indent these
lines as assembly code.
2026-04-29 13:53:07 +03:00
Martin Storsjö 0a86aead82 arm/vc1dsp: Fix a few cases of inconsistent indentation
The function ff_vc1_unescape_buffer_helper_neon intentionally
uses unusual indentation, to indicate different levels of
unrolling in the function.
2026-04-29 13:53:07 +03:00
Martin Storsjö 10a45072fc arm/jrevdct: Indent previously unindented assembly
The comments have been manually tweaked to line up properly.
2026-04-29 13:53:07 +03:00
Martin Storsjö 5e0f1b1eda arm/hevcdsp_qpel: Reindent code that seem to lack consistent indentation 2026-04-29 13:53:07 +03:00
Martin Storsjö 65d4c5bbe2 arm: Reindent asm that used consistent but differing styles
The qpel_filter macros in hevcdsp_qpel_neon.S have been
manually tweaked to keep reasonable indentation of the
comments.
2026-04-29 13:53:07 +03:00
Martin Storsjö 2325421904 arm/synth_filter_vfp: Fix indentation
This was done with manual adjustments; the reindentation
script doesn't handle the VFP/NOVFP macros at the start of
lines.
2026-04-29 13:53:07 +03:00
Ramiro Polla 8d9c1db95d arm/simple_idct_arm: Reindent previously unindented code 2026-04-29 13:53:07 +03:00
Martin Storsjö a65ed248fd arm/simple_idct_armv6: Reindent previously consistent assembly to shared style
This has manual fixups, as the indenting script wants to
lowercase constants like W46 to w46, which breaks things.
2026-04-29 13:49:27 +03:00
Martin Storsjö b27fd61020 arm/simple_idct_armv5te: Reindent previously consistent code to common style
This has manual fixups, as the indenting script wants to
lowercase constants like W26 to w26, which breaks things.
2026-04-29 13:49:27 +03:00
Martin Storsjö 8e199a2a9f arm/rv34dsp: Adjust macro argument indentation slightly
The previous form did neatly align with the lines above, but doesn't
match general indentation rules from our indentation script.
2026-04-29 13:49:27 +03:00
Martin Storsjö 9653588441 libswscale/arm: Switch consistent indentation to common style
Some of these files aligned instructions to 4/24 columns, while
we commonly indent arm/aarch64 assembly to 8/24 columns.
Some of these files also used a different alignment for the
operands.
2026-04-29 13:49:27 +03:00
Martin Storsjö c5a3cb00b7 libswresample/arm: Change to the common indentation size
These files consistently aligned instructions to 4/24 columns,
while we commonly indent arm/aarch64 assembly to 8/24 columns.
2026-04-29 13:49:27 +03:00
Martin Storsjö 25d703dd2a libavutil/arm: Fix indentation in asm.S 2026-04-29 13:49:27 +03:00
Martin Storsjö d94e2b0f7c arm/hevcdsp: Fix misindented instructions in some macros 2026-04-29 13:49:27 +03:00
Martin Storsjö 7eaeb5ab4a arm: Fix indentation of stray individual misaligned instructions 2026-04-29 13:49:27 +03:00
Martin Storsjö 17765fe831 arm: Reindent assembly where it was off by one char 2026-04-29 13:49:27 +03:00
Martin Storsjö 946e80fde7 libswscale/arm: Lowercase the "LSL" keyword 2026-04-29 13:49:27 +03:00
Martin Storsjö ea7079074c tools/indent_arm_assembly: Don't indent "foo .req bar" lines like an instruction
These are used a bit in our arm assembly, while they're used much
less in our aarch64 assembly.
2026-04-29 13:49:27 +03:00
Martin Storsjö cd7a3cd799 tools/indent_arm_assembly: Recognize more comment forms, for skipping lowercasing
When we try to lowercase register names (e.g. Q0 -> q0) we avoid
doing that for parts of the code that are comments, as comments
occasionally contain pseudocode that contain such mentions that
aren't register names, but pseudocode/reference code variables.
See 7ebb6c54eb for more details
about that.

In addition to recognizing comments starting with //, also
recognize /* and @ (which is a comment char in arm assembly, but
not in aarch64).
2026-04-29 13:49:27 +03:00
Michael Niedermayer 7c67748537 avformat/mov: check extradata in mov_read_dops()
We do want to limit an attackers ability to change once parsed structures.
So once extradata (or another array) is finished and possibly has been used we do not
want to allow an attacker to change it.

This reduces the attack surface

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-29 00:46:47 +00:00
Ted Meyer 53cd2c9f2a avformat/mov: Check read size for opus extradata
in mov_read_dops, `size` bytes is allocated for
`st->codecpar->extradata`, but ff_alloc_extradata doesn't memset, so the
contents of that buffer are just old heap data. If `avio_read` reads
fewer bytes than were requested, uninitialized data can still be left in
the extradata buffer, which is operated on by AV_WL16A and AV_WL32A.

I think the best solution here is to just check the read size and ensure
it's filling the extradata buffer in it's entirety, or erroring out if
there isn't enough data left.
2026-04-28 23:46:56 +00:00
Andreas Rheinhardt bd1587037f avutil/tests/.gitignore: Add recently added test tools
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-28 20:08:35 +02:00
marcos ashton fa3d20072b tests/fate/libavutil: add FATE test for timestamp
Test av_ts_make_string with NOPTS, zero, positive, negative, and
INT64 boundary values, av_ts2str macro, av_ts_make_time_string2
with various timebases, and av_ts_make_time_string pointer
variant.

Coverage for libavutil/timestamp.c: 0.00% -> 100.00%
2026-04-28 16:17:47 +00:00
marcos ashton 9b47495dee tests/fate/libavutil: add FATE test for tdrdi
Test av_tdrdi_alloc with 1 and 3 displays, and the inline
av_tdrdi_get_display accessor. Verifies that the returned
pointer matches entries_offset + idx * entry_size, tests
write/read-back of display width exponent/mantissa and view ID
fields, and OOM paths via av_max_alloc.

Coverage for libavutil/tdrdi.c: 0.00% -> 100.00%
2026-04-28 16:17:47 +00:00
marcos ashton 215799e369 tests/fate/libavutil: add FATE test for hdr_dynamic_vivid_metadata
Test av_dynamic_hdr_vivid_alloc and
av_dynamic_hdr_vivid_create_side_data. Verifies zero defaults,
write/read-back of system_start_code, num_windows, and
color transform params (min/avg/var/max RGB), frame side
data attachment, and OOM paths via av_max_alloc.

Coverage for libavutil/hdr_dynamic_vivid_metadata.c: 0.00% -> 100.00%
2026-04-28 16:17:47 +00:00
marcos ashton 2d9c8a9382 tests/fate/libavutil: add FATE test for buffer
Test av_buffer_alloc, av_buffer_allocz, av_buffer_create with
custom free callback, AV_BUFFER_FLAG_READONLY, av_buffer_ref,
av_buffer_is_writable, av_buffer_get_ref_count,
av_buffer_make_writable, av_buffer_realloc (including from NULL),
av_buffer_replace (including with NULL), av_buffer_pool
init/get/uninit cycle, av_buffer_pool_init2 with custom alloc
and pool_free callbacks, av_buffer_pool_buffer_get_opaque, and
OOM paths via av_max_alloc.

Coverage for libavutil/buffer.c: 0.00% -> 90.19%

Remaining uncovered lines are mutex init failures and
secondary allocation failure paths.
2026-04-28 16:17:47 +00:00
jiangjie 03931e8865 libavfilter/vf_amf_common: free the frame allocated by av_frame_alloc on error 2026-04-28 14:57:34 +00:00
Zhao Zhili 603234f945 avdevice/v4l2: fix mmap_free() skipping first buffer
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-28 13:45:20 +00:00
Zhao Zhili beb315ca31 avformat/wavdec: fix unchecked avio_read in w64_read_header
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-28 13:44:57 +00:00
Marvin Scholz f044c5e627 doc: remove unclear description
There is no caller when presuming that the user will use lavc for
decoding.
2026-04-28 14:31:19 +02:00
Marvin Scholz c9937ff139 doc: mark functions related to AVCodecParameters
This makes these functions appear in the AVCodecParameters
documentation page, so they are easier to find.
2026-04-28 14:31:19 +02:00
Marvin Scholz ab1a970bc0 doc: style changes for the AVCodecParameters
Mostly adding references and making the video/audio only
annotations not be the brief description.
2026-04-28 14:31:19 +02:00
Marvin Scholz 0e51f7abbd configure: add implicit-fallthrough warning flags 2026-04-28 12:29:37 +00:00
Marvin Scholz e24882912f swscale/yuv2rgb: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz e4f6aa8611 avcodec/wmadec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz dc7692b831 avcodec/aac: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 97ff804e21 avcodec/ac3dec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz a384a4ff3a avcodec/ansi: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 5cee00b85f avcodec/argo: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 0f3fe9e2bf avcodec/avs: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz e5e12328bf avcodec/bethsoftvideo: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 0f81f78829 avcodec/bink: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 49c62c3337 avcodec/bintext: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz d578926366 avcodec/c39: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 7b94360e0e avcodec/cavs: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz c772decdd0 avcodec/dca: add break 2026-04-28 12:29:37 +00:00
Marvin Scholz 5cdbd0337f avcodec/dds: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 9a765c453a avcodec/dpxenc: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz b70d6b4f58 avcodec/dv: add break 2026-04-28 12:29:37 +00:00
Marvin Scholz 5a5742498b avcodec/dxa: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz de011d5893 avcodec/dxtory: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 87926346e7 avcodec/eatgq: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 5f574e6416 avcodec/ffv1enc: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 4a805cfa53 avcodec/flacdsp: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz d4d5ac3bb2 avcodec/gdv: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 735e670334 avcodec/h264dec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 16e944c8e4 avcodec/imx: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 4fe52a2484 avcodec/jpeg2000dec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz c49390ee87 avcodec/jpeglsdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz f4a05e3528 avcodec/lagarith: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz b976075088 avcodec/lcldec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 0d7ea1bb55 avcodec/microdvddec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 417da4d71c avcodec/mpegaudio: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz abc3b65ccb avcodec/pafvideo: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 41dbb4412a avcodec/psd: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 3ad3315342 avcodec/rpza: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 7eff0307ff avcodec/rv34: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 120cc26594 avcodec/sgienc: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 965a4b6ae1 avcodec/sheervideo: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 31ea9122e5 avcodec/svq1dec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 8a4abaaa4d avcodec/takdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 092d223b7b avcodec/tiff: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz e6c7fd4106 avcodec/tiffenc: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 10742fdc65 avcodec/wavpackdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 55f224afeb avfilter/af_biquads: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 435a617cc8 avfilter/vf_negate: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 89870d404c avformat/aiffdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz f0e9854f79 avformat/avidec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 85c88d748f avformat/avienc: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 2ea8e764e2 avformat/bethsoftvid: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 749f01e3ea avformat/cafdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz c25c83abf5 avformat/concat: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 720d5c3c51 avformat/electronicarts: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 337a3fba9d avformat/epafdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 3f815180e8 avformat/flvdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz c26334f750 avformat/flvenc: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 223939e6be avformat/id3v2: add break 2026-04-28 12:29:37 +00:00
Marvin Scholz e2c36fbb7f avformat/idroqdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 44271c2dde avformat/jacobsubdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz f715db05fa avformat/lmlm4: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 346d7f63cb avformat/lvfdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 6d3392fd60 avformat/matroskadec: add break 2026-04-28 12:29:37 +00:00
Marvin Scholz bcf0b71d8c avformat/mov: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 9f22a4d363 avformat/mxfdec: add fall-through annotation and break 2026-04-28 12:29:37 +00:00
Marvin Scholz 50b1da33e4 avformat/mxfenc: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 452d0239ca avformat/network: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz f819d3452c avformat/nutdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz a6b8525f6e avformat/nuv: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 49fc8ddf65 avformat/oggparsetheora: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 70fed6fd33 avformat/rtmppkt: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 2777e4d389 avformat/takdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 125dd9ee2a avformat/txd: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz d607b2249f avformat/ty: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 5988639f39 avformat/yuv4mpegdec: return proper error
The header is not invalid in this case, but ffmpeg still doesn't
support it.
2026-04-28 12:29:37 +00:00
Marvin Scholz 3e48505dda swscale: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz e2a8b73688 avcodec/txd: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 20d6759f8e avcodec/vb: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz c790f4284f avcodec/vc1: add break 2026-04-28 12:29:37 +00:00
Marvin Scholz e92c4076d6 avcodec/vmnc: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 8f50eeee02 avcodec/zmbv: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz ce740510aa avutil: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz b50a586583 avutil/avsscanf: add break 2026-04-28 12:29:37 +00:00
Marvin Scholz 7e3e88d28d avutil/hwcontext_videotoolbox: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz 3c5bb10a87 avcodec/videotoolbox: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz c023f91eeb avfilter/vf_v360: add break
Also replace an av_assert0 with av_unreachable.
2026-04-28 12:29:37 +00:00
Marvin Scholz 121a81d586 avfilter/avf_showcqt: add fall-through annotation 2026-04-28 12:29:37 +00:00
Marvin Scholz 62a93f0148 avutil: replace fall-through comments 2026-04-28 12:29:37 +00:00
Marvin Scholz 752cf875d8 swscale: replace fall-through comments 2026-04-28 12:29:37 +00:00
Marvin Scholz d5ae10e6d4 avformat: replace fall-through comments 2026-04-28 12:29:37 +00:00
Marvin Scholz 49f3620119 avfilter: replace fall-through comments 2026-04-28 12:29:37 +00:00
Marvin Scholz 938fa8b14c avcodec: replace fall-through comments 2026-04-28 12:29:37 +00:00
Marvin Scholz afd3f01501 fftools: replace fall-through comments 2026-04-28 12:29:37 +00:00
Marvin Scholz cc863d68d7 avutil: add av_fallthrough 2026-04-28 12:29:37 +00:00
Marvin Scholz 3daf664a5a avcodec: cbs_lcevc: remove dead code
The error is already handled before the loop, so this can never be true.

Fix Coverity issue 1683139
2026-04-28 12:24:54 +00:00
depthfirst-dev[bot] eec78bdac1 avformat/rtspdec: reject non-positive ANNOUNCE Content-Length
rtsp_read_announce() treated any non-zero Content-Length as valid,
including negative values parsed via strtol(). This could send invalid
sizes into allocation, body reads and trailing NUL writes.

Accept only strictly positive SDP body lengths and reject invalid
Content-Length values with AVERROR_INVALIDDATA.

Found-by: Seung Min Shin (was reported to us on 10th April)
CC: 신승민 <guncraft2000@naver.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-28 12:07:16 +00:00
Zhao Zhili 9eaa559847 avformat/matroskadec: fix invalid check and uninitialized memory access
size is uninitialized when av_dynamic_hdr_smpte2094_app5_alloc failed.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-28 11:59:59 +00:00
Zhao Zhili 1b98286131 swscale: unref on allocation failure in frame_alloc_buffers()
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-28 11:58:33 +00:00
Jun Zhao 3cdd76ba96 avcodec/libsvtav1: reject tiny inputs on SVT-AV1 < 3.0.0
SVT-AV1 < 3.0.0 requires input dimensions of at least 64x64.
Older versions may otherwise silently accept smaller inputs without
producing output and cause the caller to hang. Reject such inputs
explicitly in config_enc_params() to produce a clear error.
v3.0.0+ supports sub-64px dimensions and validates the
input itself, so the check is gated with SVT_AV1_CHECK_VERSION.

Fix #22817

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-28 06:14:38 +00:00
Jun Zhao d247110148 fate/filter-video: add regression test for scale zero-dim rejection
Add a regression test covering issue #22817: cascaded scale=...:-2
filters on extreme aspect ratios previously produced zero output
dimensions silently. The test expects ffmpeg to fail fast.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-28 06:14:38 +00:00
Jun Zhao bfbc5632f1 avfilter/vf_libplacebo: propagate ff_scale_adjust_dimensions() error
ff_scale_adjust_dimensions() can now return a negative error code when
the evaluated output dimensions are non-positive.  Check the return
value and fail fast instead of continuing with the unadjusted result.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-28 06:14:38 +00:00
Jun Zhao fd51dc5d20 avfilter/vf_amf_common: propagate ff_scale_adjust_dimensions() error
ff_scale_adjust_dimensions() can now return a negative error code when
the evaluated output dimensions are non-positive.  Check the return
value and fail fast instead of continuing with the unadjusted result.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-28 06:14:38 +00:00
Jun Zhao 4fc0b36bac avfilter/vf_scale_d3d12: propagate ff_scale_adjust_dimensions() error
ff_scale_adjust_dimensions() can now return a negative error code when
the evaluated output dimensions are non-positive.  Check the return
value and fail fast instead of continuing with the unadjusted result.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-28 06:14:38 +00:00
Jun Zhao 0929b6038c avfilter/vf_scale_vulkan: propagate ff_scale_adjust_dimensions() error
ff_scale_adjust_dimensions() can now return a negative error code when
the evaluated output dimensions are non-positive.  Check the return
value and fail fast instead of continuing with the unadjusted result.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-28 06:14:38 +00:00
Jun Zhao 3f9b92be42 avfilter/vf_scale_vt: propagate ff_scale_adjust_dimensions() error
ff_scale_adjust_dimensions() can now return a negative error code when
the evaluated output dimensions are non-positive.  Check the return
value and fail fast instead of continuing with the unadjusted result.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-28 06:14:38 +00:00
Jun Zhao 8fc4cc982e avfilter/vf_scale_vaapi: propagate ff_scale_adjust_dimensions() error
ff_scale_adjust_dimensions() can now return a negative error code when
the evaluated output dimensions are non-positive.  Check the return
value and fail fast instead of continuing with the unadjusted result.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-28 06:14:38 +00:00
Jun Zhao 6a37a60726 avfilter/vf_scale_npp: propagate ff_scale_adjust_dimensions() error
ff_scale_adjust_dimensions() can now return a negative error code when
the evaluated output dimensions are non-positive.  Check the return
value and fail fast instead of continuing with the unadjusted result.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-28 06:14:38 +00:00
Jun Zhao 33d657c7d0 avfilter/vf_scale_cuda: propagate ff_scale_adjust_dimensions() error
ff_scale_adjust_dimensions() can now return a negative error code when
the evaluated output dimensions are non-positive.  Check the return
value and fail fast instead of continuing with the unadjusted result.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-28 06:14:38 +00:00
Jun Zhao a45fe72c9d avfilter/scale_eval: reject non-positive output dimensions
When scale filter expressions evaluate to zero or negative output
dimensions (e.g. cascaded scale=...:-2 on extreme aspect ratios),
ff_scale_adjust_dimensions() only checked for int32 overflow and
passed them through, potentially hanging downstream components.

Reject them explicitly so the pipeline fails fast.

Callers that currently ignore the return value will be updated in
the following patches to propagate the error.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-28 06:14:38 +00:00
Zuxy Meng c55ab93eef avcodec/x86/h264_intrapred: Replace pred8x8_horizontal_8_mmxext with SSE2
Deprecating MMX. Instruction count unchanged.

Signed-off-by: Zuxy Meng <zuxy.meng@gmail.com>
2026-04-27 20:31:20 -07:00
Jeongkeun Kim 4ea59d5665 avcodec/aarch64: add NEON DCA LFE FIR filter functions
Port lfe_fir0_float and lfe_fir1_float to AArch64 NEON. These polyphase
FIR interpolation filters have an x86 SSE/AVX path but no AArch64
equivalent, falling back to scalar C.

The inner loop computes two dot products per output pair. Precomputing a
reversed LFE sample vector before the inner loop avoids per-iteration
shuffle overhead.

Benchmarks on AWS Graviton3 (Neoverse V1, c7g.xlarge):
  lfe_fir0_float: C 5902.0 cycles -> NEON 2135.0 cycles (2.77x)
  lfe_fir1_float: C 2836.3 cycles -> NEON 1527.8 cycles (1.86x)
Measured with: taskset -c 0 ./tests/checkasm/checkasm --test=dcadsp --bench,
3-run average, Ubuntu 22.04 (kernel 6.8.0-1052-aws), perf_event_paranoid=0.

Signed-off-by: Jeongkeun Kim <variety0724@gmail.com>
2026-04-27 20:13:23 +00:00
Georgii Zagoruiko 1ced59326a aarch64/vvc: Optimisations of put_chroma_hv() functions for 10/12-bit
Apple M4:
put_chroma_hv_10_2x2_c:                                  9.1 ( 1.00x)
put_chroma_hv_10_4x4_c:                                 20.1 ( 1.00x)
put_chroma_hv_10_8x8_c:                                 35.6 ( 1.00x)
put_chroma_hv_10_8x8_neon:                              15.4 ( 2.31x)
put_chroma_hv_10_16x16_c:                              113.7 ( 1.00x)
put_chroma_hv_10_16x16_neon:                            57.0 ( 1.99x)
put_chroma_hv_10_32x32_c:                              406.9 ( 1.00x)
put_chroma_hv_10_32x32_neon:                           225.7 ( 1.80x)
put_chroma_hv_10_64x64_c:                             1498.8 ( 1.00x)
put_chroma_hv_10_64x64_neon:                           876.2 ( 1.71x)
put_chroma_hv_10_128x128_c:                           5757.0 ( 1.00x)
put_chroma_hv_10_128x128_neon:                        3446.6 ( 1.67x)
put_chroma_hv_12_2x2_c:                                  9.9 ( 1.00x)
put_chroma_hv_12_4x4_c:                                 19.2 ( 1.00x)
put_chroma_hv_12_8x8_c:                                 36.1 ( 1.00x)
put_chroma_hv_12_8x8_neon:                              17.9 ( 2.02x)
put_chroma_hv_12_16x16_c:                              112.2 ( 1.00x)
put_chroma_hv_12_16x16_neon:                            55.6 ( 2.02x)
put_chroma_hv_12_32x32_c:                              416.6 ( 1.00x)
put_chroma_hv_12_32x32_neon:                           224.3 ( 1.86x)
put_chroma_hv_12_64x64_c:                             1464.8 ( 1.00x)
put_chroma_hv_12_64x64_neon:                           860.1 ( 1.70x)
put_chroma_hv_12_128x128_c:                           5776.8 ( 1.00x)
put_chroma_hv_12_128x128_neon:                        3445.2 ( 1.68x)

RPi5:
put_chroma_hv_10_2x2_c:                                118.5 ( 1.00x)
put_chroma_hv_10_4x4_c:                                190.6 ( 1.00x)
put_chroma_hv_10_8x8_c:                                303.1 ( 1.00x)
put_chroma_hv_10_8x8_neon:                             172.6 ( 1.76x)
put_chroma_hv_10_16x16_c:                             1036.1 ( 1.00x)
put_chroma_hv_10_16x16_neon:                           626.7 ( 1.65x)
put_chroma_hv_10_32x32_c:                             3624.4 ( 1.00x)
put_chroma_hv_10_32x32_neon:                          2386.9 ( 1.52x)
put_chroma_hv_10_64x64_c:                            13612.1 ( 1.00x)
put_chroma_hv_10_64x64_neon:                          9314.8 ( 1.46x)
put_chroma_hv_10_128x128_c:                          52975.4 ( 1.00x)
put_chroma_hv_10_128x128_neon:                       37083.5 ( 1.43x)
put_chroma_hv_12_2x2_c:                                118.6 ( 1.00x)
put_chroma_hv_12_4x4_c:                                188.1 ( 1.00x)
put_chroma_hv_12_8x8_c:                                303.4 ( 1.00x)
put_chroma_hv_12_8x8_neon:                             176.7 ( 1.72x)
put_chroma_hv_12_16x16_c:                             1037.9 ( 1.00x)
put_chroma_hv_12_16x16_neon:                           626.5 ( 1.66x)
put_chroma_hv_12_32x32_c:                             3629.0 ( 1.00x)
put_chroma_hv_12_32x32_neon:                          2386.6 ( 1.52x)
put_chroma_hv_12_64x64_c:                            13649.0 ( 1.00x)
put_chroma_hv_12_64x64_neon:                          9313.6 ( 1.47x)
put_chroma_hv_12_128x128_c:                          52978.0 ( 1.00x)
put_chroma_hv_12_128x128_neon:                       37101.2 ( 1.43x)
2026-04-27 20:10:57 +00:00
Marvin Scholz 9e90fa505e fftools: ffprobe: fix type mismatch in assert
The enum is unsigned, so instead compare to -1 before assigning to
the unsigned type.
2026-04-27 14:31:02 +02:00
Marvin Scholz 0396831b04 fftools: ffprobe: use unsigned in print_list_fmt
Unsigned makes more sense in this context.
2026-04-27 14:31:02 +02:00
Marvin Scholz 92cbe0454f fftools: ffprobe: adjust type of nb_streams
There is no reason for this to be signed, it is never negative.
2026-04-27 14:31:02 +02:00
Marvin Scholz 7c254feb0a fftools: ffprobe: narrow variable scopes and adjust types
Prevents several integers of different sign comparison warnings.
2026-04-27 14:31:02 +02:00
Marvin Scholz 0fc1183a60 swscale: ops_dispatch: fix leak on error
Assign to `exec_base.in_offset_x` before the error handling,
to ensure the error cleanup path properly frees the already
allocated memory.

Fixes Coverity issue #1691725
2026-04-27 12:29:48 +00:00
Andreas Rheinhardt 4867d251ad swscale/x86/yuv2yuvX: Simplify rotating
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-26 23:48:21 +02:00
Andreas Rheinhardt f5ed254528 swscale/x86/yuv2yuvX: Port ff_yuv2yuvX_mmxext to SSE2
The mmx function performs two registers in parallel;
given the larger register size of SSE2, the same amount
of data can be processed in one register with some speedups.
(Given that this function is used for tail-processing,
not processing more data is important.)

Switching to SSE2 also fixes a bug introduced in
554c2bc708: Since said
commit, only half the dither values were used. This
seems not to matter in practice, as the functions here
use dither only in the following form:
((filtersize-1)*8+dither)>>4. The dither values used
here come from ff_dither_8x8_128 which has the property
that ff_dither_8x8_128[i][j] and ff_dither_8x8_128[i][j+4]
always lead to the same result in the above formula.

Old benchmarks:
yuv2yuvX_8_2_0_512_approximate_c:                     2309.9 ( 1.00x)
yuv2yuvX_8_2_0_512_approximate_mmxext:                 250.2 ( 9.23x)
yuv2yuvX_8_2_0_512_approximate_sse3:                    98.8 (23.39x)
yuv2yuvX_8_2_0_512_approximate_avx2:                    52.9 (43.63x)
yuv2yuvX_8_2_16_512_approximate_c:                    2263.0 ( 1.00x)
yuv2yuvX_8_2_16_512_approximate_mmxext:                245.3 ( 9.22x)
yuv2yuvX_8_2_16_512_approximate_sse3:                  114.3 (19.80x)
yuv2yuvX_8_2_16_512_approximate_avx2:                   85.6 (26.45x)
yuv2yuvX_8_2_32_512_approximate_c:                    2155.8 ( 1.00x)
yuv2yuvX_8_2_32_512_approximate_mmxext:                235.6 ( 9.15x)
yuv2yuvX_8_2_32_512_approximate_sse3:                   93.6 (23.04x)
yuv2yuvX_8_2_32_512_approximate_avx2:                   78.1 (27.60x)
yuv2yuvX_8_2_48_512_approximate_c:                    2084.8 ( 1.00x)
yuv2yuvX_8_2_48_512_approximate_mmxext:                230.2 ( 9.05x)
yuv2yuvX_8_2_48_512_approximate_sse3:                  105.0 (19.85x)
yuv2yuvX_8_2_48_512_approximate_avx2:                   71.9 (29.00x)
yuv2yuvX_8_4_0_512_approximate_c:                     3496.3 ( 1.00x)
yuv2yuvX_8_4_0_512_approximate_mmxext:                 455.0 ( 7.68x)
yuv2yuvX_8_4_0_512_approximate_sse3:                   157.5 (22.20x)
yuv2yuvX_8_4_0_512_approximate_avx2:                    88.4 (39.53x)
yuv2yuvX_8_4_16_512_approximate_c:                    3380.9 ( 1.00x)
yuv2yuvX_8_4_16_512_approximate_mmxext:                440.0 ( 7.68x)
yuv2yuvX_8_4_16_512_approximate_sse3:                  175.0 (19.32x)
yuv2yuvX_8_4_16_512_approximate_avx2:                  134.1 (25.22x)
yuv2yuvX_8_4_32_512_approximate_c:                    3277.6 ( 1.00x)
yuv2yuvX_8_4_32_512_approximate_mmxext:                427.2 ( 7.67x)
yuv2yuvX_8_4_32_512_approximate_sse3:                  149.7 (21.89x)
yuv2yuvX_8_4_32_512_approximate_avx2:                  115.5 (28.37x)
yuv2yuvX_8_4_48_512_approximate_c:                    3167.8 ( 1.00x)
yuv2yuvX_8_4_48_512_approximate_mmxext:                414.9 ( 7.63x)
yuv2yuvX_8_4_48_512_approximate_sse3:                  164.1 (19.31x)
yuv2yuvX_8_4_48_512_approximate_avx2:                  101.2 (31.30x)
yuv2yuvX_8_8_0_512_approximate_c:                     5987.5 ( 1.00x)
yuv2yuvX_8_8_0_512_approximate_mmxext:                 854.1 ( 7.01x)
yuv2yuvX_8_8_0_512_approximate_sse3:                   294.6 (20.32x)
yuv2yuvX_8_8_0_512_approximate_avx2:                   144.1 (41.56x)
yuv2yuvX_8_8_16_512_approximate_c:                    5848.9 ( 1.00x)
yuv2yuvX_8_8_16_512_approximate_mmxext:                834.4 ( 7.01x)
yuv2yuvX_8_8_16_512_approximate_sse3:                  312.1 (18.74x)
yuv2yuvX_8_8_16_512_approximate_avx2:                  214.9 (27.22x)
yuv2yuvX_8_8_32_512_approximate_c:                    5610.1 ( 1.00x)
yuv2yuvX_8_8_32_512_approximate_mmxext:                811.6 ( 6.91x)
yuv2yuvX_8_8_32_512_approximate_sse3:                  277.5 (20.21x)
yuv2yuvX_8_8_32_512_approximate_avx2:                  189.8 (29.55x)
yuv2yuvX_8_8_48_512_approximate_c:                    5415.8 ( 1.00x)
yuv2yuvX_8_8_48_512_approximate_mmxext:                782.3 ( 6.92x)
yuv2yuvX_8_8_48_512_approximate_sse3:                  289.4 (18.72x)
yuv2yuvX_8_8_48_512_approximate_avx2:                  165.3 (32.76x)
yuv2yuvX_8_16_0_512_approximate_c:                   11100.7 ( 1.00x)
yuv2yuvX_8_16_0_512_approximate_mmxext:               1682.1 ( 6.60x)
yuv2yuvX_8_16_0_512_approximate_sse3:                  558.8 (19.86x)
yuv2yuvX_8_16_0_512_approximate_avx2:                  280.1 (39.63x)
yuv2yuvX_8_16_16_512_approximate_c:                  10772.1 ( 1.00x)
yuv2yuvX_8_16_16_512_approximate_mmxext:              1611.0 ( 6.69x)
yuv2yuvX_8_16_16_512_approximate_sse3:                 578.1 (18.63x)
yuv2yuvX_8_16_16_512_approximate_avx2:                 418.8 (25.72x)
yuv2yuvX_8_16_32_512_approximate_c:                  10381.5 ( 1.00x)
yuv2yuvX_8_16_32_512_approximate_mmxext:              1560.4 ( 6.65x)
yuv2yuvX_8_16_32_512_approximate_sse3:                 525.8 (19.74x)
yuv2yuvX_8_16_32_512_approximate_avx2:                 370.7 (28.01x)
yuv2yuvX_8_16_48_512_approximate_c:                  10046.1 ( 1.00x)
yuv2yuvX_8_16_48_512_approximate_mmxext:              1512.4 ( 6.64x)
yuv2yuvX_8_16_48_512_approximate_sse3:                 546.0 (18.40x)
yuv2yuvX_8_16_48_512_approximate_avx2:                 315.0 (31.89x)

New benchmarks:
yuv2yuvX_8_2_0_512_approximate_c:                     2302.5 ( 1.00x)
yuv2yuvX_8_2_0_512_approximate_sse2:                   184.4 (12.49x)
yuv2yuvX_8_2_0_512_approximate_sse3:                   100.1 (23.01x)
yuv2yuvX_8_2_0_512_approximate_avx2:                    54.9 (41.98x)
yuv2yuvX_8_2_16_512_approximate_c:                    2224.6 ( 1.00x)
yuv2yuvX_8_2_16_512_approximate_sse2:                  180.0 (12.36x)
yuv2yuvX_8_2_16_512_approximate_sse3:                  109.5 (20.31x)
yuv2yuvX_8_2_16_512_approximate_avx2:                   81.3 (27.35x)
yuv2yuvX_8_2_32_512_approximate_c:                    2165.3 ( 1.00x)
yuv2yuvX_8_2_32_512_approximate_sse2:                  176.6 (12.26x)
yuv2yuvX_8_2_32_512_approximate_sse3:                   93.7 (23.11x)
yuv2yuvX_8_2_32_512_approximate_avx2:                   73.1 (29.61x)
yuv2yuvX_8_2_48_512_approximate_c:                    2088.0 ( 1.00x)
yuv2yuvX_8_2_48_512_approximate_sse2:                  170.7 (12.23x)
yuv2yuvX_8_2_48_512_approximate_sse3:                  103.4 (20.20x)
yuv2yuvX_8_2_48_512_approximate_avx2:                   69.4 (30.10x)
yuv2yuvX_8_4_0_512_approximate_c:                     3496.8 ( 1.00x)
yuv2yuvX_8_4_0_512_approximate_sse2:                   320.3 (10.92x)
yuv2yuvX_8_4_0_512_approximate_sse3:                   158.8 (22.02x)
yuv2yuvX_8_4_0_512_approximate_avx2:                    86.4 (40.49x)
yuv2yuvX_8_4_16_512_approximate_c:                    3443.5 ( 1.00x)
yuv2yuvX_8_4_16_512_approximate_sse2:                  325.3 (10.59x)
yuv2yuvX_8_4_16_512_approximate_sse3:                  171.9 (20.03x)
yuv2yuvX_8_4_16_512_approximate_avx2:                  123.6 (27.85x)
yuv2yuvX_8_4_32_512_approximate_c:                    3272.2 ( 1.00x)
yuv2yuvX_8_4_32_512_approximate_sse2:                  302.7 (10.81x)
yuv2yuvX_8_4_32_512_approximate_sse3:                  148.9 (21.98x)
yuv2yuvX_8_4_32_512_approximate_avx2:                  110.6 (29.58x)
yuv2yuvX_8_4_48_512_approximate_c:                    3166.3 ( 1.00x)
yuv2yuvX_8_4_48_512_approximate_sse2:                  291.0 (10.88x)
yuv2yuvX_8_4_48_512_approximate_sse3:                  162.9 (19.44x)
yuv2yuvX_8_4_48_512_approximate_avx2:                  102.3 (30.95x)
yuv2yuvX_8_8_0_512_approximate_c:                     5967.6 ( 1.00x)
yuv2yuvX_8_8_0_512_approximate_sse2:                   691.2 ( 8.63x)
yuv2yuvX_8_8_0_512_approximate_sse3:                   294.2 (20.28x)
yuv2yuvX_8_8_0_512_approximate_avx2:                   154.9 (38.52x)
yuv2yuvX_8_8_16_512_approximate_c:                    5780.2 ( 1.00x)
yuv2yuvX_8_8_16_512_approximate_sse2:                  606.2 ( 9.53x)
yuv2yuvX_8_8_16_512_approximate_sse3:                  309.3 (18.69x)
yuv2yuvX_8_8_16_512_approximate_avx2:                  208.7 (27.69x)
yuv2yuvX_8_8_32_512_approximate_c:                    5604.3 ( 1.00x)
yuv2yuvX_8_8_32_512_approximate_sse2:                  592.3 ( 9.46x)
yuv2yuvX_8_8_32_512_approximate_sse3:                  281.1 (19.94x)
yuv2yuvX_8_8_32_512_approximate_avx2:                  185.4 (30.23x)
yuv2yuvX_8_8_48_512_approximate_c:                    5413.7 ( 1.00x)
yuv2yuvX_8_8_48_512_approximate_sse2:                  570.4 ( 9.49x)
yuv2yuvX_8_8_48_512_approximate_sse3:                  294.9 (18.36x)
yuv2yuvX_8_8_48_512_approximate_avx2:                  166.5 (32.51x)
yuv2yuvX_8_16_0_512_approximate_c:                   11099.4 ( 1.00x)
yuv2yuvX_8_16_0_512_approximate_sse2:                 1213.6 ( 9.15x)
yuv2yuvX_8_16_0_512_approximate_sse3:                  563.0 (19.72x)
yuv2yuvX_8_16_0_512_approximate_avx2:                  294.8 (37.65x)
yuv2yuvX_8_16_16_512_approximate_c:                  10718.1 ( 1.00x)
yuv2yuvX_8_16_16_512_approximate_sse2:                1121.2 ( 9.56x)
yuv2yuvX_8_16_16_512_approximate_sse3:                 563.7 (19.01x)
yuv2yuvX_8_16_16_512_approximate_avx2:                 389.5 (27.51x)
yuv2yuvX_8_16_32_512_approximate_c:                  10373.3 ( 1.00x)
yuv2yuvX_8_16_32_512_approximate_sse2:                1096.2 ( 9.46x)
yuv2yuvX_8_16_32_512_approximate_sse3:                 526.7 (19.70x)
yuv2yuvX_8_16_32_512_approximate_avx2:                 354.7 (29.24x)
yuv2yuvX_8_16_48_512_approximate_c:                  10066.9 ( 1.00x)
yuv2yuvX_8_16_48_512_approximate_sse2:                1055.8 ( 9.53x)
yuv2yuvX_8_16_48_512_approximate_sse3:                 527.9 (19.07x)
yuv2yuvX_8_16_48_512_approximate_avx2:                 313.7 (32.09x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-26 23:48:21 +02:00
Andreas Rheinhardt 62285be009 swscale/x86/swscale_template: Don't set use_mmx_vfilter when disabled
Commit 554c2bc708
ported the yuv2planeX functions that are set iff
use_mmx_vfilter is set to external assembly
and did it in a way that resulted in linking failures
when inline assembly is enabled, but external assembly
is disabled. This was later fixed in commit
c00567647e, but in such
a manner that use_mmx_vfilter can be set without any
of the accompanying yuv2planeX functions being set;
and in case inline assembly was unavailable,
these external assembly functions would never be selected.

This makes the filter-fps and filter-fps-cfr tests fail
with inline assembly but with --disable-x86asm, as
reported in issue #21113. Fix this by moving sws_init_swscale_mmxext
directly into ff_sws_init_swscale_x86() and setting
use_mmx_vfilter directly besides the yuv2planeX function pointer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-26 23:48:21 +02:00
Andreas Rheinhardt 3dd03e4d4c avcodec/libvorbisenc: Cleanup on error
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-26 23:08:46 +02:00
Andreas Rheinhardt df70e8297b avcodec/libvorbisenc: Return error upon error
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-26 23:08:46 +02:00
Andreas Rheinhardt 51c5cc0ca3 avcodec/libvorbisenc: Fix leak of vorbis_comment upon error
Just free it immediately and unconditionally after it is no longer
needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-26 23:08:46 +02:00
Semih Baskan bdc0a29204 avcodec/nvenc: gate MVHEVC capability check on codec_id
NV_ENC_H264_PROFILE_HIGH_10 and NV_ENC_HEVC_PROFILE_MULTIVIEW_MAIN
both equal 3 when their respective NVENC_HAVE_* flags are defined.
The MVHEVC check in nvenc_check_capabilities() matches against
ctx->profile alone, so an H.264 encode with profile=high10 is
rejected as if it were an HEVC multiview request on hardware
without MVHEVC support.

Signed-off-by: Semih Baskan <strst.gs@gmail.com>
2026-04-26 19:25:12 +00:00
Timo Rothenpieler 1351c2c019 forgejo/workflows: make labeler also removed non-applicable labels again 2026-04-26 15:28:38 +00:00
Zhao Zhili e717604a29 avfilter/mpdecimate: fix kept-frame forwarding and error handling
When duplicate frames are forced to be kept, forward the input frame
without cloning instead of creating an unnecessary extra reference.
This removes the leak path introduced when clone allocation fails.

For frames that become the new reference, keep using a clone for
forwarding.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-26 16:05:11 +08:00
Macdu 78da965b58 avcodec/atrac9tab: correct base curve value 2026-04-25 22:44:39 +02:00
Nicolas George fc4960b155 MAINTAINERS: add myself for libavfilter
I have been maintaining the framework and orphaned filters
for ages but apparently it was never recorded in this file.
2026-04-25 19:18:28 +02:00
Nicolas George 0b08d82425 configure: use ./src instead of src
Fix “do "src/doc/t2h.pm" failed, '.' is no longer in @INC; did you mean do "./src/doc/t2h.pm"?”
when we have such a symlink.
2026-04-25 17:25:28 +02:00
James Almer 45fe315cf0 tests/fate/mpegts: add tests for LCEVC samples
Both single track (Payloads inside SEI messages) and dual track.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-24 16:04:48 -03:00
llyyr 5134b0aceb libavutil/hwcontext_vulkan: fix internal queue sync device creation
6f811ad never set VK_DEVICE_QUEUE_CREATE_INTERNALLY_SYNCHRONIZED_BIT_KHR
on the queues at vkCreateDevice. Without the flag, the driver doesn't
actually synchronizes queues.

Fixes: 6f811ad751 ("hwcontext_vulkan: implement internal queue synchronization")
2026-04-24 16:07:28 +05:30
llyyr 51660ad523 libavutil/vulkan: replace GetDeviceQueue with GetDeviceQueue2
vkGetDeviceQueue2 with flags = 0 is equivalent to vkGetDeviceQueue and
is available since Vulkan 1.1. Needed to support queues created with
non-zero VkDeviceQueueCreateFlags.

Fixes VUID-vkGetDeviceQueue-flags-01841 VVL error.
2026-04-24 16:07:25 +05:30
ASTRA 163ba704b7 avformat/wavdec: Fix use-of-uninitialized-value in find_guid()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-24 06:36:41 +00:00
AdityaTeltia 71d5fa8d4d avformat/hls_sample_encryption: add missing padding for audio setup buffer
Fixes ticket #22890.

The ff_hls_senc_parse_audio_setup_info function passes setup_data to
parsers like avpriv_ac3_parse_header and init_get_bits8 which require
the buffer to be padded with AV_INPUT_BUFFER_PADDING_SIZE bytes at the end.
2026-04-24 03:23:06 +00:00
Ramiro Polla 08f56d4898 avcodec/webp: remove write-only lossless field from WebPContext 2026-04-23 16:46:42 +00:00
Ramiro Polla 9e8e82308b avcodec/webp: use av_fourcc2str() to print fourccs 2026-04-23 16:46:42 +00:00
Ramiro Polla 0cd2bbe4f4 avformat/apngdec: fix playback of piped apng files
The check for avio_size() made apng_read_header() return an error
instead of just disabling looping.
2026-04-23 16:46:21 +00:00
Ramiro Polla 2e92764b86 avformat/apngdec: remove unused function argument 2026-04-23 16:46:21 +00:00
Lynne 162ad61486 vulkan/ffv1: fix second-line linecache initialization for Golomb
This was a difficult problem to find.

Sponsored-by: Sovereign Tech Fund
2026-04-22 23:24:04 +02:00
Marvin Scholz 0c6b4ad5fc doc: add narrow variable scope in loops to style examples 2026-04-22 13:29:18 +00:00
jade 5242bdae82 avformat/id3v2: add image/jxl for JPEG XL image attachments
This allows JPEG XL images to be recognized as valid attachments.
Since JPEG is already widely used for cover art, JXL's support for
lossless JPEG transcodes can decrease the total size of music collections.
This fixes JXL cover art rendering in applications like mpv which rely
on FFmpeg for demuxing.

Signed-off-by: jade <heartstopp1ng@proton.me>
2026-04-22 13:28:17 +00:00
Marvin Scholz fc8d975b0b .forgejo/CODEOWNERS: fix incorrect username
The username does not exist, instead replaced it with the user
who authored the commit that added it.
2026-04-22 12:55:43 +00:00
Marvin Scholz d4cf7cf1cf lavfi: vf_drawtext: properly propagate errors
Do not ignore errors from draw_text().
2026-04-22 12:33:26 +00:00
Marvin Scholz 69072fe8d8 lavfi: vf_drawtext: check memory allocation
Switch to av_calloc and check the allocation.

Fix #22867
2026-04-22 12:33:26 +00:00
Lynne 117807510a vf_overlay_vulkan: port to compile-time SPIR-V generation 2026-04-22 12:45:45 +02:00
Lynne c7d3d3ac55 vf_blend_vulkan: port to compile-time SPIR-V generation 2026-04-22 12:45:45 +02:00
Lynne 4d6cd9f983 vf_scdet_vulkan: port to compile-time SPIR-V generation 2026-04-22 12:45:40 +02:00
Ashrit Shetty 9acd820732 avcodec/mfenc: populate video input type with size, rate, interlace
mf_encv_input_adjust() currently only validates the pixel format and
otherwise leaves the input IMFMediaType unchanged. The Microsoft
H.264, H.265 and AV1 encoder MFTs tolerate this and internally infer
the missing attributes from the previously-set output type. Other
MediaFoundation encoder MFTs that follow the specification more
strictly reject the input type with MF_E_INVALIDMEDIATYPE (due to
MF_E_ATTRIBUTENOTFOUND on MF_MT_FRAME_SIZE / MF_MT_FRAME_RATE) when
those attributes are absent, which causes IMFTransform::SetInputType
to fail and aborts encoding.

Set MF_MT_FRAME_SIZE, MF_MT_FRAME_RATE and MF_MT_INTERLACE_MODE on
the input media type, mirroring what mf_encv_output_adjust() already
writes to the output type. Behaviour on the Microsoft MFTs is
unchanged (they were already using these values) and encoding now
works with stricter third-party MFTs.

The MF_MT_FRAME_SIZE assignment has been present but commented out
since the original MediaFoundation wrapper was added in 050b72ab5e.

Signed-off-by: Ashrit Shetty <ashritshetty@microsoft.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2026-04-22 10:48:24 +03:00
Dmitrii Gershenkop d1d873c003 avfilter/vf_frc_amf: Add AMF Frame Rate Converter filter 2026-04-21 16:47:05 +00:00
Diego de Souza 0bba4603e2 avcodec/cuviddec: fix monochrome formats misclassified as YUV444
Monochrome formats (gray, gray10le) have log2_chroma_w == 0 and
log2_chroma_h == 0 because they have no chroma planes — the same
values as YUV444. This caused them to be misclassified as YUV444 by
the is_yuv444 detection introduced in bcea693f75.

After fed6612415 changed cuvid_test_capabilities to use is_yuv444
instead of hardcoding cudaVideoChromaFormat_420, monochrome AV1
streams were rejected with "Codec av1_cuvid is not supported with
this chroma format".

Add an nb_components > 1 guard to exclude single-component formats
from the YUV444 path.

Patch by: Aniket Dhok <adhok@nvidia.com>
Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-04-21 16:51:54 +02:00
Diego de Souza afc8556a6a avcodec/cuviddec: handle 4-byte AV1CodecConfigurationRecord
AV1CodecConfigurationRecord may contain only the 4-byte header and no
configOBUs. Still skip the header in that case so only configOBUs are
passed to cuvidParseVideoData().

Otherwise the av1C header itself is treated as sequence header data
and AV1 decoding can fail with an unknown error.

Suggested-by: Aniket Dhok <adhok@nvidia.com>
Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-04-21 14:03:58 +00:00
Paul Adenot 99d8d3891f avcodec: Allow enabling DTX in libopusenc 2026-04-21 13:38:44 +00:00
Víctor Manuel Jáquez Leal f4ac7dee87 avcodec/vulkan_encode_h265: fix capabilities flags
Replace the H264 ones.
2026-04-21 13:08:59 +00:00
Jun Zhao 75838b9c89 lavc/hevc: add aarch64 NEON for reference sample filtering
3-tap [1,2,1]>>2: shared implementation body across size-specialized
entry points (8x8/16x16/32x32) to reduce code size. Fold the 3-tap
kernel into uhadd + urhadd: uhadd gives floor((prev+next)/2), then
urhadd rounds with curr to produce (prev + 2*curr + next + 2) >> 2
on 16 bytes in-place (no widen/narrow needed). Overlap-last technique
for tail avoids partial stores. Caller pads input arrays by 16 bytes
to guarantee safe over-read.

Strong smoothing (32x32): preloaded weight tables, interleaved
umull/umlal pairs (two 16-byte blocks at a time) to hide
rshrn-to-store latency, with paired st1 for 32-byte writes.

checkasm --bench --runs=15 (Apple M4, average of 3 trials):
  ref_filter_3tap_8x8_8_neon:    4.1x
  ref_filter_3tap_16x16_8_neon:  3.3x
  ref_filter_3tap_32x32_8_neon:  2.5x
  ref_filter_strong_8_neon:      1.9x

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-21 07:50:49 +00:00
Jun Zhao 188757d43d tests/checkasm: add hevc_pred ref_filter_3tap and ref_filter_strong tests
Test 3-tap for 8x8/16x16/32x32 (both filtered_left and
filtered_top outputs). Test strong smoothing for filtered_top
and in-place left modification.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-21 07:50:49 +00:00
Jun Zhao a3d8e417c0 lavc/hevc: extract reference sample filter into function pointers
Extract 3-tap [1,2,1]>>2 and strong intra smoothing from
intra_pred() into HEVCPredContext function pointers, preparing
for arch-specific overrides.

ref_filter_3tap[3] indexed by log2_size - 3 (sizes 8/16/32).
ref_filter_strong for 32x32 luma only.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-21 07:50:49 +00:00
Lynne d3e915d6d1 vf_xfade_vulkan: remove unused includes 2026-04-21 09:39:54 +02:00
Lynne 6f811ad751 hwcontext_vulkan: implement internal queue synchronization 2026-04-21 08:34:47 +02:00
Lynne 8483de2858 chromaber_vulkan: switch to compile-time SPIR-V generation 2026-04-21 08:28:50 +02:00
Lynne 8001b19dc8 vf_gblur_vulkan: port to compile-time SPIR-V generation 2026-04-21 08:28:50 +02:00
Lynne ada9716172 vsrc_testsrc_vulkan: convert to compile-time SPIR-V generation 2026-04-21 08:28:50 +02:00
Lynne 4061e3351f vf_transpose_vulkan: convert to compile-time SPIR-V generation 2026-04-21 08:28:50 +02:00
Lynne d0ee5d0556 vf_flip_vulkan: convert to compile-time SPIR-V generation 2026-04-21 08:28:50 +02:00
Lynne 2f7d3290c0 vf_xfade_vulkan: convert to compile-time SPIR-V generation 2026-04-21 08:28:49 +02:00
Lynne f8f485fb3c vf_interlace_vulkan: convert to compile-time SPIR-V generation 2026-04-21 08:28:49 +02:00
Lynne d381151ae3 vulkan_filter: add an argument for setting the Z workgroup count 2026-04-21 08:28:45 +02:00
Zuxy Meng dc23adde9b avcodec/x86/h264_intrapred: Replace pred8x8_dc_8_mmxext with SSE2
Deprecating MMX w/o performance regression; nearly identical performance
numbers on my Zen 4 (1.99x vs c)

Signed-off-by: Zuxy Meng <zuxy.meng@gmail.com>
2026-04-20 19:38:56 -07:00
nyanmisaka c92304f8c7 avfilter: add transpose_cuda video filter
This patch adds the transpose_cuda video filter.
It's similar to the existing transpose filter but accelerated by CUDA.

It supports the same pixel formats as the scale_cuda filter.
This also supersedes the deprecated transpose_npp filter.

Example usage:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i <INPUT> -vf "transpose_cuda=dir=clock" <OUTPUT>

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2026-04-20 21:08:21 +02:00
Arien Shibani c67a4554d1 CONTRIBUTING.md: add blank line after top heading
Insert spacing after the first heading (MD022-style).
2026-04-20 12:32:50 +00:00
Arien Shibani 849e8307ce doc/transforms.md: add document title and fix heading structure
Add a top-level title and demote former section headings (MD041-style hierarchy).

Add blank lines around headings and fenced code blocks where appropriate (MD022 and MD031-style). Some Markdown parsers, including kramdown, only recognize headings that are preceded by a blank line.
2026-04-20 12:32:50 +00:00
Arien Shibani 6e3366e9bc INSTALL.md: add title heading and normalize section levels
Use a top-level heading on the first line (MD041-style) and adjust section levels for clearer document structure. Improves navigation for assistive technologies that rely on heading outlines.
2026-04-20 12:32:50 +00:00
Arien Shibani 519c80b626 README.md: use consistent ATX heading style
Align heading markers with markdownlint MD003 suggestions.
2026-04-20 12:32:50 +00:00
Andreas Rheinhardt 5e69e6d49c avformat/pdvenc: Don't silently truncate value
This muxer seems to intend to support output that does
not begin at zero (instead of e.g. just hardcoding
nb_frames_pos to 16). But then it is possible
that avio_seek() returns values > INT_MAX even
though the part of the file written by us can not
exceed this value. So the return value of avio_seek()
needs to be checked as 64bit integer and not silently
truncated to int.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-20 12:54:31 +02:00
Andreas Rheinhardt 2b8438a495 avformat/pdvenc: Remove always-false checks
The number of streams is always one (namely one video stream
with codec id AV_CODEC_ID_PDV) due to the MAX_ONE_OF_EACH,
ONLY_DEFAULT_CODECS flags. Also, the generic code (init_muxer()
in mux.c) checks that video streams have proper dimensions set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-20 12:54:31 +02:00
Andreas Rheinhardt 6135ccbf80 avcodec/pdvenc: Return directly upon error
This encoder has the FF_CODEC_CAP_INIT_CLEANUP cap set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-20 12:54:31 +02:00
Andreas Rheinhardt 87a6be19f8 avcodec/pdvenc: Remove always false check
av_image_check_size() already checks that width*height
fits into an int.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-20 12:54:31 +02:00
Andreas Rheinhardt c94cb9c04f avcodec/pdvenc: Remove always-false pixel format check
Already checked via CODEC_PIXFMTS.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-20 12:54:31 +02:00
Andreas Rheinhardt e908c92f5a avcodec/cavs: Don't allocate block separately
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-20 12:21:41 +02:00
Jeongkeun Kim de18feb0f0 avutil/aarch64: add pixelutils 32x32 SAD NEON implementation
This adds a NEON-optimized function for computing 32x32 Sum of Absolute
Differences (SAD) on AArch64, addressing a gap where x86 had SSE2/AVX2
implementations but AArch64 lacked equivalent coverage.

The implementation mirrors the existing sad8 and sad16 NEON functions,
employing a 4-row unrolled loop with UABAL and UABAL2 instructions for
efficient load-compute interleaving, and four 8x16-bit accumulators to
handle the wider 32-byte rows.

Benchmarks on AWS Graviton3 (Neoverse V1, c7g.xlarge) using checkasm:
  sad_32x32_0: C 146.4 cycles -> NEON  98.1 cycles (1.49x speedup)
  sad_32x32_1: C 141.4 cycles -> NEON  98.9 cycles (1.43x speedup)
  sad_32x32_2: C 140.7 cycles -> NEON  95.0 cycles (1.48x speedup)

Signed-off-by: Jeongkeun Kim <variety0724@gmail.com>
2026-04-19 19:27:55 +00:00
llyyr 4af27ba4ca doc/APIchanges: fix date and version in latest entry
This incorrectly lists the libavcodec major version as 60 instead of
62. Also fix the date and commit hash while at it

Fixes: 7faa6ee2aa ("libavformat/matroska: Support smpte 2094-50 metadata")

Signed-off-by: llyyr <llyyr.public@gmail.com>
2026-04-19 15:37:33 +00:00
Romain Beauxis 82d7e375f1 libavdevice/alsa.c: fix NULL pointer dereference 2026-04-19 15:00:08 +00:00
Andreas Rheinhardt 415b466d41 avcodec/x86/vp3dsp: Port ff_vp3_idct_dc_add_mmxext to SSE2
This change should improve performance on Skylake and later
Intel CPUs (which have only half the ports for saturated adds/subs
for mmx register compared to xmm register): llvm-mca predicts
a 25% performance improvement on Skylake.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-19 08:21:17 +02:00
Andreas Rheinhardt e7a613b274 avcodec/x86/vp3dsp: Avoid loads and stores
Instead reuse values in registers.

Old benchmarks:
idct_add_c:                                             74.2 ( 1.00x)
idct_add_sse2:                                          60.4 ( 1.23x)
idct_put_c:                                            100.8 ( 1.00x)
idct_put_sse2:                                          58.7 ( 1.72x)

New benchmarks:
idct_add_c:                                             74.2 ( 1.00x)
idct_add_sse2:                                          55.2 ( 1.34x)
idct_put_c:                                            107.5 ( 1.00x)
idct_put_sse2:                                          54.1 ( 1.99x)

Hint: For x64, all the intermediate stores could be avoided.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-19 08:21:17 +02:00
Andreas Rheinhardt ed59fc77e8 avcodec/x86/vp3dsp: Use named args in idct functions
Also avoid REX prefixes while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-19 08:21:17 +02:00
Andreas Rheinhardt c1af56357b avcodec/x86/vp3dsp: Avoid unnecessary macro, repetition
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-19 08:21:17 +02:00
Andreas Rheinhardt 88879f2eff tests/checkasm/vp3dsp: Add test for idct_add, idct_put, idct_dc_add
Due to a discrepancy between SSE2 and the C version coefficients
for idct_put and idct_add are restricted to a range not causing
overflows.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-19 08:21:08 +02:00
Andreas Rheinhardt 84b9de0633 avcodec/x86/vp3dsp: Port ff_put_vp_no_rnd_pixels8_l2_mmx to SSE2
This allows to use pavgb to reduce the amount of instructions used
to calculate the average; processing two rows via movhps allows
to reduce the amount of pxor and pavgb even further and turned
out to be beneficial.
This patch also avoids a load as the constant used here can be easily
generated at runtime.

Old benchmarks:
put_no_rnd_pixels_l2_c:                                 13.3 ( 1.00x)
put_no_rnd_pixels_l2_mmx:                               11.6 ( 1.15x)

New benchmarks:
put_no_rnd_pixels_l2_c:                                 13.4 ( 1.00x)
put_no_rnd_pixels_l2_sse2:                               7.5 ( 1.77x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-19 08:15:54 +02:00
Andreas Rheinhardt 37bc3a237b tests/checkasm/vp3dsp: Add test for put_no_rnd_pixels_l2
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-19 08:14:50 +02:00
Andreas Rheinhardt 79ce4432e0 avcodec/simple_idct10_template: Reduce amount of registers used
This allows to avoid the stack for the 8 bit simple IDCT;
for the other IDCTs, it avoids storing and restoring two
xmm registers on Win64.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-19 07:36:37 +02:00
Andreas Rheinhardt e1782fb016 avutil/x86/pixelutils: Don't use mmx in 8x8 SAD
This function is exported, so has to abide by the ABI
and therefore issues emms since commit
5b85ca5317. Yet this is
expensive and using SSE2 instead improves performance.
Also avoid the initial zeroing and the last pointer
increment while just at it.
This removes the last usage of mmx from libavutil*.

Old benchmarks:
sad_8x8_0_c:                                            13.2 ( 1.00x)
sad_8x8_0_mmxext:                                       27.8 ( 0.48x)
sad_8x8_1_c:                                            13.2 ( 1.00x)
sad_8x8_1_mmxext:                                       27.6 ( 0.48x)
sad_8x8_2_c:                                            13.3 ( 1.00x)
sad_8x8_2_mmxext:                                       27.6 ( 0.48x)

New benchmarks:
sad_8x8_0_c:                                            13.3 ( 1.00x)
sad_8x8_0_sse2:                                         11.7 ( 1.13x)
sad_8x8_1_c:                                            13.8 ( 1.00x)
sad_8x8_1_sse2:                                         11.6 ( 1.20x)
sad_8x8_2_c:                                            13.2 ( 1.00x)
sad_8x8_2_sse2:                                         11.8 ( 1.12x)

Hint: Using two psadbw or one psadbw and movhps made no difference
in the benchmarks, so I chose the latter due to smaller codesize.

*: except if lavu provides avpriv_emms for other libraries

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-18 21:21:11 +02:00
Michael Niedermayer d538a71ad5 avcodec/svq1dec: Check input space for minimum
We reject inputs that are significantly smaller than the smallest frame.
This check raises the minimum input needed before time consuming computations are performed
it thus improves the computation per input byte and reduces the potential DoS impact

Fixes: Timeout
Fixes: 472769364/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SVQ1_DEC_fuzzer-5519737145851904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-18 18:32:50 +00:00
Andreas Rheinhardt fcffc0e1c5 avformat/matroskaenc: Remove pointless side-data size checks
Just presume that we any present side data is actually valid.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-17 23:53:12 +02:00
Andreas Rheinhardt 38df985fba avformat/matroskaenc: Use separate buffer for SMPTE 2094 blockadditional
Otherwise the buffer for the hdr10+ blockadditional would
be clobbered if both are present (the buffers can only be
reused after the ebml_writer_write() call).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-17 23:53:07 +02:00
Andreas Rheinhardt 25ce544d4b avformat/matroskaenc: Increase size of EBML_WRITER array
7faa6ee2aa added support
for writing AV_PKT_DATA_DYNAMIC_HDR_SMPTE_2094_APP5,
yet forgot to update the size of the EBML element buffer.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-17 23:52:53 +02:00
Vignesh Venkat 7faa6ee2aa libavformat/matroska: Support smpte 2094-50 metadata
Add support for parsing and muxing smpte 2094-50 metadata. It will
be stored as an ITUT-T35 message in the BlockAdditional element with
an AddId type of 4 (which is reserved for ITUT-T35 in the matroska
spec).

https://www.matroska.org/technical/codec_specs.html#itu-t35-metadata

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
2026-04-17 18:51:25 +00:00
Lynne c1b19ee69f aacdec: add support for 960-frame HE-AAC (DAB+) decoding
Finally, after so many years. I'm sure there's good DAB+ content
out there being broadcast. Go and listen to it.
2026-04-17 16:46:52 +02:00
Hassan Hany 9e4041d5ea avcodec/opus: use precomputed NLSF weights for Silk decoder
Precompute the SILK NLSF residual weights from the stage-1 codebooks and use the table during LPC decode. This removes the per-coefficient mandated fixed-point weight calculation in silk_decode_lpc() while preserving the same decoded values.
2026-04-17 14:39:20 +00:00
Niklas Haas 96f82f4fbb swscale/x86/ops: simplify SWS_OP_CLEAR patterns
Mark the components to be cleared, not the components to be preserved.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:25:17 +02:00
Niklas Haas 08707934cc swscale/ops_backend: simplify SWS_OP_CLEAR declarations
Mark the components to be cleared, not the components to be preserved.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:25:17 +02:00
Niklas Haas 7a71a01a1b swscale/ops: nuke SwsComps.unused
Finally, remove the last relic of this accursed design mistake.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:25:17 +02:00
Niklas Haas a797e30f71 swscale/aarch64/ops: compute SWS_OP_PACK mask directly
Instead of implicitly relying on SwsComps.unused, which contains the exact
same information. (cf. ff_sws_op_list_update_comps)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:25:17 +02:00
Niklas Haas 6d1e549195 swscale/aarch64/ops: use SWS_OP_NEEDED() instead of next->comps.unused
These are basically identical, but the latter is being phased out.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:25:17 +02:00
Niklas Haas 18cc71fc8e swscale/aarch64/ops: fix SWS_OP_LINEAR mask check
The implementation of AARCH64_SWS_OP_LINEAR loops over elements of this mask
to determine which *output* rows to compute. However, it is being set by this
loop to `op->comps.unused`, which is a mask of unused *input* rows. As such,
it should be looking at `next->comps.unused` instead.

This did not result in problems in practice, because none of the linear
matrices happened to trigger this case (more input columns than output rows).

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:25:17 +02:00
Niklas Haas df4fe85ae3 swscale/ops_chain: replace SwsOpEntry.unused by SwsCompMask
Needed to allow us to phase out SwsComps.unused altogether.

It's worth pointing out the change in semantics; while unused tracks the
unused *input* components, the mask is defined as representing the
computed *output* components.

This is 90% the same, expect for read/write, pack/unpack, and clear; which
are the only operations that can be used to change the number of components.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:25:10 +02:00
Niklas Haas 215cd90201 swscale/x86/ops: simplify DECL_DITHER definition
This extra indirection boilerplate just for the 0-size fast path really isn't
doing us any favors.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:24:55 +02:00
Niklas Haas 9f0dded48d swscale/ops_chain: check for exact linear mask match
Makes this logic a lot simpler and less brittle. We can trivially adjust the
list of linear masks that are required, whenever it changes as a result of any
future modifications.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:24:55 +02:00
Niklas Haas e20a32d730 swscale/x86/ops: align linear kernels with reference backend
See previous commit.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:24:55 +02:00
Niklas Haas 9b1c1fe95f swscale/ops_backend: align linear kernels with actually needed masks
Using the power of libswscale/tests/sws_ops -summarize lets us see which
kernels are actually needed by real op lists.

Note: I'm working on a separate series which will obsolete this implementation
whack-a-mole game altogether, by generating a list of all possible op kernels
at compile time.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:24:55 +02:00
Niklas Haas af2674645f swscale/ops: drop offset from SWS_MASK_ALPHA
This is far more commonly used without an offset than with; so having it there
prevents these special cases from actually doing much good.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:24:55 +02:00
Niklas Haas 526195e0a3 swscale/x86/ops_float: fix typo in linear_row
First vector is %2, not %3. This was never triggered before because all of
the existing masks never hit this exact case.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:24:55 +02:00
Niklas Haas 6a83e15392 swscale/ops_chain: simplify SwsClearOp checking
Since this now has an explicit mask, we can just check that directly, instead
of relying on the unused comps hack/trick.

Additionally, this also allows us to distinguish between fixed value and
arbitrary value clears by just having the SwsOpEntry contain NAN values iff
they support any clear value.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:24:22 +02:00
Niklas Haas 80bd6c0cd5 swscale/ops: don't strip range metadata for unused components
As alluded to by the previous commit, this is now no longer necessary to
prevent their print-out.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:23:36 +02:00
Niklas Haas 3680642e1b swscale/ops: simplify min/max range print check
This does come with a slight change in behavior, as we now don't print the
range information in the case that the range is only known for *unused*
components. However, in practice, that's already guaranteed by update_comps()
stripping the range info explicitly in this case.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:23:36 +02:00
Niklas Haas 9bb2b11d5b swscale/ops: add SwsCompMask parameter to print_q4()
Instead of implicitly excluding NAN values if ignore_den0 is set. This
gives callers more explicit control over which values to print, and in
doing so, makes sure "unintended" NaN values are properly printed as such.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:23:36 +02:00
Niklas Haas cf2d40f65d swscale/ops: add explicit clear mask to SwsClearOp
Instead of implicitly testing for NaN values. This is mostly a straightforward
translation, but we need some slight extra boilerplate to ensure the mask
is correctly updated when e.g. commuting past a swizzle.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:23:36 +02:00
Niklas Haas 4020607f0a swscale/ops: add SwsCompMask and related helpers
This new type will be used over the following commits to simplify the
codebase.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:23:36 +02:00
Niklas Haas ce2ca1a186 swscale/ops_optimizer: fix commutation of U32 clear + swap_bytes
This accidentally unconditionally overwrote the entire clear mask, since
Q(n) always set the denominator to 1, resulting in all channels being
cleared instead of just the ones with nonzero denominators.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 23:23:36 +02:00
Niklas Haas 953d278a01 tests/swscale: fix input pattern generation for very small sizes
This currently completely fails for images smaller than 12x12; and even in that
case, the limited resolution makes these tests a bit useless.

At the risk of triggering a lot of spurious SSIM regressions for very
small sizes (due to insufficiently modelling the effects of low resolution on
the expected noise), this patch allows us to at least *run* such tests.

Incidentally, 8x8 is the smallest size that passes the SSIM check.
2026-04-16 20:59:39 +00:00
Niklas Haas 0da2bbab68 swscale/ops_dispatch: re-indent (cosmetic) 2026-04-16 20:59:39 +00:00
Niklas Haas 4c19f82cc0 swscale/ops_dispatch: compute minimum needed tail size
Not only does this take into account extreme edge cases where the plane
padding can significantly exceed the actual width/stride, but it also
correctly takes into account the filter offsets when scaling; which the
previous code completely ignored.

Simpler, robuster, and more correct. Now valgrind passes for 100% of format
conversions for me, with and without scaling.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas cd8ece4114 swscale/ops_dispatch: generalize the number of tail blocks
This is a mostly straightforward internal mechanical change that I wanted
to isolate from the following commit to make bisection easier in the case of
regressions.

While the number of tail blocks could theoretically be different for input
vs output memcpy, the extra complexity of handling that mismatch (and
adjusting all of the tail offsets, strides etc.) seems not worth it.

I tested this commit by manually setting `p->tail_blocks` to higher values
and seeing if that still passed the self-check under valgrind.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas dba7b81b38 swscale/ops_dispatch: avoid calling comp->func with w=0
The x86 kernel e.g. assumes that at least one block is processed; so avoid
calling this with an empty width. This is currently only possible if e.g.
operating on an unpadded, very small image whose total linesize is less than
a single block.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas 35174913ac swscale/ops_dispatch: fix and generalize tail buffer size calculation
This code had two issues:

1. It was over-allocating bytes for the input offset map case, and
2. It was hard-coding the assumption that there is only a single tail block

We can fix both of these issues by rewriting the way the tail size is derived.

In the non-offset case, and assuming only 1 tail block:
    aligned_w - safe_width
  = num_blocks * block_size - (num_blocks - 1) * block_size
  = block_size

Additionally, the FFMAX(tail_size_in/out) is unnecessary, because:
    tail_size = pass->width - safe_width <= aligned_w - safe_width

In the input offset case, we instead realize that the input kernel already
never over-reads the input due to the filter size adjustment/clamping, so
the only thing we need to ensure is that we allocate extra bytes for the
input over-read.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas f604add8c1 swscale/ops_dispatch: remove pointless AV_CEIL_RSHIFT()
The over_read/write fields are not documented as depending on the subsampling
factor. Actually, they are not documented as depending on the plane at all.

If and when we do actually add support for horizontal subsampling to this
code, it will most likely be by turning all of these key variables into
arrays, which will be an upgrade we get basically for free.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas dd8ff89adf swscale/ops_dispatch: add helper to explicitly control pixel->bytes rounding
This makes it far less likely to accidentally add or remove a +7 bias when
repeating this often-used expression.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas 16a57b2985 swscale/ops_dispatch: ensure block size is multiple of pixel size
This could trigger if e.g. a backend tries to operate on monow formats with
a block size that is not a multiple of 1. In this case, `block_size_in`
would previously be miscomputed (to e.g. 0), which is obviously wrong.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas 86307dad4a swscale/ops_dispatch: make offset calculation code robust against overflow
As well as weird edge cases like trying to filter `monow` and pixels landing
in the middle of a byte. Realistically, this will never happen - we'd instead
pre-process it into something byte-aligned, and then dispatch a byte-aligned
filter on it.

However, I need to add a check for overflow in any case, so we might as well
add the alignment check at the same time. It's basically free.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas 95e4f7cac5 swscale/ops_dispatch: fix rounding direction of plane_size
This is an upper bound, so it should be rounded up.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas c6e47b293d swscale/ops_dispatch: pre-emptively guard against int overflow
By using size_t whenever we compute derived figures.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas 0524e66aec swscale/ops_dispatch: drop pointless const (cosmetic)
These are clearly not mutated within their constrained scope, and it just
wastes valuable horizontal space.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas c98810ac78 swscale/ops_dispatch: zero-init tail buffer
Prevents valgrind from complaining about operating on uninitialized bytes.
This should be cheap as it's only done once during setup().

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas ba516a34cd swscale/x86/ops_int: use sized mov for packed_shuffle output
This code made the input read conditional on the byte count, but not the
output, leading to a lot of over-write for cases like 15, 5.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Niklas Haas 4264045137 swscale/x86/ops: set missing over_read metadata on filter ops
These align the filter size to a multiple of the internal tap grouping
(either 1/2/4 for vpgatherdd, or the XMM size for the 4x4 transposed kernel).
This may over-read past the natural end of the input buffer, if the aligned
size exceeds the true size.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 20:59:39 +00:00
Peter von Kaenel d013863f00 avcodec/lcevcdec: poll on LCEVC_Again from LCEVC_ReceiveDecoderPicture
The V-Nova LCEVC pipeline processes frames on internal background
worker threads. LCEVC_ReceiveDecoderPicture returns LCEVC_Again (-1)
when the worker has not yet completed the frame, which is the
documented "not ready, try again" response. The original code treated
any non-zero return as a fatal error (AVERROR_EXTERNAL), causing decode
to abort mid-stream.

Poll until LCEVC_Success or a genuine error is returned.

Signed-off-by: Peter von Kaenel <Peter.vonKaenel@harmonicinc.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-16 17:19:28 -03:00
Andreas Rheinhardt 9ab37ef918 avcodec/packet: Remove always-true check
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-16 19:27:03 +00:00
Andreas Rheinhardt 4b5e1d25c3 avcodec/decode: Short-circuit side-data processing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-16 19:27:03 +00:00
Andreas Rheinhardt a85709537e avcodec/decode: Avoid temporary frame in ff_reget_buffer()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-16 19:27:03 +00:00
Andreas Rheinhardt b595b3075e avcodec/decode: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-16 19:27:03 +00:00
Andreas Rheinhardt f99e4a0f23 avcodec/decode: Optimize call away if possible
post_process_opaque is only used by LCEVC, so it is unused
on most builds.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-16 19:27:03 +00:00
Andreas Rheinhardt 312bfd512d avcodec/decode: Remove always-true checks
dc->lcevc.ctx is only != NULL for video.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-16 19:27:03 +00:00
Andreas Rheinhardt 2d062dd0c6 avcodec/decode: Make post_process_opaque a RefStruct reference
Avoids the post_process_opaque_free callback; the only user of
this is already a RefStruct reference and presumably other users
would want to use a pool for this, too, so they would use
RefStruct-objects, too.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-16 19:27:03 +00:00
Andreas Rheinhardt 0ee1947d9b avcodec/lcevcdec: Use pool to avoid allocations of FFLCEVCFrame
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-16 19:27:03 +00:00
Kacper Michajłow 03967fcff4 tests/checkasm/sw_ops: fix too large shift for int
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-04-16 18:56:22 +00:00
Kacper Michajłow 369dbbe488 swscale/ops_memcpy: guard exec->in_stride[-1] access
When use_loop == true and idx < 0, we would incorrectly check
in_stride[idx], which is OOB read. Reorder conditions to avoid that.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-04-16 18:56:22 +00:00
Niklas Haas 1764683668 swscale/ops_backend: disable FP contraction where possible
In particular, Clang defaults to FP contraction enabled. GCC defaults to
off in standard C mode (-std=c11), but the C standard does not actually
require any particular default.

The #pragma STDC pragma, despite its name, warns on anything except Clang.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/22796
See-also: https://discourse.llvm.org/t/fp-contraction-fma-on-by-default/64975
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-16 17:19:51 +00:00
Hassan Hany 3b19a61837 avcodec/vorbisdec: validate windowtype and transformtype 2026-04-16 10:24:41 +00:00
Gyan Doshi 5abc240a27 avcodec/videotoolboxenc: add missing field and rectify cap flags 2026-04-16 09:58:06 +00:00
Daniel Verkamp 8eae5de5af avformat/wavenc: Keep fmt chunk first for -rf64 auto
When the WAV muxer's `-rf64 auto` option is used, the output is intended
to be a normal WAV file if possible, only extended to RF64 format when
the file size grows too large. This was accomplished by reserving space
for the extra RF64-specific data using a standard JUNK chunk (ignored by
readers), then overwriting the reserved space later with a ds64 chunk if
needed.

In the original rf64 auto implementation, the JUNK chunk was placed
right after the RIFF/WAVE file header, before the fmt chunk; this is the
design suggested by the "Achieving compatibility between BWF and RF64"
section of the RF64 spec:

  RIFF 'WAVE' <JUNK chunk> <fmt-ck> ...

However, this approach means that the fmt chunk is no longer in its
conventional location at the beginning of the file, and some WAV-reading
tools are confused by this layout. For example, the `file` tool is not
able to show the format information for a file with the extra JUNK chunk
before fmt.

This change shuffles the order of the chunks for `-rf64 auto` mode so
that the reserved space follows fmt instead of preceding it:

  RIFF 'WAVE' <fmt-ck> <JUNK chunk> ...

With this small modification, tools expecting the fmt chunk to be the
first chunk in the file work with files produced by `-rf64 auto`.

This means the fmt chunk won't be in the location required by RF64, so
if the automatic RF64 conversion is triggered, the fmt chunk needs to be
relocated by rewriting it following the ds64 chunk during the conversion:

  RF64 'WAVE' <ds64 chunk> <fmt-ck> ...
2026-04-16 09:12:45 +00:00
Andreas Rheinhardt 39f34ee019 tests/checkasm/h264chroma: Use more realistic block sizes
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-16 07:36:01 +02:00
Andreas Rheinhardt 3de38c6b6e avcodec/h264chroma: Fix incorrect alignment documentation
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-16 07:36:01 +02:00
Andreas Rheinhardt 53a26f7d41 avcodec/mpegvideo_dec: Use C version of h264chroma mc2 functions
H.264 only uses these functions with height 2 or 4 and
the aarch64, arm and mips versions of them optimize based
on this. Yet this is not true when these functions are used
by the lowres code in mpegvideo_dec.c. So revert back to
the C versions of these functions for mpegvideo_dec so that
the H.264 decoder can still use fully optimized functions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-16 07:36:01 +02:00
James Almer 2feb213287 avcodec/lcevc: make CBS reallocate the LCEVC payload
Frame side data unfortunately lacks padding, which CBS needs, so we can't reuse
the existing AVBufferRef.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-15 16:13:44 -03:00
Niklas Haas dcfd8ebe86 tests/checkasm/sw_ops: remove random value clears
These can randomly trigger the alpha/zero fast paths, resulting in spurious
tests or randomly diverging performance if the backend happens to implement
that particular fast path.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-15 14:51:16 +00:00
Niklas Haas 80b86f0807 tests/checkasm/sw_ops: fix check_scale()
This was not actually testing integer path. Additionally, for integer
scales, there is a special fast path for expansion from bits to full range,
which we should separate from the random value test.
2026-04-15 14:51:16 +00:00
Niklas Haas e199d6b375 swscale/x86/ops: add missing component annotation on expand_bits
This only does a single component; so it should be marked as such.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-15 14:51:16 +00:00
Niklas Haas b6755b0158 swscale/ops_memcpy: always use loop on buffers with large padding
The overhead of the loop and memcpy call is less than the overhead of
possibly spilling into  one extra unnecessary cache line. 64 is still a
good rule of thumb for L1 cache line size in 2026.

I leave it to future code archeologists to find and tweak this constant if
it ever becomes unnecessary.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-15 14:51:16 +00:00
Niklas Haas 026a6a3101 tests/checkasm/sw_ops: remove redundant filter tests
Most of these filters don't test anything meaningfully different relative to
each other; the only filters that really have special significant are POINT
(for now) and maybe BILINEAR down the line.

Apart from that, SINC, combined with the src size loop, already tests both
extreme cases (large and small filters), with large, oscillating unwindonwed
weights.

The other filters are not adding anything of substance to this, while massively
slowing down the runtime of this test. We can, of course, change this if the
backends ever get more nuanced handling.

checkasm: all 855 tests passed (down from 1575)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-15 14:51:16 +00:00
Niklas Haas 91582f7287 tests/checkasm/sw_ops: explicitly test all backends
The current code was a bit clumsy in that it always picked the first
available backend when choosing the new function. This meant that some x86
paths were not being tested at all, whenever the memcpy backend (which has
higher priority) could serve the request.

This change makes it so that each backend is explicitly tested against only
implementations provided by that same backend.

checkasm: all 1575 tests passed (up from 1305)

As an aside, it also lets us benchmark the memcpy backend directly against
the C reference backend.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-15 14:51:16 +00:00
Niklas Haas d5089a1c62 tests/checkasm/sw_ops: don't shadow 'report'
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-15 14:51:16 +00:00
Niklas Haas 3c1781f931 tests/checkasm/sw_ops: separate op compilation from testing
This commit is purely moving around code; there is no functional change.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-15 14:51:16 +00:00
Niklas Haas e83de76f08 tests/checkasm/sw_ops: check all planes in CHECK_COMMON()
This can help e.g. properly test that the masked/excluded components are
left unmodified.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-15 14:51:16 +00:00
Niklas Haas eac90ce6ce tests/checkasm/sw_ops: set correct plane index order
All four components were accidentally being read/written to/from the same
plane.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-15 14:51:16 +00:00
Niklas Haas 590eb4b70d tests/checkasm/sw_ops: remove some unnecessary checks
These don't actually exist at runtime, and will soon be removed from the
backends as well.

This commit is intentionally a bit incomplete; as I will rewrite this
based on the auto-generated macros in the upcoming ops_micro series.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-15 14:51:16 +00:00
Stéphane Cerveau 3f9e04b489 vulkan: fix encode feedback query handling
Check that the driver supports both BUFFER_OFFSET and BYTES_WRITTEN
encode feedback flags before creating the query pool, failing with
EINVAL if either is missing.

Set these flags explicitly instead of masking off HAS_OVERRIDES with a
bitwise NOT, which could pass unrecognized bits from newer drivers to
vkCreateQueryPool causing validation errors and
crashes.
2026-04-14 21:31:45 +00:00
Vignesh Venkat c8dd769217 ffprobe: Support printing SMPTE 2094 APP5 side data
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
2026-04-14 20:41:14 +00:00
Vignesh Venkat 37aefb6e40 avcodec/dav1d: Support parsing smpte 2094-50 metadata
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
2026-04-14 20:35:57 +00:00
Andreas Rheinhardt d5fc732359 avcodec/codec_internal: Include avcodec.h for enum AVCodecConfig
Forward-declaring an enum is not legal C (the underlying type of
the enum may depend upon the enum constants, so this may cause
ABI issues with -fshort-enums); compilers warn about this
with -pedantic.

This essentially reverts 7e84865cff.
Notice that almost* all files that include codec_internal.h also
need to include avcodec.h, so this does not lead to unnecessary
rebuilds.

This addresses part of #22684.

*: The only file I am aware of that defines an FFCodec and does not
need AVCodecContext as complete type is null.c (but even it already
includes it implicitly); the avcodec.c test tool seems to be the only
file where this commit actually leads to an unnecessary avcodec.h
inclusion.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-14 16:04:47 +02:00
Andreas Rheinhardt fc8c6d4665 swscale/swscale: Remove ineffective check
If any of the dstStrides is not aligned mod 16, the warning
above this one will be triggered, setting stride_unaligned_warned,
so that the following check for stride_unaligned_warned will
be always false.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-14 15:22:49 +02:00
Paul Adenot 6c114bd6fa avcodec/vp9: Rollback dimensions when format is rejected
Fixes: BMO#2029296

Found-by: Mozilla Security Team, Paul Adenot for the write variant
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-14 01:42:53 +00:00
Kacper Michajłow 1092852406 swscale/ops: remove type from continuation functions
The glue code doesn't care about types, so long the functions are
chained correctly. Let's not pretend there is any type safety there, as
the function pointers were casted anyway from unrelated types.
Particularly some f32 and u32 are shared.

This fixes errors like so:
src/libswscale/ops_tmpl_int.c:471:1: runtime error: call to function linear_diagoff3_f32 through pointer to incorrect function type 'void (*)(struct SwsOpIter *, const struct SwsOpImpl *, unsigned int *, unsigned int *, unsigned int *, unsigned int *)'
libswscale/ops_tmpl_float.c:208: note: linear_diagoff3_f32 defined here

Fixes: #22332
2026-04-13 23:28:30 +00:00
Kacper Michajłow 9a2a0557ad swscale/ops: remove optimize attribute from op functions
It was added to force auto vectorization on GCC builds. Since then auto
vectorization has been enabled for whole code base, 1464930696.

According to GCC documentaiton, the optimize attribute should be used
for debugging purposes only. It is not suitable in production code.

In particular it's unclear whether the attribute is applied, as it's is
actually lost when function is inlined, so usage of it is quite fragile.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-04-13 23:28:30 +00:00
Michael Niedermayer 29a0973855 avformat/rtpdec_qdm2: Check block_size
Fixes: out of array access
no testcase

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-13 20:19:37 +00:00
Andreas Rheinhardt 660d6ece1b avutil/tests/.gitignore: Add recently added test tools
Reviewed-by: Marvin Scholz <epirat07@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 16:12:31 +02:00
Ramiro Polla 49a2d426e9 configure: collapse else + if into elif 2026-04-13 12:46:49 +00:00
Ramiro Polla 31f280e1e6 configure: add missing quotes around user-specified tool paths
Found-by: Luke Jolliffe <luke.jolliffe@bbc.co.uk>
2026-04-13 12:46:49 +00:00
Ramiro Polla c1d4fe8b44 configure: fix html docs generation when makeinfo is disabled
The makeinfo_html variable wasn't being disabled when the makeinfo test
failed, which prevented texi2html from being probed.

Fixes 589da160b2.

Found-by: Luke Jolliffe <luke.jolliffe@bbc.co.uk>
2026-04-13 12:46:49 +00:00
Zhao Zhili b62ae766c1 avfilter/vf_ssim360: fix integer overflow in tape_length allocation
tape_length * 8 overflows 32-bit int for large input widths. Then
av_malloc_array() allocates a tiny buffer while the subsequent
loop writes tape_length*8 BilinearMap entries, causing
heap-buffer-overflow.

Validate the value in float before converting to int and left
shifting, to avoid both float-to-int and signed left shift
overflow UB. Also split av_malloc_array() arguments to avoid
the multiplication overflow.

Fixes: #21511

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-13 19:49:32 +08:00
Zhao Zhili b796d72eb2 fftools/ffmpeg_filter: skip autoscale for hardware format
This fix failure:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda \
  -i The_Beauty_of_Earth-1.mp4 \
  -vf scale_cuda=2880:1440 \
  -c:v hevc_nvenc \
  -pix_fmt cuda \
  -b:v 8M -c:a copy \
  -y test_scale.mp4

> Reconfiguring filter graph because hwaccel changed
> Impossible to convert between the formats supported by the filter
> 'Parsed_scale_cuda_0' and the filter 'auto_scale_0'.
> Error reinitializing filters!

Signed-off-by: Zhao Zhili <quinkblack@foxmail.com>
2026-04-13 19:46:54 +08:00
Zhao Zhili a85a8e6757 configure: fix VSX remaining enabled when -mvsx is unsupported
When check_cflags -mvsx fails, the && short-circuit prevents
check_cc from running. Since check_cc is responsible for
disabling vsx on failure, skipping it leaves vsx incorrectly
enabled.

Fix by removing the && so check_cc always executes.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-13 11:45:36 +00:00
Andreas Rheinhardt 32678dcc88 avcodec/x86/snowdsp_init: Remove disabled SSE2 functions
Disabled in 3e0f7126b5
(almost 20 years ago) and no one fixed them, so remove them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:56:35 +02:00
Andreas Rheinhardt bd2964e611 avcodec/x86/snowdsp_init: Use standard init pattern
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:56:01 +02:00
Andreas Rheinhardt 338dc25642 avcodec/x86/snowdsp_init: Remove MMXEXT, SSE2 inner_add_yblock versions
They have been superseded by SSSE3; the SSE2 version was even disabled
(and segfaults if enabled).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:53:17 +02:00
Andreas Rheinhardt 5c830fccf4 avcodec/x86/snowdsp: Add SSSE3 inner_add_yblock
Compared to the MMX version, this version benefits from wider
registers and pmaddubsw. It also has fewer unnecessary loads
and stores: On x64, the MMX version has 12 unnecessary GPR loads
and 6 stores in each line when width is eight; for width 16,
there are 17 unnecessary GPR loads and six stores per line.
Even the 32bit SSSE3 version only has six loads and zero stores
per line more than the x64 version. Furthermore, in contrast
to the MMX version, the SSSE3 version also does not clobber
the array of block pointers given to it.

Benchmarks:
inner_add_yblock_2_c:                                   29.2 ( 1.00x)
inner_add_yblock_2_mmx:                                 32.5 ( 0.90x)
inner_add_yblock_2_ssse3:                               28.6 ( 1.02x)
inner_add_yblock_4_c:                                   85.2 ( 1.00x)
inner_add_yblock_4_mmx:                                 89.2 ( 0.96x)
inner_add_yblock_4_ssse3:                               84.5 ( 1.01x)
inner_add_yblock_8_c:                                  302.0 ( 1.00x)
inner_add_yblock_8_mmx:                                 77.0 ( 3.92x)
inner_add_yblock_8_ssse3:                               30.6 ( 9.85x)
inner_add_yblock_16_c:                                1164.7 ( 1.00x)
inner_add_yblock_16_mmx:                               260.4 ( 4.47x)
inner_add_yblock_16_ssse3:                              82.3 (14.15x)

Both the MMX and SSSE3 versions leave the size 2 and 4 cases
to ff_snow_inner_add_yblock_c() (but the MMX version has
a prologue at the beginning that it needs to undo before
the call, leading to the higher overhead for these sizes).
I don't know why the SSSE3 version is marginally faster than
the C version in these cases.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:51:35 +02:00
Andreas Rheinhardt 2fdccaf7d6 tests/checkasm/mpegvideo_unquantize: Fix precedence problem
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:51:35 +02:00
Andreas Rheinhardt 4f30bd6fba tests/checkasm/llvidencdsp: Fix nonsense randomization
The first loop was never entered due to a precedence problem;
the second loop initialized everything, although it was not intended
that way.
This has been added in 56b8769a1c.
Sorry for this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:51:34 +02:00
Andreas Rheinhardt e0ed3fa834 tests/checkasm: Add snowdsp test
Only inner_add_yblock for now.
Hint: Said function uses a pointer to an array of pointers as parameter.
The MMX version clobbers the array in such a way that calling the
function repeatedly with the same arguments (as happens inside bench_new())
leads to buffer overflows and segfaults. Therefore CALL4 had to be
overridden to restore the original pointers. This workaround will be
removed soon when the MMX version is removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:46:24 +02:00
Andreas Rheinhardt 764e021946 avcodec/snowdata: Add explicit alignment for obmc tables
This is in preparation for adding SSSE3 assembly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:46:24 +02:00
Andreas Rheinhardt 28d0a5091a avcodec/snow_dwt: Remove pointless forward declaration
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:46:24 +02:00
Andreas Rheinhardt 5f373872c0 avcodec/x86/snow_dwt: Avoid slice_buffer in inner_add_yblock
It is unnecessary and avoids the src_y parameter;
it also makes this function more ASM-friendly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:46:24 +02:00
Andreas Rheinhardt fd77f00a8f avcodec/snow: Avoid always-true branch
The input lines used in ff_snow_inner_add_yblock()
must always be set (because their values are used).
The MMX assembly always relied on this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:46:24 +02:00
Andreas Rheinhardt 13d621cc7c avcodec/snow: Disable dead code in ff_snow_inner_add_yblock()
It is only used with add != 0 (and the assembly functions
only support this case).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:46:24 +02:00
Andreas Rheinhardt eed0830a0c avcodec/snowdata: Don't use 8 bits for six bits data
This has been done in 561a18d3ba
in order to avoid shifts, yet this rationale no longer applies
since d593e32983. So shift them back;
this is in preparation for using these coefficients together with
pmaddubsw.

Hint: 561a18d3ba also added a block
guarded by "if(LOG2_OBMC_MAX == 8". I changed the condition to remove
this check (i.e. kept the block) which should not change the output
at all. Yet all FATE tests pass if the block is completely
removed. I don't know if this block is necessary at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 12:46:24 +02:00
Andreas Rheinhardt 761b6f2359 swscale/x86/output: Remove obsolete MMXEXT function
Possible now that the SSE2 function is available
even when the stack is not aligned.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 08:46:44 +02:00
Andreas Rheinhardt 8a7c1f7fb8 swscale/x86/output: Make xmm functions usable even without aligned stack
x86-32 lacks one GPR, so it needs to be read from the stack.
If the stack needs to be realigned, we can no longer access
the original location of one argument, so just request a bit
more stack size and copy said argument at a fixed offset from
the new stack.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 08:46:44 +02:00
Andreas Rheinhardt 0bb161fd09 swscale/x86/output: Simplify creating dither register
Only the lower quadword needs to be rotated, because
the register is zero-extended immediately afterwards anyway.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 08:46:44 +02:00
Andreas Rheinhardt f5c5bca803 swscale/x86/scale: Remove always-false mmsize checks
Forgotten in a05f22eaf3.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 08:46:44 +02:00
Andreas Rheinhardt 999ccf6495 swresample/x86/{audio_convert,rematrix}: Remove remnants of MMX
Forgotten in 2b94f23b06,
4e51e48ebd and
374b3ab03c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 01:16:46 +02:00
Andreas Rheinhardt e29c7089d2 avcodec/x86/vp8dsp_loopfilter: Remove always-true mmsize checks
Forgotten in 6a551f1405.
Also fix the comment claiming that there are MMXEXT functions
in this file.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 00:41:22 +02:00
Andreas Rheinhardt 9f560c8c1a avcodec/x86/vp3dsp: Remove unused macros
Forgotten in a677b38298.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-13 00:41:22 +02:00
Jun Zhao 411484e8c9 lavc/videotoolbox_vp9: fix vpcC flags offset
Write the 24-bit vpcC flags field at the current cursor position after
the version byte. The previous code wrote to p+1 instead of p, leaving
one byte uninitialized between version and flags and shifting all
subsequent fields (profile, level, bitdepth, etc.) by one byte.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-12 22:15:51 +00:00
Jun Zhao 57397a683d lavc/videotoolboxenc: return SEI parse errors
Return the actual find_sei_end() error when SEI appending fails instead of
reusing the previous status code. This preserves the real parse failure for
callers instead of reporting malformed SEI handling as success.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-04-12 22:15:51 +00:00
Niklas Haas b09d57c41d avfilter/buffersrc: re-add missing overflow warning
This was originally introduced by commit 05d6cc116e. During the FFmpeg-libav
split, this function was refactored by commit 7e350379f8 into
av_buffersrc_add_frame(), replacing av_buffersrc_add_ref(). The new function
did not include the overflow warning, despite the same being done for
buffersink.

Then, when commit a05a44e205 merged the two functions back together, the
libav implementation was favored over the FFmpeg implementation, silently
removing the overflow warning in the process.

This commit re-adds that missing warning.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-12 20:02:18 +00:00
nyanmisaka ab7b6ef0a2 hwcontext_vulkan: fix double free when vulkan_map_to_drm fails
The multiplanar image with storage_bit enabled fails to be exported
to DMA-BUF on the QCOM turnip driver, thus triggering this double-free issue.

```
[Parsed_hwmap_2 @ 0xffff5c002a70] Configure hwmap vulkan -> drm_prime.
[hwmap @ 0xffff5c001180] Filter input: vulkan, 1920x1080 (0).
[AVHWFramesContext @ 0xffff5c004e00] Unable to export the image as a FD!
free(): double free detected in tcache 2
Aborted
```

Additionally, add back an av_unused attribute. Otherwise, the compiler
will complain about unused variables when CUDA is not enabled.

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-04-12 20:50:38 +08:00
zuxy 56b97c03d4 avcodec/x86/h264_intrapred: Replace pred8x8_top_dc_8_mmxext with SSE2
More about deprecating MMX than any performance gain; nearly identical
performance numbers on my Zen 4 (1.36x vs c), but llvm-mca predicts
>60% perf gain on Intel CPUs newer than Skylake.

Signed-off-by: Zuxy Meng <zuxy.meng@gmail.com>
2026-04-11 19:11:46 -07:00
Niklas Haas c29465bcb6 swscale/x86/ops: use plain ret instruction
The original intent here was probably to make the ops code agnostic to
which operation is actually last in the list, but the existence of a
divergence between CONTINUE and FINISH already implies that we hard-code
the assumption that the final operation is a write op.

So we can just massively simplify this with a call/ret pair instead of
awkwardly exporting and then jumping back to the return label. This actually
collapses FINISH down into just a plain RET, since the op kernels already
don't set up any extra stack frame.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-11 16:30:15 +00:00
Tymur Boiko f7ca6f7481 vulkan: fix -Wdiscarded-qualifiers warning and misleading DRM modifier log
ff_vk_find_struct returns const void *, so storing it in const void *drm_create_pnext
fixes the initialization warning but then dpb_hwfc->create_pnext = drm_create_pnext
assigns const void * to void *, triggering the same warning at that line. The right
fix is a (void *) cast at the call site, same as done for buf_pnext.

Also restrict the GetPhysicalDeviceImageFormatProperties2 verbose log in
try_export_flags to the DRM modifier path only: when has_mods is false the log
always printed mod[0]=0x0, which is misleading since no DRM modifier is involved.

Signed-off-by: Tymur Boiko <tboiko@nvidia.com>
2026-04-11 12:50:07 +00:00
Kacper Michajłow eaadd05232 .forgejo/CODEOWNERS: add myself for hls.*
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-04-11 01:58:35 +02:00
Kacper Michajłow 721545a3c2 MAINTAINERS: add myself as HLS demuxer maintainer
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-04-11 01:58:35 +02:00
Kacper Michajłow cc41e6a462 tests/fate/hlsenc: add hls-event-no-endlist test
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-04-11 01:58:34 +02:00
Kacper Michajłow 6d98a9a2e8 avformat/hls: fix seeking in EVENT playlists that start mid-stream
HLS EVENT playlists (e.g. Twitch VODs) are seekable but not finished,
so live_start_index causes playback to begin near the end. The first
packet's DTS then becomes first_timestamp, creating a wrong mapping
between timestamps and segments.

Fix this by subtracting the cumulative duration of skipped segments from
first_timestamp so it reflects the true start of the playlist.

Also set per-stream start_time from first_timestamp so correct time is
reported, reset pts_wrap_reference on seek to prevent bogus wrap
arounds.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-04-11 01:58:34 +02:00
Niklas Haas ef13a29d08 avfilter/framepool: fix frame pool uninit check
Fixes a memory leak caused by AV_MEDIA_TYPE_VIDEO == 0 being excluded by
the !pool->type check. We can just remove the entire check because
av_buffer_pool_uninit() is already safe on NULL.

Fixes: fe2691b3bb
Reported-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 22:02:00 +02:00
Alexandru Ardelean e43aab67ed avdevice/v4l2: rename 'buff_data' -> 'buf_desc'
Since we've added a 'buf_data' struct, rename this to avoid any confusion
about this one.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
2026-04-10 16:02:28 +00:00
Alexandru Ardelean 1011e4d647 avdevice/v4l2: wrap buf_start and buf_len into a struct
This reduces the number of malloc() & free() calls, and structures the
data for the buffers a bit neatly.
In case more per-buffer data needs to be added, having a separate struct
is useful.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
2026-04-10 16:02:28 +00:00
Alexandru Ardelean 24adcf3a72 avdevice/v4l2: fix potential memleak when allocating device buffers
In the loop which allocates the buffers for a V4L2 device, if failure
occurs for a certain buffer (e.g. 3rd of 4 buffers), then the previously
allocated buffers (and the buffer array) would not be free'd in
the mmap_init(). This would cause a leak.

This change handles the error cases of that loop to free all allocated
resources, so that when mmap_init() fails nothing is leaked.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
2026-04-10 16:02:28 +00:00
Niklas Haas 0e983a0604 swscale: align allocated frame buffers to SwsPass hints
This avoids hitting the slow memcpy fallback paths altogether, whenever
swscale.c is handling plane allocation.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas b5573a8683 swscale/ops_dispatch: cosmetic
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas 3a15990368 swscale/ops_dispatch: forward correct pass alignment
As a consequence of the fact that the frame pool API doesn't let us directly
access the linesize, we have to "un-translate" the over_read/write back to
the nearest multiple of the pixel size.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas 5441395a48 swscale/graph: add optimal alignment/padding hints
Allows the pass buffer allocator to make smarter decisions based on the actual
alignment requirements of the specific pass.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas 2deca0ec19 swscale: clean up allocated frames on error
Matches the semantics of sws_frame_begin(), which also cleans up any
allocated buffers on error.

This is an issue introduced by the commit that allowed ff_sws_graph_run()
to fail in the first place.

Fixes: 563cc8216b
2026-04-10 15:12:18 +02:00
Niklas Haas 6c89a30ecd swscale: add FFFramePool and use it for allocating planes
The major consequence of this is that we start allocating buffers per plane,
instead of allocating one contiguous buffer. This makes the no-op/refcopy
case slightly slower, but doesn't meaningfully affect the rest:

yuva444p -> yuva444p, time=157/1000 us (ref=78/1000 us), speedup=0.497x slower
Overall speedup=1.016x faster, min=0.983x max=1.092x

However, this is a necessary consequence of the desire to allow partial plane
allocations / single plane refcopies. This slowdown also does not affect
vf_scale, which already uses avfilter/framepool.c (via ff_get_video_buffer).

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas fe2691b3bb avfilter/framepool: stack-allocate FFFramePool
Saves a pointless free/alloc cycle on reinit. For the vast majority of filter
links, this going to be allocated anyway; and on the occasions that it's not,
the waste is marginal.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas a2ca55c563 avfilter/framepool: remove unnecessary braces (style)
As per the FFmpeg coding style guidelines, braces should be avoided on
isolated single-line statement bodies.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas 5c4490a0a6 avfilter/framepool: fix whitespace (cosmetic)
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas 38543781cc avfilter/framepool: move variable declarations to site of definition
This is not C89 anymore.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas 6efbd99e48 avfilter/framepool: remove check for impossible condition
FFALIGN(..., pool->align) = (...) & ~(pool->align - 1), so this condition
equates to: ((...) & ~(align - 1) & (align - 1)), which is trivially 0.

(Note that all expressions are of type `int`)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas 0b43b8ef31 avfilter/framepool: make FFFramePool public
This struct is overally pretty trivial and there is little to no internal
state or invariants that need to be protected.

Making it public allows e.g. libswscale to allocate buffers for individual
planes directly.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas 3e99631873 avfilter/framepool: remove pointless ternary (cosmetic)
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas 53ce7265ab avfilter/framepool: use strongly typed union of pixel/sample format
Replacing the generic `int format` field. This aids in debugging, as
e.g. gdb will tend to translate the strongly typed enums back into human
readable names automatically.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas 9034587d10 avfilter/framepool: make ff_sws_frame_pool_{audio,video}_init static
Not used outside of the (strictly more flexible) _reinit() anymore.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas 39ecc89988 avfilter/framepool: nuke ff_frame_pool_get_*_config
This helper is of dubious utility - it was only used to reinitialize the
frame pools, which is better handled by `ff_frame_pool_reinit()`, and at
present only serves to make extending the API harder.

Users who really need to randomly query the state of the frame pool can
already keep track of the values they set.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas a0510f7f72 avfilter/framepool: update frame dimensions on reinit
The previous logic (ported from libavfilter/video.c) would leave the frame
pool intact if the linesize did not change as a result of changing the frame
dimensions. However, this caused ff_default_get_video_buffer2() to return
frames with the old width/height.

I think this bug was avoided in practice because the only filters to actually
support changing the resolution at runtime already always explicitly overrode
the width/height of allocated output buffers by the link properties.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:18 +02:00
Niklas Haas ad7956d5bb avfilter/{audio,video}: switch to ff_frame_pool_*_reinit()
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:17 +02:00
Niklas Haas 083a014746 avfilter/framepool: add ff_frame_pool_*_reinit() helpers
This moves the check-uninit-reinit logic out of audio.c/video.c and into
framepool.c, where it can be more conveniently re-used by future users.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:17 +02:00
Niklas Haas 143b810e75 avfilter/framepool: remove alloc argument
Not really needed by anything and makes this API a bit clunkier to extend.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:17 +02:00
Niklas Haas 82871857eb avfilter/framepool: actually use specified allocator for audio frames
This bug means audio buffers were never correctly zero'd as intended by
libavfilter/audio.c

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-10 15:12:17 +02:00
Tymur Boiko 25e187f849 vulkan: fix DRM map, decode barriers, and video frame setup for modifier output
When mapping Vulkan Video frames to DMA-BUF, synchronize using an exportable
binary semaphore and sync_fd where supported. Submit a lightweight exec that
waits on each plane's timeline semaphore at the current value, signals a
SYNC_FD-exportable binary semaphore, then export with vkGetSemaphoreFdKHR.
Store that binary semaphore in AVVkFrameInternal and reuse it across maps
instead of creating and destroying each time: for
VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT, copy transference means a
successful vkGetSemaphoreFdKHR unsignals the semaphore like a wait, so it can
be signaled again on the next map submit. If export is unavailable, fall back
to vkWaitSemaphores.

Moved drm_sync_sem destroy to vulkan_free_internal

Export dma-buf fds with GetMemoryFdKHR for each populated f->mem[i], iterating
up to the sw_format plane count instead of stopping at the image count, so
multi-memory bindings are not skipped. Describe DRM layers using
max(sw planes, image count) and query subresource layout with the correct
aspect and image index when one VkImage backs multiple planes. Reference the
source hw_frames_ctx on the mapped frame and close dma-buf fds on failure paths.

For DMA-BUF-capable pools, honor VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT
from format export queries when binding memory. With DRM modifiers and a
video profile in create_pnext, preserve caller usage and image flags instead of
overwriting them from generic supported_usage probing; use the modifier list
create info when probing export flags for modifier tiling.

Include VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR from the output frames
context's usage together with DST (fixes
VUID-VkVideoBeginCodingInfoKHR-slotIndex-07245) instead of adding DPB usage
only when !is_current.

In ff_vk_decode_add_slice, pass VkVideoProfileListInfoKHR (from the output
frames context's create_pnext) as the pNext argument to
ff_vk_get_pooled_buffer instead of the full create_pnext chain. In
ff_vk_frame_params, set tiling to OPTIMAL only when it is not already
DRM_FORMAT_MODIFIER_EXT. In ff_vk_decode_init, when the output pool's
create_pnext includes VkImageDrmFormatModifierListCreateInfoEXT, initialize the
DPB pool with that modifier-list pNext and DRM_FORMAT_MODIFIER_EXT tiling;
otherwise use VkVideoProfileListInfoKHR and OPTIMAL as before. When
VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR is unset, the output
and DPB pools cannot use different layouts or tiling, so the DPB pool must
match the output pool.

Also fix av_hwframe_map ioctl sync_fd export, multi-planar semaphore handling,
and related failure-path cleanup.

Signed-off-by: Tymur Boiko <tboiko@nvidia.com>
2026-04-10 11:39:40 +00:00
James Almer 492e6e68dc doc/APIchanges: fix date and version in the latest entry
Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-09 17:21:28 -03:00
Vignesh Venkat 6ba6db4f19 libavutil: Add functions for SMPTE-2094-50 HDR metadata
SMPTE-2094-50 is an upcoming standard that is close to being
finalized.

Define a side data type for carrying this metadata. And add
functions for parsing and writing it. This is very similar to
the handling of HDR10+ metadata.

The spec is available here: https://github.com/SMPTE/st2094-50

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
2026-04-09 20:01:00 +00:00
Lynne 283faf55f8 Changelog: add v360_vulkan to the changelog 2026-04-09 16:51:30 +02:00
Lynne d3d0b7a5ee lavfi/v360: add a Vulkan-compute based filter
This just adds a Vulkan compute-based 360-degree video conversion.
It implements a sufficient subset of the most popular 360-degree video formats.

Options such as rotation are dynamic and can be adjusted during runtime.

Some of the work was based on Paul B. Mahol's patch from 2020. There
were spots where the arithmetic conversion was incorrect.
2026-04-09 12:31:24 +02:00
Priyanshu Thapliyal 056562a5ff fate/lavf: add PDV round-trip and seek coverage
Add FATE coverage for PDV encoding and decoding via lavf, including
intra and inter frame cases, skip-nokey decoding, and container-level
seek coverage.

Use -strict experimental in the encode commands because the encoder
is marked experimental.
2026-04-09 03:01:43 +00:00
Priyanshu Thapliyal 4c0d563f85 avformat/pdvenc: add Playdate video muxer
Add a muxer for the Playdate PDV container format.

The muxer writes the frame table and packet layout required by the
Playdate runtime. It requires seekable output and a predeclared
maximum number of frames (-max_frames).

Includes validation for single video stream input, dimension and
framerate checks, and bounded payload/table offset checks. The frame
entry table is allocated once in write_header() using max_frames + 1.

Document the muxer in doc/muxers.texi and add a Changelog entry.
2026-04-09 03:01:43 +00:00
Priyanshu Thapliyal 43e5b26c00 avcodec/pdvenc: add Playdate video encoder
Add a native encoder for the Playdate PDV format.

Supports monob (1-bit) video, producing zlib-compressed intra frames
and XOR-based delta frames.

Includes bounds checking, overflow guards, correct linesize handling
using ptrdiff_t, and proper buffer allocation ordering.

Mark the encoder as experimental by setting AV_CODEC_CAP_EXPERIMENTAL,
since it has not been validated against Panic's official Playdate
player or SDK.
2026-04-09 03:01:43 +00:00
Michael Niedermayer d0761626cf avcodec/escape130: Initialize old_y_avg
Fixes: use of uninitialized memory

Found-by: Carl Sampson <carl.sampson@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-09 01:14:39 +02:00
bird 5c3602abaa avformat/sctp: add size check in sctp_read() matching sctp_write()
Commit 5b98cea4 added a size < 2 guard to sctp_write() to prevent
out-of-bounds access when max_streams is enabled, but the identical
pattern in sctp_read() was not addressed.

When max_streams is non-zero, sctp_read() passes (buf + 2, size - 2)
to ff_sctp_recvmsg(). If size < 2, size - 2 wraps to a large value
on the implicit cast to size_t in the callee.

Add the same guard.

Signed-off-by: bird <6666242+bird@users.noreply.github.com>
2026-04-08 20:52:52 +00:00
David Hampton db53fe1ac2 avdevice/alsa.c: Conditionally compile out ESTRPIPE
NetBSD doesn't have this error code, so put in a test to prevent
compiling related code on NetBSD systems.
2026-04-08 20:44:16 +00:00
Andreas Rheinhardt 87f74e4f39 avcodec/g726: Remove dead sample rate check
Checked generically since 39206c5e58.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-08 21:33:43 +02:00
Andreas Rheinhardt 8463ca8dc9 avcodec/g726: Don't return value from g726_reset()
It always returns zero which none of the callers check,
so just return nothing instead.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-08 21:33:40 +02:00
Andreas Rheinhardt e97f52e557 avcodec/g726: Fix indentation
Forgotten in e344c1ea36.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-08 21:33:17 +02:00
Andreas Rheinhardt 12b58b86cc avcodec/x86/rv40dsp: Fix wrong comment
Forgotten in d25b3497f2
and 9abf906800.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-08 21:00:04 +02:00
Andreas Rheinhardt ae5314a6bf avcodec/x86/rv34dsp: Port ff_rv34_idct_add_mmxext to SSSE3
With this commit, the RV30 and RV40 decoders no longer clobber
the fpu state for normal decoding (only error resilience can
still do so).

rv34_idct_add_c:                                        58.1 ( 1.00x)
rv34_idct_add_mmxext:                                   16.5 ( 3.52x)
rv34_idct_add_ssse3:                                    12.2 ( 4.76x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-08 21:00:00 +02:00
Andreas Rheinhardt d728f3c808 tests/checkasm/rv34dsp: Add test for rv34_idct_add
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-08 20:59:56 +02:00
Andreas Rheinhardt 4c64a8a986 avcodec/rv34: Remove pointless has_ac variable
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-08 20:59:52 +02:00
Andreas Rheinhardt c48f21f778 avcodec/rv34: Use VLC symbol table to avoid LUTs
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-08 20:54:21 +02:00
James Almer 4c69c5f156 configure: only warn about spirv-headers if vulkan was explicitly requested
Given it's autodected by default, its checks should not print warnings nor abort the process.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-08 12:29:28 -03:00
James Almer 58752ffcdd avfilter/af_whisper: don't set an AVOption accessible field to read only memory
It should also not be set to an av_malloc'd one given it's not an exported option.

Fixes issue #22741.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-08 11:52:44 -03:00
Timo Rothenpieler 5c35d0b880 avformat/tls_gnutls: actually send client cert if one is provided
Without setting this flag, apparently gnutls will only send the client
certificate according some logic based on what it thinks the server
accepts.
This is not the case a lot of times.
Just force it to send the client cert the user supplied, if one was
supplied, no matter what.

Fixes #22707
2026-04-08 12:26:29 +00:00
Zhao Zhili 9917308cc2 swscale/vulkan: fix dither buffer leak on mapping failure
A failure while preparing a dither buffer leaves the newly allocated
buffer outside the cleanup range, leaking Vulkan resources. Make the
failure path cover the current buffer as well.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-07 17:53:14 +00:00
Niklas Haas cd1126a3cd swscale/ops: add assertion that comps_src is sane
This assertion guards against bugs like that fixed in the previous
commit.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-07 15:10:04 +00:00
Niklas Haas 420019a313 swscale/ops_optimizer: properly swizzle comps_src when splitting
Fixes a pre-existing latent bug in the subpass splitting, that was
made worse / exposed by 048ca3b367.

Fixes: cba54e9e3b
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-07 15:10:04 +00:00
nyanmisaka dcbfa11c96 avcodec/amfenc: remove the AMF_VIDEO_ENCODER_AV1_CAP_{WIDTH,HEIGHT}_ALIGNMENT_FACTOR_LOCAL
These have been defined in AMF 1.4.35+ but we are on 1.5.0.

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-04-07 14:54:21 +00:00
nyanmisaka 113c1c0624 avcodec/amfenc: let the HEVC encoder profile follow the target bit depth
Previously, you could even set the Main profile for the P010 input and 10-bit output.

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-04-07 14:54:21 +00:00
nyanmisaka 2f592f0699 avcodec/amfenc: use pixel desc to determine YUV and bit depth
Therefore, YUV420P and X2BGR10 are now being taken into consideration.

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-04-07 14:54:21 +00:00
nyanmisaka 0acc73b7fb avcodec/amfenc: support full range in AV1 and update deprecated AMF range flags for H264/HEVC
Furthermore, the flags for H264/HEVC have been updated to those renamed in AMF 1.5.0+,
instead of using the old ones that were already marked as deprecated:

AMF_VIDEO_ENCODER_FULL_RANGE_COLOR -> AMF_VIDEO_ENCODER_OUTPUT_FULL_RANGE_COLOR
AMF_VIDEO_ENCODER_HEVC_NOMINAL_RANGE -> AMF_VIDEO_ENCODER_HEVC_OUTPUT_FULL_RANGE_COLOR

The macro content remains the same, therefore it will not cause regressions.

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-04-07 14:54:21 +00:00
James Almer e7696357de avformat/dashdec: export LCEVC Stream Groups when the manifest reports the relevant dependency
Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-07 10:04:55 -03:00
Jack Lau 0510aff11b avformat/hlsenc: fix compile error when mp4 is disabled
Regression since dc4c798970

Handle the case where mp4 is disabled since mp4 as
an optional dependency of hls_muxer.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-04-07 02:20:34 +00:00
Ruikai Peng e90c2ff4b5 avcodec/libdav1d: fix heap overflow in US ITU-T T.35 metadata parsing
The US country_code path in parse_itut_t35_metadata() reads the
the provider_code with bytestream2_get_be16u(), which is a
unchecked version that does not validate the remaining
length before reading. When an AV1 stream contains ITU-T T.35
metadata with country_code set to 0xB5 (which is US) and a
payload shorter than 2 bytes, this results in a heap overflow
reading 2 bytes past the allocation.

The UK country code already guards against this issue by
checking it before the unchecked read. We're using the same
pattern to the US country code path.

Pwno crafted an AV1 IVF with a metadata OBU containing ITU-T T.35
with country_code=0xB5 and a 1-byte payload. Decoding with libdav1d
triggers the overflow. ASan says:

ERROR: AddressSanitizer: heap-buffer-overflow
READ of size 2 at 0x5020000003f0 thread T0
  #0 bytestream_get_be16 src/libavcodec/bytestream.h:98
  #1 bytestream2_get_be16u src/libavcodec/bytestream.h:98
  #2 parse_itut_t35_metadata src/libavcodec/libdav1d.c:376

0x5020000003f1 is located 0 bytes after 1-byte region

Found-by: Pwno
2026-04-06 23:39:40 +00:00
James Almer 757cc97790 avcodec/lcevcdec: support differing base and enhancement bitdepths
Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-06 14:07:59 -03:00
James Almer 3a2eae155d avcodec/lcevcdec: add 14bit pixel formats
Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-06 14:07:59 -03:00
James Almer 01b0b86225 avcodec/lcevc_parser: move pixel format table to a shared file
Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-06 14:07:59 -03:00
Patrice Dumas 589da160b2 configure: add makeinfo option
Rename makeinfo enabled variable to makeinfo_command. Do not put
makeinfo_command in HAVE_LIST, it is not used.
2026-04-06 15:07:17 +00:00
Andreas Rheinhardt 7fd2be97b9 avcodec/x86/h264_chromamc: Avoid mmx in chroma_mc8_ssse3 functions
No impact on performance here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 11:28:49 +02:00
Andreas Rheinhardt 0c4c9c66bd avfilter/x86/vf_atadenoise: Don't load args unnecessarily
These args will be read directly from the stack into xmm register,
so loading them into GPRs is unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 11:28:49 +02:00
Andreas Rheinhardt e1297f3080 avcodec/x86/h264_idct: Use tmp reg in SUMSUB_BA if possible
It allows to exchange a paddw by a movdqa.

Old benchmarks:
idct8_add4_8bpp_c:                                     664.6 ( 1.00x)
idct8_add4_8bpp_sse2:                                  142.2 ( 4.67x)
idct8_add_8bpp_c:                                      215.5 ( 1.00x)
idct8_add_8bpp_sse2:                                    35.1 ( 6.14x)

New benchmarks:
idct8_add4_8bpp_c:                                     666.9 ( 1.00x)
idct8_add4_8bpp_sse2:                                  135.3 ( 4.93x)
idct8_add_8bpp_c:                                      217.7 ( 1.00x)
idct8_add_8bpp_sse2:                                    34.0 ( 6.41x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 11:28:49 +02:00
Andreas Rheinhardt ed116bab02 avcodec/x86/me_cmp: Use tmp reg in SUMSUB_BA if possible
It allows to exchange a paddw by a movdqa.

Old benchmarks:
hadamard8_diff_0_c:                                    366.1 ( 1.00x)
hadamard8_diff_0_sse2:                                  56.4 ( 6.49x)
hadamard8_diff_0_ssse3:                                 53.0 ( 6.90x)
hadamard8_diff_1_c:                                    183.0 ( 1.00x)
hadamard8_diff_1_sse2:                                  28.0 ( 6.53x)
hadamard8_diff_1_ssse3:                                 26.0 ( 7.03x)

New benchmarks:
hadamard8_diff_0_c:                                    371.4 ( 1.00x)
hadamard8_diff_0_sse2:                                  55.0 ( 6.76x)
hadamard8_diff_0_ssse3:                                 49.5 ( 7.50x)
hadamard8_diff_1_c:                                    183.4 ( 1.00x)
hadamard8_diff_1_sse2:                                  26.8 ( 6.85x)
hadamard8_diff_1_ssse3:                                 23.1 ( 7.92x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 11:28:49 +02:00
Andreas Rheinhardt da59f288c6 avcodec/hevc/dsp_template: Add restrict to add_residual functions
Allows the compiler to optimize the the aliasing checks away
and saves 5376B here (GCC 15, -O3).
Also, avoid converting the stride to uint16_t for >8bpp:
stride /= sizeof(pixel) will use an unsigned division
(i.e. a logical right shift)*, which is not what is intended here.

*: If size_t is the corresponding unsigned type to ptrdiff_t

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 11:28:49 +02:00
Andreas Rheinhardt 72058ccdf8 tests/checkasm/sw_scale: Don't use declare_func_emms in yuv2nv12cX check
There are no implementations of yuv2nv12cX clobbering the fpu state,
so make the test stricter to ensure that it stays that way.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 11:28:49 +02:00
Andreas Rheinhardt 135cc04c3b tests/checkasm/sw_yuv2yuv: Don't use declare_func_emms
It is not needed (there are no MMX functions here) and
given that there is no emms_c() cleaning up after convert_unscaled,
convert_unscaled must not clobber the fpu state.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 11:28:49 +02:00
Andreas Rheinhardt 14c30b9d19 tests/checkasm/png: Don't use declare_func_emms for add_paeth_pred
There is an x86 implementation using MMX registers, but it actually
issues emms on its own (since 57a29f2e7d).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 11:28:49 +02:00
Andreas Rheinhardt fcea2aa75d tests/checkasm/vf_fspp: Don't use declare_func_emms for store_slice
Forgotten in ff85a20b7d.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 11:28:49 +02:00
Andreas Rheinhardt 96f0e6e927 tests/checkasm/sw_yuv2rgb: Don't use declare_func_emms unnecessarily
The last MMX(EXT) convert_unscaled functions have been removed
in 61e851381f. And anyway, there
is no emms_c cleaning up after these functions, so they must not
clobber the fpu state; that they did it at the time this checkasm
test has been added was a bug introduced by
e934194b6a and fixed by the removal
of said MMX(EXT) functions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 11:28:49 +02:00
Andreas Rheinhardt 759512d36a avcodec/x86/cavsidct: Use tmp reg in SUMSUB_BA if possible
It allows to exchange a paddw by a movdqa.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 11:28:49 +02:00
Andreas Rheinhardt 8b700fad94 avcodec/mpegvideoencdsp: Add restrict to shrink
Makes GCC avoid creating the aliasing fallback path
and saves 1280B of .text here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 10:39:17 +02:00
Andreas Rheinhardt 6e95052ac2 avcodec/x86/mpegvideoenc_template: Avoid indirect call
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-06 10:39:17 +02:00
Sankalpa Sarkar 7b49a69f43 fate: add unit tests for libavutil/timecode functions 2026-04-05 22:23:08 +02:00
Sankalpa Sarkar b462674645 fate/hlsenc: Add tests for untested features 2026-04-05 14:02:48 +00:00
Dana Feng 235d5fd30a .forgejo/codeowners: Add @danaf as reviewer for mpdecimate filter
This will provide notifications when there are pull requests that
touch the mpdecimate filter code.

Signed-off-by: Dana Feng <danaf@twosigma.com>
2026-04-05 00:26:55 +00:00
Dana Feng 31a711aa68 vf_mpdecimate: Add comprehensive tests for keep and max options
Add tests for the mpdecimate filter to verify correct behavior:
- fate-filter-mpdecimate-keep: tests keep=3 option
- fate-filter-mpdecimate-keep1: tests keep=1 option
- fate-filter-mpdecimate-maxdrop-pos: tests max=3 (positive) option
- fate-filter-mpdecimate-maxdrop-neg: tests max=-3 (negative) option

Signed-off-by: Dana Feng <danaf@twosigma.com>
2026-04-05 00:26:55 +00:00
Dana Feng 63822ae21f vf_mpdecimate: Fix keep option logic for keep > 0
Fix the following issues with the keep option:

- Add similarity check during keep period. Previously, the code
  returned early during the keep period without checking if the
  frame is actually similar to the reference.

- Reset keep_count on different frames. Previously, the counter
  could accumulate across non-consecutive similar frames, causing
  frames to be dropped earlier than expected.

- Keep the same frame reference if appropriate. Previously, the
  code made similar frames the new reference, causing reference
  drift and gradual scene changes.

Signed-off-by: Dana Feng <danaf@twosigma.com>
2026-04-05 00:26:55 +00:00
Michael Niedermayer b11729f154 avutil/samplefmt: Dont claim that av_get_sample_fmt_string checks sample_fmt
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-05 00:19:09 +00:00
marcos ashton e18c8c533d tests/fate/libavutil: add FATE test for mathematics
Test the integer math utility functions: av_gcd, av_rescale,
av_rescale_rnd (all rounding modes including PASS_MINMAX),
av_rescale_q, av_compare_ts, av_compare_mod, av_rescale_delta,
and av_add_stable. Includes large-value tests that exercise the
128-bit multiply path in av_rescale_rnd.

av_bessel_i0 is not tested since it uses floating point math
that is not bitexact across platforms.

Coverage for libavutil/mathematics.c: 0.00% -> 82.03%

Remaining uncovered lines are av_bessel_i0 (float, 23 lines)
and one edge case fallback in av_rescale_delta.
2026-04-05 00:12:29 +00:00
marcos ashton 66b1dbfb98 tests/fate/libavutil: add FATE test for samplefmt
Test all public API functions: name/format round-trip lookups,
bytes_per_sample, is_planar, packed/planar conversions,
alt_sample_fmt, get_sample_fmt_string, samples_get_buffer_size,
samples_alloc, samples_alloc_array_and_samples, samples_copy,
and samples_set_silence. OOM error paths are exercised via
av_max_alloc().

Coverage for libavutil/samplefmt.c: 0.00% -> 95.28%

Remaining uncovered lines are the fill_arrays failure path
and the overlapping memmove branch in samples_copy.
2026-04-05 00:12:29 +00:00
marcos ashton 117897bcd0 tests/fate/libavutil: add FATE test for rc4
Test the three public API functions: av_rc4_alloc, av_rc4_init,
and av_rc4_crypt. Verifies keystream output against RFC 6229
test vectors for 40, 56, 64, and 128-bit keys, encrypt/decrypt
round-trip, inplace operation, and the invalid key_bits error path.

Coverage for libavutil/rc4.c: 0.00% -> 100.00%
2026-04-05 00:12:29 +00:00
Lynne 2b6fbcad6d swscale/vulkan: compile SPIR-V backed only if SPIR-V headers are found
Instead of making Vulkan depend on the headers, make the compilation of
the SPIR-V backend depend on the headers.

Sponsored-by: Sovereign Tech Fund
2026-04-04 19:02:27 +00:00
nyanmisaka 69fc910777 avfilter/scale_cuda: fix color bleeding in lanczos scaling
Prior to this, the results were not saturated into the uchar/ushort range before
being written. The characteristics of the Lanczos filter exposed this issue.

In addition, the results were truncated rather than rounded, which resulted
in checkerboard artifacts in solid color areas and were noticeable when
using Lanczos with 8-bit input.

Example:
ffmpeg -init_hw_device cuda -f lavfi -i testsrc2=s=960x540,format=yuv420p \
-vf hwupload,scale_cuda=format=yuv420p:w=-2:h=720:interp_algo=lanczos \
-c:v h264_nvenc -qp:v 20 -t 1 <OUTPUT>

Fix #20784

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-04-04 11:31:16 +00:00
Patrice Dumas 2dff0156ba doc/t2h.pm: Never use node nor empty @top heading in ffmpeg_heading_command 2026-04-04 12:52:53 +05:30
Hankang Li e33b3962e5 swscale: fix signed integer overflow in color conversion arithmetic
Fixes: #22331

Signed-off-by: Hankang Li <hankang201222@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-04 02:43:59 +02:00
James Almer b47a459867 configure: don't abort if spirv-headers are not present
Vulkan was soft enabled, so this check has no reason to call die()

Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-03 16:54:21 -03:00
Ramiro Polla 1f6699ef26 ffbuild/common: remove DBG=1 to preprocess external asm
It had been added in bc8e044d (2015), and broken in 3ddae9ee (2017).

Nobody has complained since, so it's safe to assume that it is not
being used.
2026-04-03 16:15:33 +02:00
Lynne 554dcc2885 vf_scale_vulkan: make sure that pixfmts are different when using swscale
The swscale internals currently have a quirk which causes the memcpy
backend to be called when the pixfmts match. Obviously, this doesn't do
what is expected, as hardware frames cannot just be copied.
Check for this.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:06 +02:00
Lynne 990768080e tests/swscale: add support for testing Vulkan hardware acceleration
Sponsored-by: Sovereign Tech Fund

Co-authored-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-04-02 21:15:06 +02:00
Lynne 47e4e95173 swscale/vulkan: add a native SPIR-V assembler backend
swscale gets runtime-defined assembly once again!

This commit splits the Vulkan backend into two, SPIR-V and GLSL,
enabling falling back onto the GLSL implementation if an instruction
is unavailable, or simply for testing.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:06 +02:00
Lynne 6a723420dc swscale/vulkan: add a SPIR-V assembler header file
This commit adds a SPIR-V assembler header file. It was partially generated
from the SPIR-V header file JSON definition, then edited by hand to template
and reduce its size as much as possible.
It only implements the essentials required for SPIR-V assembly that swscale
requires.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:06 +02:00
Lynne 5fa4085774 swscale/vulkan: use uniform buffers for dither matrix
Uniform buffers are much simpler to index, and require no work from
the driver compiler to optimize.
In SPIR-V, large 2D shader constants can be spilled into scratch memory,
since you need to create a function variable to index them during runtime.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:06 +02:00
Lynne d4bcd3340e swscale/vulkan: add a check for BGRA features
The issue is that very often, hardware has limited support for BGRA
formats.

As this is a limitation of Vulkan itself, we cannot work around this
in a compatible way.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:06 +02:00
Lynne 72a0b20e42 configure: enable Vulkan only if the SPIR-V headers are installed
FFmpeg has had an issue with GLSL compilation libraries since they
were first merged 6 years ago. The libraries don't have a stable ABI,
are very difficult for packagers to compile and integrate, are slow,
not threadsafe, and uncomfortable to use. The decision to switch all
Vulkan code to either compile-time GLSL or SPIR-V assembly was taken
in January, and since then, and included with the release of FFmpeg 8.1,
the progress has been steadily eliminating all remaining runtime GLSL
compilation.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Lynne ebfd18ad03 hwcontext_vulkan: temporarily disable formats which require shader+framework processing
The main issue is that BGR formats only semi-exist in Vulkan. Unlike all
other formats, they require the user to manually remap the pixel order, and
are also forbidden from being written to without a format in shaders. The main
reason for this was conservative - Vulkan is supposed to work everywhere, including
platforms where there is no write-time remapping/swizzing support.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Lynne 5a6480af0c hwcontext_vulkan: do not indicate support for rgb565
It requires special handling.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Lynne 2bea947027 hwcontext_vulkan: don't indicate support for AV_PIX_FMT_UYVA
Uploading and downloading is broken.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Lynne 4b1e79f062 hwcontext_vulkan: return ENOTSUP in vulkan_frames_init
If a format is not supported, EINVAL is not the appropriate
return code.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Lynne 0a543441be swscale/vulkan: always reserve 4 image descriptors
The issue is that with multiplane images, or packed images,
there may be some mismatching between what .elems has, and what
we need.
Descriptors are cheap, so just always reserve 4.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Lynne eb71c6c9a4 swscale/vulkan: move execution context to be a part of a shader
The issue is that the main Vulkan context is shared between possibly
multiple shaders, and registering a new shader requires allocating
descriptors.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Lynne 7c33948b29 swscale/vulkan: fix potential memory issues
The issue is that updating descriptors relies on the pointers of
the structures remaining the same since creation.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:01 +02:00
Sankalpa Sarkar 65eed0732c avformat: check avio_read() return values in dss/dtshd/mlv
Multiple demuxers call avio_read() without checking its return
value. When input is truncated, destination buffers remain
uninitialized but are still used for offset calculations, memcmp,
and metadata handling. This results in undefined behavior
(detectable with Valgrind/MSan).

Fix this by checking the return value of avio_read() in:
- dss.c: dss_read_seek() — check before using header buffer
- dtshddec.c: FILEINFO chunk — check before using value buffer
- mlvdec.c: check_file_header() — check before memcmp on version

Fixes: #21520
2026-04-02 19:06:59 +00:00
Kacper Michajłow 1e031d4af7 configure: treat unrecognized option warnings as errors in test_ld
This fixes dummy warnings when link/lld-link is called by the clang:
lld-link: warning: ignoring unknown argument '--as-needed'
lld-link: warning: ignoring unknown argument '-rpath-link=:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil'

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-04-02 16:37:55 +00:00
Kacper Michajłow 740dc9e027 configure: test if -lm is available on host compiler
Fixes host binaries compilation on platforms without math lib.

Fixes clang host compilation, which replaces `-lm` with `m.lib` that
does not exist:
LINK : fatal error LNK1181: cannot open input file 'm.lib'
clang: error: linker command failed with exit code 1181 (use -v to see invocation)

Fixes MSVC (cl) host warning:
cl : Command line warning D9002 : ignoring unknown option '-lm'

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-04-02 16:37:55 +00:00
Kacper Michajłow 43be5cccd8 configure: add llvm toolchain option
This uses llvm tools. `clang-*` toolchain is left mostly for backward
compatibility, although it doesn't use llvm tools, only clang. On top of
that it's for enabling sanitizers. While `llvm` toolchain can be use
without sanitizer suffix.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-04-02 16:37:55 +00:00
Ruikai Peng 7466d8a850 avformat/whip: check RTP history packet size before RTX retransmission
handle_rtx_packet() constructs an RTX packet by shifting the payload
of a history entry to insert the original sequence number. It uses
memmove with length (ori_size - 12), but never checks that ori_size
is at least 12 bytes (the minimum RTP header size).

Zero-initialized history slots have seq == 0 and size == 0.
rtp_history_find() only compares sequence numbers, so an RTCP NACK
requesting seq 0 early in a session matches such a slot. The
subtraction then wraps to a huge value when converted to size_t,
causing a stack buffer overflow in memmove().

Add a little size check to reject history entries smaller than and
valid RTP header before any arithmetic on their size.

Found-by: Pwno
2026-04-02 12:19:09 +00:00
Niklas Haas 85bef2c2bc swscale/ops: split SwsConst up into op-specific structs
It was a bit clunky, lacked semantic contextual information, and made it
harder to reason about the effects of extending this struct. There should be
zero runtime overhead as a result of the fact that this is already a big
union.

I made the changes in this commit by hand, but due to the length and noise
level of the commit, I used Opus 4.6 to verify that I did not accidentally
introduce any bugs or typos.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-02 11:48:15 +00:00
Niklas Haas 75b7e8904b swscale/ops: move comment (cosmetic)
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-02 11:48:15 +00:00
Niklas Haas dc705268c7 swscale/ops: define flags_identity as an enum constant
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-02 11:48:15 +00:00
Niklas Haas 32ba5c13de swscale/ops_chain: split generic setup helpers into op-specific helpers
This has the side benefit of not relying on the q2pixel macro to avoid division
by zero, since we can now explicitly avoid operating on undefined clear values.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-02 11:48:15 +00:00
Niklas Haas 50793bc9bd swscale/ops_chain: remove unused helper function
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-02 11:48:15 +00:00
Niklas Haas c24d67a0ff swscale/vulkan/ops: use QSTR/QTYPE to print all rationals
Now this helper is a bit more useful.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-02 11:48:15 +00:00
Niklas Haas 7a4cffa25d swscale/vulkan/ops: simplify QTYPE macro
There's no reason for this macro to hard-code op->c.q4[i].

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-04-02 11:48:15 +00:00
Zhao Zhili eedf8f0165 avcodec/hevc: workaround hevc-alpha videos generated by VideoToolbox
Apple VideoToolbox is the dominant producer of hevc-alpha videos, but
early versions generates non-standard VPS extensions that fail to
parse and return AVERROR_INVALIDDATA. Fix this by returning
AVERROR_PATCHWELCOME instead of AVERROR_INVALIDDATA for unsupported
VPS extension configurations. Setting poc_lsb_not_present for the
alpha layer in the fallback path when it has no direct dependency
on the base layer, so that IDR slices on the alpha layer won't
incorrectly read pic_order_cnt_lsb.

Fix #22384

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-01 22:54:36 +08:00
Zhao Zhili 28ab24b717 avformat/matroskadec: avoid calling get_bytes_left() three times with the same state
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-01 14:19:35 +00:00
Zhao Zhili bba9bf7e7e avcodec/libdav1d: fix null pointer dereference in LCEVC side data handling
ff_frame_new_side_data() may set sd to NULL and return 0 when
side_data_pref() determines that existing side data should be
preferred.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-01 14:17:27 +00:00
Zhao Zhili f9d289020d avcodec/av1dec: fix null pointer dereference in LCEVC side data handling
ff_frame_new_side_data() may set sd to NULL and return 0 when
side_data_pref() determines that existing side data should be
preferred.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-01 14:17:27 +00:00
Andreas Rheinhardt f6bbd63557 avutil/tests/.gitignore: Add recently added test tools
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-01 14:04:16 +00:00
Zhao Zhili 316531e61c avfilter/vidstabtransform: always use in-place transform path
libvidstab's vsTransformPrepare() takes different internal code paths
for in-place (src == dest) vs. separate-buffer operation. The
separate-buffer path stores a shallow copy of the source frame pointer
in td->src without allocating internal memory (srcMalloced stays 0).
When a subsequent frame takes the in-place path, vsFrameIsNull(&td->src)
is false so vsFrameAllocate() is skipped, and vsFrameCopy() writes into
the stale pointer left over from the previous frame, corrupting memory
that the caller no longer owns.

Whether a given frame is writable depends on pipeline scheduling and
frame reference management, which can change between FFmpeg versions.
Since FFmpeg 8.1, changes in the scheduler caused some frames to arrive
as non-writable, leading to alternation between in-place and
separate-buffer paths that triggered the bug.

Fix this by marking the input pad with AVFILTERPAD_FLAG_NEEDS_WRITABLE.

Fix #22595
2026-04-01 21:56:37 +08:00
Zhao Zhili c695ad1197 avfilter/vidstabtransform: use existing ctx variable for outlink
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-01 21:56:37 +08:00
Brad Smith e64a1d2953 libavutil/ppc: Remove mfspr-based AltiVec detection code for Linux
The getauxval() and auxv methods cover the last 25+ years of Linux.

Signed-off-by: Brad Smith <brad@comstyle.com>
2026-04-01 04:33:44 +00:00
Michael Niedermayer ddcb9dd3b5 avcodec/aac/aacdec_usac: Implement missing bits of otts_bands_phase and residual_bands computation
Fixes: out of array access
Fixes: matejsmycka/poc.mp4

Introducing commit: `baad75cafa6bac298b72c177f657a2eb8e31cff1` — "aacdec_usac: add support for parsing Mpsp212 (MPEG surround)", 2025-11-17.

Found-by: Matěj Smyčka <matejsmycka@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-31 22:29:18 +00:00
Lynne 9c04a40136 vulkan/ffv1: implement floating-point decoding
Sponsored-by: Sovereign Tech Fund
2026-03-31 23:47:45 +02:00
Lynne f5054f726d ffv1enc_vulkan: implement floating-point encoding
Sponsored-by: Sovereign Tech Fund
2026-03-31 23:47:45 +02:00
Lynne 29b8614e62 vulkan/ffv1: fix bitstream initialization for Golomb
Was broken when we switched to descriptors.

Sponsored-by: Sovereign Tech Fund
2026-03-31 23:47:45 +02:00
Lynne 35c6cdb191 hwcontext_vulkan: add support for GBRPF16/GBRAPF16
Sponsored-by: Sovereign Tech Fund
2026-03-31 23:47:39 +02:00
Martin Storsjö 77ff3bcb90 aarch64: Add AARCH64_VALID_JUMP_CALL_TARGET
We currently don't have any cases where this is needed, but include
it for completeness and clarity.

These macros for BTI were added in
08b4716a9e.

A later comment in this file, added in
248986a0db, referenced the macro
AARCH64_VALID_JUMP_CALL_TARGET which never was added here before.
2026-03-31 19:57:46 +00:00
Martin Storsjö 8ed8e221bd aarch64: Fix a URL typo
This was added in 248986a0db.
2026-03-31 19:57:46 +00:00
marcos ashton 878eabdfef tests/fate/libavutil: add FATE test for video_enc_params
Unit test covering av_video_enc_params_alloc,
av_video_enc_params_block, and
av_video_enc_params_create_side_data.

Tests allocation for all three codec types (VP9, H264, MPEG2) and
the NONE type, with 0 and 4 blocks, with and without size output.
Verifies block getter indexing by writing and reading back
coordinates, dimensions, and delta_qp values. Tests frame-level qp
and delta_qp fields, and side data creation with frame attachment.

Coverage for libavutil/video_enc_params.c: 0.00% -> 86.21%
(remaining uncovered lines are OOM error paths)

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-31 18:05:51 +01:00
marcos ashton c8ec660d78 tests/fate/libavutil: add FATE test for detection_bbox
Unit test covering av_detection_bbox_alloc, av_get_detection_bbox,
and av_detection_bbox_create_side_data.

Tests allocation with 0, 1, and 4 bounding boxes, with and without
size output. Verifies bbox getter indexing by writing and reading
back coordinates, labels, and confidence values. Tests classify
fields (labels and confidences), the header source field, and
side data creation with frame attachment.

Coverage for libavutil/detection_bbox.c: 0.00% -> 86.67%
(remaining uncovered lines are OOM error paths)

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-31 18:05:51 +01:00
marcos ashton be2fa77344 tests/fate/libavutil: add FATE test for spherical
Unit test covering all 4 public API functions in libavutil/spherical.c:
av_spherical_alloc, av_spherical_projection_name, av_spherical_from_name,
and av_spherical_tile_bounds.

Tests allocation with and without size output, all 7 projection type
name lookups, projection name round-trip verification, out-of-range
handling, and tile bounds computation for full-frame, quarter-tile,
and centered-tile configurations.

Coverage for libavutil/spherical.c: 0.00% -> 100.00%

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-31 18:05:51 +01:00
Andreas Rheinhardt c1aed85491 avcodec/x86/h264_idct: Avoid spilling register unnecessarily
It is only needed in the unlikely codepath. The ordinary one
only uses six xmm registers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-31 17:31:58 +02:00
Andreas Rheinhardt 9fdd7e23e3 avfilter/x86/vf_atadenoise: Avoid load
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-31 16:49:51 +02:00
Araz Iusubov 3b55818764 avcodec/amfdec: set context dimensions from decoder size 2026-03-31 14:07:31 +00:00
Ramiro Polla 53537f6cf5 swscale/aarch64: mark CPS kernel functions as indirect branch targets
Only the process functions are entered via an indirect _call_ from C.
The kernel functions and process_return are dispatched to by indirect
_branches_ instead (continuation-passing style design).

Make use of the recently added "jumpable" parameter to the function
macro in libavutil/aarch64/asm.S to fix these functions when BTI is
enabled.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-31 11:48:52 +00:00
Ramiro Polla af443abe99 aarch64: Add support for indirect branch targets in the function macro
The function macro emits AARCH64_VALID_CALL_TARGET for exported symbols,
marking them as valid destinations for indirect _calls_. Functions that
are reached by indirect _branches_ (i.e. tail-call dispatch chains
where the link register is not set) require AARCH64_VALID_JUMP_TARGET
instead.

This commit adds a "jumpable" parameter to the function macro that, when
set, emits AARCH64_VALID_JUMP_TARGET instead of AARCH64_VALID_CALL_TARGET.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-31 11:48:52 +00:00
Dmitrii Gershenkop 8b93c94f47 avutil/hwcontext_amf: Add AMF_IFACE_CALL macro
Using AMF interfaces in C can be cumbersome and visually difficult to process in some cases: i.e.: object->function(object, args). To improve code readability, a new macro is added. This commit is instrumental for future AMF integration refactoring.
2026-03-31 11:33:00 +00:00
Dmitrii Gershenkop 6f75e879b6 avfilter/vf_vpp_amf: Minor clean up.
-vf_vpp_amf.c: Remove unused variables.
-vf_amf_common.c: Fix hdrmeta_buffer memory leak.
-hwcontext_amf.c: Fix av_amf_extract_hdr_metadata not picking up light metadata if display mastering metadata is not set.
-doc/filters.texi: Remove irrelevant example with HDR metadata for vpp_amf.
2026-03-31 11:17:51 +00:00
Kacper Michajłow 7d57621b83 avutil/x86/x86util: tone down NASM workaround and use info section
The use of code section (.text) was forced by the unreleased NASM
3.02rc3 which made the issue worse, but preventing assambling anything
without code section, including when only data was present.

This works fine for the most part, but using code (.text) section with
IMAGE_COMDAT_SELECT_ANY causes issues with lib.exe after stripping such
object:
fatal error LNK1143: invalid or corrupt file: no symbol for COMDAT section 0x2

Esentially it makes our workaround not work in all cases, and while
string could be disabled like it already is for MSVC/ICL builds, it used
to work so let's preserve that state.

This make it not compatible with NASM 3.02rc3 when CV debug info is
generated, but hopefully the upstream fix will be merged before release,
to avoid this regression:
https://github.com/netwide-assembler/nasm/pull/221

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-30 19:46:53 +02:00
Jun Zhao 89c21b5ab7 lavc/hevc: add aarch64 NEON for Planar prediction
Add NEON-optimized implementation for HEVC intra Planar prediction at
8-bit depth, supporting all block sizes (4x4 to 32x32).

Planar prediction implements bilinear interpolation using an incremental
base update: base_{y+1}[x] = base_y[x] - (top[x] - left[N]), reducing
per-row computation from 4 multiply-adds to 1 subtract + 1 multiply.
Uses rshrn for rounded narrowing shifts, eliminating manual rounding
bias. All left[y] values are broadcast in the NEON domain, avoiding
GP-to-NEON transfers.

4x4 interleaves row computations across 4 rows to break dependencies.
16x16 uses v19-v22 for persistent base/decrement vectors, avoiding
callee-saved register spills. 32x32 processes 8 rows per loop iteration
(4 iterations total) to reduce code size while maintaining full NEON
utilization.

Speedup over C on Apple M4 (checkasm --bench):

    4x4: 2.25x    8x8: 6.40x    16x16: 9.72x    32x32: 3.21x

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-30 14:32:10 +00:00
Jun Zhao 60b372c934 lavc/hevc: add aarch64 NEON for DC prediction
Add NEON-optimized implementation for HEVC intra DC prediction at 8-bit
depth, supporting all block sizes (4x4 to 32x32).

DC prediction computes the average of top and left reference samples
using uaddlv, with urshr for rounded division. For luma blocks smaller
than 32x32, edge smoothing is applied: the first row and column are
blended toward the reference using (ref[i] + 3*dc + 2) >> 2 computed
entirely in the NEON domain. Fill stores use pre-computed address
patterns to break dependency chains.

Also adds the aarch64 initialization framework (Makefile, pred.c/pred.h
hooks, hevcpred_init_aarch64.c).

Speedup over C on Apple M4 (checkasm --bench):

    4x4: 2.28x    8x8: 3.14x    16x16: 3.29x    32x32: 3.02x

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-30 14:32:10 +00:00
Jun Zhao 514f57f85d tests/checkasm: add HEVC intra prediction test
Add checkasm test for HEVC intra prediction covering DC, planar, and
angular modes at all block sizes (4x4 to 32x32) for 8-bit and 10-bit
depth.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-30 14:32:10 +00:00
nyanmisaka 87b7e578ec avcodec/amfenc: add encoder average QP stats
This allows for real-time monitoring of the encoder's average QP in ffmpeg CLI.

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-03-30 13:23:56 +00:00
Andreas Rheinhardt f56d073d7e swscale/tests/.gitignore: Add sws_ops_aarch64
Forgotten in a1bfaa0e78.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 14:31:25 +02:00
Andreas Rheinhardt 3a1e63e007 avcodec/x86/vvc/alf: Avoid zeroing unnecessarily
In case of >8bpp, there is already a zero register available
(for clipping); in case of Unix64, one can simply use an
unused register. Doing so reduces codesize.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt 8901f858eb avcodec/x86/vvc/alf: Hoist creating shift register out of loop
Possible now that this function no longer uses unnecessarily many
registers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt a3dfc511a5 avcodec/x86/vvc/alf: Don't push+pop unused register
This function only uses 14 GPRs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt 5de2c4c89e avcodec/x86/vvc/alf: Avoid reload
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt d727b7a64e avcodec/x86/vvc/alf: Avoid modifying nonvolatile registers
Avoids push+pop on Win64; in any case, using registers m0-m7
more often saves codesize.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt b1d6f31d65 avcodec/x86/vvc/alf: Use correct shift amount
Fixes a bug in 94f9ad8061.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt 2cce9a8279 avcodec/x86/vvc/alf: Avoid modifying nonvolatile registers
Avoids push+pop on Win64; in any case, using registers m0-m7
more often saves codesize.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt cb1ffc58ca avcodec/x86/vvc/of: Don't use ymm regs where xmm are sufficient
Also use a register in the 0-7 range as clobber reg,
as this reduces codesize (by 51B).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt 1785542a80 avcodec/x86/vvc/of: Don't add to zero
Instead rewrite the code to use assignment. Saves zeroing and
additions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt 06fa26d2e8 avcodec/x86/vvc/of: Deduplicate common code
The height 8 and 16 cases differ from the second BDOF mini block onwards,
but even the beginning of said mini block is the same and can therefore
be deduplicated. This saves 821B here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt 002b3bc1b3 avcodec/x86/vvc/of: Avoid punpckldq
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt ada58bd0e2 avcodec/x86/vvc/of: Use xmm registers where sufficient
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt ad34eb2ae6 avcodec/x86/vvc/of: Correct comment
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt 2570f5d307 avcodec/x86/vvc/of: Avoid scalar log2
Instead convert the integers to floats and inspect the exponent.

Old benchmarks:
apply_bdof_8_8x16_c:                                  3295.2 ( 1.00x)
apply_bdof_8_8x16_avx2:                                312.7 (10.54x)
apply_bdof_8_16x8_c:                                  3269.1 ( 1.00x)
apply_bdof_8_16x8_avx2:                                203.6 (16.05x)
apply_bdof_8_16x16_c:                                 6584.8 ( 1.00x)
apply_bdof_8_16x16_avx2:                               413.6 (15.92x)
apply_bdof_10_8x16_c:                                 3313.9 ( 1.00x)
apply_bdof_10_8x16_avx2:                               321.5 (10.31x)
apply_bdof_10_16x8_c:                                 3306.5 ( 1.00x)
apply_bdof_10_16x8_avx2:                               200.4 (16.50x)
apply_bdof_10_16x16_c:                                6659.7 ( 1.00x)
apply_bdof_10_16x16_avx2:                              402.4 (16.55x)
apply_bdof_12_8x16_c:                                 3305.7 ( 1.00x)
apply_bdof_12_8x16_avx2:                               321.8 (10.27x)
apply_bdof_12_16x8_c:                                 3258.1 ( 1.00x)
apply_bdof_12_16x8_avx2:                               198.6 (16.41x)
apply_bdof_12_16x16_c:                                6600.2 ( 1.00x)
apply_bdof_12_16x16_avx2:                              392.6 (16.81x)

New benchmarks:
apply_bdof_8_8x16_c:                                  3269.9 ( 1.00x)
apply_bdof_8_8x16_avx2:                                266.5 (12.27x)
apply_bdof_8_16x8_c:                                  3252.9 ( 1.00x)
apply_bdof_8_16x8_avx2:                                182.6 (17.81x)
apply_bdof_8_16x16_c:                                 6596.7 ( 1.00x)
apply_bdof_8_16x16_avx2:                               362.7 (18.19x)
apply_bdof_10_8x16_c:                                 3351.3 ( 1.00x)
apply_bdof_10_8x16_avx2:                               269.0 (12.46x)
apply_bdof_10_16x8_c:                                 3329.1 ( 1.00x)
apply_bdof_10_16x8_avx2:                               174.5 (19.08x)
apply_bdof_10_16x16_c:                                6654.3 ( 1.00x)
apply_bdof_10_16x16_avx2:                              357.8 (18.60x)
apply_bdof_12_8x16_c:                                 3274.1 ( 1.00x)
apply_bdof_12_8x16_avx2:                               276.0 (11.86x)
apply_bdof_12_16x8_c:                                 3263.5 ( 1.00x)
apply_bdof_12_16x8_avx2:                               176.8 (18.46x)
apply_bdof_12_16x16_c:                                6576.4 ( 1.00x)
apply_bdof_12_16x16_avx2:                              357.8 (18.38x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Andreas Rheinhardt 03b83f8feb avcodec/x86/vvc/of: Remove redundant instructions
m8 here (corresponding to a mix of sgx2 and sgy2 in derive_bdof_vx_vy
in the C version) is always nonnegative, so the psignd boils down to
a check for m8 being zero. But if an entry of m8 is zero, then
the corresponding entry of m9 is automatically zero, too, as sgx2
being zero implies sgxdi being zero and sgy2 implies sgxgy, sgydi
being zero.* So just remove these redundant instructions.

*: In other words, one could remove the sgx2,sgy2>0 checks from
the end of derive_bdof_vx_vy() as long as av_log2(0) is defined.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-30 13:51:53 +02:00
Ramiro Polla 2517c328fc swscale/aarch64: add NEON sws_ops backend
This commit pieces together the previous few commits to implement the
NEON backend for sws_ops.

In essence, a tool which runs on the target (sws_ops_aarch64) is used
to enumerate all the functions that the backend needs to implement. The
list it generates is stored in the repository (ops_entries.c).

The list from above is used at build time by a code generator tool
(ops_asmgen) to implement all the sws_ops functions the NEON backend
supports, and generate a lookup function in C to retrieve the assembly
function pointers.

At runtime, the NEON backend fetches the function pointers to the
assembly functions and chains them together in a continuation-passing
style design, similar to the x86 backend.

The following speedup is observed from legacy swscale to NEON:
A520: Overall speedup=3.780x faster, min=0.137x max=91.928x
A720: Overall speedup=4.129x faster, min=0.234x max=92.424x

And the following from the C sws_ops implementation to NEON:
A520: Overall speedup=5.513x faster, min=0.927x max=14.169x
A720: Overall speedup=4.786x faster, min=0.585x max=20.157x

The slowdowns from legacy to NEON are the same for C/x86. Mostly low
bit-depth conversions that did not perform dithering in legacy.

The 0.585x outlier from C to NEON is gbrpf32le -> gbrapf32le, which is
mostly memcpy with the C implementation. All other conversions are
better.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-30 11:38:35 +00:00
Ramiro Polla 534757926f swscale/aarch64: introduce ops_asmgen for NEON backend
The NEON sws_ops backend follows the same continuation-passing style
design as the x86 backend.

Unlike the C and x86 backends, which implement the various operation
functions through the use of templates and preprocessor macros, the
NEON backend uses a build-time code generator, which is introduced by
this commit.

This code generator has two modes of operation:
 -ops:
  Generates an assembly file in GNU assembler syntax targeting AArch64,
  which implements all the sws_ops functions the NEON backend supports.
 -lookup:
  Generates a C function with a hierarchical condition chain that
  returns the pointer to one of the functions generated above, based on
  a given set of parameters derived from SwsOp.

This is the core of the NEON sws_ops backend.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-30 11:38:35 +00:00
Ramiro Polla 991611536c swscale/aarch64: introduce a runtime aarch64 assembler interface
The runtime assembler interface provides an instruction-level IR and
builder API tailored to the needs of the swscale dynamic pipeline.
It is not meant to be a general purpose assembler interface.

Currently only a static file backend, which emits GNU assembler text,
has been implemented. In the future, this interface will be used to
write functions dynamically at runtime.

This code will be compiled both for runtime usage to generate optimized
functions and for build-time usage to generate static assembly files.
Therefore, it must not depend on internal FFmpeg libraries.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-30 11:38:35 +00:00
Ramiro Polla a1bfaa0e78 swscale/aarch64: introduce tool to enumerate sws_ops for NEON backend
The NEON sws_ops backend will use a build-time code generator for the
various operation functions it needs to implement. This build time code
generator (ops_asmgen) will need a list of the operations that must be
implemented. This commit adds a tool (sws_ops_aarch64) that generates
such a list (ops_entries.c).

The list is generated by iterating over all possible conversion
combinations and collecting the parameters for each NEON assembly
function that has to be implemented, defined by an unique set of
parameters derived from SwsOp. Whenever swscale evolves, with improved
optimization passes, new pixel formats, or improvements to the backend
itself, this file (ops_entries.c) should be regenerated by running:
    $ make sws_ops_entries_aarch64

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-30 11:38:35 +00:00
Kacper Michajłow e54e117998 avutil/x86/x86util: define .text section additionally to COMDAT one
This is needed to cover the case when assembled source doesn't have
.text section. NASM documentation suggest to add $ suffix to section
name for COMDAT in .text, but this actually requires the main .text
section to exist also. And use less generic suffix for our dummy
sub-section.

Third time's the charm.

Fixes: 80cd067715
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-30 01:08:45 +02:00
Soham Kute e3bcb9ac76 avformat/tests: add FATE tests for yuv4mpegpipe pixel formats
The existing fate-lavf-yuv420p.y4m covers only the default format.
Add four entries that pass -pix_fmt explicitly to the lavf_video
macro: yuv422p, yuv444p, yuv411p, and gray.

These exercise the branches in yuv4mpegpipe_write_header() that write
the "C422", "C444", "C411", and "Cmono" chroma descriptor strings in
the stream header.  All four are gated on ENCDEC(RAWVIDEO,YUV4MPEGPIPE)
and added to FATE_LAVF_VIDEO_SCALE so they inherit the requirement for
CONFIG_SCALE_FILTER that lavf_video's -auto_conversion_filters needs.

Reference files were generated from the actual encoder output and
follow the md5+size+CRC format used by the other lavf references.

Signed-off-by: Soham Kute <officialsohamkute@gmail.com>
2026-03-29 23:01:39 +00:00
Soham Kute 9bf999c24f avcodec/tests: add encoder-parser API test for H.261
Add tests/api/api-enc-parser-test.c, a generic encoder+parser round-trip
test that takes codec_name, width, and height on the command line
(defaults: h261 176 144).

Three cases are tested:

garbage - a single av_parser_parse2() call on 8 bytes with no Picture
Start Code; verifies out_size == 0 so the parser emits no spurious data.

bulk - encodes 2 frames, concatenates the raw packets, feeds the whole
buffer to a fresh parser in one call, then flushes.  Verifies that
exactly 2 non-empty frames come out and that the parser found the PSC
boundary between them.

split - the same buffer fed in two halves (chunk boundary falls inside
frame 0).  Verifies the parser still emits exactly 2 frames when input
arrives incrementally, and that the collected bytes are identical to
the bulk output (checked with memcmp).

Implementation notes: avcodec_get_supported_config() selects the pixel
format; chroma height uses AV_CEIL_RSHIFT with log2_chroma_h from
AVPixFmtDescriptor; data[1] and data[2] are checked independently so
semi-planar formats work; the encoded buffer is given
AV_INPUT_BUFFER_PADDING_SIZE zero bytes at the end; parse_stream()
skips the fed chunk if consumed==0 to prevent an infinite loop.

Two FATE entries in tests/fate/api.mak: QCIF (176x144) and CIF
(352x288), both standard H.261 resolutions.

Signed-off-by: Soham Kute <officialsohamkute@gmail.com>
2026-03-29 23:01:39 +00:00
Soham Kute dc8183377c avutil/tests/file: replace trivial test with error-path coverage
The original test only mapped the source file and printed its content,
exercising none of the error branches in av_file_map().

Replace it with a test that maps a real file (path via argv[1] for
out-of-tree builds) and verifies it is non-empty, then calls
av_file_map() on a nonexistent file twice: once with log_offset=0 to
confirm the error is logged at AV_LOG_ERROR, and once with log_offset=1
to confirm the level is raised by one, covering the
log_level_offset_offset path in av_vlog().  A custom av_log callback
captures the emitted level independently of the global log level.
The two error cases share a single for() loop to avoid duplication.

Add a FATE entry in tests/fate/libavutil.mak with CMP=null since
there is no fixed stdout to compare.

Signed-off-by: Soham Kute <officialsohamkute@gmail.com>
2026-03-29 23:01:39 +00:00
Kacper Michajłow 80cd067715 avutil/x86util: don't produce empty object files on win{32,64}
In cases when preprocesor would remove all code, nasm would produce
empty object files. This is technically not wrong, but often cause
issues with various tooling:

* NASM fails to emit CodeView debug info when there is no code [1]
* Older VS2022 builds hangs on empty files [2]
* GNU binutils `strip` errors when there is no sections [3]
error: the input file '.o' has no sections

Workaround those issues by adding dummy byte in COMDAT section,
which is then dropped by linker, as the `__x86util_notref` symbol is not
referenced from C. [4] IMAGE_COMDAT_SELECT_ANY (2) is used to allow
multiple symbol definition.

This is limited to win{32,64} as this is the target where issues were
observed.

[1] https://github.com/netwide-assembler/nasm/issues/216
[2] https://developercommunity.visualstudio.com/t/MSVC-Hangs-when-compiling-ffmpeg-When-l/10233953
[3] https://trac.ffmpeg.org/ticket/6711
[4] https://www.nasm.us/docs/3.01/nasm09.html#section-9.6.1

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-29 23:00:06 +02:00
Kacper Michajłow 2b1d8ba3ec avfilter/x86/vf_atadenoise: move %if ARCH_X86_64 after x86util include
This is consistent pattern with other files. Also is needed for next
commit to always include x86util.asm

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-29 22:22:29 +02:00
Kacper Michajłow 2b8ca0f3c5 avfilter/x86/avf_showcqt: add missing section declaration
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-29 22:22:29 +02:00
Jun Zhao 368f58109e doc/muxers: fix mpegts muxer documentation
Fix the default value of mpegts_original_network_id from 0x0001 to
0xff01 to match the actual code (DVB_PRIVATE_NETWORK_START).

Add the missing hevc_digital_hdtv service type to the
mpegts_service_type option list.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-29 11:06:36 +00:00
Jun Zhao 4c0dff0878 lavf/mpegtsenc: Add parentheses to clarify operator precedence in CC update
While "cc + 1 & 0xf" is technically correct because addition has
higher precedence than bitwise AND in C, the intent of "(cc + 1) & 0xf"
is not immediately obvious without recalling the precedence table.

Add explicit parentheses to make the intended evaluation order clear
and improve readability.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-29 11:06:36 +00:00
Niklas Haas 3f39783337 swscale/ops_chain: simplify ff_sws_compile_op_tables() with int index
Instead of this needlessly complicated dance of allocating on-stack copies
of SwsOpList only to iterate with AVERROR(EAGAIN).

This was originally thought to be useful for compiling multiple ops at once,
but even that can be solved in easier ways.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 12:13:40 +02:00
Niklas Haas f6a2d41fe2 swscale/ops: keep track of correct dither min/max
Mostly, this just affects the metadata in benign ways, e.g.:

 rgb24 -> yuv444p:
   [ u8 +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
     min: {0, 0, 0, _}, max: {255, 255, 255, _}
   [ u8 +++X] SWS_OP_CONVERT      : u8 -> f32
     min: {0, 0, 0, _}, max: {255, 255, 255, _}
   [f32 ...X] SWS_OP_LINEAR       : matrix3+off3 [...]
     min: {16, 16, 16, _}, max: {235, 240, 240, _}
   [f32 ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 -1}
-    min: {33/2, 33/2, 33/2, _}, max: {471/2, 481/2, 481/2, _}
+    min: {16.001953, 16.001953, 16.001953, _}, max: {235.998047, 240.998047, 240.998047, _}
   [f32 +++X] SWS_OP_CONVERT      : f32 -> u8
     min: {16, 16, 16, _}, max: {235, 240, 240, _}
   [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)

However, it surprisingly actually includes a semantic change, whenever
converting from limited range to monob or monow:

 yuv444p -> monow:
   [ u8 +XXX] SWS_OP_READ         : 1 elem(s) planar >> 0
     min: {0, _, _, _}, max: {255, _, _, _}
   [ u8 +XXX] SWS_OP_CONVERT      : u8 -> f32
     min: {0, _, _, _}, max: {255, _, _, _}
   [f32 .XXX] SWS_OP_LINEAR       : luma [...]
     min: {-20/219, _, _, _}, max: {235/219, _, _, _}
   [f32 .XXX] SWS_OP_DITHER       : 16x16 matrix + {0 -1 -1 -1}
-    min: {179/438, _, _, _}, max: {689/438, _, _, _}
+    min: {-0.089371, _, _, _}, max: {2.071106, _, _, _}
+  [f32 .XXX] SWS_OP_MAX          : {0 0 0 0} <= x
+    min: {0, _, _, _}, max: {2.071106, _, _, _}
   [f32 .XXX] SWS_OP_MIN          : x <= {1 _ _ _}
-    min: {179/438, _, _, _}, max: {1, _, _, _}
+    min: {0, _, _, _}, max: {1, _, _, _}
   [f32 +XXX] SWS_OP_CONVERT      : f32 -> u8
     min: {0, _, _, _}, max: {1, _, _, _}
   [ u8 XXXX] SWS_OP_WRITE        : 1 elem(s) planar >> 3
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Note the presence of an extra SWS_OP_MAX, to correctly clamp sub-blacks
(values below 16) to 0.0, rather than underflowing. This was previously
undetected because the dither was modelled as adding 0.5 to every pixel value,
but that's only true on average - not always.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 12:13:11 +02:00
Niklas Haas 7989fd973a swscale/ops: add min/max to SwsDitherOp
This gives more accurate information to the range tracker.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 12:10:38 +02:00
Niklas Haas 915523e136 swscale/ops: add missing check on SwsDitherOp.y_offset
Doesn't actually affect anything in the currently generated ops lists.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 12:10:38 +02:00
Niklas Haas 7af7b8664b swscale/ops_chain: check SWS_COMP_GARBAGE instead of next->comps.unused
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 09:39:09 +00:00
Niklas Haas 048ca3b367 swscale/ops_optimizer: check COMP_GARBAGE instead of next->comps.unused
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 09:39:09 +00:00
Niklas Haas e8f6c9dbf2 swscale/ops: only print SWS_OP_SCALE denom if not 1
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 09:39:09 +00:00
Niklas Haas ff397a327a swscale/ops: remove unneeded conditional on describe_comp_flags
next->comps.unused[] is redundant with SWS_COMP_GARBAGE now.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 09:39:09 +00:00
Niklas Haas 804041045e swscale/ops: remove redundant unused mask from ops printout
This is now fully redundant with the previous op's output; because unused
components are always marked as garbage on the input side.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 09:39:09 +00:00
Niklas Haas 13388c0cac swscale/ops: test for SWS_COMP_GARBAGE instead of next->comps.unused
When printing/describing operations.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 09:39:09 +00:00
Niklas Haas 6fb0efb35c swscale/ops: strip value range from garbage components
Just removes the unnecessary value range after the WRITE, as a result of
the previous change and the fact that we already skipped printing these for
unused components.

 rgb24 -> bgr24:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 ...X -> +++X] SWS_OP_SWIZZLE      : 2103
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 ...X -> XXXX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
-    min: {0 0 0 _}, max: {255 255 255 _}
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 09:39:09 +00:00
Niklas Haas 7d94d9fc52 swscale/ops: mark all unused components as GARBAGE
This only affects the print-out of the SWS_OP_WRITE at the end of every op,
list, because the ops list print-out was otherwise already checking the unused
mask.

 rgb24 -> bgr24:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 ...X -> +++X] SWS_OP_SWIZZLE      : 2103
     min: {0 0 0 _}, max: {255 255 255 _}
-  [ u8 ...X -> +++X] SWS_OP_WRITE        : 3 elem(s) packed >> 0
+  [ u8 ...X -> XXXX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
     min: {0 0 0 _}, max: {255 255 255 _}
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 09:39:09 +00:00
Niklas Haas 672c0ad69a swscale/ops: slightly refactor unused[] computation
Needed for the upcoming removal of op->comps.unused[]. This keeps the
dependency array entirely within the ff_sws_op_list_update_comps() function,
apart from being arguably simpler and easier to follow.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 09:39:09 +00:00
Niklas Haas c0cc7f341a swscale/ops: simplify SwsOpList.order_src/dst
Just define these directly as integer arrays; there's really no point in
having them re-use SwsSwizzleOp; the only place this was ever even remotely
relevant was in the no-op check, which any decent compiler should already
be capable of optimizing into a single 32-bit comparison.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 09:39:09 +00:00
Niklas Haas d33403ba50 avfilter/buffersrc: use 1 << n for flags (cosmetic)
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 09:38:01 +00:00
WyattBlue 33f837a9e9 avfilter/af_whisper.c: Set split_on_word
This prevents `max_len` splitting via tokens, which splits words
like "don't" and proper nouns inappropriately.
2026-03-29 09:37:41 +00:00
nyanmisaka 107a309f3c fftools/ffmpeg_filter: fix the incomplete printing of reason for video filter graph reconfiguration
"Reconfiguring filter graph because video parameters changed to yuv420p10le(pc, bt709), 1920x1080, unspecified alph"

Fixup f07573f

Adding a missing space fixed this.
2026-03-29 09:34:23 +00:00
James Almer 482e7a1696 avformat/matroskadec: remove unnecessary log
Added by mistake in ec86dade2f

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-29 00:08:26 -03:00
James Almer ad7d270935 avcodec/libdav1d: call ff_attach_decode_data() on output frames
This will allow the injection of LCEVC side data.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-28 22:07:54 -03:00
James Almer 823c6fc0b8 avcodec/decode: make LCEVC injection available to decoders that don't call ff_get_buffer()
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-28 22:07:54 -03:00
James Almer 8528c697c7 avcodec/av1dec: add support for LCEVC ITU-T35 payloads
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-28 22:07:54 -03:00
James Almer 4c7a8df34d avcodec/av1dec: refactor parsing ITU-T35 metadata
Use a switch case. Will be useful in the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-28 22:07:54 -03:00
James Almer 29d8c2af4d avcodec/libdav1d: add support for LCEVC ITU-T35 payloads
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-28 22:07:54 -03:00
James Almer fe1ffd63fb avcodec/libdav1d: refactor parsing ITU-T35 metadata
Use a switch case. Will be useful in the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-28 22:07:54 -03:00
James Almer ec86dade2f avformat/matroskadec: add support for LCEVC ITU-T35 payloads
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-28 22:07:54 -03:00
James Almer 47dc4e3429 avformat/matroskadec: refactor parsing Block Additional
Use a switch case. Will be useful in the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-28 22:07:50 -03:00
Andreas Rheinhardt 1a7979a2f8 avcodec/x86/h26x/h2656_inter: Simplify splatting coefficients
For pre-AVX2, vpbroadcastw is emulated via a load, followed
by two shuffles. Yet given that one always wants to splat
multiple pairs of coefficients which are adjacent in memory,
one can do better than that: Load all of them at once, perform
a punpcklwd with itself and use one pshufd per register.
In case one has to sign-extend the coefficients, too,
one can replace the punpcklwd with one pmovsxbw (instead of one
per register) and use pshufd directly afterwards.

This saved 4816B of .text here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-29 01:05:23 +01:00
Andreas Rheinhardt a72b00675c avcodec/x86/h26x/h2656_inter: Don't prepare unused coeffs for hv funcs
8 tap motion compensation functions with both vertical and horizontal
components are under severe register pressure, so that the filter
coefficients have to be put on the stack. Before this commit,
this meant that coefficients for use with pmaddubsw and pmaddwd
were always created. Yet this is completely unnecessary, as
every such register is only used for exactly one purpose and
it is known at compile time which one it is (only 8bit horizontal
filters are used with pmaddubsw), so only prepare that one.
This also allows to half the amount of stack used.

This saves 2432B of .text here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-29 01:05:23 +01:00
Andreas Rheinhardt 88870f33ab avcodec/x86/h26x/h2656_inter: Remove always-true checks
It has already been checked before that we are only dealing
with high bitdepth here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-29 01:05:23 +01:00
Andreas Rheinhardt eb5ac9fee7 avfilter/x86/vf_idetdsp: Avoid (v)movdqa
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-29 01:05:23 +01:00
Andreas Rheinhardt c00721310f avcodec/x86/hevc/deblock: Avoid vmovdqa
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-29 01:05:23 +01:00
Andreas Rheinhardt 5c88f46c92 avutil/x86/aes: Only assemble iff HAVE_AESNI_EXTERNAL
This avoids relying on DCE and works around a NASM bug [1].

[1]: https://github.com/netwide-assembler/nasm/issues/216

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 23:25:54 +01:00
Andreas Rheinhardt 4c179adeaf avcodec/Makefile: Add avformat->h2645_parse.o lcevctab.o dependencies
Fixes static --disable-everything builds.
Forgotten in 053822d9ce
and 49c449b33a.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 23:25:31 +01:00
Andreas Rheinhardt e91727e7ef avcodec/x86/mpeg4videodsp: Fix build failure without x86asm
Since ba793127c4,
the x86 mpeg4videodsp code uses ff_emulated_edge_mc_sse2()
instead of ff_emulated_edge_mc_8. This leads to linker errors
when x86asm is disabled. Fix this by also falling back to ff_gmc_c()
in case edge emulation is needed with external SSE2 being unavailable.

An alternative is to go back to ff_emulated_edge_mc_8(), but this
would readd the uglyness to videodsp for a niche case.

Reported-by: James Almer <jamrial@gmail.com>
Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 22:39:05 +01:00
James Almer a5c10346fc avcodec/lcevcdec: do nothing with unsupported pixel formats
Instead of failing and stopping the decoding process.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-28 18:33:12 -03:00
James Almer 5a75d905cb avformat/mpegts: create stream groups after having parsed the entire PMT
Some faulty files have an LCEVC descriptor with a single stream, resulting in
a group being created but never fully populated with the current
implementation.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-28 18:13:36 -03:00
James Almer d069ba22ff avcodec/decode: don't try to apply LCEVC enhancements if some other kind of post processing is active
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-28 20:14:13 +00:00
James Almer d6a22cda38 avcodec/decode: add a hwaccel specific post_process callback to FrameDecodeData
Leave the existing one for non decoder-specific, post processing usage.
With this, scenarios like nvdec decoding can work algonside lcevc enhancement application.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-28 20:14:13 +00:00
Lynne 5482deeb66 lavfi/scale_vulkan: fix width/height match check
Sponsored-by: Sovereign Tech Fund
2026-03-28 19:36:58 +01:00
Lynne 0e077f2dc1 swscale/vulkan: do not apply order_src/dst for packed r/w
> packed = load all components from a single plane (the index given by order_src[0])
> planar = load one component each from separate planes (the index given by order_src[i])

Sponsored-by: Sovereign Tech Fund
2026-03-28 19:36:04 +01:00
Lynne 69c9cfbddf swscale/vulkan: fix redundant check for packed data
This is always in the branch where packed == false.

Sponsored-by: Sovereign Tech Fund
2026-03-28 19:36:04 +01:00
Niklas Haas 814f862832 swscale/graph: add scaling ops when required
The question of whether to do vertical or horizontal scaling first is a tricky
one. There are several valid philosophies:

1. Prefer horizontal scaling on the smaller pixel size, since this lowers the
   cost of gather-based kernels.
2. Prefer minimizing the number of total filter taps, i.e. minimizing the size
   of the intermediate image.
3. Prefer minimizing the number of rows horizontal scaling is applied to.

Empirically, I'm still not sure which approach is best overall, and it probably
depends at least a bit on the exact filter kernels in use. But for now, I
opted to implement approach 3, which seems to work well. I will re-evaluate
this once the filter kernels are actually finalized.

The 'scale' in 'libswscale' can now stand for 'scaling'.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 2ef01689c4 swscale/x86/ops: add 4x4 transposed kernel for large filters
Above a certain filter size, we can load the offsets as scalars and loop
over filter taps instead. To avoid having to assemble the output register
in memory (or use some horrific sequence of blends and insertions), we process
4 adjacent pixels at a time and do a 4x4 transpose before accumulating the
weights.

Significantly faster than the existing kernels after 2-3 iterations.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 4bf51d6615 swscale/x86/ops: add reference SWS_OP_FILTER_H implementation
This uses a naive gather-based loop, similar to the existing legacy hscale
SIMD. This has provably correct semantics (and avoids overflow as long as
the filter scale is 1 << 14 or so), though it's not particularly fast for
larger filter sizes.

We can specialize this to more efficient implementations in a subset of cases,
but for now, this guarantees a match to the C code.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 568cdca9cc swscale/x86/ops: implement support for SWS_OP_FILTER_V
Ideally, we would like to be able to specialize these to fixed kernel
sizes as well (e.g. 2 taps), but that only saves a tiny bit of loop overhead
and at the moment I have more pressing things to focus on.

I found that using FMA instead of straight mulps/addps gains about 15%, so
I defined a separate FMA path that can be used when BITEXACT is not specified
(or when we can statically guarantee that the final sum fits into the floating
point range).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 7966de1ce6 swscale/x86/ops: add support for applying y line bump
A singular `imul` per line here is completely irrelevant in terms of
overhead, and definitely not the worth of whatever precomputation would be
required to avoid it.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 77588898e2 swscale/x86/ops: add some missing packed shuffle instances
Missing ayuv64le -> gray and vyu444 -> gray; these conversions can arise
transiently during scaling.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 98f2aba45a swscale/x86/ops: add bxq/yq variants of bxd/yd
Sometimes, bxd/yd need to be passed directly to a 64-bit memory operand,
which requires the use of the 64-bit variants. Since we can't guarantee that
the high bits are correctly zero'd on function entry, add an explicit
movsxd instruction to cover the first loop iteration.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 48369f6cf2 swscale/x86/ops: reserve one more temporary register
Slightly more convenient for the calculations inside the filter kernel, and
ultimately not significant due to the fact that the extra register only needs
to be saved on the loop entrypoint.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 4ff32b6e86 swscale/ops_chain: add optional check() call to SwsOpEntry
Allows implementations to implement more advanced logic to determine if an
operation is compatible or not.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 7b6170a9a5 tests/swscale: don't hard-error on low bit depth SSIM loss
This is an expected consequence of the fact that the new ops code does not
yet do error diffusion, which only really affects formats like rgb4 and monow.

Specifically, this avoids erroring out with the following error:

 loss 0.214988 is WORSE by 0.0111071, ref loss 0.203881
 SSIM {Y=0.745148 U=1.000000 V=1.000000 A=1.000000}

When scaling monow -> monow from 96x96 to 128x96.

We can remove this hack again in the future when error diffusion is implemented,
but for now, this check prevents me from easily testing the scaling code.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas d8b82c1097 tests/checkasm/sw_ops: add tests for SWS_OP_FILTER_H/V
These tests check that the (fused) read+filter ops work.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 0402ecc270 tests/checkasm/sw_ops: set value range on op list input
May allow more efficient implementations that rely on the value range being
constrained.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 43242e8a88 tests/checkasm/sw_ops: increase line count
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 1a8c3d522e swscale/ops_backend: add support for SWS_OP_FILTER_H
Naive scalar loop to serve mainly as a reference for the asm backends.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas e787f75ec8 swscale/ops_backend: add support for SWS_OP_FILTER_V
These could be implemented as a special case of DECL_READ(), but the
amount of extra noise that entails is not worth it; especially due to the
extra setup/free code that needs to be used here.

I've decided that, for now, the canonical implementation shall convert the
weights to floating point before doing the actual scaling. This is not a huge
efficiency loss (since the result will be 32-bit anyways, and mulps/addps are
1-cycle ops); so the main downside comes from the single extra float conversion
on the input pixels.

In theory, we may revisit this later if it turns out that using e.g. pmaddwd
is a win even for vertical scaling, but for now, this works and is a simple
starting point. Vertical scaling also tends to happen after horizontal scaling,
at which point the input will be F32 already to begin with.

For smaller types/kernels (e.g. U8 input with a reasonably sized kernel),
the result here is exact either way, since the resulting 8+14 bit sum fits
exactly into float.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 542557ba47 swscale/ops_backend: implement support for y_bump map
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas fce3deaa3b swscale/ops_backend: add SwsOpExec to SwsOpIter
Needed for the scaling kernel, which accesses line strides.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 0b91b5a5e4 swscale/ops_backend: remove unused/wrong #define
PIXEL_MIN is either useless (int) or wrong (float); should be -FLT_MAX
rather than FLT_MIN, if the intent is to capture the most negative possible
value.

Just remove it since we don't actually need it for anything.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas e6e9c45892 swscale/ops_dispatch: try again with split subpasses if compile() fails
First, we try compiling the filter pass as-is; in case any backends decide to
handle the filter as a single pass. (e.g. Vulkan, which will want to compile
such using internal temporary buffers and barriers)

If that fails, retry with a chained list of split passes.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas e3daeff965 swscale/ops_dispatch: compute input x offset map for SwsOpExec
This is cheap to precompute and can be used as-is for gather-style horizontal
filter implementations.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas dc88946d7b swscale/ops_dispatch: fix plane width calculation
This was wrong if sub_x > 1.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 78878b9daa swscale/ops_dispatch: refactor tail handling
Rather than dispatching the compiled function for each line of the tail
individually, with a memcpy to a shared buffer in between, this instead copies
the entire tail region into a temporary intermediate buffer, processes it with
a single dispatch call, and then copies the entire result back to the
destination.

The main benefit of this is that it enables scaling, subsampling or other
quirky layouts to continue working, which may require accessing lines adjacent
to the main input.

It also arguably makes the code a bit simpler and easier to follow, but YMMV.

One minor consequence of the change in logic is that we also no longer handle
the last row of an unpadded input buffer separately - instead, if *any* row
needs to be padded, *all* rows in the current slice will be padded. This is
a bit less efficient but much more predictable, and as discussed, basically
required for scaling/filtering anyways.

While we could implement some sort of hybrid regime where we only use the new
logic when scaling is needed, I really don't think this would gain us anything
concrete enough to be worth the effort, especially since the performance is
basically roughly the same across the board:

16 threads:
  yuv444p 1920x1080 -> ayuv 1920x1080: speedup=1.000x slower (input memcpy)
  rgb24   1920x1080 -> argb 1920x1080: speedup=1.012x faster (output memcpy)

1 thread:
  yuv444p 1920x1080 -> ayuv 1920x1080: speedup=1.062x faster (input memcpy)
  rgb24   1920x1080 -> argb 1920x1080: speedup=0.959x slower (output memcpy)

Overall speedup is +/- 1% across the board, well within margin of error.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 015abfab38 swscale/ops_dispatch: precompute relative y bump map
This is more useful for tight loops inside CPU backends, which can implement
this by having a shared path for incrementing to the next line (as normal),
and then a separate path for adding an extra position-dependent, stride
multiplied line offset after each completed line.

As a free upside, this encoding does not require any separate/special handling
for the exec tail.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 2583d7ad9b swscale/ops_dispatch: add line offsets map to SwsOpPass
And use it to look up the correct source plane line for each destination
line. Needed for vertical scaling, in which case multiple output lines can
reference the same input line.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:14 +01:00
Niklas Haas 9f0353a5b7 swscale/ops_optimizer: implement filter optimizations
We have to move the filters out of the way very early to avoid blocking
SWS_OP_LINEAR fusion, since filters tend to be nested in between all the
decode and encode linear ops.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:13 +01:00
Niklas Haas a41bc1dea3 swscale/ops_optimizer: merge duplicate SWS_OP_SCALE
(As long as the constant doesn't overflow)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:13 +01:00
Niklas Haas cba54e9e3b swscale/ops: add helper function to split filter subpasses
An operation list containing multiple filter passes, or containing nontrivial
operations before a filter pass, need to be split up into multiple execution
steps with temporary buffers in between; at least for CPU backends.

This helper function introduces the necessary subpass splitting logic

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:13 +01:00
Niklas Haas bf09910292 swscale/ops: add filter kernel to SwsReadWriteOp
This allows reads to directly embed filter kernels. This is because, in
practice, a filter needs to be combined with a read anyways. To accomplish
this, we define filter ops as their semantic high-level operation types, and
then have the optimizer fuse them with the corresponding read/write ops
(where possible).

Ultimately, something like this will be needed anyways for subsampled formats,
and doing it here is just incredibly clean and beneficial compared to each
of the several alternative designs I explored.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:13 +01:00
Niklas Haas 63140bff5e swscale/ops: define SWS_OP_FILTER_H/V
This commit merely adds the definitions. The implementations will follow.

It may seem a bit impractical to have these filter ops given that they
break the usual 1:1 association between operation inputs and outputs, but
the design path I chose will have these filter "pseudo-ops" end up migrating
towards the read/write for CPU implementations. (Which don't benefit from
any ability to hide the intermediate memory internally the way e.g. a fused
Vulkan compute shader might).

What we gain from this design, on the other hand, is considerably cleaner
high-level code, which doesn't need to concern itself with low-level
execution details at all, and can just freely insert these ops wherever
it needs to. The dispatch layer will take care of actually executing these
by implicitly splitting apart subpasses.

To handle out-of-range values and so on, the filters by necessity have to
also convert the pixel range. I have settled on using floating point types
as the canonical intermediate format - not only does this save us from having
to define e.g. I32 as a new intermediate format, but it also allows these
operations to chain naturally into SWS_OP_DITHER, which will basically
always be needed after a filter pass anyways.

The one exception here is for point sampling, which would rather preserve
the input type. I'll worry about this optimization at a later point in time.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:13 +01:00
Niklas Haas 53ee892035 swscale/graph: add way to roll back passes
When an op list needs to be decomposed into a more complicated sequence
of passes, the compile() code may need to roll back passes that have already
been partially compiled, if a later pass fails to compile.

This matters for subpass splitting (e.g. for filtering), as well as for
plane splitting.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:13 +01:00
Niklas Haas 475b11b2e0 swscale/filters: write new filter LUT generation code
This is a complete rewrite of the math in swscale/utils.c initFilter(), using
floating point math and with a bit more polished UI and internals. I have
also included a substantial number of improvements, including a method to
numerically compute the true filter support size from the parameters, and a
more robust logic for the edge conditions. The upshot of these changes is
that the filter weight computation is now much simpler and faster, and with
fewer edge cases.

I copy/pasted the actual underlying kernel functions from libplacebo, so this
math is already quite battle-tested. I made some adjustments to the defaults
to align with the existing defaults in libswscale, for backwards compatibility.

Note that this commit introduces a lot more filter kernels than what we
actually expose; but they are cheap to carry around, don't take up binary
space, and will probably save some poor soul from incorrectly reimplementing
them in the future. Plus, I have plans to expand the list of functions down
the line, so it makes sense to just define them all, even if we don't
necessarily use them yet.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 18:50:13 +01:00
Niklas Haas f76aa4e408 swscale/tests/sws_ops: add option for summarizing all operation patterns
This can be used to either manually verify, or perhaps programmatically
generate, the list of operation patterns that need to be supported by a
backend to be feature-complete.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Niklas Haas d7a079279f swscale/tests/sws_ops: refactor argument parsing
To allow for argumentless options in the future.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Ramiro Polla b6e470467e swscale/tests/sws_ops: add -v option to set log verbosity
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-28 16:48:13 +00:00
Niklas Haas d3db2dc518 swscale/tests/sws_ops: simplify using ff_sws_enum_op_lists()
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Niklas Haas 4395e8f3a2 swscale/ops: add helper function to enumerate over all op lists
This moves the logic from tests/sws_ops into the library itself, where it
can be reused by e.g. the aarch64 asmgen backend to iterate over all possible
operation types it can expect to see.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Niklas Haas f62c837eb6 swscale/ops: move op-formatting code to helper function
Annoyingly, access to order_src/dst requires access to the SwsOpList, so
we have to append that data after the fact.

Maybe this is another incremental tick in favor of `SwsReadWriteOp` in the
ever-present question in my head of whether the plane order should go there
or into SwsOpList.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Niklas Haas 8fae195395 swscale/ops: avoid printing values for ignored components
Makes the list output a tiny bit tidier. This is cheap to support now thanks
to the print_q4() helper.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Niklas Haas 1caa548caf swscale/ops: refactor PRINTQ() macro
Instead of allocating a billion tiny temporary buffers, these helpers now
directly append to an AVBPrint. I decided to explicitly control whether or not
a value with denom 0 should be printed as "inf/nan" or as "_", because a lot
of ops have the implicit semantic of "den == 0 -> ignored". At the same time,
we don't want to obscure legitimate NAN/INF values when the do occur
unintentionally.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Niklas Haas 0d54a1b53a swscale/ops: remove , from comp min/max print-out for consistency
Interferes with an upcoming simplification, otherwise.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Niklas Haas a0bb0c2772 swscale/ops: use AVBPrint for assembling op descriptions
This commit does not yet touch the PRINTQ macro, but it gets rid of at least
one unnecessary hand-managed buffer.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Niklas Haas 95e6c68707 swscale/ops: print exact constant on SWS_OP_SCALE
More informative.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Niklas Haas f6d963553b swscale/ops: correctly uninit all ops in ff_sws_op_list_remove_at()
This only ever removed a single op, even with count > 1.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Niklas Haas 6f1664382d swscale/format: add helper function to get "default" SwsFormat
But still apply the sanitization/defaulting logic from ff_fmt_from_frame().

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Niklas Haas 08a7b714f2 swscale/format: move SwsFormat sanitization to helper function
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-28 16:48:13 +00:00
Priyanshu Thapliyal d1bcaab230 avcodec/alsdec: preserve full float value in zero-truncated samples
Signed-off-by: Priyanshu Thapliyal <priyanshuthapliyal2005@gmail.com>
2026-03-28 12:18:37 +00:00
Priyanshu Thapliyal febc82690d avcodec/alsdec: propagate read_diff_float_data() errors in read_frame_data()
The return value of read_diff_float_data() was previously ignored,
allowing decode to continue silently with partially transformed samples
on malformed floating ALS input. Check and propagate the error.

All failure paths in read_diff_float_data() already return
AVERROR_INVALIDDATA, so the caller fix is sufficient without
any normalization inside the function.

Signed-off-by: Priyanshu Thapliyal <priyanshuthapliyal2005@gmail.com>
2026-03-28 11:53:38 +00:00
Andreas Rheinhardt bb65b54f2f avcodec/x86/sbcdsp: Port MMX sbc_calc_scalefactors to SSE4
Besides giving a nice speedup over the MMX version,
it also avoids processing unnecessarily much input and
touching unnecessarily much output in the 2ch-4subbands case.

calc_scalefactors_1ch_4subbands_c:                     106.9 ( 1.00x)
calc_scalefactors_1ch_4subbands_mmx:                    46.7 ( 2.29x)
calc_scalefactors_1ch_4subbands_sse4:                   11.8 ( 9.05x)
calc_scalefactors_1ch_8subbands_c:                     220.5 ( 1.00x)
calc_scalefactors_1ch_8subbands_mmx:                    92.3 ( 2.39x)
calc_scalefactors_1ch_8subbands_sse4:                   23.8 ( 9.28x)
calc_scalefactors_2ch_4subbands_c:                     222.5 ( 1.00x)
calc_scalefactors_2ch_4subbands_mmx:                   139.3 ( 1.60x)
calc_scalefactors_2ch_4subbands_sse4:                   23.6 ( 9.41x)
calc_scalefactors_2ch_8subbands_c:                     440.3 ( 1.00x)
calc_scalefactors_2ch_8subbands_mmx:                   196.8 ( 2.24x)
calc_scalefactors_2ch_8subbands_sse4:                   46.5 ( 9.48x)

The MMX version has been removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 11:25:38 +01:00
Andreas Rheinhardt e4e5beb394 tests/checkasm/sbcdsp: Add test for calc_scalefactors
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 11:25:38 +01:00
Andreas Rheinhardt cd886bf0a5 avcodec/x86/sbcdsp: Port ff_sbc_analyze_[48]_mmx to SSE2
Halfs the amount of pmaddwd and improves performance a lot:
sbc_analyze_4_c:                                        55.7 ( 1.00x)
sbc_analyze_4_mmx:                                       7.0 ( 7.94x)
sbc_analyze_4_sse2:                                      4.3 (12.93x)
sbc_analyze_8_c:                                       131.1 ( 1.00x)
sbc_analyze_8_mmx:                                      22.4 ( 5.84x)
sbc_analyze_8_sse2:                                     10.7 (12.25x)

It also saves 224B of .text and allows to remove the emms_c()
from sbcenc.c (notice that ff_sbc_calc_scalefactors_mmx()
issues emms on its own, so it already abides by the ABI).

Hint: A pshufd could be avoided per function if the constants
were reordered.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 11:25:38 +01:00
Andreas Rheinhardt 7cf5e90586 tests/checkasm: Add sbcdsp tests
Only sbc_analyze_4 and sbc_analyze_8 for now.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 11:25:38 +01:00
Andreas Rheinhardt 90215634f1 avcodec/sbcenc: Remove redundant memset()
A codec's private context is zero-allocated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 11:25:38 +01:00
Andreas Rheinhardt f670006960 avcodec/sbcenc: Use correct size for PutBitContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 11:25:38 +01:00
Andreas Rheinhardt 3540a6a308 avcodec/sbcenc: Don't output uninitialized data
Check in init whether the parameters are valid.
This can be triggered with
ffmpeg -i tests/data/asynth-44100-2.wav -c sbc -sbc_delay 0.001 \
-b:a 100k -f null -

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 11:25:38 +01:00
Andreas Rheinhardt b5ce98b3ff avcodec/sbcdsp: Constify
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 11:25:38 +01:00
Andreas Rheinhardt af45345f7e tests/fate: Add SBC tests
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 11:25:38 +01:00
Andreas Rheinhardt 0a81a1ce66 avcodec/x86/sbcdsp: Fix calculating four-subbands stereo scalefactors
sbc_calc_scalefactors uses an int32_t [16/*max blocks*/][2/*max
channels*/][8/*max subbands*/] array. The MMX version of this code
treats the two inner arrays as one [2*8] array to process
and it processes subbands*channels of them. But when subbands
is < 8 and channels is two, the entries to process are not
contiguous: One has to process 0..subbands-1 and 8..7+subbands,
yet the code processed 0..2*subbands-1.
This commit fixes this by processing entries 0..7+subbands
if there are two channels.

Before this commit, the following command line triggered an
av_assert2() in put_bits():
ffmpeg_g -i tests/data/asynth-44100-2.wav -c sbc -b:a 200k \
-sbc_delay 0.003 -f null -

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 11:25:38 +01:00
Andreas Rheinhardt 1c9f56f969 avcodec/sbc: Use union to save space
One buffer is encoder-only, the other decoder-only.
Also move crc_ctx before the buffers (into padding).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 11:25:38 +01:00
Andreas Rheinhardt 7e032d6963 avcodec/sbcdec: Remove AVClass* from context
This decoder has no private class.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 11:25:38 +01:00
Andreas Rheinhardt e249dfce72 doc/optimization: Don't refer to non-existing subdirectory
Removed in cdd139d760.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 04:43:28 +00:00
James Almer 62f944d594 avfilter/vf_lcevc: add missing pixel formats
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-27 21:00:53 -03:00
James Almer 1b7483dddd avfilter/vf_lcevc: workaround for unknown initial dimensions
This is not enough as filters down the chain may get wrong dimensions

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-27 21:00:19 -03:00
James Almer eb40d70081 avcodec/lcevcdec: add missing pixel formats
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-27 21:00:14 -03:00
James Almer 96b1b0bf67 avcodec/lcevcdec: also decompose NON_IDR NALUs
The first Global Config process block may be in one of them.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-27 20:56:45 -03:00
Anton Khirnov 3befae81f1 lavc/decode: change sw format selection logic in avcodec_default_get_format()
Choose the first non-hwaccel format rather than the last one. This
matches the logic in ffmpeg CLI and selects YUVA rather than YUV for
HEVC with alpha.
2026-03-27 19:42:08 -03:00
Anton Khirnov dba8c62400 lavfi/vf_tiltandshift: stop (ab)using AVFrame.opaque
This filter uses AVFrame.opaque to build a linked list of AVFrames. This
is very wrong, as AVFrame.opaque is intended to store caller's private
data and may not be touched by filters. What's worse, the filter leaks
the opaque values to the outside.

Use an AVFifo instead of a linked list to implement the same logic.
2026-03-27 19:42:08 -03:00
Andreas Rheinhardt 6ed6815b46 avcodec/tests/motion: Remove test tool
It only tests MMX (me_cmp does not have pure MMX functions any more)
and MMXEXT and is therefore x86-only. Furthermore, checkasm is superior
in every regard.

Removing it also fixes a build failure (there is no dependency of this
tool on me_cmp).

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-27 18:48:48 +01:00
osamu620 edab091ac2 avcodec/jpeg2000: Remove trailing whitespace
Remove trailing whitespace
2026-03-27 13:56:00 +00:00
Osamu Watanabe 8490363634 avcodec/jpeg2000: Fix undefined behavior on ROI shift-up 2026-03-27 13:56:00 +00:00
Georgii Zagoruiko 1c385023aa aarch64/vvc: Optimisations of put_chroma_v() functions for 10/12-bit
Apple M4:
put_chroma_v_10_2x2_c:                                   5.8 ( 1.00x)
put_chroma_v_10_4x4_c:                                   9.0 ( 1.00x)
put_chroma_v_10_4x4_neon:                                1.7 ( 5.29x)
put_chroma_v_10_8x8_c:                                  22.1 ( 1.00x)
put_chroma_v_10_8x8_neon:                                5.8 ( 3.79x)
put_chroma_v_10_16x16_c:                                56.3 ( 1.00x)
put_chroma_v_10_16x16_neon:                             21.2 ( 2.66x)
put_chroma_v_10_32x32_c:                               181.6 ( 1.00x)
put_chroma_v_10_32x32_neon:                             86.9 ( 2.09x)
put_chroma_v_10_64x64_c:                               680.3 ( 1.00x)
put_chroma_v_10_64x64_neon:                            337.4 ( 2.02x)
put_chroma_v_10_128x128_c:                            2567.3 ( 1.00x)
put_chroma_v_10_128x128_neon:                         1374.8 ( 1.87x)
put_chroma_v_12_2x2_c:                                   6.4 ( 1.00x)
put_chroma_v_12_4x4_c:                                   8.2 ( 1.00x)
put_chroma_v_12_4x4_neon:                                1.5 ( 5.56x)
put_chroma_v_12_8x8_c:                                  18.9 ( 1.00x)
put_chroma_v_12_8x8_neon:                                5.7 ( 3.29x)
put_chroma_v_12_16x16_c:                                52.6 ( 1.00x)
put_chroma_v_12_16x16_neon:                             19.9 ( 2.65x)
put_chroma_v_12_32x32_c:                               185.7 ( 1.00x)
put_chroma_v_12_32x32_neon:                             81.9 ( 2.27x)
put_chroma_v_12_64x64_c:                               661.8 ( 1.00x)
put_chroma_v_12_64x64_neon:                            342.1 ( 1.93x)
put_chroma_v_12_128x128_c:                            2547.8 ( 1.00x)
put_chroma_v_12_128x128_neon:                         1368.0 ( 1.86x)

RPi4:
put_chroma_v_10_2x2_c:                                  64.8 ( 1.00x)
put_chroma_v_10_4x4_c:                                 157.2 ( 1.00x)
put_chroma_v_10_4x4_neon:                               39.7 ( 3.96x)
put_chroma_v_10_8x8_c:                                 562.1 ( 1.00x)
put_chroma_v_10_8x8_neon:                               98.8 ( 5.69x)
put_chroma_v_10_16x16_c:                              1170.7 ( 1.00x)
put_chroma_v_10_16x16_neon:                            380.7 ( 3.07x)
put_chroma_v_10_32x32_c:                              3696.6 ( 1.00x)
put_chroma_v_10_32x32_neon:                           1723.8 ( 2.14x)
put_chroma_v_10_64x64_c:                             13170.9 ( 1.00x)
put_chroma_v_10_64x64_neon:                           7284.1 ( 1.81x)
put_chroma_v_10_128x128_c:                           46068.3 ( 1.00x)
put_chroma_v_10_128x128_neon:                        27219.5 ( 1.69x)
put_chroma_v_12_2x2_c:                                  63.8 ( 1.00x)
put_chroma_v_12_4x4_c:                                 156.5 ( 1.00x)
put_chroma_v_12_4x4_neon:                               39.3 ( 3.98x)
put_chroma_v_12_8x8_c:                                 560.9 ( 1.00x)
put_chroma_v_12_8x8_neon:                               98.7 ( 5.68x)
put_chroma_v_12_16x16_c:                              1169.9 ( 1.00x)
put_chroma_v_12_16x16_neon:                            380.8 ( 3.07x)
put_chroma_v_12_32x32_c:                              3693.9 ( 1.00x)
put_chroma_v_12_32x32_neon:                           1728.4 ( 2.14x)
put_chroma_v_12_64x64_c:                             13170.9 ( 1.00x)
put_chroma_v_12_64x64_neon:                           7284.9 ( 1.81x)
put_chroma_v_12_128x128_c:                           46068.0 ( 1.00x)
put_chroma_v_12_128x128_neon:                        27224.6 ( 1.69x)
2026-03-27 13:42:50 +00:00
Ingo Oppermann 4bb2989cce fftools/ffmpeg_filter: remove duplicate assignment
Signed-off-by: Ingo Oppermann <ingo@datarhei.com>
2026-03-27 06:37:27 +00:00
James Almer 5dfe661f03 avformat/mov: ignore duplicate streams referenced with an sbas tref entry
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-26 22:17:07 -03:00
Priyanshu Thapliyal ae6f233988 avcodec/alsdec: fix mantissa unpacking in compressed Part A path
Signed-off-by: Priyanshu Thapliyal <priyanshuthapliyal2005@gmail.com>
2026-03-26 16:25:09 +00:00
Zhao Zhili fd9f1e9c52 avfilter/vf_drawtext: fix newline rendered as .notdef glyph
GET_UTF8 advances the pointer past the newline byte before the
newline check, so shape_text_hb receives text that includes the
newline character. Since HarfBuzz does not treat U+000A as
default-ignorable, it gets shaped into a .notdef glyph.

Fixes #21565

Reported-by: scriptituk <info@scriptit.uk>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-03-26 07:24:15 +00:00
Kacper Michajłow 0f600cbc16 configure: enable nasm debug information also for non-ELF targets
The default NASM selection of debug information formats should cover all
cases nicely. See `nasm -h -F` for the default and supported formats.

This commit allows emitting debug information for macho{32,64} (DWARF)
and win{32,64} (CodeView), where previously only ELF targets would
get debug information.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-26 00:25:29 +00:00
Niklas Haas 238df21a4f avfilter/vf_libplacebo: early-free unused resources
Otherwise, this will indefinitely persist the last couple of mapped frames
(including any extra decoded frames) in memory, even though they will never be
used again, causing a gradual memory leak until filter uninit.

Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: nxtedition AB
2026-03-25 17:47:09 +00:00
Priyanshu Thapliyal e7b4ddc9d6 avcodec/pngdec: fix dead overflow check in decode_text_to_exif()
The expression (exif_len & ~SIZE_MAX) is always 0 for size_t,
making the overflow guard permanently dead code.

Reported-by: Guanni Qu <qguanni@gmail.com>
Signed-off-by: Priyanshu Thapliyal <priyanshuthapliyal2005@gmail.com>
2026-03-25 16:48:12 +00:00
Aleksoid e84b3c7e98 avcodec/vp9: Fixed memory leak when vp9_frame_alloc() function fails. 2026-03-25 14:31:34 +00:00
Kacper Michajłow e17d84ac8a avcodec/vp9: fix cbs fragment leak on error
Fixes: c0bf1382a7
Fixes: 490257166/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP9_fuzzer-6185031050788864
Fixes: 490131106/clusterfuzz-testcase-minimized-fuzzer_loadfile-5438205762797568
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-25 14:02:19 +00:00
Zhao Zhili 44ad73031d avcodec/bsf/lcevc_metadata: fix copy-paste typo in chroma loc setup
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-03-25 12:19:46 +00:00
Zhao Zhili 3cfbf56192 doc/developer: allow whitespace changes mixed with functional changes
The cosmetic-changes policy in developer.texi was written during the SVN
era, when reviewing indentation changes mixed with functional changes
was genuinely difficult.

Since FFmpeg has moved to Git, reviewers now have simple built-in tools
to ignore whitespace changes:

  git diff -w
  git log -p --ignore-all-space

Forgejo's pull request UI also offers a 'Hide whitespace changes'
toggle, making it trivial to focus on the functional diff.

For those who prefer reviewing patches in their mail client, the same
result can be achieved by saving the patch and running:

  git apply --ignore-whitespace <patch> && git diff -w

Relax the policy so that indentation changes which are invisible to
git diff --ignore-all-space may accompany functional changes, while
still requiring non-whitespace cosmetic changes to be in separate
commits.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-03-25 04:14:23 +00:00
marcos ashton 5d70f0844c libavutil/stereo3d: fix prefix matching in *_from_name() functions
The three *_from_name() functions used av_strstart() for prefix matching,
which returns incorrect results when one name is a prefix of another.

av_stereo3d_from_name("side by side (quincunx subsampling)") matched
"side by side" at index 1 and returned AV_STEREO3D_SIDEBYSIDE instead of
AV_STEREO3D_SIDEBYSIDE_QUINCUNX. Similarly,
av_stereo3d_primary_eye_from_name("nonexistent") matched "none" and
returned AV_PRIMARY_EYE_NONE instead of -1.

Switch all three functions from av_strstart() to strcmp() for exact
matching. No in-tree callers rely on prefix matching.

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-25 01:32:20 +00:00
marcos ashton 9559a6036d libavfilter/vf_v360: fix operator precedence in stereo loop condition
The loop condition in the DEFINE_REMAP macro:

  stereo < 1 + s->out_stereo > STEREO_2D

is parsed by C as:

  (stereo < (1 + s->out_stereo)) > STEREO_2D

Since STEREO_2D is 0 and relational operators return 0 or 1, the
outer comparison against 0 is a no-op for STEREO_2D and STEREO_SBS.
But for STEREO_TB (value 2) the loop runs 3 iterations instead of 2,
producing an out-of-bounds stereo pass.

Add parentheses so the comparison is evaluated first:

  stereo < 1 + (s->out_stereo > STEREO_2D)

This gives 1 iteration for 2D and 2 for any stereo format (SBS or TB),
matching the actual number of stereo views.

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-25 01:19:08 +00:00
Priyanshu Thapliyal 1853c80e20 avcodec/alsdec: fix abs(INT_MIN) UB in read_diff_float_data()
Replace abs() with FFABSU() to avoid undefined behavior when
raw_samples[c][i] == INT_MIN. Per libavutil/common.h, FFABS()
has the same INT_MIN UB as abs(); FFABSU() is the correct
helper as it casts to unsigned before negation.

Reported-by: Guanni Qu <qguanni@gmail.com>
Signed-off-by: Priyanshu Thapliyal <priyanshuthapliyal2005@gmail.com>
2026-03-25 00:16:41 +00:00
Ted Meyer fc7cab6be3 avformat/mov: Handle integer overflow in MOV parser
A chromium UBSAN fuzzer caught this instance.
2026-03-24 23:48:18 +00:00
wangbin 49c449b33a avformat/codecstring: fix undefined lcevc symbols if muxers are disabled 2026-03-24 23:14:41 +00:00
Andreas Rheinhardt 76a5d7c545 avfilter/framepool: Mark init, uninit functions as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-24 23:13:00 +00:00
Andreas Rheinhardt c3486e96dd avfilter/framepool: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-24 23:13:00 +00:00
Andreas Rheinhardt e1e2c85537 avfilter/framepool: Use av_unreachable() for unreachable code
Instead of av_assert0(0).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-24 23:13:00 +00:00
Andreas Rheinhardt 1c101330d6 avfilter/framepool: Remove impossible branches
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-24 23:13:00 +00:00
Andreas Rheinhardt 92d06a8027 avcodec/vvc/ctu: Put scratchbufs into union to save space
This reduces sizeof(VVCLocalContext) from 4580576B to
3408032B here.

Reviewed-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-24 18:12:00 +01:00
Andreas Rheinhardt a10c731723 avcodec/vvc/ctu: Move often accessed fields to the start of structs
And move the big buffers to the end. This reduces codesize
as offset+displacement addressing modes are either unavailable
or require more bytes of displacement is too large. E.g. this
saves 5952B on x64 here and 3008B on AArch64. This change should
also improve data locality.

Reviewed-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-24 18:10:55 +01:00
Andreas Rheinhardt e41799d6ec avcodec/vvc: Use static_assert where appropriate
Reviewed-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-24 18:09:43 +01:00
Lynne f40fcf8024 libavfilter/scale_vulkan: do not unnencessarily set s->qf on every frame
The initialization function already does this.

Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:23 +01:00
Lynne 940e407c64 libavfilter/scale_vulkan: use swscale's Vulkan code
This commit enables using swscale's newly added Vulkan code.

Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:17 +01:00
Lynne e88d4ef718 swscale/vulkan: take order_src/order_dst into account
This fixes rgba/gbrap/bgra conversions.

Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:17 +01:00
Lynne e01d19aad6 swscale/vulkan: implement SWS_OP_LINEAR
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:17 +01:00
Lynne 4805f317a6 swscale/vulkan: implement SWS_OP_DITHER
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:17 +01:00
Lynne d212ff08e0 swscale/vulkan: implement SWS_OP_CONVERT
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:17 +01:00
Lynne bea41f1f90 swscale/vulkan: implement SWS_OP_LSHIFT/SWS_OP_RSHIFT
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:17 +01:00
Lynne d35a77879c swscale/vulkan: implement SWS_OP_MIN/SWS_OP_MAX
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:16 +01:00
Lynne bf93a67733 swscale/vulkan: implement SW_OP_SCALE
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:16 +01:00
Lynne 41f748d2ee swscale/vulkan: add precise qualifier to f32
Sponsored-by: Sovereign Tech Fund
2026-03-24 15:21:09 +01:00
James Almer d61d724905 avcodec/bsf/lcevc_metadata: write Aditional Info blocks after the Global Config block
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-24 11:14:17 -03:00
James Almer 35a1e43a6a avcodec/cbs_lcevc: fix writing process blocks with size 6
6 is an undefined value for payload_size_type. For those, 7 is used to signal
a custom_byte_size synxtax element.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-24 11:12:25 -03:00
Niklas Haas 00d1f41b2e swscale/ops_backend: avoid UB (null pointer arithmetic)
Just use uintptr_t, it accomplishes the exact same thing while being defined
behavior.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-24 13:20:59 +00:00
Scott Theisen 7516bf24db libavformat/mpegts.c: pat_cb(): Ensure all PIDs are valid
but just ignore invalid PAT entries so subsequent valid
entries are parsed.

ISO/IEC 13818-1:2021 specifies a valid range of [0x0010, 0x1FFE] in
§ 2.4.4.6 Semantic definition of fields in program association section
and Table 2-3 – PID table

ts->current_pid is always 0 since that is the PID for the PAT.
2026-03-23 19:50:13 +00:00
Nariman-Sayed 2501954d49 avformat/rtpdec: fix RTCP RR cumulative packet loss clamping
Per RFC 3550 Appendix A.3, the cumulative number of packets lost is a
signed 24-bit field. Clamp to signed 24-bit range using av_clip_intp2
and av_zero_extend to handle duplicate packets correctly.
2026-03-23 19:49:25 +00:00
Romain Beauxis 053fb462d8 tests/fate/ogg-*.mak: Make sure that copy tests do not run when
$(FFMPEG) is not compiled.
2026-03-23 10:53:33 -05:00
James Almer e1158301f0 avformat/mov: don't try to create an LCEVC group if there's a single track
In this scenario, as it's the case with DASH segments, the lcevc track will be
alone but potentially have a sbas tref entry referencing itself, which will
make avformat_stream_group_add_stream() fail.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-23 10:50:13 -03:00
Kacper Michajłow 9c63742425 avutil/attributes: enable av_flatten when available
This enables av_flatten on Clang in particular.

It was disabled because at the time this attribute was not supported.
It was implemented in Clang/LLVM 3.5 [1].

Use `__has_attribute` to check for availability. This has been added in
Clang 2.9 [2].

This reverts change 5858a67f13.

[1] https://github.com/llvm/llvm-project/commit/41af7c2fdc8cc2ef186669dcb21cac58d5bd69ee
[2] https://github.com/llvm/llvm-project/commit/274a70ed7f4315c83273173fce4c3b0e097958d6

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-22 15:55:54 +00:00
Romain Beauxis 878fb73135 libavfilter/vf_frei0r: use .so suffix for plugins on macOS 2026-03-22 14:27:36 +00:00
James Almer 711b1a52bd avformat/movenc: check if a packet is to be discarded when calculating edit list durations
Demuxers like mov will export packets not meant for presentation (e.g. because
an edit list doesn't include them) by flagging them as discard, but the mov
muxer completely ignored this, resulting in output edit lists considering every
packet.

Fixes issue #22552

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-21 23:35:39 -03:00
Michael Niedermayer 1bde76da89 avcodec/dvdsub_parser: Fix buf_size check
Fixes: signed integer overflow
Fixes: out of array access
Fixes: dvdsub_int_overflow_mixed_ps.mpg

Found-by: Quang Luong of Calif.io in collaboration with OpenAI Codex
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-22 00:33:26 +00:00
Andreas Rheinhardt 9d97771bc6 avcodec/bsf/extract_extradata: Remove pointless checks
It doesn't hurt to keep track of filtered_size:
The end result will be ignored if extradata is not removed
from the bitstream.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-21 15:05:17 +00:00
Andreas Rheinhardt 1dd853010a avcodec/bsf/extract_extradata: Redo extracting LCEVC extradata
Changes compared to the current version include:
1. We no longer use a dummy PutByteContext on the first pass
for checking whether there is extradata in the NALU. Instead
the first pass no longer writes anything to any PutByteContext
at all; the size information is passed via additional int*
parameters. (This no longer discards const when initializing
the dummy PutByteContext, fixing a compiler warning.)
2. We actually error out on invalid data in the first pass,
ensuring that the second pass never fails.
3. The first pass is used to get the exact sizes of both
the extradata and the filtered data. This obviates the need
for reallocating the buffers lateron. (It also means
that the extradata side data will have been allocated with
av_malloc (ensuring proper alignment) instead of av_realloc().)
4. The second pass now writes both extradata and (if written)
the filtered data instead of parsing the NALUs twice.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-21 15:05:17 +00:00
Andreas Rheinhardt 548b9f5ca7 avcodec/bsf/extract_extradata: Inline constants
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-21 15:05:17 +00:00
stevxiao a077da895b avfilter/dnn_backend_torch: add CUDA/ROCm device support
Add support for CUDA and ROCm (AMD GPU) devices in the LibTorch DNN
backend.

This works for both NVIDIA CUDA and AMD ROCm, as PyTorch exposes ROCm
through the CUDA-compatible API.

Usage:

./ffmpeg -i input.mp4 -vf scale=224:224,format=rgb24,dnn_processing=dnn_backend=torch:model=sr_model_torch.pt:device=cuda output.mp4

Reviewed-by: Guo Yejun <yejun.guo@intel.com>
Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-03-21 16:25:40 +08:00
marcos ashton 924cc51ffe tests/fate/pcm: add FATE tests for pcm_bluray encoder and decoder
Add enc_dec_pcm roundtrip tests for the pcm_bluray codec covering
mono, stereo, 5.1, 7.0, and 7.1 channel layouts in s16. The 5.1
and 7.0 tests use an explicit pan filter for channel layout
conversion so the PAN_FILTER dependency is declared only where
needed. An additional s32 test uses a FATE sample file with real
>16-bit content (divertimenti_2ch_96kHz_s24.wav) and decodes to
s32le to verify the full 32-bit round-trip.

enc_dec_pcm is used instead of transcode because the MPEGTS muxer
produces different binary output on 32-bit and 64-bit platforms,
causing the intermediate file checksum to fail on 32-bit CI.

Coverage for libavcodec/pcm-bluray.c: 0.00% -> 93.75%
Coverage for libavcodec/pcm-blurayenc.c: 0.00% -> 91.71%

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-21 01:04:20 +00:00
marcos ashton 345071f747 tests/fate/libavutil: add FATE test for stereo3d
Add a unit test covering av_stereo3d_alloc, av_stereo3d_alloc_size,
av_stereo3d_create_side_data, av_stereo3d_type_name,
av_stereo3d_from_name, av_stereo3d_view_name,
av_stereo3d_view_from_name, and av_stereo3d_primary_eye_name.
The from_name calls are driven by a static name table so each
string appears exactly once. Round-trip inverse checks verify
that type_name/from_name and view_name/view_from_name are
consistent with each other.

Coverage for libavutil/stereo3d.c: 0.00% -> 100.00%

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-21 01:04:20 +00:00
marcos ashton ed19c181c2 tests/fate/libavutil: add FATE test for film_grain_params
Add a unit test covering alloc, create_side_data, and select
for AV1 and H.274 film grain parameter types (22 cases).

Coverage for libavutil/film_grain_params.c: 0.00% -> 97.73%

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-21 01:04:20 +00:00
marcos ashton a43ea8bff7 avfilter/af_pan: fix sscanf() return value checks in parse_channel_name
sscanf() returns EOF (-1) on input failure, which is non-zero and
passes a bare truthy check. When this happens, the %n directive is
never processed, so len stays uninitialized. Using that value to
advance the arg pointer causes an out-of-bounds read and crash.

Check for >= 1 instead, matching the fix applied to the other
sscanf() call in init() by commit b5b6391d64.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/22451
Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-21 00:44:30 +00:00
tark1998 442e6c80bf avformat/mov: add m4v to allowed extensions
M4V is a standard extension for MPEG-4 video files, commonly used by
Apple devices and software. While it is functionally similar to MP4,
it was missing from the list of recognized extensions for the
MOV/MP4 demuxer.
2026-03-21 00:40:39 +00:00
marcos ashton dfa53aae5f avutil/bswap: fix implicit conversion warning in av_bswap64
Explicitly cast uint64_t arguments to uint32_t before passing them
to av_bswap32(). The truncation is intentional (extracting low and
high halves), but clang on macOS 26 warns about it.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/22453
Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-21 00:34:50 +00:00
Weidong Wang 06d19d000d avformat/rsd: reject short ADPCM_THP extradata reads
Use ffio_read_size() to enforce exact-length reads of the per-channel
ADPCM_THP coefficient tables. Previously the return value of
avio_read() was unchecked, silently accepting truncated extradata.
2026-03-21 00:29:04 +00:00
Michael Niedermayer e9c6d411c4 doc/CVSS
A simple (FFmpeg specific) guide how to choose CVSS
2026-03-20 22:01:43 +01:00
Michael Niedermayer 313e776ba7 avcodec/ffv1dec: Allocate the minimum size for fltmap and fltmap32 with the current implementation
Found-by: Lynne
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-20 15:50:09 +00:00
Jeremy James 3d4461e16d fftools/ffprobe: Show stream group side data
Specifically output side data from tile groups with -show_stream_groups
which includes rotation information in HEIC images.

Signed-off-by: Jeremy James <jeremy.james@gmail.com>
2026-03-20 12:45:44 +00:00
Martin Storsjö f72f692afa aarch64: Add PAC sign/validation of the link register
Whenever the link register is stored on the stack, sign it
before storing it and validate at a symmetrical point (with the
stack at the same level as when it was signed).

These macros only have an effect if built with PAC enabled (e.g.
through -mbranch-protection=standard), otherwise they don't
generate any extra instructions.

None of these cases were present when PAC support was added
in 248986a0db in 2022.

Without these changes, PAC still had an effect in the compiler
generated code and in the existing cases where we these macros were
used - but make it apply to the remaining cases of link register
on the stack.
2026-03-20 13:16:06 +02:00
Martin Storsjö dbf7354d98 aarch64/inter_sme2: Remove needless backup/restore of x29/x30
The sme_entry/sme_exit macros already take care of backing up/restoring
these registers. Additionally, as long as no function calls are
made within the function, x30 doesn't need to be backed up at all.
2026-03-20 13:16:06 +02:00
Peter Bennett 42029a8836 libavcodec/mediacodec: MythTV Fix for incorrect stride with amazon fire stick
With 1080i MPEG2 video, amazon fire stick uses a different stride from what
is returned.
2026-03-20 04:40:06 +00:00
Zhao Zhili 163b9b6c7e avformat/lcevc: return error when no valid NAL units are found
ff_lcvec_parse_config_record() returns success before this patch
when no IDR or NON_IDR NAL units are found.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-03-20 10:47:13 +08:00
Zhao Zhili eadce30402 avformat/lcevc: merge duplicate IDR and NON_IDR branches
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-03-20 10:45:31 +08:00
stevxiao 7b534c2bdc avfilter/dnn_backend_tf: fix ctx async field access
ctx->options.async does not exist on DnnContext; the correct
field is ctx->async directly on the context struct.

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-03-20 02:22:06 +00:00
James Almer 053822d9ce avformat/codecstring: add support for LCEVC streams
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-19 11:59:59 -03:00
James Almer cbfd280f77 avformat/lcevc: add a function to parse sequence and global config blocks
This exposes parsing already being done to write lvcC boxes, for the purpose
of having these values available elsewhere.
Will be useful for the following change.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-19 11:59:58 -03:00
Andreas Rheinhardt ba793127c4 avcodec/x86/mpeg4videodsp: Use SSE2 emulated_edge_mc
Possible now that this function is no longer MMX.

Old benchmarks:
gmc_edge_emulation_c:                                  782.3 ( 1.00x)
gmc_edge_emulation_ssse3:                              220.3 ( 3.55x)

New benchmarks:
gmc_edge_emulation_c:                                  770.9 ( 1.00x)
gmc_edge_emulation_ssse3:                              111.0 ( 6.94x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-19 14:44:40 +01:00
Andreas Rheinhardt b33d1d1ba2 avcodec/x86/mpeg4videodsp: Add gmc_ssse3
It beats MMX by a lot, because it has to process eight words.
Also notice that the MMX code expects registers to be preserved
between separate inline assembly blocks which is not guaranteed;
the new code meanwhile does not presume this.

Benchmarks:
gmc_c:                                                 817.8 ( 1.00x)
gmc_mmx:                                               210.7 ( 3.88x)
gmc_ssse3:                                              80.7 (10.14x)

The MMX version has been removed.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-19 14:44:37 +01:00
Andreas Rheinhardt e922923fd8 avcodec/x86/mpeg4videodsp: Use smaller edge_emu buffer
edge_emu_mc allows to use different src and dst strides,
so one can replace the outsized edge emu buffer with
one that is much smaller and nevertheless big enough
for all our needs; it also avoids having to check
whether the buffer is actually big enough.

This also improves performance (if the compiler uses
stack probing). Old benchmarks:
gmc_c:                                                 814.5 ( 1.00x)
gmc_mmx:                                               243.7 ( 3.34x)

New benchmarks:
gmc_c:                                                 813.8 ( 1.00x)
gmc_mmx:                                               213.5 ( 3.81x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-19 14:44:33 +01:00
Andreas Rheinhardt 338316f0a3 tests/checkasm: Add test for mpeg4videodsp
It already uncovered a bug in the MMX version of gmc.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-19 14:44:30 +01:00
Andreas Rheinhardt e33260809c avcodec/x86/mpeg4videodsp: Fix sprite_warping_accuracy 0-2
MPEG-4 GMC uses the following motion prediction scheme:
For output pixel (x,y), the reference pixel at fractional
coordinates (ox+dxx*x+dxy*y,oy+dyx*x+dyy*y) is used as prediction;
the latter is calculated via bilinear interpolation. The coefficients
here are fixed-point values with 16+shift fractional bits
where shift is sprite_warping_accuracy+1. For the weights,
only the shift most significant fractional bits are used.
shift can be at most four*.

The x86 MMX gmc implementation performs these calculations
using 16-bit words. To do so, it restricts itself to the case
in which the four least significant bits of dxx,dxy,dyx,dyy
are zero and shifts these bits away. Yet in case shift is
less than four, the 16 bits retained also contain at least
one bit that actually belongs to the fpel component
(which is already taken into account by using the correct
pixels for interpolation).

(This has been uncovered by a to-be-added checkasm test.
I don't know whether there are actual files in the wild
using sprite_warping_accuracy 0-2.)

*: It is always four when encoding with xvid and GMC.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-19 14:44:08 +01:00
James Almer 106616f13d avformat/mov: tighten sample count value in mov_read_sdtp
sc->sample_count and sc->sdtp_count are both unsigned ints.

Fixes Coverity issue CID 168634.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-18 20:34:33 -03:00
Niklas Haas 292056ec03 forgejo/pre-commit/ignored-words: add re-use
We allow both readd and re-add, so it makes sense to allow both reuse and
re-use. They are both listed in my dictionary.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 23:32:35 +00:00
Andreas Rheinhardt 30a811cc7d avcodec/rv34dsp: Reduce size of chroma pixels tabs
Only two sizes exist.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-18 18:05:20 +01:00
Andreas Rheinhardt 42ebefbd98 tests/checkasm/rv34dsp: Don't use unnecessarily large buffers
RV34 uses 4x4 blocks.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-18 18:05:06 +01:00
Andreas Rheinhardt c90cf2aa1f avcodec/x86/rv34dsp: Port ff_rv34_idct_dc_noround_mmxext to sse2
No change in benchmarks here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-18 18:04:44 +01:00
James Almer b50cbdc04f fftools/ffmpeg_demux: properly unnitialize the side_data_prefer_packet AVBprint buffer
Fixes Coverity issue CID 1689616.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-18 13:29:23 -03:00
James Almer e22a1ed712 avcodec/h2645_sei: don't use provider_code uninitialized
Regression since 8172be423e.
Fixes Coverity issue CID 1689618.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-18 13:25:08 -03:00
Zhao Zhili 9800032722 checkasm/aarch64: fix operator precedence bug in ARG_STACK
The expression ((8*(MAX_ARGS - 8) + 15) & ~15 + 16)
evaluates to zero on Apple platforms due to assembler operator
precedence differences. LLVM's integrated assembler uses different
precedence rules depending on the target:

unsigned AsmParser::getBinOpPrecedence(AsmToken::TokenKind K,
				   MCBinaryExpr::Opcode &Kind) {
    bool ShouldUseLogicalShr = MAI.shouldUseLogicalShr();
    return IsDarwin ? getDarwinBinOpPrecedence(K, Kind, ShouldUseLogicalShr)
	      : getGNUBinOpPrecedence(MAI, K, Kind, ShouldUseLogicalShr);
}

In Darwin mode (Apple targets), arithmetic operators (+, -) have
higher precedence than bitwise operators (&, |, ^), similar to C.
In GNU mode (ELF targets), bitwise operators have higher precedence
than arithmetic operators.
2026-03-18 13:48:18 +00:00
Niklas Haas 70537ec8e6 swscale/x86/ops: cosmetic
And remove a pointless assertion.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 09:09:44 +00:00
Niklas Haas a8606aba8e swscale/x86/ops: move over_read/write determination to setup func
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 09:09:44 +00:00
Niklas Haas 8e3eacd7ad swscale/ops_chain: allow implementations to expose over_read/write
And plumb it all the way through to the SwsCompiledOp. This is cleaner than
setting up this metadata up-front in x86/ops.c; and more importantly, it
allows us to determine the amount of over-read programmatically during ops
setup.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 09:09:44 +00:00
Niklas Haas 3aef0213e7 swscale/ops_chain: add SwsContext to SwsImplParams
Mainly so that implementations can consult sws->flags, to e.g. decide
whether the kernel needs to be bit-exact.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 09:09:44 +00:00
Niklas Haas 9c6638b179 swscale/ops_chain: add SwsOpTable to SwsImplParams
Mainly so setup functions can look at table->block_size, and perhaps
the table flags, as well as anything else we may add in the future.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 09:09:44 +00:00
Niklas Haas ef114cedef swscale/ops_chain: refactor setup() signature
This is basically a cosmetic commit that groups all of the parameters to
setup() into a single struct, as well as the return type. This gives the
immediate benefit of freeing up 8 bytes per op table entry, though the
main motivation will come in the following commits.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 09:09:44 +00:00
Niklas Haas 3310fe95ae swscale/ops_dispatch: also print ops list after optimizing
Will make more sense in light of the fact that this may not correspond
to the op list actually sent to the backends, due to subpass splitting.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 09:09:44 +00:00
Niklas Haas 039b492019 swscale/ops_dispatch: correctly round tail size
If the block size is somehow less than 8, this may round down, leading to
one byte too few being copied (e.g. for monow/rgb4).

This was never an issue for current backends because they all have block sizes
of 8 or larger, but a future platform may have different requirements.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 09:09:44 +00:00
Niklas Haas 800c3a71e9 swscale/ops_dispatch: properly handle negative strides
The `memcpy_in` condition is reversed for negative strides, which require a
memcpy() on the *first* line, not the last line. Additionally, the check
just completely didn't work for negative linesizes, due to comparing against
a negative stride.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 09:09:44 +00:00
Niklas Haas 91e76dc766 swscale/ops_dispatch: remove slice_align hack
Added in commit 00907e1244 to hack around a problem that was caused by
the Vulkan backend's incorrect use of the ops dispatch code, which was fixed
properly in commit 143cb56501.

This logic never made sense to begin with, it was only meant to disable the
memcpy logic for Vulkan specifically.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 09:09:44 +00:00
Niklas Haas 18962a3764 swscale/ops: loop over copied list instead of original (cosmetic)
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 09:09:44 +00:00
Niklas Haas 5230624619 swscale/graph: allocate output buffers after adding all passes
There's no reason to immediately allocate all of these; we can do it at the
end when we know for sure which passes we have.

This will matter especially if we ever add a way to remove passes again after
adding them (spoiler: we will).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-18 09:09:44 +00:00
Jun Zhao c51a420b59 doc/examples/hw_decode: check fopen return value for output file
The output file fopen() result is not checked. If it fails (e.g.
permission denied or invalid path), output_file is NULL and the
subsequent fwrite() call will crash.

Add a NULL check with an error message, consistent with the
existing error handling pattern in this example.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-18 02:08:09 +00:00
Jun Zhao c29206e456 doc/examples/transcode: query encoder for supported configs
avcodec_get_supported_config() is called with dec_ctx (the decoder
context) to query supported pixel formats and sample formats, but
the intent is to configure the encoder. The decoder supported
format list may differ from the encoder, leading to format
negotiation failures or incorrect output.

Pass enc_ctx instead so the actual encoder capabilities are
queried.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-18 02:08:09 +00:00
Jun Zhao d25d6b991d doc/examples/vaapi_encode: return raw error codes from encode_write
encode_write() mapped all return values from avcodec_receive_packet()
into 0 or -1, which destroyed the AVERROR_EOF signal needed by the
caller. The flush call in main() could never see AVERROR_EOF, so a
successful encode always exited with a non-zero status.

Let encode_write() return the original error code and have each
call site handle the expected status:

  - Encoding loop: ignore AVERROR(EAGAIN) (need more input)
  - Flush path:    ignore AVERROR_EOF (normal end-of-stream)

This makes the control flow explicit and easier to follow for
anyone reading the example.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-18 02:08:09 +00:00
Jun Zhao 8d80b13cbe doc/examples/remux: fix NULL pointer dereference in cleanup
The cleanup path uses `ofmt->flags` to check AVFMT_NOFILE, but
`ofmt` is only assigned after avformat_alloc_output_context2
succeeds. If a failure occurs between output context allocation
and the `ofmt` assignment (e.g. stream_mapping allocation fails),
ofmt_ctx is non-NULL while ofmt is still NULL, causing a crash.

Use ofmt_ctx->oformat->flags instead, which is always valid when
ofmt_ctx is non-NULL.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-18 02:08:09 +00:00
Jun Zhao 68e18d3a1c doc/examples/encode_audio: fix hardcoded stereo sample stride
The sample generation loop hardcodes a stride of 2 (stereo) with
samples[2*j], but the channel count is dynamically selected by
select_channel_layout() which picks the layout with the highest
channel count. If the encoder supports more than 2 channels,
samples will be written at wrong offsets.

Use c->ch_layout.nb_channels as the stride instead.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-18 02:08:09 +00:00
Jun Zhao 042ff80562 doc/examples/qsv_decode: fix raw frame dump for chroma planes
The output loop used sw_frame->width as the write size for all
planes. This is only correct for NV12 where the interleaved UV
plane happens to have the same byte width as the Y plane. For
other pixel formats (e.g. YUV420P where U/V planes are half
width, or P010 where samples are 2 bytes), the output would be
corrupted.

Use av_image_get_linesize() to compute the correct byte width
for each plane based on the actual pixel format.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-18 02:08:09 +00:00
Jun Zhao 2c47383d74 doc/examples/hw_decode: fix fwrite error check
fwrite() returns size_t (unsigned), so comparing its return value
with < 0 is always false and write errors are silently ignored.
Check against the expected byte count instead.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-18 02:08:09 +00:00
Jun Zhao 1cf02df122 doc/examples/decode_video: check fopen return value in pgm_save
pgm_save() passes the FILE pointer from fopen() directly to
fprintf() and fwrite() without a NULL check. If fopen() fails
(e.g. permission denied or disk full), this causes a NULL pointer
dereference and crash.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-18 02:08:09 +00:00
Jun Zhao 752faebaa6 doc/examples/vaapi_encode: open raw YUV input in binary mode
fopen() with "r" opens the file in text mode, which on Windows
translates \r\n to \n, corrupting raw NV12 pixel data. Use "rb"
to open in binary mode, matching the output file which already
uses "w+b".

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-18 02:08:09 +00:00
Jun Zhao 40f085ac3d doc/examples: fix output context cleanup in transcode examples
avformat_close_input() is designed for input format contexts only.
Using it on output contexts is API misuse — it accesses iformat
(which is NULL for output contexts) and does not follow the correct
output cleanup path.

Replace with the proper pattern already used in remux.c and
transcode.c: avio_closep() to close the IO handle, followed by
avformat_free_context() to free the format context.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-18 02:08:09 +00:00
Guangyu Sun 34bff02984 avcodec/libvpxenc: fix sRGB colorspace for non-RGB pixel formats
When encoding VP9 with a YUV pixel format (e.g. yuv420p) and
AVCOL_SPC_RGB colorspace metadata, libvpxenc unconditionally set
VPX_CS_SRGB. This produced a spec-violating bitstream: Profile 0
(4:2:0) with sRGB colorspace, which is only valid for Profile 1/3
(4:4:4). The resulting file is undecodable.

Fix this by setting ctx->vpx_cs to VPX_CS_SRGB in set_pix_fmt()
for 4:4:4 YUV formats when AVCOL_SPC_RGB is set, matching the
existing GBRP path. This covers the legitimate case of RGB data in
YUV444 containers (e.g. H.264 High 4:4:4 with identity matrix).

With this change, any AVCOL_SPC_RGB that reaches the switch in
set_colorspace() is guaranteed to be a subsampled format where
sRGB is invalid. Return an error so the user can fix their
pipeline rather than silently producing incorrect output.

To reproduce:

  ffmpeg -f lavfi -i testsrc=s=64x64:d=1:r=1 \
    -c:v libvpx-vp9 -pix_fmt yuv420p -colorspace rgb bad.webm
  ffprobe bad.webm
  # -> "vp9 (Profile 0), none(pc, gbr/...), 64x64"
  ffmpeg -i bad.webm -f null -
  # -> 0 frames decoded, error

See also:
  https://issues.webmproject.org/487307225

Signed-off-by: Guangyu Sun <gsun@roblox.com>
Signed-off-by: James Zern <jzern@google.com>
2026-03-17 13:39:59 -07:00
Martin Storsjö 846746be4b aarch64: Add Armv9.3-A GCS (Guarded Control Stack) support
Signal that our assembly is compliant with the GCS feature, if
the GCS feature is enabled in the compiler (available since Clang
18 and GCC 15) - this is enabled by -mbranch-protection=standard
with a new enough compiler.

GCS doesn't require any specific modifications to the assembly
code, but requires that all functions return to the expected call
address (checked through a shadow stack).
2026-03-17 20:37:53 +00:00
Martin Storsjö 1f7ed8a78d aarch64: hevcdsp: Make returns match the call site
For cases when returning early without updating any pixels, we
previously returned to return address in the caller's scope,
bypassing one function entirely. While this may seem like a neat
optimization, it makes the return stack predictor mispredict
the returns - which potentially can cost more performance than
it gains.

Secondly, if the armv9.3 feature GCS (Guarded Control Stack) is
enabled, then returns _must_ match the expected value; this feature
is being enabled across linux distributions, and by fixing the
hevc assembly, we can enable the security feature on ffmpeg as well.
2026-03-17 20:37:53 +00:00
Sun Yuechi 1c7b72cd6b lavc/riscv: remove unused fixed_vtype.S
Signed-off-by: Sun Yuechi <sunyuechi@iscas.ac.cn>
2026-03-17 16:40:05 +00:00
Huihui_Huang 6e37545d6b swscale: fix possible lut leak in adapt_colors()
adapt_colors() allocates a SwsLut3D before calling add_convert_pass(). If add_convert_pass() fails, the function returns without freeing the previously allocated lut. Free lut on that error path.

Signed-off-by: Huihui_Huang <hhhuang@smu.edu.sg>
2026-03-17 15:56:40 +08:00
Martin Storsjö ac4d50cb26 swscale/ops_chain: Make ff_op_priv_free clear the freed pointer 2026-03-16 20:31:12 +00:00
Martin Storsjö e07daf85a4 swscale/ops_chain: Don't pass an aligned union as parameter by value
Passing a struct/union by value can generally be inefficient.
Additionally, when the struct/union is declared to be aligned,
whether it really stays aligned when passed as a parameter by
value is unclear.

This fixes build errors like this, with MSVC targeting 32 bit ARM:

    libswscale/ops_chain.h(91): error C2719: 'unnamed-parameter': formal parameter with requested alignment of 16 won't be aligned
2026-03-16 20:31:12 +00:00
Diego de Souza 6ef0ef51dc avcodec/nvdec: fix surface pool limits and unsafe_output lifetime
Cap ulNumDecodeSurfaces to 32 and ulNumOutputSurfaces to 64 to prevent
cuvidCreateDecoder from failing with CUDA_ERROR_INVALID_VALUE when
initial_pool_size exceeds the hardware limits.

Also cap the decoder index pool (dpb_size) to 32 so that indices
handed out via av_refstruct_pool_get stay within the valid range
for cuvidDecodePicture's CurrPicIdx.

When unsafe_output is enabled, stop holding idx_ref in the unmap
callback. Since cuvidMapVideoFrame copies decoded data into an
independent output mapping slot, the decode surface index can safely
be reused as soon as the DPB releases it, without waiting for the
downstream consumer to release the mapped frame. This decouples the
decode surface index lifetime (max 32) from the output mapping slot
lifetime (max 64), eliminating the "No decoder surfaces left" error
that occurred when downstream components like nvenc held too many
frames.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-03-16 18:18:12 +00:00
Marvin Scholz cce545a74b avutil: attributes: fix AV_HAS_STD_ATTRIBUTE checks
Attributes with the language-supported [[attr]] style are only supported
since C++11 and C23 respectively, so this needs to be accounted for in
these checks.

This solves a huge amount of warning spam of:
  warning: [[]] attributes are a C23 extension [-Wc23-extensions]
when using --enable-extra-warnings.
2026-03-16 18:32:20 +01:00
Jun Zhao c49f6bec20 lavf/vvcdec: fix false-positive VVC detection of MP3 files
The VVC probe only checked forbidden_zero_bit but not
nuh_layer_id range in the NAL unit header. This allowed
certain MP3 files to be misdetected as VVC streams because
their frame data coincidentally contained 00 00 01 start
code patterns that looked like valid NAL units.

Add a check for nuh_layer_id (must be <= 55). The existing
check_temporal_id() already validates nuh_temporal_id_plus1
is in [1, 7]. Together these two checks reject the bogus
NAL units produced by MP3 frame data.

Note: nuh_reserved_zero_bit is intentionally not checked
here, as it is reserved for future use by the spec and may
become non-zero in a later revision.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-16 16:21:12 +00:00
Michael Niedermayer 4b83833087 avformat/wsddec: Use ffio_read_size() in get_metadata()
Fixes: use of uninitialized memory
Fixes: 492587173/clusterfuzz-testcase-minimized-ffmpeg_dem_WSD_fuzzer-6596163492184064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-16 15:51:53 +01:00
Nariman-Sayed b20f42b156 avformat/tls_openssl: fix DTLS retransmission when packet lost in blocking mode
OpenSSL DTLS can't retransmit lost packets in blocking mode.
Switch to non-blocking mode and use DTLSv1_handle_timeout()
to properly handle DTLS handshake retransmissions.
2026-03-16 14:49:36 +00:00
Philip Tang 261960392e avformat/whip: add timeout option for HTTP
WHIP can receive timeout option to allow dropping
connection attempts which would otherwise hang in the event that remote
server is not replying.
2026-03-16 14:46:13 +00:00
Zhao Zhili dbd783f389 avformat/lcevc: fix wrong NAL count written for NON IDR
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-03-16 13:26:52 +00:00
Zhao Zhili 82b39de805 avformat/lcevc: fix memleak on write_nalu() failure
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-03-16 13:26:52 +00:00
Zhao Zhili cc866fb5e9 avformat/movenc: fix loop variable shadowing in LCEVC stream group init
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-03-16 13:25:59 +00:00
Nicholas Carlini 3e8bec7871 avformat/mpegts: fix descriptor accounting across multiple IOD descriptors
pmt_cb() passes mp4_descr + mp4_descr_count as the output base but
MAX_MP4_DESCR_COUNT (16) as the capacity, not the remaining capacity.
init_MP4DescrParseContext() resets d->descr_count to 0 on every call,
so the bounds check at parse_MP4ESDescrTag compares a fresh 0 against
16 regardless of the shifted base.

A PMT with two IOD descriptors of 16 ESDescrs each will crash. The first
fills the buffer mp4_descr[0..15], and then the second writes
mp4_descr[16..31] -- 1152 bytes past the end of the stack.

This change passes the remaining capacity instead of always passing 16.
The writeback in mp4_read_iods is incremented so the caller's running
count is preserved.

Fixes: stack-buffer-overflow

Found-by: Nicholas Carlini <nicholas@carlini.com>
2026-03-16 11:51:27 +00:00
Anton Khirnov 5b112b17c0 opus/dec_celt: avoid emph_coeff becoming a subnormal
This happens for silence frames, which on many CPUs massively slows down
processing the decoded output.

Cf. https://github.com/Genymobile/scrcpy/issues/6715
2026-03-16 11:51:49 +01:00
Weidong Wang 236dbc9f82 avcodec/xxan: zero-initialize y_buffer
Fixes ticket #22420.

When the first decoded frame is type 1, xan_decode_frame_type1() reads y_buffer as prior-frame state before any data has been written to it.
Since y_buffer is allocated with av_malloc(), this may propagate uninitialized heap data into the decoded luma output.

Allocate y_buffer with av_mallocz() instead.
2026-03-16 10:24:33 +00:00
James Almer 6ba0b59d8b avcodec/bytestream2: don't allow using NULL pointers
This is UB.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-15 19:27:07 -03:00
James Almer 2556db6173 avcodec/bsf/extract_extradata: don't use a NULL pointer to initialize an empty PutByteContext
Fixes UB in the form or adding a 0 offset to a NULL pointer, and substracting a
NULL pointer from another.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-15 19:27:07 -03:00
James Almer 5ebd50415f avcodec/bsf/extract_extradata: reallocate buffers with the final used size
The buffers are allocated using the worst case scenario of the entire NALU
being written, when this is in many times not the case.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-15 19:27:01 -03:00
James Almer 1434d99b19 avcodec/bsf/extract_extradata: write correct length start codes for LCEVC
The specification for LCEVC states that start codes may be three or four bytes
long except for the first NALU in an AU, which must be four bytes long.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-15 19:20:06 -03:00
James Almer d1431d3f50 avcodec/bsf/extract_extradata: write correct length start codes for h26x
The specification for H.26{4,5,6} states that start codes may be three or four
bytes long long except for the first NALU in an AU, and for NALUs of parameter
set types, which must be four bytes long.
This is checked by ff_cbs_h2645_unit_requires_zero_byte(), which is made
available outside of CBS for this change.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-15 19:20:06 -03:00
James Almer 6bc257e292 avformat/nal: remove trailing zeroes from NALUs
Based on the behaviour from cbs_h2645, which removes actual
trailing_zero_8bits bytes and possibly also work arounds issues in
ff_h2645_extract_rbsp(). In this case, the same issue could be
present in ff_nal_find_startcode().

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-15 19:20:06 -03:00
James Almer 1d65e985b3 fftools/ffmpeg_demux: add options to override mastering display and content light level metadata
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-15 17:52:05 -03:00
James Almer 8172be423e avcodec/h2645_sei: fix parsing payloads for UK country_code
The correct syntax after country_code is:

t35_uk_country_code_second_octet      b(8)
t35_uk_manufacturer_code_first_octet  b(8)
t35_uk_manufacturer_code_second_octet b(8)

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-15 17:25:12 -03:00
James Almer 3af824a540 avcodec/h2645_sei: reindent after the previous change
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-15 17:25:12 -03:00
James Almer 64edbb37f1 avcodec/h2645_sei: refactor decode_registered_user_data()
Switch statements are cleaner and will be useful for an upcoming change.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-15 17:25:12 -03:00
WyattBlue 482395f830 avfilter/af_whisper: Add translate parameter 2026-03-15 06:53:19 +00:00
James Almer 539fc854e7 fftools/ffmpeg_mux_init: add support for LCEVC Stream Group muxing
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-14 20:50:27 -03:00
James Almer 9f9db1f673 avformat/options: add missing AVOption for AVStreamGroupLCEVC
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-14 20:50:27 -03:00
James Almer 0878ae59f9 avformat/movenc: add support for LCEVC track muxing
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-14 20:50:21 -03:00
James Almer 77ddfcfeb1 Changelog: move an entry wrongly put in the 8.1 section to next
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-14 20:43:11 -03:00
Michael Niedermayer 70286d59f1 avcodec/exr: Check input space before reverse_lut()
Fixes: use of uninitialized memory
Fixes: 490707906/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_DEC_fuzzer-6310933506097152

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-14 23:24:11 +01:00
Pierre-Anthony Lemieux dfc5d176c9 fuzzer: improve documentation 2026-03-14 21:36:58 +00:00
Nicholas Carlini 55bf0e6cd5 avformat/mpegts: remove JPEG-XS early return on invalid header_size
new_pes_packet() moves a buffer with pkt->buf = pes->buffer before
JPEG-XS validation. If header_size > pkt->size, an early return leaves
pes->buffer as a stale alias of pkt->buf with refcount 1. Later,
mpegts_read_packet() calls av_packet_unref(), freeing the buffer
through pkt->buf. The flush loop then re-enters new_pes_packet() and
dereferences the dangling pes->buffer; a second path hits it via
av_buffer_unref() in handle_packets() after a seek.

Drop the early return. The packet is delivered with AV_PKT_FLAG_CORRUPT
set, matching the PES-size-mismatch case above, and the function falls
through to the normal cleanup path. The else guards the header trim so
pkt->data/pkt->size stay valid for the memset.

Fixes: use after free
Fixes regression since 16f89d342e.

Found-by: Nicholas Carlini <nicholas@carlini.com>
2026-03-14 21:01:41 +00:00
Michael Niedermayer 770bc1c23a avcodec/aac/aacdec_usac_mps212: Introduce a temporary array for ff_aac_ec_data_dec()
This also reverts: c2364e9222

Fixes: out of array access (testcase exists but did not replicate for me)

Founbd-by: Gil Portnoy <dddhkts1@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-14 21:23:53 +01:00
Michael Niedermayer 12303cd922 avcodec/cbs_h266_syntax_template: Check tile_y
Fixes: invalid state leading to out of array access
Fixes: 490615782/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-4711353817563136

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-14 21:23:17 +01:00
Andreas Rheinhardt e33573813d avcodec/x86/apv_dsp: Don't clip unnecessarily
It is redundant due to packusdw.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-14 19:31:45 +01:00
Andreas Rheinhardt 691f9cd428 avcodec/apv_dsp: Reindent after previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-14 19:31:45 +01:00
Andreas Rheinhardt 59b119023f avcodec/apv_dsp: Remove dead 8 bit code
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-14 19:31:45 +01:00
Andreas Rheinhardt 506ea84c1c avcodec/apv_decode: Don't rely on AV_PIX_FMT_YUV420 == 0
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-14 19:31:44 +01:00
Andreas Rheinhardt 99339f7b2b avcodec/apv_decode: Remove unused array entries
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-14 19:31:44 +01:00
Andreas Rheinhardt 6b5b0d6a50 avcodec/apv_decode: Remove always-false branches
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-14 19:31:44 +01:00
Andreas Rheinhardt 4300931e23 avcodec/apv_decode: Fix pixel format selection
The current code just happens to work for 10 and 12.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-14 19:31:44 +01:00
Lynne c102e89448 hwcontext_vulkan: deprecate AVVulkanDeviceContext.lock/unlock_queue
Without replacement, as VK_KHR_internally_synchronized_queues will be required.
2026-03-14 17:05:06 +00:00
Nicholas Carlini 39e1969303 avcodec/h264_slice: reject slice_num >= 0xFFFF
An H.264 picture with 65536 slices makes slice_num collide with the
slice_table sentinel. slice_table is uint16_t, initialized via
memset(..., -1, ...) so spare entries (one per row, mb_stride =
mb_width + 1) stay 0xFFFF. slice_num is an uncapped ++h->current_slice.
At slice 65535 the collision makes slice_table[spare] == slice_num
pass, defeating the deblock_topleft check in xchg_mb_border and the
top_type zeroing in fill_decode_caches.

With both guards bypassed at mb_x = 0, top_borders[top_idx][-1]
underflows 96 bytes and XCHG writes at -88 below the allocation
(plus -72 and -56 for chroma in the non-444 path).

Fixes: heap-buffer-overflow

Found-by: Nicholas Carlini <nicholas@carlini.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-14 16:52:58 +00:00
Jun Zhao 795bccdaf5 lavfi/bwdif: fix heap-buffer-overflow with small height videos
Reproduce:
  ffmpeg -i /tmp/bwdif_test_input_160x4_gray16.jpg -vf "bwdif" -f null -

filter_intra accesses rows 3 lines away via cur[mrefs3] and cur[prefs3].
For small height videos (h <= 4), this causes heap-buffer-overflow.

Add boundary check for filter_intra when YADIF_FIELD_END is set.
The boundary condition (y < 3) or (y + 3 >= td->h) precisely matches
filter_intra's 3-line context requirement.

Test file: 160x4 gray16 JPEG
https://code.ffmpeg.org/attachments/db2ace24-bc00-4af6-a53a-5df6b0d51b15

fix #21570

Reviewed-by: Thomas Mundt <tmundt75@gmail.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-14 23:26:51 +08:00
Zhao Zhili 9a1e9f9368 MAINTAINERS: add myself to maintained modules and update CODEOWNERS 2026-03-14 15:18:22 +00:00
Ramiro Polla 5640bd3a4f swscale/tests/swscale: require reference file to perform comparisons
The legacy scaler is no longer implicitly used to generate a reference
to perform comparisons for every conversion. It is now up to the user
to generate a reference file and use it as input for a separate run to
perform comparisons.

It is now possible to compare against previous runs of the graph-based
scaler, for example to test for newer optimizations.

This reduces the overall time necessary to obtain speedup numbers from
the legacy scaler to the graph-based scaler (or any other comparison,
for that matter) since the reference must only be run once.

For example, to check the speedup between the legacy scaler and the
graph-based scaler:
  ./libswscale/tests/swscale [...] -bench 50 -legacy 1 > legacy_ref.txt
  ./libswscale/tests/swscale [...] -bench 50 -ref legacy_ref.txt

If no -ref file is specified, we are assuming that we are generating a
reference file, and therefore all information is printed (including
ssim/loss, and benchmarks if -bench is used).

If a -ref file is specified, the output printed depends on whether we
are testing for correctness (ssim/loss only) or benchmarking (time/
speedup only, along with overall speedup).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 5146519131 swscale/tests/swscale: add -pretty option to align fields in output
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla d1779ece67 swscale/tests/swscale: print number of iterations in benchmark output
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 1568cae66f swscale/tests/swscale: some tweaks to the output format
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 6ed173f238 swscale/tests/swscale: always print loss in output
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 822d592575 swscale/tests/swscale: make loss printing code more consistent
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 1980d8ba8a swscale/tests/swscale: remove duplicate printing of parameters on error
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla b03ff92567 swscale/tests/swscale: print losses using scientific notation
This emphasizes the order of magnitude of the loss, which is what is
important for us.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 739d9eca59 swscale/tests/swscale: be more strict with reference file format
The format of the reference file is the output which is printed to
stdout from this tool itself.

Malformed reference files cause an error, with a more descriptive error
message. Running a subset of the reference conversions is still
supported through -src and/or -dst.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 041b6f330f swscale/tests/swscale: indent after previous commit
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 6780353460 swscale/tests/swscale: restore reference file functionality
The test results (along with SSIM) are printed to stdout again so that
the output can be parsed by -ref.

Benchmark results have also been added to the output.

We still need to re-run the reference tests to perform benchmarks, but
this will be simplified in the next few commits.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 0b427ea47e swscale/tests/swscale: reorder test results output
The conversion parameters, ssim/loss, and benchmark results will
eventually be merged into the same output line.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 58cdd89789 swscale/tests/swscale: allow passing -bench 0 to disable benchmarks
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 101a2f6fc6 swscale/tests/swscale: add option to run main conversion with legacy scaler
The low bit depth workaround code is duplicated in this commit, but the
other occurrence will be removed in a few commits, so I see no reason
to factor it out.

The legacy scaler still has some conversions that give results much
worse than the expected loss, but we still want them as reference, so
we don't trigger expected loss errors on conversions with the legacy
scaler.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 3eb178a197 swscale/tests/swscale: split scale_new() out of run_test()
We will eventually be able to select between running the new graph-based
scaler or the legacy scaler.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla c27df6ccc9 swscale/tests/swscale: add helper function to log sws_scale_frame() failures
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla c6d78efa9b swscale/tests/swscale: split init_frame() out of run_test()
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 7e635337cf swscale/tests/swscale: introduce struct test_results to collect results
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 8d35328e54 swscale/tests/swscale: split print_results() out of run_test()
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 2b0e1920e5 swscale/tests/swscale: propagate error out of run_test()
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Ramiro Polla 2222b523f2 swscale/tests/swscale: cosmetics (avoid assignments in conditions) 2026-03-14 06:13:19 +00:00
Ramiro Polla 713979919d Revert "tests/swscale: check supported inputs for legacy swscale separately"
Support for input and output formats are already checked in run_self_tests().

This reverts commit a22faeb992.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-14 06:13:19 +00:00
Niklas Haas 80e48f2e78 swscale/tests/swscale: fix typos 2026-03-14 06:13:19 +00:00
Michael Niedermayer f73849887c avcodec/wmv2dec: More Checks about reading skip bits
Fixes: out of array read with --disable-safe-bitstream-reader
Fixes: poc_wmv2.avi

Note, this requires the safe bitstream reader to be turned off by the user and the user disregarding the security warning

Change suggested by: Guanni Qu <qguanni@gmail.com>
Found-by: Guanni Qu <qguanni@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 23:22:54 +01:00
Gil Portnoy 26dd9f9b56 avcodec/cbs_h266_syntax_template: Fix w/h typo
Fixes: out of array access
Fixes: vvc_poc_subpic_wh_bug.h266

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 23:21:31 +01:00
Gil Portnoy e1d9080e6a avcodec/aac/aacdec_usac_mps212: Fix wrong end_band parameter to coarse_to_fine()
note, all call sites set start_band=0, this is thus a cosmetic fix

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 23:03:36 +01:00
Gil Portnoy d75b7c2252 avcodec/aac/aacdec_usac_mps212: Fix typo in huff_data_2d()
This is not a security issue

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 23:03:36 +01:00
Gil Portnoy 8b9851b005 avcodec/aac/aacdec_usac_mps212: Off-by-one bounds check in ff_aac_ec_data_deci()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

No testcase, the check seems redundant
2026-03-13 23:03:35 +01:00
Oliver Chang d519ab8993 aacdec_usac: skip FD-specific decoding for LPD channels
`spectrum_decode` currently executes Frequency Domain (FD) decoding steps
for all channels, regardless of their `core_mode`. When a channel is in
Linear Prediction Domain (LPD) mode (`core_mode == 1`), FD-specific
parameters such as scalefactor offsets (`sfo`) and individual channel
stream (`ics`) information are not parsed.

This causes a global-buffer-overflow in `dequant_scalefactors`. Because
`spectrum_scale` is called on LPD channels, it uses stale or
uninitialized `sfo` values to index `ff_aac_pow2sf_tab`. In the reported
crash, a stale `sfo` value of 240 resulted in an index of 440
(240 + POW_SF2_ZERO), exceeding the table's size of 428.

Fix this by ensuring `spectrum_scale` and `imdct_and_windowing` are only
called for channels where `core_mode == 0` (FD).

Co-authored-by: CodeMender <codemender-patching@google.com>
Fixes: https://issues.oss-fuzz.com/486160985
2026-03-13 22:57:25 +01:00
Michael Niedermayer c5d5fb2309 avformat/dhav: Fix handling or slightly larger files
Fixes: integer overflow
Fixes: 490241718/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-4902512932225024

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 22:48:55 +01:00
Michael Niedermayer eb5d607861 avutil/timecode: Check for integer overflow in av_timecode_init_from_components()
Fixes: integer overflow
Fixes: testcase that calls av_timecode_init_from_components() with hh set explicitly to INT_MAX

Found-by: Youngjae Choi, Mingyoung Ban, Seunghoon Woo
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 22:48:32 +01:00
Jun Zhao 254b92ec8a lavc/hevc: reorder aarch64 NEON pel function assignments
Group assignments by filter family (qpel, epel), variant
(base, uni, bi, uni_w, bi_w) and direction (pixels, h, v, hv).
Add NEON8_FNASSIGN_QPEL_H macro to replace repeated manual
qpel horizontal assignments.

No functional change.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-13 21:43:37 +00:00
Jun Zhao 489d36b5e1 lavc/hevc: add aarch64 NEON for epel uni horizontal filter
Add NEON-optimized implementations for HEVC EPEL uni-directional
horizontal interpolation (put_hevc_epel_uni_h) at 8-bit depth.

These functions perform horizontal 4-tap EPEL filtering with
output directly to uint8_t pixels (no weighting):
- 4-tap horizontal EPEL filter
- Output: (filter_result + 32) >> 6, clipped to [0, 255]

Supports all block widths: 4, 6, 8, 12, 16, 24, 32, 48, 64.

Performance results on Apple M4:
./tests/checkasm/checkasm --test=hevc_pel --bench

put_hevc_epel_uni_h4_8_neon:   2.26x
put_hevc_epel_uni_h6_8_neon:   2.71x
put_hevc_epel_uni_h8_8_neon:   4.40x
put_hevc_epel_uni_h12_8_neon:  3.60x
put_hevc_epel_uni_h16_8_neon:  3.00x
put_hevc_epel_uni_h24_8_neon:  3.72x
put_hevc_epel_uni_h32_8_neon:  3.14x
put_hevc_epel_uni_h48_8_neon:  3.16x
put_hevc_epel_uni_h64_8_neon:  3.15x

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-13 21:43:37 +00:00
Jun Zhao f5e6cca935 lavc/hevc: add aarch64 NEON for qpel uni-weighted HV filter
Add NEON-optimized implementations for HEVC QPEL uni-directional
weighted HV interpolation (put_hevc_qpel_uni_w_hv) at 8-bit depth,
for block widths 6, 12, 24, and 48.

These functions perform horizontal then vertical 8-tap QPEL filtering
with weighting (wx, ox, denom) and output to uint8_t. Previously
only widths 4, 8, 16, 32, 64 were implemented; this completes
coverage for all standard HEVC block widths.

Performance results on Apple M4:
./tests/checkasm/checkasm --test=hevc_pel --bench

put_hevc_qpel_uni_w_hv6_8_neon:   3.11x
put_hevc_qpel_uni_w_hv12_8_neon:  3.19x
put_hevc_qpel_uni_w_hv24_8_neon:  2.26x
put_hevc_qpel_uni_w_hv48_8_neon:  1.80x

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-13 21:43:37 +00:00
Jun Zhao fe41ff7413 lavc/hevc: add aarch64 NEON for qpel uni-weighted vertical filter
Add NEON-optimized implementations for HEVC QPEL uni-weighted
vertical interpolation (put_hevc_qpel_uni_w_v) at 8-bit depth.

These functions perform weighted uni-directional prediction with
vertical QPEL filtering:
- 8-tap vertical QPEL filter
- Weighted prediction: (filter_result * wx + offset) >> shift

Previously only sizes 4, 8, 16, 64 were optimized. This patch adds
optimized implementations for all remaining sizes: 6, 12, 24, 32, 48.

Performance results on Apple M4:
./tests/checkasm/checkasm --test=hevc_pel --bench

put_hevc_qpel_uni_w_v6_8_neon:   3.40x
put_hevc_qpel_uni_w_v12_8_neon:  3.24x
put_hevc_qpel_uni_w_v24_8_neon:  3.06x
put_hevc_qpel_uni_w_v32_8_neon:  2.66x
put_hevc_qpel_uni_w_v48_8_neon:  2.67x

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-13 21:43:37 +00:00
Jun Zhao 32df0352b7 lavc/hevc: move subs earlier in qpel uni-weighted NEON loops
Move the subs instruction before the store macro in the 8x-unrolled
loops of qpel_uni_w_v4/v8/v16/v64 and qpel_uni_w_hv4/hv8/hv16, so
that many NEON instructions from the store macro separate it from the
conditional branch. This gives the CPU pipeline time to resolve the
condition flags before the branch decision.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-13 21:43:37 +00:00
Linke e44d76f61f avformat/av1: fix uvlc loop past end of bitstream
When get_bits_left() returns a negative value (bitstream reader already past the end of the buffer), the while condition while (get_bits_left(gb)) evaluates to true since any non-zero int is truthy.

With the safe bitstream reader enabled, get_bits1() returns 0 past the buffer end, so the break never triggers and leading_zeros increments toward INT_MAX.

Change the condition to > 0, consistent with skip_1stop_8data_bits() which already uses <= 0 for the same pattern.

Signed-off-by: Linke <1102336121@qq.com>
2026-03-13 21:29:14 +00:00
Gil Portnoy 51606de0e9 avcodec/cbs_h266_syntax_template: Fix rows vs columns
Fixes: out of array access
Fixes: vvc_poc_cbs_divergence_max.h266

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 21:59:22 +01:00
Ted Meyer 86f53f9ffb avformat/mov: do not allocate out-of-range buffers
There's a possibility here with a well-crafted MP4 file containing only
the nested boxes in order: MOOV.TRAK.MDIA.MINF.STBL.SDTP where the
header size uses the 64 bit large size, and the ending stdp box has some
size value >= 0x100000014.

On a 32 bit build of ffmpeg, av_malloc's size parameter drops the high
order bits of `entries`, and and the allocation is now a controlled size
that is significantly smaller than `entries`. The following loop will
then write off the ended of allocated memory with data that follows the
box fourcc.
2026-03-13 21:53:12 +01:00
Karl Mogensen fa281d1394 avfilter/af_lv2: call lilv_instance_activate before lilv_instance_run
Why: the change is done to comply with lilv expectations of hosts.

Added call lilv_instance_activate in the config_output function to abide by lilv documentation that states it must be called before lilv_instance_run:
"This MUST be called before calling lilv_instance_run()" - documentation source (https://github.com/lv2/lilv/blob/main/include/lilv/lilv.h)

Added call lilv_instance_deactivate in the uninit function to abide by lv2 documentation:
"If a host calls activate(), it MUST call deactivate() at some point in the future" - documentation source (https://gitlab.com/lv2/lv2/-/blob/main/include/lv2/core/lv2.h)

Added instance_activated integer to LV2Context struct to track if instance was activated and only do lilv_instance_deactivate if was activated to abide by lv2 documentation:
"Hosts MUST NOT call deactivate() unless activate() was previously called." - documentation source (https://gitlab.com/lv2/lv2/-/blob/main/include/lv2/core/lv2.h)

Regarding the patcheck warning (possibly constant :instance_activated):
This is a false positive since the struct member is zero-initialized.

Fixes: trac issue #11661 (https://trac.ffmpeg.org/ticket/11661)
Reported-by: Dave Flater
Signed-off-by: Karl Mogensen <karlmogensen0@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 21:31:54 +01:00
Andreas Rheinhardt b3996ee578 avcodec/lcevctab: Use smaller types
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-13 16:09:40 +00:00
Andreas Rheinhardt 464f440773 avcodec/lcevctab: Properly deduplicate ff_lcevc_resolution_type
(Currently lcevctab.o does not export anything.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-13 16:09:40 +00:00
Andreas Rheinhardt 1b70aab908 configure: Add lcevc->cbs_lcevc dependency
Forgotten in 49d75d81f6.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-13 16:09:40 +00:00
James Almer aa70cd0d19 avfilter/vf_vpp_amf: look for HDR metadata in link side data
This is the correct way to use and propagate this kind of metadata.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-13 12:52:57 -03:00
James Almer 49d75d81f6 avcodec/lcevcdec: don't try to derive final dimensions from SAR
Not only do some sources not provide an aspect ratio, as is the case of
MPEG-TS, but also some enhanced streams have no change in dimensions, and this
heuristic would generate bugus values.
Instead, we need to parse the LCEVC bitstream for a Global Config process block
in order to get the actual dimensions. This add a little overhead, but it can't
be avoided.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-13 09:18:42 -03:00
James Almer c5aa31d252 avcodec/lcevc_parser: move the resolution type table to a header
Will be useful in the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-13 09:18:42 -03:00
James Almer ce7375fc17 avcodec/cbs_lcevc: don't look for process blocks if the unit was not decomposed
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-13 09:18:42 -03:00
Zhao Zhili f189657ec6 avformat/rtmpproto: fix listen_timeout conversion for special negative values
rtmpproto converts listen_timeout to milliseconds by multiplying it
by 1000 before passing it to TCP. However, negative values are special
sentinels (e.g., -1 for infinite wait) and should not be multiplied.

This worked prior to commit 49c6e6cc44 because there was no range
validation. Since that commit, ff_parse_opts_from_query_string
validates option values against their declared ranges, causing these
multiplied negative values to fail.

Fixes ticket #22469.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-03-13 11:38:39 +00:00
Michael Niedermayer b4b569f922 avcodec/aom_film_grain: Remove impossible check
fgp is freshly allocated so it cannot be equal to ref

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 04:39:52 +01:00
Michael Niedermayer ebb6ac1bc7 avcodec/aom_film_grain: avoid duplicate indexes in ff_aom_parse_film_grain_sets()
Fixes: use after free
Fixes: 478301106/clusterfuzz-testcase-minimized-ffmpeg_dem_HEVC_fuzzer-6155792247226368

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 04:39:52 +01:00
Michael Niedermayer 4ccad70d57 avformat/hxvs: Do not allow backward steps in hxvs_probe()
Fixes: infinite loop
Fixes: 487632033/clusterfuzz-testcase-minimized-ffmpeg_dem_IMAGE2_fuzzer-4565877872984064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 04:39:35 +01:00
Michael Niedermayer f84c859ec5 avcodec/bsf/extract_extradata: Replace incorrect size accounting
Fixes: out of array writes
Fixes: 492054712/clusterfuzz-testcase-minimized-ffmpeg_BSF_EXTRACT_EXTRADATA_fuzzer-5705993148497920

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 02:03:59 +00:00
Michael Niedermayer 3b98e29da8 swscale/output: fix integer overflows in chroma in yuv2rgba64_X_c_template()
Fixes: signed integer overflow: 130489 * 16525 cannot be represented in type 'int'
Fixes: 488950053/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-4627272670969856

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 02:51:19 +01:00
Michael Niedermayer 7241b80422 avcodec/lcldec: Fixes uqvq overflow
Fixes: integer overflow
Fixes: 490241717/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZLIB_DEC_fuzzer-4560518961758208

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 02:49:59 +01:00
Olivier Laflamme 10d36e5d3d fftools/ffprobe: Initialize data_dump_format_id
This was used uninitialized previously

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 01:19:39 +00:00
Niklas Haas 86eb07154d doc/scaler: document new sws scaler flags
And label the old ones as deprecated.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 22:09:13 +01:00
Niklas Haas 803ac77187 swscale: mark scale-related SwsFlags as deprecated
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 22:09:13 +01:00
Niklas Haas 3503b19711 swscale: add enum SwsScaler, SwsContext.scaler to replace legacy flags
Another step towards a cleaner API, with a cleaner separation of purposes.
Also avoids wasting a whopping one third of the flag space on what really
shouldn't have been a flag to begin with.

I pre-emptively decided to separate the scaler selection between "scaler"
and "scaler_sub", the latter defining what's used for things like 4:2:0
subsampling.

This allows us to get rid of the awkwardly defined SWS_BICUBLIN flag, in favor
of that just being the natural consequence of using a different scaler_sub.

Lastly, I also decided to pre-emptively axe the poorly defined and
questionable SWS_X scaler, which I doubt ever saw much use. The old flag
is still available as a deprecated flag, anyhow.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 22:09:04 +01:00
Niklas Haas a1b8cbb8bc swscale/utils: separate luma and chroma scaler selection
Pre-requisite for adding support for configuring these independently.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 22:08:07 +01:00
Niklas Haas 36c31fd5ba swscale: don't hard code number of scaler params
In case we ever need to increase this number in the future.
I won't bother bumping the ABI version for this new #define, since it doesn't
affect ABI, and I'm about to bump the ABI version in a following commit.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 22:08:07 +01:00
Niklas Haas 8115a05aa5 swscale: fix SWS_SPLINE documentation
This was incorrectly inferred to be a Keys spline when the documentation
was first added; but it's actually an "unwindowed" (in theory) natural
cubic spline with C2 continuity everywhere, which is a completely different
thing.

(SWS_BICUBIC is closer to being a Keys spline)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 22:08:07 +01:00
Niklas Haas 55dd4a18bb tests/checkasm/sw_ops: declare temporary arrays static
These are quite large; GCC on my end warns about big stack allocations.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 21:02:48 +00:00
Niklas Haas baac4a1174 swscale/x86/ops: add section comments (cosmetic)
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 21:02:48 +00:00
Niklas Haas 7fb1e0832c swscale/ops_dispatch: move ENOTSUP error to ff_sws_compile_pass()
Or else this might false-positive when we retry compilation after subpass
splitting.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 21:02:48 +00:00
Niklas Haas e7c84a8e6a swscale/ops_dispatch: infer destination format from SwsOpList
This is now redundant.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 21:02:48 +00:00
Niklas Haas b5db7c7354 swscale/ops_dispatch: have ff_sws_compile_pass() take ownership of ops
More useful than just allowing it to "modify" the ops; in practice this means
the contents will be undefined anyways - might as well have this function
take care of freeing it afterwards as well.

Will make things simpler with regards to subpass splitting.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 21:02:48 +00:00
Niklas Haas adf2d4e90f swscale/ops_dispatch: add helper function to clean up SwsCompiledOp
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 21:02:48 +00:00
Niklas Haas 8227a21c27 swscale/ops_optimizer: always clear unused dither components
Makes the op list a bit more stable.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 21:02:48 +00:00
Niklas Haas 563cc8216b swscale/graph: allow setup() to return an error code
Useful for a handful of reasons, including Vulkan (which depends on external
device resources), but also a change I want to make to the tail handling.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 21:02:48 +00:00
Niklas Haas 6c92ab6a4e swscale/graph: remove redundant check
Such formats are already rejected by ff_sws_decode/encode_pixfmt().

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 21:02:48 +00:00
Niklas Haas 4e63dbeb6d swscale/ops_chain: add more integer types to SwsOpPriv
In particular, I need i32, but the others are also reasonable additions.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 21:02:48 +00:00
Niklas Haas f535212a2c swscale/ops_chain: allow free callback to take SwsOpPriv
I mainly want to be able to store two pointers side-by-side.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 21:02:48 +00:00
Niklas Haas 66f3a62b46 swscale/ops_backend: use in/out_bump[] in process()
Instead of recomputing the input/output address on each iteration, we
can use the in_bump/out_bump arrays the way the x86 backend does.

I initially avoided this in order to ensure the reference backend always does
the correct thing, even if some future bug causes the bump values to be
computed incorrectly, but doing it this way makes an upcoming change easier.

(And besides, it would be easier to just add an av_assert2() to catch those
cases)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-12 21:02:48 +00:00
James Almer 927c81b569 avutil/version: bump after recent additions
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-12 17:18:00 -03:00
Andreas Rheinhardt 835781af23 configure,swscale/x86/Makefile: Remove special red-zone handling
ff_h[yc]scale_fast_mmxext() call other functions from inline assembly;
these functions look like leaf functions to GCC, so it may use the
red zone to avoid modifying the stack. But this makes the call
instructions in the inline asm corrupt the stack.

In order to fix this 424bcc46b5
made libswscale/x86/swscale_mmx.o be compiled with -mno-red-zone.
Later Libav fixed it in their version in commit
b14fa5572c by saving and restoring
the memory clobbered by the call (as is still done now). This was
merged into FFmpeg in 0e7fc3cafe,
without touching the -mno-red-zone hack.

Libav later renamed swscale_mmx.c to just swscale.c in
16d2a1a51c which was merged into FFmpeg
in commit 2cb4d51654, without
removing the -mno-red-zone hack, although the file it applies to
no longer existed.

This commit removes the special red-zone handling given that it is
inactive anyway.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-12 18:26:45 +01:00
Andreas Rheinhardt 9bbe1ec86f avutil/opt: Remove obsolete LIBAVUTIL_VERSION_MAJOR checks
Removing them has been forgotten during the lavu 59->60 bump.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-12 18:26:42 +01:00
Romain Beauxis 87bf42899b Add myself as maintainer to the various ogg files. 2026-03-12 15:22:56 +00:00
Nicolas Gaullier fbb3c99032 fate/gapless: remove duplicate ffprobe dependencies
Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-03-12 13:54:35 +00:00
Nicolas Gaullier 2cf8d64f3c fate/probe: simplify for consistency
Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-03-12 13:54:35 +00:00
Nicolas Gaullier db336e1c51 fate/scale2ref_keep_aspect: fix dependency
Regression since 5b5e692da6.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-03-12 13:54:35 +00:00
Ramiro Polla 72167e5150 avcodec/mjpegdec: deprecate extern_huff option 2026-03-12 14:47:01 +01:00
Nicolas Gaullier afcde6551c avformat/mov: fix skip_samples when sample_rate and time_base do not match
Fixes #21076.
2026-03-12 12:42:06 +00:00
Nicolas Gaullier b66c314c4b fftools/ffprobe: keep decoder buffers unflushed for show_streams()
When a decoder buffer is flushed, parts of the private context is reset,
which may affect show_streams().

Example:
ffprobe -of flat fate-suite/ac3/mp3ac325-4864-small.ts \
    -analyze_frames -show_entries stream=ltrt_cmixlev
Before: ltrt_cmixlev="0.000000"
After:  ltrt_cmixlev="0.707107"

Currently, it seems that only ac3 downmix info is concerned.
(ac3 downmix options are exported since 376bb8481a).

Fix regression since 045a8b15b1.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-03-12 12:18:58 +00:00
Nicolas Gaullier 8a0ae6b344 fftools/ffmpeg_sched: report progress using max dts instead of trailing_dts()
This is to reapply 18217bb0f5.
Its commit msg is still meaningful:
"Using the max instead of the min avoids the progress stopping
with gaps in sparse streams (subtitles)."

Also on a very similar issue: currently, a single stream with
no data makes ffmpeg reports N/A for both time and speed.
Fix this by ignoring missing dtses.

Fix regressions since d119ae2fd8.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-03-12 12:15:15 +00:00
Romain Beauxis 9dc44b43b2 fftools/ffplay.c: Also print demuxer-level metadata updates. 2026-03-12 02:45:13 +00:00
Michael Niedermayer ba0f8083fd avformat/aiffdec: Check for partial read
Fixes: read of uninitialized memory
Fixes: 490305404/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-6406386140643328

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-11 20:06:26 +00:00
Kacper Michajłow 5074d9f06e hwcontext_amf: fix version variable type and remove cast
Fixes compilation errors on newer Clang/GCC that errors out on
incompatible pointers.

error: incompatible pointer types passing 'unsigned long long *' to
parameter of type 'amf_uint64 *' (aka 'unsigned long *')
[-Wincompatible-pointer-types]

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-11 18:41:10 +00:00
Lynne 7c79c79a50 aacdec_usac_mps212: reject reserved freq_res value 2026-03-11 17:43:09 +00:00
Kacper Michajłow b028dac149 configure: bump AMF requirement to 1.5.0
6972b127de requires at least version
1.5.0, as earlier versions are not compatible with C due to unguarded
`extern "C"`.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-11 17:32:20 +00:00
Shreesh Adiga 5085432f8b avutil/crc: add aarch64 NEON PMULL+EOR3 SIMD implementation for av_crc
Implemented clmul algorithm for aarch64 using PMULL and EOR3 instructions.
The logic and structure is same as x86 clmul implementation with
slight rearrangement of constants as per PMULL and PMULL2 instructions.

Benchmarking in Android (Termux) on a MediaTek Dimensity 9400 SoC:

./tests/checkasm/checkasm --test=crc --bench --runs=12
benchmarking with native FFmpeg timers
nop: 0.2
checkasm: SVE 128 bits, using random seed 2502847808
checkasm: bench runs 4096 (1 << 12)
CRC:
 - crc.crc [OK]
PMULL:
 - crc.crc [OK]
checkasm: all 10 tests passed
crc_8_ATM_c:                                            26.0 ( 1.00x)
crc_8_ATM_pmull_eor3:                                    0.7 (37.17x)
crc_8_EBU_c:                                            46.4 ( 1.00x)
crc_8_EBU_pmull_eor3:                                    1.5 (31.47x)
crc_16_ANSI_c:                                          36.3 ( 1.00x)
crc_16_ANSI_pmull_eor3:                                  1.1 (31.70x)
crc_16_ANSI_LE_c:                                       90.9 ( 1.00x)
crc_16_ANSI_LE_pmull_eor3:                               2.8 (32.30x)
crc_16_CCITT_c:                                        118.0 ( 1.00x)
crc_16_CCITT_pmull_eor3:                                 3.7 (32.00x)
crc_24_IEEE_c:                                           1.6 ( 1.00x)
crc_24_IEEE_pmull_eor3:                                  0.1 (12.19x)
crc_32_IEEE_c:                                          45.2 ( 1.00x)
crc_32_IEEE_pmull_eor3:                                  1.4 (31.39x)
crc_32_IEEE_LE_c:                                       49.1 ( 1.00x)
crc_32_IEEE_LE_crc:                                      2.5 (19.51x)
crc_32_IEEE_LE_pmull_eor3:                               1.5 (32.84x)
crc_custom_polynomial_c:                                45.3 ( 1.00x)
crc_custom_polynomial_pmull_eor3:                        1.3 (35.16x)
2026-03-11 14:03:36 +00:00
Shreesh Adiga 952e588600 avutil/crc: refactor helper functions to separate header file
Move the reverse and xnmodp functions to a separate header
so that it can be reused for aarch64 implementation of av_crc.
2026-03-11 14:03:36 +00:00
Shreesh Adiga b19bd0de6c avutil/cpu: add aarch64 CPU feature flag for PMULL and EOR3 2026-03-11 14:03:36 +00:00
Timo Rothenpieler fb088f224b avfilter/vf_vpp_amf: fix build on non-windows
sscanf and sscanf_s are identical for pure number parsing anyway.
2026-03-11 14:12:26 +01:00
Dmitrii Gershenkop 910000fe59 avfilter/vf_vpp_amf: Extend AMF Color Converter HDR capabilities 2026-03-11 10:23:35 +01:00
Ramiro Polla e3ee346749 swscale/tests/swscale: add -s option to set frame size
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-11 08:05:08 +00:00
Ramiro Polla 5c5444db59 swscale/tests/swscale: avoid redundant ref->src conversions
The ref->src conversion only needs to be performed once per source
pixel format.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-11 08:05:08 +00:00
Ramiro Polla a09cddc803 swscale/tests/swscale: make auxiliary conversions bitexact and accurate_rnd
This prevents the propagation of dither_error across frames, and should
also improve reproducibility across platforms.

Also remove setting of flags for sws_src_dst early on, since it will
inevitably be overwritten during the tests.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-11 08:05:08 +00:00
Ramiro Polla d935000f09 swscale/tests/swscale: give names to SwsContext variables 2026-03-11 08:05:08 +00:00
Ramiro Polla 49b1e214cf swscale/tests/swscale: pass opts and mode arguments as const pointers 2026-03-11 08:05:08 +00:00
Ramiro Polla e34071e7d5 swscale/tests/swscale: split init_ref() out of main()
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-11 08:05:08 +00:00
Ramiro Polla f83c9718ec swscale/tests/swscale: split parse_options() out of main()
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-11 08:05:08 +00:00
Ramiro Polla 953efc9f56 swscale/tests/swscale: remove hardcoded dimension checks
Remove dimension checks originally added to please static analysis
tools. There is little reason to have arbitrary limits in this
developer test tool. The reference files are under control by the user.

This reverts f70a651b3f and c0f0bec2f2.
2026-03-11 08:05:08 +00:00
Ramiro Polla 955cf563c8 swscale/tests/swscale: always allocate frame in scale_legacy()
Legacy swscale may overwrite the pixel formats in the context (see
handle_formats() in libswscale/utils.c). This may lead to an issue
where, when sws_frame_start() allocates a new frame, it uses the wrong
pixel format.

Instead of fixing the issue in swscale, just make sure dst is always
allocated prior to calling the legacy scaler.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-11 08:05:08 +00:00
Niklas Haas 2589ce4a2c tests/swscale: unref buffers before each iteration
Otherwise, we always pass frames that already have buffers allocated, which
breaks the no-op refcopy optimizations.

Testing with -p 0.1 -threads 16 -bench 10, on an AMD Ryzen 9 9950X3D:

 Before:
  Overall speedup=2.776x faster, min=0.133x max=629.496x
  yuv444p 1920x1080 -> yuv444p 1920x1080, flags=0x100000 dither=1
     time=9 us, ref=9 us, speedup=1.043x faster

 After:
  Overall speedup=2.721x faster, min=0.140x max=574.034x
  yuv444p 1920x1080 -> yuv444p 1920x1080, flags=0x100000 dither=1
    time=0 us, ref=28 us, speedup=516.504x faster

(The slowdown in the legacy swscale case is from swscale's lack of a no-op
refcopy optimizaton, plus the fact that it's now actually doing memory
work instead of a no-op / redundant memset)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-11 08:05:08 +00:00
Niklas Haas 271bacffec tests/swscale: exclude init time from benchmark
This was originally intended to also include performance gains/losses
due to complicated setup logic, but in practice it just means that changing
the number of iterations dramatically affects the measured speedup; which
makes it harder to do quick bench runs during development.
2026-03-11 08:05:08 +00:00
James Almer a9984fec81 avcodec/lcevc_parser: check return value of init_get_bits8()
Fixes coverity issue CID 1684198.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-10 15:50:20 -03:00
Lynne 215e22d1f1 ffv1enc_vulkan: fix typo
Fixes a segfault when host mapping is unsupported.
2026-03-10 19:31:00 +01:00
Diego de Souza 63e0a2add2 avcodec/nvenc: change default H.264 profile from main to high
The NVENC H.264 high profile provides up to 16% bitrate savings
(BD-Rate measured with VMAF) compared to the main profile.

Since most users do not explicitly set a profile, changing the
default benefits the common case. Users requiring the main profile
for legacy decoder compatibility can still set it explicitly.

The change is gated behind a versioned define so it only takes
effect on the next major version bump (libavcodec 63).

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-03-10 15:08:16 +00:00
Andreas Rheinhardt 0afa879a69 avcodec/aac/aacdec_usac: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:19 +01:00
Andreas Rheinhardt 7e70503ed4 avcodec/vp5: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:19 +01:00
Andreas Rheinhardt 67217549c8 avcodec/get_bits: Rename macro variables to avoid shadowing
Especially 'n' often leads to shadowing, e.g. in mpeg12dec.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:19 +01:00
Andreas Rheinhardt 3343567482 avcodec/motion_est: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:19 +01:00
Andreas Rheinhardt ac25aed6b3 avcodec/eatgq: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:19 +01:00
Andreas Rheinhardt 2d9cf94283 avfilter/vf_chromanr: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:19 +01:00
Andreas Rheinhardt 380e1cdb0c avfilter/af_afftfilt: Don't get max align multiple times
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:19 +01:00
Andreas Rheinhardt a4efdcaa53 avfilter/af_apsyclip: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:19 +01:00
Andreas Rheinhardt b0839506d7 avfilter/vf_blurdetect: Fix shadowing
Also use smaller scope in general.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:19 +01:00
Andreas Rheinhardt 1bbac3643b avfilter/avf_showspectrum: Avoid allocation
Also fixes an instance of shadowing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:19 +01:00
Andreas Rheinhardt 7950e5d1a5 avcodec/rka: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:19 +01:00
Andreas Rheinhardt 0a1606f86c avcodec/hpeldsp: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:19 +01:00
Andreas Rheinhardt 92046bcd7b avcodec/cbs: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 06ea751c51 avcodec/mpegaudioenc: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt bffaa6aaab avcodec/utvideodec: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 78f8ef341e avcodec/wmaenc: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt c0ba18c527 avcodec/dv_tablegen: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt ba57a33351 avformat/id3v2: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 90dae166b5 avformat/http: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 8ddb82fd75 avformat/lafdec: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 1617feef50 avformat/asfdec_f: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 2ed4660960 avformat/rtpenc_mpegts: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 6de2565b8e avformat/rtpdec_xiph: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 422ad600cd avformat/oggparseopus: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 51ae4f443d avcodec/cbs_av1_syntax_template: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 615d5c2715 avformat/dsfdec: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 1e440f2745 avformat/dovi_isom: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 9c0f942293 avformat/aviobuf: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 1778991846 avformat/avio: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 5962ca0c20 avformat/avidec: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 8f9239a869 avformat/mpc8: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 378928e79f avformat/mpegtsenc: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 968511ad03 avformat/dhav: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt a49eed2fb1 avformat/oggenc: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 4014d35dda avformat/bonk: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 5198d8802c avformat/matroskadec: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt fd88a52be0 avformat/matroskaenc: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 7a0ae45bcf avformat/rmenc: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 6aa367b9b3 avformat/smacker: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 54672d194c avformat/srtpproto: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt b53752dc4c avformat/tcp: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 619839ac16 avformat/tee: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 034b37a51d avformat/vividas: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt a2a42aa404 avformat/vorbiscomment: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 0037c5abdd avformat/webpenc: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 61c22c71c2 avformat/yuv4mpegdec: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 33971e6c4e avformat/apetag: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 6a78db80f0 avformat/hlsenc: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 999c04db35 avutil/channel_layout: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 3fbe80d17e avutil/aes: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt df7b8cae7b avutil/slicethread: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt 0992c19c30 avfilter/avf_showspectrum: Fix allocation check
If s->stop is set, the return value would be overwritten
before being checked. This bug was introduced in the switch
to AV_TX in 014ace8f98.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:17 +01:00
Georgii Zagoruiko c1be2107c9 aarch64/vvc: Optimisations of put_luma_h() functions for 10/12-bit
RPi4:
put_chroma_h_10_2x2_c:                                  63.4 ( 1.00x)
put_chroma_h_10_4x4_c:                                 151.4 ( 1.00x)
put_chroma_h_10_8x8_c:                                 555.1 ( 1.00x)
put_chroma_h_10_8x8_neon:                              113.9 ( 4.88x)
put_chroma_h_10_16x16_c:                              1068.5 ( 1.00x)
put_chroma_h_10_16x16_neon:                            439.4 ( 2.43x)
put_chroma_h_10_32x32_c:                              3432.6 ( 1.00x)
put_chroma_h_10_32x32_neon:                           1878.3 ( 1.83x)
put_chroma_h_10_64x64_c:                             12872.2 ( 1.00x)
put_chroma_h_10_64x64_neon:                           7868.2 ( 1.64x)
put_chroma_h_10_128x128_c:                           45612.2 ( 1.00x)
put_chroma_h_10_128x128_neon:                        28742.1 ( 1.59x)
put_chroma_h_12_2x2_c:                                  63.7 ( 1.00x)
put_chroma_h_12_4x4_c:                                 151.5 ( 1.00x)
put_chroma_h_12_8x8_c:                                 555.2 ( 1.00x)
put_chroma_h_12_8x8_neon:                              114.2 ( 4.86x)
put_chroma_h_12_16x16_c:                              1068.1 ( 1.00x)
put_chroma_h_12_16x16_neon:                            438.8 ( 2.43x)
put_chroma_h_12_32x32_c:                              3419.7 ( 1.00x)
put_chroma_h_12_32x32_neon:                           1878.7 ( 1.82x)
put_chroma_h_12_64x64_c:                             12862.2 ( 1.00x)
put_chroma_h_12_64x64_neon:                           7868.2 ( 1.63x)
put_chroma_h_12_128x128_c:                           45613.5 ( 1.00x)
put_chroma_h_12_128x128_neon:                        28743.3 ( 1.59x)

Apple M4:
put_chroma_h_10_2x2_c:                                   2.5 ( 1.00x)
put_chroma_h_10_4x4_c:                                   6.5 ( 1.00x)
put_chroma_h_10_8x8_c:                                  17.8 ( 1.00x)
put_chroma_h_10_8x8_neon:                                6.8 ( 2.60x)
put_chroma_h_10_16x16_c:                                53.3 ( 1.00x)
put_chroma_h_10_16x16_neon:                             30.4 ( 1.75x)
put_chroma_h_10_32x32_c:                               181.8 ( 1.00x)
put_chroma_h_10_32x32_neon:                            116.2 ( 1.56x)
put_chroma_h_10_64x64_c:                               684.2 ( 1.00x)
put_chroma_h_10_64x64_neon:                            470.3 ( 1.45x)
put_chroma_h_10_128x128_c:                            2567.6 ( 1.00x)
put_chroma_h_10_128x128_neon:                         1879.3 ( 1.37x)
put_chroma_h_12_2x2_c:                                   1.9 ( 1.00x)
put_chroma_h_12_4x4_c:                                   7.0 ( 1.00x)
put_chroma_h_12_8x8_c:                                  16.8 ( 1.00x)
put_chroma_h_12_8x8_neon:                                7.9 ( 2.12x)
put_chroma_h_12_16x16_c:                                55.0 ( 1.00x)
put_chroma_h_12_16x16_neon:                             29.0 ( 1.90x)
put_chroma_h_12_32x32_c:                               182.5 ( 1.00x)
put_chroma_h_12_32x32_neon:                            116.9 ( 1.56x)
put_chroma_h_12_64x64_c:                               666.8 ( 1.00x)
put_chroma_h_12_64x64_neon:                            474.5 ( 1.41x)
put_chroma_h_12_128x128_c:                            2588.1 ( 1.00x)
put_chroma_h_12_128x128_neon:                         1912.2 ( 1.35x)
2026-03-10 12:48:54 +00:00
James Almer 125bb2e045 avcodec/lcevc_parser: Check that block_size is not negative
Based on 248b481c33

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-09 18:39:33 -03:00
Andreas Rheinhardt f6894debc0 avfilter/vf_hqdn3d: Remove unnecessary emms_c()
Added in e995cf1bcc,
yet this filter does not have any dsp function using MMX:
it only has generic x86 assembly, no SIMD at all,
so this emms_c() was always unnecessary.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 19:07:34 +01:00
nyanmisaka 3f10a054dc fftools/ffmpeg: fix read_key() always return 255 when there was no input
fixup 08d327e

When an uchar is set to -1, it will become 255 when read as an int.
Duplicate variables for two terminal types can also avoid unused variable warnings.

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-03-09 16:13:18 +00:00
Niklas Haas 68046d0b33 Revert "swscale/vulkan/ops: move buffer desc setting to helper function"
This reverts commit 32554fc107.

Accidentally pushed this commit twice, with the wrong location.
Correct version is 97682155e6.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:16:42 +01:00
Niklas Haas bd9590db70 swscale/ops_dispatch: remove unnecessary SwsOpExec fields
These were abstraction-violating in the first place. Good riddance.

This partially reverts commit c911295f09.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:01:51 +01:00
Niklas Haas 143cb56501 swscale/vulkan/ops: use opaque run function
Avoids some unnecessary round-trips through the execution harness, as well
as removing one unnecessary layer of abstraction (SwsOpExec).

It's a bit unfortunate that we have to cast away the const on the AVFrame,
since the Vulkan functions take non-const everywhere, even though all they're
doing is modifying frame internal metadata, but alas.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:01:51 +01:00
Niklas Haas 911176c880 swscale/ops_dispatch: add SwsCompiledFunc.opaque
Allows compiled functions to opt out of the ops_dispatch execution harness
altogether and just get dispatched directly as the pass run() function.

Useful in particular for Vulkan.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:01:51 +01:00
Niklas Haas 9571f5cf15 swscale/graph: simplify ff_sws_graph_add_pass() usages
Now that this function returns a status code and takes care of cleanup on
failure, many call-sites can just return the function directly.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:01:51 +01:00
Niklas Haas 2e29833832 swscale/graph: have ff_sws_graph_add_pass() free priv on failure
This is arguably more convenient for most downstream users, as will be
more prominently seen in the next commit.

Also allows this code to re-use a pass_free() helper with the graph uninit.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:01:51 +01:00
Niklas Haas 42a47838ea swscale/graph: add setup()/free() to ff_sws_graph_add_pass() signature
This is just slightly common enough a pattern that it IMO makes sense to do
so. This will also make more sense after the following commits.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:01:51 +01:00
Niklas Haas 5b8889f4e8 swscale/graph: add typedef for SwsPassSetup
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:01:51 +01:00
Niklas Haas 254c07bf60 swscale/graph: rename sws_filter_run_t to SwsPassFunc
This name is weirdly out-of-place in the libswscale naming convention.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:01:51 +01:00
Niklas Haas fdc0a66cbd swscale/graph: skip threading for single-slice passes
This condition was weaker than necessary.

In particular, graph->num_thread == 1 guarantees pass->num_slices == 1.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:01:51 +01:00
Niklas Haas 97682155e6 swscale/vulkan/ops: move buffer desc setting to helper function
And call it on the read/write ops directly, rather than this awkward loop.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 12:01:51 +01:00
Niklas Haas 9b7439c31b swscale: don't pointlessly loop over NULL buffers
This array is defined as contiguous.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:58 +01:00
Niklas Haas dd75b6b57c swscale: add sanity clear on AVFrame *dst
Before allocating/referencing buffers, make sure these fields are in a
defined state.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:58 +01:00
Niklas Haas 76c60b192d swscale: restructure sws_scale_frame() slightly
Results in IMHO slightly more readable code flow, and will be useful in an
upcoming commit (that adds logic to ref individual planes).

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:58 +01:00
Niklas Haas b52df46585 tests/checkasm/sw_ops: fix exec.slice_h assignment
This should match the number of lines. As an aside, align these declarations.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:58 +01:00
Niklas Haas a534156083 swscale/graph: pass SWS_OP_FLAG_OPTIMIZE
Instead of optimizing it with an explicit call. May enable more optimizations
in the future.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:58 +01:00
Niklas Haas f77ab892f5 swscale/ops_dispatch: print op list on successful compile
Instead of once at the start of add_convert_pass(). This makes much
more sense in light of the fact that we want to start e.g. splitting
passes apart.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:58 +01:00
Niklas Haas a31973e99c swscale/ops_dispatch: avoid redundant ff_sws_op_list_update_comps()
This is already called by compile_backend(), and nothing else in this file
depends on accurate values.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:58 +01:00
Niklas Haas 32554fc107 swscale/vulkan/ops: move buffer desc setting to helper function
And call it on the read/write ops directly, rather than this awkward loop.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:58 +01:00
Niklas Haas b6ebee038f swscale/vulkan/ops: move fractional read/write rejection to implementation
Rather than testing for it separately for some reason.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:57 +01:00
Niklas Haas 104475ecb9 swscale/vulkan/ops: fix undefined behavior on SWS_OP_CLEAR
op->rw.frac dereferences nonsense on clear ops.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:57 +01:00
Niklas Haas b8cd331305 swscale/vulkan/ops: log op name in generated shader
I think this just makes for a marginally nicer debugging experience.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:57 +01:00
Niklas Haas eebc07aba7 swscale/ops: simplify ff_sws_op_list_print
Using the new ff_sws_op_type_name() helper.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:57 +01:00
Niklas Haas 1addde59f9 swscale/ops: add ff_sws_op_type_name
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:57 +01:00
Niklas Haas 1d16161a8b swscale/ops: use SwsCompFlags typedef instead of plain int
This improves the debugging experience. These are all internal structs so
there is no need to worry about ABI stability as a result of adding flags.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-09 11:25:57 +01:00
Andreas Rheinhardt 1a9c345ee8 avutil/mips: Add msa optimizations for pixelutils
Adapted from the corresponding me_cmp code. Only the width 16 function
has been adapted, because it seems that the width 8 function actually
reads 16 bytes per line.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Andreas Rheinhardt 471db1d323 avutil/arm: Add armv6 optimizations for pixelutils
Adapted from the corresponding me_cmp code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Andreas Rheinhardt 9b84b8682f avutil/riscv: Add rvv optimizations for pixelutils
Adapted from the corresponding me_cmp code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Andreas Rheinhardt 022c42649c avutil/aarch64: Add neon optimizations for pixelutils
Adapted from the corresponding me_cmp code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Andreas Rheinhardt e114c63234 avutil/x86/pixelutils: Avoid near-empty header
lavu/x86/pixelutils.h only declares exactly one function,
namely the arch-specific init function. Such declarations
are usually contained in the ordinary header providing
the generic init function, yet the latter is public in this case.

Given that said function is called from exactly one callsite,
the header can be made more useful by moving the actual x86-init
function to it (as a static inline function) and removing
pixelutils_init.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Andreas Rheinhardt 085f06a13f avutil/pixelutils: Don't unconditionally include arch-specific header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Andreas Rheinhardt c9e056bc85 avutil/x86/pixelutils: Remove pointless AVX2 sad32x32 functions
Memory operands of VEX encoded instructions generally have
no alignment requirement and so can be used in the case where
both inputs are unaligned, too. Furthermore, unaligned load
instructions are as fast as aligned loads (from aligned addresses)
for modern cpus, in particular those with AVX2.

Therefore it makes no sense to have three different AVX2 sad32x32
functions. So remove two of them (the remaining one is the same
as the old one where src1 was aligned and src2 was not).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Andreas Rheinhardt 2862fa37e1 tests/checkasm: Add pixelutils test
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Ramiro Polla 4792440ab8 swscale/unscaled: fix planarCopyWrapper for float formats with same endianness 2026-03-09 08:22:58 +00:00
Andreas Rheinhardt 32b42dfd9b avcodec/x86/pngdsp: Don't use 64bit unnecessarily
The automatic zero-extensions when assigning a 32bit register
make using 64bits unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 07:28:29 +01:00
Andreas Rheinhardt a8679f456f avcodec/x86/pngdsp: Avoid jump
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 07:28:29 +01:00
Andreas Rheinhardt f0a28cf9ce avcodec/x86/pngdsp: Don't use mmx register in ff_add_bytes_l2_sse2()
This change has no measurable impact on performance here;
it is intended to avoid unpredictable behavior with floating
point operation like the one that led to commit
57a29f2e7d.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 07:28:29 +01:00
Aditya Banavi 31c2f814ca avformat/tls_gnutls: fix DTLS handshake failure in some WebRTC cases
The early code may encounter handshake failure when publish
WHIP to some server.

See RFC 8827 section 6.5:
All implementations MUST support DTLS 1.2 with the
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 cipher suite
and the P-256 curve.

So this patch uses the specific curve to avoid incompatibility.

Signed-off-by: Aditya Banavi <adityabanavi@gmail.com>
2026-03-09 03:11:04 +00:00
Michael Niedermayer 248b481c33 avcodec/bsf/extract_extradata: Check that block_size is not negative
Fixes: out of array access
Fixes: 490576036/clusterfuzz-testcase-minimized-ffmpeg_BSF_EXTRACT_EXTRADATA_fuzzer-4605696279904256

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-08 23:34:14 +00:00
Romain Beauxis e5e8efae5c libavformat/mov.c: Fix seek in fragmented mp4 files where the audio and video streams are written to seperate fragments 2026-03-08 16:22:24 -05:00
Michael Niedermayer c1263a3dd9 Bump versions for master after release/8.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-08 02:31:23 +01:00
Michael Niedermayer 67c886222f Bump versions for release/8.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-08 02:29:20 +01:00
Michael Niedermayer 5e933b463b doc/APIchanges: Fill in missing values
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-08 02:29:20 +01:00
Michael Niedermayer 82c55b7ed7 Changelog: Add Version 8.1 marker
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-08 01:42:57 +01:00
James Almer ebf70aa854 avformat/demux: update Stream Groups in avformat_find_stream_info() from parsed values
Dimensions are not available at the container level for LCEVC in mpegts, so derive them
from the parsed values taken from the enhancement stream.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:22:42 -03:00
James Almer b9cb948ec1 avformat/mpegts: add support for LCEVC streams
As defined in ITU-T H.222.0 v9, LCEVC streams use the "Byte stream format"
defined in Annex B of ISO/IEC 23094-2:2021.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:22:42 -03:00
James Almer 0cd4bb2f96 avcodec: add an LCEVC parser
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:22:40 -03:00
James Almer 58052b484e avcodec/codec_desc: make LCEVC a video media type
Every container signals it as such, and the data media stream type is too
undefined and unsupported across the codebase that even if no standalone
decoder can be present for it, it's preferable to it.

This is technically an API break, but LCEVC support has been minimal until
now so it should be safe.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:22:14 -03:00
James Almer c6057f4d96 fftools/ffmpeg_mux_init: don't autoselect video codecs known to lack decoders
They should not be given priority even in a stream copy scenario.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:21:44 -03:00
James Almer 8add479cd3 avcodec/parser: set avctx->pix_fmt for codecs with the enhancement prop set
There will be no decoder for those, so the parser's derived value may be used.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:21:44 -03:00
James Almer c23d56b173 avcodec/codec_desc: add a codec prop to signal enhancement layers
Some video codecs are not meant to output frames on their own but to be applied
on top of frames generated by other codecs, as is the case of LCEVC, Dolby Vision,
etc. Add a codec prop to signal this kind of codec, so that library users may know
to not expect a standalone decoder for them to be present.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:21:38 -03:00
Andreas Rheinhardt 2f9d3ce5a2 avcodec/h261dec: Don't pretend decoding a skipped macroblock can fail
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt f37cfb370f avcodec/avcodec: Deprecate intra_dc_precision
It is only used by the MPEG-2 encoder, so replace it
by a private option instead. Use a more elaborate term
for it: intra_dc_precision ("dc" could be anything).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt cdc632efb3 avcodec/mpegvideo_enc: Ignore intra_dc_precision for non-MPEG-2
This option is only allowed to be set for MPEG-2, so ignore it
except for MPEG-2 and move handling of it to mpeg12enc.c.
This is in preparation for deprecating the AVCodecContext option.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt 76a005dccf avcodec/rv10enc: Set encode_picture_header in rv10_encode_init()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt 8a431cd8ba avcodec/rv10enc: Check dimensions once during init
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt 27d95c3cf8 avcodec/mpegvideo_enc: Move dimension-alignment check to rv10enc.c
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt 9051caa12c avcodec/mpegvideo_enc: Inline intra_dc_precision when known
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt ee72731722 tests/fate/vcodec: Test intra_dc_precision
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt 38c578b909 swscale_x86/swscale_template: Remove unused macros
WRITEBGR24MMX is unused after a05f22eaf3.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 18:06:43 +01:00
James Almer 6dd446918a swscale/utils: don't abort early in sws_freeContext() for non legacy API
There are some buffers still allocated even with it.
Fixes memleaks.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 15:46:23 +00:00
Lynne 5a6eeed9f0 vulkan_ffv1: warn users on low number of slices
Files with a low amount of slices take a considerably longer amount
of time to decode. Experimentally, 16 seems to be a good safe minimum.
2026-03-07 15:14:25 +01:00
Lynne 8f2dea9ae8 Changelog: add entry for the prores Vulkan encoder 2026-03-07 15:14:21 +01:00
Lynne b8a4d8a18d aacdec_usac_mps212: fix CID 1681700
Fixes Coverity issue #1681700
2026-03-07 11:56:47 +00:00
Lynne c40318d663 aacdec_usac_mps212: Fix CID 1681701
Fixes Coverity issue #1681701
2026-03-07 11:56:47 +00:00
Lynne 46cf8f1873 aacdec_usac_mps212: fix CID 1681703
Fixes Coverity issue #1681703
2026-03-07 11:56:47 +00:00
Lynne 558738a6d0 aacdec_usac_mps212: Fix CID 1681704
Fixes Coverity issue #1681704
2026-03-07 11:56:47 +00:00
Lynne e7e001a804 aacdec_usac_mps212: fix CID 1681705
Fixes Coverity issue #1681705
2026-03-07 11:56:47 +00:00
Devraj Ajmera 4a390fcd20 avformat/rtpenc: validate MPEG-TS RTP payload size
Ensure that the RTP payload size is at least one TS packet
(188 bytes) when packetizing MPEG-TS.

Previously, small payload sizes were silently rounded up,
which could lead to incorrect behavior. Return EINVAL
with a clear error message instead.

Signed-off-by: Devraj Ajmera <devrajajmera077@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-07 12:17:27 +01:00
Michael Niedermayer c2364e9222 avcodec/aac/aacdec_usac_mps212: Fix invalid array index
Without the specification, limiting the index is the best that can be done.

Fixes: out of array access
Fixes: 487591441/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-6205915698364416

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-07 11:11:52 +00:00
Michael Niedermayer c4ee599760 avcodec/aac/aacdec_usac_mps212: Fix invalid shift
Fixes: left shift of negative value -2
Fixes: 487591441/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-6205915698364416

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-07 11:11:52 +00:00
Michael Niedermayer 1e7d7c4f52 fftools/ffmpeg_demux: Check metadata provided filename
Fixes: path traversal with  -dump_attachment:t
Fixes: malicious.mkv

Based on code from libavformat/concatdec.c
This will be factored out possibly into libavutil once there is agreement on the API

Found-by: Shangzhi Xu <mxu490469@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-07 11:51:39 +01:00
stevxiao 20cf8befd5 doc/filters: add entry for deinterlace_d3d12
Add documentation for the filter "deinterlace_d3d12" to the filters documentation.

This is the follow-up for commit https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22386/commits

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-03-07 04:47:16 +00:00
James Almer a1496ced65 avcodec/av1dec: sync frame header and tile group behavior with CBS
A new Sequence Header or a Temporal Delimiter OBU invalidate any previous frame
if not yet complete (As is the case of missing Tile Groups).
Similarly, a new Frame Header invalidates any onging Tile Group parsing.

Fixes: out of array access
Fixes: av1dec_tile_desync.mp4
Fixes: av1dec_tile_desync_bypass.mp4

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-06 23:18:35 -03:00
James Almer 282cf4425d avcodec/cbs_av1: don't try to write a Redundant Frame Header as a normal one
Section 6.8.1 of the AV1 specification states:

"If obu_type is equal to OBU_REDUNDANT_FRAME_HEADER, it is a requirement of
bitstream conformance that SeenFrameHeader is equal to 1."

Leave the existing behavior for reading scenarios as such a file may still
be readable.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-06 23:18:35 -03:00
James Almer 9f0441a774 swscale/x86/input: don't overread input in RGB24_TO_UV_FN
Fixes a 4 byte overread after 846823b174 removed padding

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-06 23:13:45 -03:00
Ramiro Polla 252ab61726 avutil/frame: fix typos 2026-03-07 00:54:49 +00:00
Michael Niedermayer 6023ad715c avformat/mlvdec: avoid uninitialized read in read_string()
Fixes: read of uninitialized memory
Fixes: 488256339/clusterfuzz-testcase-minimized-ffmpeg_dem_MLV_fuzzer-6347338118660096

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:32:22 +01:00
Michael Niedermayer d5e2e678ab avcodec/magicyuv: fix small median images
Fixes: out of array acces
Fixes: 487838419/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_DEC_fuzzer-4683933221715968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:25:29 +01:00
Michael Niedermayer 1e63151355 swscale/output: Fix integer overflow in alpha in yuv2rgba64_1_c_template()
Fixes: signed integer overflow: -1548257 * 2048 cannot be represented in type 'int'
Fixes: #21592

Found-by: HAORAN FANG
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:09:44 +01:00
Michael Niedermayer 946ce12e1c swscale/utils: Check *Inc
Fixes: signed integer overflow: -2147483648 - 65536 cannot be represented in type 'int'
Fixes: #21588

Found-by: HAORAN FANG
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:09:44 +01:00
Michael Niedermayer 9adced3278 avfilter/vf_scale: Fix integer overflow in config_props()
Fixes: signed integer overflow: 536870944 * 16 cannot be represented in type 'int'
Fixes: #21587

Found-by: HAORAN FANG
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:09:44 +01:00
Michael Niedermayer a59180022a swscale/output: Fixes integer overflow in yuv2planeX_8_c
Fixes: integer overflow (does not replicate, but looks like it should overflow with some craftet parameters)
Fixes: #21584

Found-by: HAORAN FANG
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:09:26 +01:00
Michael Niedermayer dc9bf66796 swscale/utils: initialize chroma when luma switched to cascade
When luma init switched to cascade the chroma init was skiped

Fixes: NULL pointer dereference
Fixes: #21583

Found-by: HAORAN FANG
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:09:26 +01:00
Michael Niedermayer 6084f07189 avcodec/utils: fix duration computation based on frame_bytes
Fixes: signed integer overflow: 256 * 8396351 cannot be represented in type 'int'
Fixes: 482692578/clusterfuzz-testcase-minimized-ffmpeg_dem_SWF_fuzzer-5865521093607424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:08:03 +01:00
Andreas Rheinhardt 0ddece40c5 avcodec/x86/vvc/alf: Simplify vb_pos comparisons
The value of vb_pos at vb_bottom, vb_above is known
at compile-time, so one can avoid the modifications
to vb_pos and just compare against immediates.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt 1960320112 avcodec/x86/vvc/alf: Avoid pointless wrappers for alf_filter
They are completely unnecessary for the 8bit case (which only
handles 8bit) and overtly complicated for the 10 and 12bit cases:
All one needs to do is set up the (1<<bpp)-1 vector register
and jmp from (say) the 12bpp function stub inside the 10bpp
function. The way it is done here even allows to share the
prologue between the two functions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt 467f8d8415 avcodec/x86/vvc/alf: Improve offsetting pointers
It can be combined with an earlier lea for the loop
processing 16 pixels at a time; it is unnecessary
for the tail, because the new values will be overwritten
immediately afterwards anyway.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt cb5f6c055b avcodec/x86/vvc/alf: Don't modify rsp unnecessarily
The vvc_alf_filter functions don't use x86inc's stack managment
feature at all; they merely push and pop some regs themselves.
So don't tell x86inc to provide stack (which in this case
entails aligning the stack).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt 38062ebd18 avcodec/x86/vvc/alf: Remove pointless counter, stride
Each luma alf block has 2*12 auxiliary coefficients associated
with it that the alf_filter functions consume; the C version
simply increments the pointers.

The x64 dsp function meanwhile does things differenty:
The vvc_alf_filter functions have three levels of loops.
The middle layer uses two counters, one of which is
just the horizontal offset xd in the current line. It is only
used for addressing these auxiliary coefficients and
yet one needs to perform work translate from it to
the coefficient offset, namely a *3 via lea and a *2 scale.
Furthermore, the base pointers of the coefficients are incremented
in the outer loop; the stride used for this is calculated
in the C wrapper functions. Furthermore, due to GPR pressure xd
is reused as loop counter for the innermost loop; the
xd from the middle loop is pushed to the stack.

Apart from the translation from horizontal offset to coefficient
offset all of the above has been done for chroma, too, although
the coefficient pointers don't get modified for them at all.

This commit changes this to just increment the pointers
after reading the relevant coefficients.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt d2e7fe5b19 avcodec/x86/vvc/alf: Improve deriving ac
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt 5da3cab645 avcodec/x86/vvc/alf: Avoid broadcast
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt c9da0193ff avcodec/x86/vvc/alf: Don't use 64bit where unnecessary
Reduces codesize (avoids REX prefixes).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt a489a623fb avcodec/x86/vvc/alf: Use memory sources directly
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt df7885d6c3 avcodec/x86/vvc/alf: Improve writing classify parameters
The permutation that was applied before the write macro
is actually only beneficial when one has 16 entries to write,
so move it into the macro to write 16 entries and optimize
the other macro.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt 1bc91eb552 avcodec/x86/vvc/alf: Avoid checking twice
Also avoids a vpermq in case width is eight.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt e4a9d54e48 avcodec/x86/vvc/alf: Avoid nonvolatile registers
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt a2d9cd6dcb avcodec/x86/vvc/alf: Don't calculate twice
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 01a897020e avcodec/x86/vvc/alf: Use xmm registers where sufficient
One always has eight samples when processing the luma remainder,
so xmm registers are sufficient for everything. In fact, this
actually simplifies loading the luma parameters.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 9cb5280c0e avcodec/x86/vvc/alf: Improve storing 8bpp
When width is known to be 8 (i.e. for luma that is not width 16),
the upper lane is unused, so use an xmm-sized packuswb and avoid
the vpermq altogether. For chroma not known to be 16 (i.e. 4,8 or
12) defer extracting from the high lane until it is known to be needed.
Also do so via vextracti128 instead of vpermq (also do this for
bpp>8).
Also use vextracti128 and an xmm-sized packuswb in case of width 16
instead of an ymm-sized packuswb followed by vextracti128.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 56a4c15c23 avcodec/x86/vvc/alf: Avoid checking twice
Also avoid doing unnecessary work in the width==8 case.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 43cc8f05df avcodec/x86/vvc/alf: Don't clip for 8bpp
packuswb does it already.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt a8b3b9c26f avcodec/x86/vvc/alf: Remove unused array
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 94f9ad8061 avcodec/x86/vvc/alf: Use immediate for shift when possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 2159e40ab3 avcodec/x86/vvc/of: Avoid jump
At the end of the height==8 codepath, a jump to RET at the end
of the height==16 codepath is performed. Yet the epilogue
is so cheap on Unix64 that this jump is not worthwhile.
For Win64 meanwhile, one can still avoid jumps, because
for width 16 >8bpp and width 8 8bpp content a jump is performed
to the end of the height==8 position, immediately followed
by a jump to RET. These two jumps can be combined into one.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 2a93d09968 avcodec/x86/vvc/of: Ignore upper lane for width 8
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 9fe9fd95b6 avcodec/x86/vvc/of: Only clip for >8bpp
packuswb does it already for 8bpp.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 83694749ad avcodec/x86/vvc/of,dsp_init: Avoid unnecessary wrappers
Write them in assembly instead; this exchanges a call+ret
with a jmp and also avoids the stack for (1<<bpp)-1.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt d6ed5d6e3d avcodec/x86/vvc/of: Deduplicate writing, save jump
Both the 8bpp width 16 and >8bpp width 8 cases write
16 contiguous bytes; deduplicate writing them. In fact,
by putting this block of code at the end of the SAVE macro,
one can even save a jmp for the width 16 8bpp case
(without adversely affecting the other cases).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt e7e19fcb1b avcodec/x86/vvc/of: Avoid unnecessary jumps
For 8bpp width 8 content, an unnecessary jump was performed
for every write: First to the end of the SAVE_8BPC macro,
then to the end of the SAVE macro. This commit changes this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt dee361a5bf avcodec/x86/vvc/of: Avoid initialization, addition for last block
When processing the last block, we no longer need to preserve
some registers for the next block, allowing simplifications.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt c6205355b4 avcodec/x86/vvc/of: Avoid initialization, addition for first block
Output directly to the desired destination registers instead
of zeroing them, followed by adding the desired values.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt f177672df2 avcodec/x86/vvc/of: Avoid unnecessary additions
BDOF_PROF_GRAD just adds some values to m12,m13,
so one can avoid two pxor, paddw by deferring
saving these registers prematurely.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Niklas Haas 47f89ea88b swscale: explicitly track if a context is "legacy" or not
The legacy API is defined by sws_init_context(), sws_scale() etc., whereas
the "modern" API is defined by just using sws_scale_frame() without prior
init call.

This int allows us to cleanly distinguish the type of context, paving the
way for some minor refactoring.

As an immediate benefit, we now gain a bunch of explict error checks to
ensure the API is used correctly (i.e. sws_scale() not called before
sws_init_context()).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-06 19:06:33 +01:00
Andreas Rheinhardt 5d3ad4f06e avutil/error: Fix overflow when negating
-INT_MIN is not representable in an int.
Fixes issue #22388.

Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 17:28:00 +01:00
Michael Niedermayer 987d13d13c avformat/avformat: Fix warning: assignment discards const qualifier from pointer target type
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 15:59:20 +01:00
Zhao Zhili 6fdbb5a93e avfilter/dnn: fix missing set default value to options
There are two options which use non-zero default value: async and
batch_size of openvino. init_model_ov checks and set batch_size to
one when batch_size is equal to zero, so the only option affected
by missing default value is async. Now async works as expected.
2026-03-06 21:41:11 +08:00
stevxiao ba38fa206e avfilter: update deinterlace_d3d12 filter options name
This commit update deinterlace_d3d12 filter options name.

Currently it follows the options name with "deinterlace_vaapi",
In this commit, it will follow filters such as "yadif" and "w3fdif".

Sample command lines:

1. Software decode with hwupload:

    ffmpeg -init_hw_device d3d12va=d3d12 -i interlaced.ts \
      -vf "format=nv12,hwupload,deinterlace_d3d12=method=default,hwdownload,format=nv12" \
      -c:v libx264 output.mp4

2. Full hardware pipeline:

    ffmpeg -hwaccel d3d12va -hwaccel_output_format d3d12 -i interlaced.ts \
      -vf "deinterlace_d3d12=method=custom:mode=field" \
      -c:v h264_d3d12va output.mp4

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-03-06 01:45:09 -05:00
Michael Niedermayer 20cade1ba3 doc/developer: Favor SI units where applicable
This should make things more consistent over time

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 04:29:52 +00:00
Michael Niedermayer e5c1ca60d8 avcodec/cbs_h266_syntax_template: bound slice width/height by remaining tiles
Fixes: out of array access
Fixes: crash_vvc_heap_oob_read.bin

Found-by: akshay jain <akshaythe@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 04:06:01 +01:00
Michael Niedermayer ea9e85e549 avformat/rtsp: Explicitly check protocol
Fixes: redirect to non rtsp protocol
Fixes: YWH-PGM40646-41

Found-by: BapToutatis

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 03:37:19 +01:00
Michael Niedermayer 88eb772900 avformat/rtsp: Pass blacklist
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 03:37:19 +01:00
Michael Niedermayer 2326bc5f69 avformat/rtsp: Use ff_format_check_set_url()
Fixes: redirect to blacklisted protocol
Fixes: YWH-PGM40646-41

Found-by: BapToutatis
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 03:37:19 +01:00
Michael Niedermayer 394a7ff8ce avformat: Add ff_format_check_set_url()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 03:37:18 +01:00
Michael Niedermayer e24b9820b4 avfilter/vf_convolution: Handle corner cases with small frames
Fixes: out of array read
Fixes: #YWH-PGM40646-35

Found-by: jpraveenrao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 03:21:37 +01:00
Michael Niedermayer 8970658472 avfilter/vf_convolution: Use avpriv_mirror
Fixes: out of array read
Fixes: #YWH-PGM40646-35

Found-by: jpraveenrao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 03:21:37 +01:00
Michael Niedermayer d707a4af80 avcodec/pnmdec: Check input size against width*height assuming at least 1bit per pixel
Fixes: Timeout
Fixes: 481427018/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PHM_DEC_fuzzer-6315469467615232
Fixes: 485843949/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PHM_DEC_fuzzer-4753439270961152

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 02:33:59 +01:00
Niklas Haas 1c2a300f66 swscale/graph: remove pointless helper
Basically identical to ff_sws_graph_add_pass() after the previous commit.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas d9e594ca96 swscale/graph: have ff_sws_graph_add_pass() return an error code
This allows distinguishing between different types of failure, e.g.
AVERROR(EINVAL) on invalid pass dimensions.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas 4b5122bfb2 swscale/ops_dispatch: move on-stack mutation to ops backends
And move the remainder printing there as well.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas b4bcb00cd3 swscale/ops: add and use ff_sws_op_list_input/output()
Makes various pieces of code that expect to get a SWS_OP_READ more robust,
and also allows us to generalize to introduce more input op types in the
future (in particular, I am looking ahead towards filter ops).

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas cc334a223e swscale/ops_backend: move static table out of function body
Ditto for x86.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas 68f3886460 swscale/ops_dispatch: split off compile/dispatch code from ops.c
This code is self-contained and logically distinct from the ops-related
helpers in ops.c, so it belongs in its own file.

Purely cosmetic; no functional change.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas 4178c4d430 swscale/ops: remove unneeded macro
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas 5384908e56 swscale/ops: move pass compilation logic to helper function
Purely cosmetic.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Ramiro Polla 493dfc356f swscale/swscale_internal: fix typos in flag names 2026-03-05 20:38:55 +01:00
Kacper Michajłow 6e322fa582 configure: warn about excessive stack usage
Use a 120 KiB per-function threshold. This roughly matches the default
thread stack size on Musl, which is 128 KiB, leaving some headroom for
caller frames.

This warning draws attention to functions in the codebase that may have
excessively large stack frames. A few functions could benefit from
reducing their frame size.

120 KiB is a reasonable limit. If a function requires more stack, it
likely would benefit from restructuring the code.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-05 16:02:04 +00:00
Alexandru Ardelean 3291afd30f libavutil: hwcontext_amf: remove unreachable statements
Inside the amf_device_derive() function, there seem to be some
unreachable 'break' statements, which can be removed.
And also the final 'return 0' statement will also be unreachable
especially since there is a default case in the switch block.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
2026-03-05 15:42:00 +00:00
IndecisiveTurtle cebe0b577e lavc: implement a Vulkan-based prores encoder
Adds a vulkan implementation of the reference prores kostya encoder. Provides about 3-4x speedup over the CPU code
2026-03-05 14:02:39 +00:00
IndecisiveTurtle 576de002e5 lavc: Split out common components used by vulkan prores encoder 2026-03-05 14:02:39 +00:00
Nicolas Gaullier fe86fd07d3 fftools/ffprobe: do not show refs when not processing frames
refs does not belong to AVCodecParameters, so require a decoder:
it should only be showed when frames are actually processed by ffprobe.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-03-05 13:49:59 +00:00
James Almer 77298c29bc avformat/mov: check return value of mov_read_iref_cdsc()
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-05 09:57:28 -03:00
Martin Storsjö 74cfcd1c69 aarch64/vvc: Fix DCE undefined references with MSVC
This fixes compiling with MSVC for aarch64 after
510999f6b0.

While MSVC does do dead code elimintation for function references
within e.g. "if (0)", it doesn't do that for functions referenced
within a static function, even if that static function itself ends
up not used.

A reproduction example:

    void missing(void);
    void (*func_ptr)(void);

    static void wrapper(void) {
        missing();
    }

    void init(int cpu_flags) {
        if (0) {
            func_ptr = wrapper;
        }
    }

If "wrapper" is entirely unreferenced, then MSVC doesn't produce
any reference to the symbol "missing". Also, if we do
"func_ptr = missing;" then the reference to missing also is
eliminated. But for the case of referencing the function in a
static function, even if the reference to the static function can
be eliminated, then MSVC does keep the reference to the symbol.
2026-03-05 11:57:40 +02:00
James Almer f10c0ae276 avformat/mov: Fix multiple issues related to mov_read_iref_dimg()
forward errors and cleanup in teh failure cases

Fixes: freeing uninitialized pointers
Fixes: 487160965/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6525162874011648

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-05 02:43:30 +00:00
Michael Niedermayer cbbe68fb1a avcodec/snowenc: avoid NULL ptr arithmetic
Fixes: applying non-zero offset 16 to null pointer
Fixes: 471614378/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5967030642868224

Note: FF_PTR_ADD() does not work as this code has NULL + 123 cases where the pointer is unsused afterwards

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-05 01:23:40 +01:00
Zuoqiang He 1fc7464cf7 libavcodec/huffyuvdsp: Add NEON optimization for the add_int16 function
Benchmark Results (1024 iterations, Raspberry Pi 5 - Cortex-A76):
add_int16_128_c:                                       914.0 ( 1.00x)
add_int16_128_neon:                                    516.9 ( 1.77x)
add_int16_rnd_width_c:                                 914.0 ( 1.00x)
add_int16_rnd_width_neon:                              517.5 ( 1.77x)

Co-Authored-By: Martin Storsjö <martin@martin.st>
2026-03-04 22:31:19 +00:00
Martin Storsjö 8324c8ea89 checkasm: ac3dsp: Increase the float tolerance for sum_square_butterfly_float
Accept up to 15 ULP difference.

This fixes running "checkasm --test=ac3dsp <seed>" for the seeds
2043066705, 24168 and 111972 on ARM, and the seeds 40552 and
209754 on aarch64.

This is the same change as 8e4c904c8e,
increasing the tolerance further.

With this change, checkasm passes for over 500 000 seeds on both
ARM and aarch64.
2026-03-04 22:30:40 +00:00
Georgii Zagoruiko 510999f6b0 aarch64/vvc: sme2 optimisation of alf_filter_luma() 8/10/12 bit
Apple M4:
vvc_alf_filter_luma_8x8_8_c:                           347.3 ( 1.00x)
vvc_alf_filter_luma_8x8_8_neon:                        138.7 ( 2.50x)
vvc_alf_filter_luma_8x8_8_sme2:                        134.5 ( 2.58x)
vvc_alf_filter_luma_8x8_10_c:                          299.8 ( 1.00x)
vvc_alf_filter_luma_8x8_10_neon:                       129.8 ( 2.31x)
vvc_alf_filter_luma_8x8_10_sme2:                       128.6 ( 2.33x)
vvc_alf_filter_luma_8x8_12_c:                          293.0 ( 1.00x)
vvc_alf_filter_luma_8x8_12_neon:                       126.8 ( 2.31x)
vvc_alf_filter_luma_8x8_12_sme2:                       126.3 ( 2.32x)
vvc_alf_filter_luma_16x16_8_c:                        1386.1 ( 1.00x)
vvc_alf_filter_luma_16x16_8_neon:                      560.3 ( 2.47x)
vvc_alf_filter_luma_16x16_8_sme2:                      540.1 ( 2.57x)
vvc_alf_filter_luma_16x16_10_c:                       1200.3 ( 1.00x)
vvc_alf_filter_luma_16x16_10_neon:                     515.6 ( 2.33x)
vvc_alf_filter_luma_16x16_10_sme2:                     531.3 ( 2.26x)
vvc_alf_filter_luma_16x16_12_c:                       1223.8 ( 1.00x)
vvc_alf_filter_luma_16x16_12_neon:                     510.7 ( 2.40x)
vvc_alf_filter_luma_16x16_12_sme2:                     524.9 ( 2.33x)
vvc_alf_filter_luma_32x32_8_c:                        5488.8 ( 1.00x)
vvc_alf_filter_luma_32x32_8_neon:                     2233.4 ( 2.46x)
vvc_alf_filter_luma_32x32_8_sme2:                     1093.6 ( 5.02x)
vvc_alf_filter_luma_32x32_10_c:                       4738.0 ( 1.00x)
vvc_alf_filter_luma_32x32_10_neon:                    2057.5 ( 2.30x)
vvc_alf_filter_luma_32x32_10_sme2:                    1053.6 ( 4.50x)
vvc_alf_filter_luma_32x32_12_c:                       4808.3 ( 1.00x)
vvc_alf_filter_luma_32x32_12_neon:                    1981.2 ( 2.43x)
vvc_alf_filter_luma_32x32_12_sme2:                    1047.7 ( 4.59x)
vvc_alf_filter_luma_64x64_8_c:                       22116.8 ( 1.00x)
vvc_alf_filter_luma_64x64_8_neon:                     8951.0 ( 2.47x)
vvc_alf_filter_luma_64x64_8_sme2:                     4225.2 ( 5.23x)
vvc_alf_filter_luma_64x64_10_c:                      19072.8 ( 1.00x)
vvc_alf_filter_luma_64x64_10_neon:                    8448.1 ( 2.26x)
vvc_alf_filter_luma_64x64_10_sme2:                    4225.8 ( 4.51x)
vvc_alf_filter_luma_64x64_12_c:                      19312.6 ( 1.00x)
vvc_alf_filter_luma_64x64_12_neon:                    8270.9 ( 2.34x)
vvc_alf_filter_luma_64x64_12_sme2:                    4245.4 ( 4.55x)
vvc_alf_filter_luma_128x128_8_c:                     88530.5 ( 1.00x)
vvc_alf_filter_luma_128x128_8_neon:                  35686.3 ( 2.48x)
vvc_alf_filter_luma_128x128_8_sme2:                  16961.2 ( 5.22x)
vvc_alf_filter_luma_128x128_10_c:                    76904.9 ( 1.00x)
vvc_alf_filter_luma_128x128_10_neon:                 32439.5 ( 2.37x)
vvc_alf_filter_luma_128x128_10_sme2:                 16845.6 ( 4.57x)
vvc_alf_filter_luma_128x128_12_c:                    77363.3 ( 1.00x)
vvc_alf_filter_luma_128x128_12_neon:                 32907.5 ( 2.35x)
vvc_alf_filter_luma_128x128_12_sme2:                 17018.1 ( 4.55x)
2026-03-04 23:52:58 +02:00
Georgii Zagoruiko 0edd75e150 aarch64/asm.S: to support SME added macro to save/restore registers d8-d16 2026-03-04 23:52:58 +02:00
Georgii Zagoruiko 905348df9d configure: add detection of SME-I16I64 extension 2026-03-04 23:52:57 +02:00
Georgii Zagoruiko 70691bbb27 configure: add detection of assembler support for SME2 2026-03-04 23:52:36 +02:00
Martin Storsjö a0d23706e8 aarch64: Switch to a more correct Windows flag for detecting I8MM
Newer revisions of WinSDK 10.0.26100.0 have exposed more flags for
IsProcessorFeaturePresent; now there is a separate one for
detecting specifically I8MM and not just SVE-I8MM. Switch to using
this flag instead.
2026-03-04 21:46:18 +00:00
zhanghongyuan e686f53424 fftools/ffplay: improve keyboard shortcut documentation
Clarify the behavior of seek keyboard shortcuts in both the
documentation and command-line help text. Specifically:
- left/right: mention custom interval option support
- page down/up: improve wording for chapter seeking fallback
2026-03-04 21:30:40 +00:00
Tong Wu 5b8a4a0e14 avcodec/d3d12va_encode_h264: simplify deblock default option
The deblocking filter is enabled by default. This behavior is the same
as priv->deblock == 1.

Signed-off-by: Tong Wu <wutong1208@outlook.com>
2026-03-04 14:25:00 +00:00
Georgii Zagoruiko 90431417cb aarch64/vvc: Optimisations of put_luma_hv() functions for 10/12-bit
Apple M2:
put_luma_hv_10_4x4_c:                                   36.3 ( 1.00x)
put_luma_hv_10_8x8_c:                                   82.9 ( 1.00x)
put_luma_hv_10_8x8_neon:                                34.9 ( 2.37x)
put_luma_hv_10_16x16_c:                                239.2 ( 1.00x)
put_luma_hv_10_16x16_neon:                             119.0 ( 2.01x)
put_luma_hv_10_32x32_c:                                900.3 ( 1.00x)
put_luma_hv_10_32x32_neon:                             429.3 ( 2.10x)
put_luma_hv_10_64x64_c:                               2984.7 ( 1.00x)
put_luma_hv_10_64x64_neon:                            1736.2 ( 1.72x)
put_luma_hv_10_128x128_c:                            11194.2 ( 1.00x)
put_luma_hv_10_128x128_neon:                          6357.3 ( 1.76x)
put_luma_hv_12_4x4_c:                                   35.9 ( 1.00x)
put_luma_hv_12_8x8_c:                                   82.6 ( 1.00x)
put_luma_hv_12_8x8_neon:                                34.3 ( 2.41x)
put_luma_hv_12_16x16_c:                                240.2 ( 1.00x)
put_luma_hv_12_16x16_neon:                             115.3 ( 2.08x)
put_luma_hv_12_32x32_c:                                787.7 ( 1.00x)
put_luma_hv_12_32x32_neon:                             414.2 ( 1.90x)
put_luma_hv_12_64x64_c:                               3058.4 ( 1.00x)
put_luma_hv_12_64x64_neon:                            1592.3 ( 1.92x)
put_luma_hv_12_128x128_c:                            11350.8 ( 1.00x)
put_luma_hv_12_128x128_neon:                          6378.3 ( 1.78x)

RPi4:
put_luma_hv_10_4x4_c:                                  637.8 ( 1.00x)
put_luma_hv_10_8x8_c:                                 1044.9 ( 1.00x)
put_luma_hv_10_8x8_neon:                               483.7 ( 2.16x)
put_luma_hv_10_16x16_c:                               3098.0 ( 1.00x)
put_luma_hv_10_16x16_neon:                            1603.1 ( 1.93x)
put_luma_hv_10_32x32_c:                              10054.8 ( 1.00x)
put_luma_hv_10_32x32_neon:                            5843.6 ( 1.72x)
put_luma_hv_10_64x64_c:                              40506.2 ( 1.00x)
put_luma_hv_10_64x64_neon:                           24384.0 ( 1.66x)
put_luma_hv_10_128x128_c:                           130604.2 ( 1.00x)
put_luma_hv_10_128x128_neon:                         99746.6 ( 1.31x)
put_luma_hv_12_4x4_c:                                  638.2 ( 1.00x)
put_luma_hv_12_8x8_c:                                 1074.6 ( 1.00x)
put_luma_hv_12_8x8_neon:                               482.6 ( 2.23x)
put_luma_hv_12_16x16_c:                               3094.0 ( 1.00x)
put_luma_hv_12_16x16_neon:                            1602.5 ( 1.93x)
put_luma_hv_12_32x32_c:                              10034.4 ( 1.00x)
put_luma_hv_12_32x32_neon:                            5843.3 ( 1.72x)
put_luma_hv_12_64x64_c:                              40447.5 ( 1.00x)
put_luma_hv_12_64x64_neon:                           24377.2 ( 1.66x)
put_luma_hv_12_128x128_c:                           130610.4 ( 1.00x)
put_luma_hv_12_128x128_neon:                         99765.8 ( 1.31x)
2026-03-04 12:53:16 +00:00
Niklas Haas cef2fbfd4b swscale/vulkan: fix include order (cosmetic)
Non-local includes before local includes.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-04 12:04:12 +01:00
Niklas Haas 1512e52cb4 swscale: switch to refstruct for hw_priv
This is a bit more forward-facing than a bare allocation, and importantly,
allows the `swscale/utils.c` code to remain agnostic about how to correctly
uninit this struct.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-04 12:04:09 +01:00
Niklas Haas 5b39be1f0a swscale: fix build on --disable-unstable
By excluding the Vulkan makefile entirely when --disable-unstable is passed.
This also correctly avoids compiling e.g. unused GLSL compilers.

Fixes: #22295
See-Also: #22366

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-04 11:53:10 +01:00
zengshuang 9d73d10c50 avformat,avcodec: use PRI format macros for uint32_t in log messages
Use PRIu32/PRIX32 format specifiers instead of %d/%u/%X for uint32_t
variables in av_log calls. On some platforms (e.g. NuttX), uint32_t is
typedef'd as unsigned long rather than unsigned int, which triggers
-Wformat warnings despite both types being 4 bytes. Using PRI macros
is the portable way to match the actual underlying type of uint32_t.

Signed-off-by: zengshuang <zengshuang@xiaomi.com>
2026-03-04 10:40:12 +00:00
David Christle 2c7fe8d8ad swscale/aarch64: add NEON rgb32tobgr24 and rgb24tobgr32 conversions
Add NEON alpha drop/insert using ldp+tbl+stp instead of ld4/st3 and
ld3/st4 structure operations. Both use a 2-register sliding-window
tbl with post-indexed addressing. Instruction scheduling targets
narrow in-order cores (A55) while remaining neutral on wide OoO.

Scalar tails use coalesced loads/stores (ldr+strh+lsr+strb for alpha
drop, ldrh+ldrb+orr+str for alpha insert) to reduce per-pixel
instruction count. Independent instructions placed between loads and
dependent operations to fill load-use latency on in-order cores.

checkasm --bench on Apple M3 Max (decicycles, 1920px):
  rgb32tobgr24_c:    114.4 ( 1.00x)
  rgb32tobgr24_neon:  64.3 ( 1.78x)
  rgb24tobgr32_c:    128.9 ( 1.00x)
  rgb24tobgr32_neon:  80.9 ( 1.59x)

C baseline is clang auto-vectorized; speedup is over compiler NEON.

Signed-off-by: David Christle <dev@christle.is>
2026-03-04 10:30:08 +00:00
David Christle 86a62388cc tests/checkasm: add rgb32tobgr24 and rgb24tobgr32 tests
Add checkasm coverage for rgb32tobgr24 (alpha drop) and rgb24tobgr32
(alpha insert) with test widths exercising all code tiers and
overwrite detection via sentinel bytes.

Signed-off-by: David Christle <dev@christle.is>
2026-03-04 10:30:08 +00:00
David Christle ddd720ae61 swscale/aarch64: add NEON rgb24tobgr24 byte-swap
Add a NEON rgb24tobgr24 using ld3/st3 to swap R and B channels in
packed 24bpp RGB buffers. Handles all input sizes with a 16-pixel
NEON fast path, 8-pixel NEON cleanup, and scalar tail.

checkasm --bench on Apple M3 Max (1920*3 = 5760 bytes):
  rgb24tobgr24_c:    722.0 ( 1.00x)
  rgb24tobgr24_neon:  94.9 ( 7.61x)

Signed-off-by: David Christle <dev@christle.is>
2026-03-04 10:30:08 +00:00
David Christle 78f6cec1b4 tests/checkasm: add rgb24tobgr24 test
Add checkasm coverage for rgb24tobgr24 with test widths exercising
all code tiers (scalar, 8-pixel NEON, 16-pixel NEON).

Signed-off-by: David Christle <dev@christle.is>
2026-03-04 10:30:08 +00:00
Michael Niedermayer 8d3b044f84 avformat/mov: check for duplicate stsd before changing state
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-04 10:17:35 +00:00
Niklas Haas 613925a96e avformat/http: fix Cache-Control header parsing
This was calling atoi() on `p + offset`, which is nonsense (p may point to
the start of the cache-control string, which does not necessarilly coincide
with the location of the max-age value). Based on the code, the intent
was clearly to parse the value *after* the matched substring.
2026-03-04 08:49:53 +00:00
Niklas Haas 7a348f662d avformat/http: close stale connection on wrong seek
If http_seek_internal() gives us an unexpected position, we should
close the connection to avoid leaking reading incorrect bytes on subsequent
reads.
2026-03-04 08:49:53 +00:00
Niklas Haas fcc1a03a0e avformat/http: move retry label (cosmetic)
Move this closer to the corresponding `goto`. From the PoV of the control
flow, these placements are completely identical.
2026-03-04 08:49:53 +00:00
Niklas Haas 142d999fda avformat/http: restore offset on http_open_cnx() failure
The retry path restores this offset, but the failure path does not. This
is especially important for the case of the continuation handler in
http_read_stream(), which may result in subsequent loop iterations (after
repeated failures to read additional data) seeking to the wrong offset.
2026-03-04 08:49:53 +00:00
Niklas Haas f5ddf1c4a8 avformat/http: fix http_connect() offset mismatch error code
This (arbitrarily) returns -1, which happens to be AVERROR(EPERM) on my
machine. Return the more descriptive AVERORR(EIO) instead.

Also add a log message to explain what's going on.
2026-03-04 08:49:53 +00:00
Niklas Haas fb7558dcb0 avformat/http: avoid int overflow
This was meant to accumulate int64_t timestamp values.

Fixes: b8daba42cd
2026-03-04 08:49:53 +00:00
Niklas Haas 0540b42657 swscale/graph: correctly handle single threaded mode
The code was evidently designed at one point in time to support "direct"
execution (not via a thread pool) for num_threads == 1, but this was never
implemented.

As a side benefit, reduces context creation overhead in single threaded
mode (relevant e.g. inside the libswscale self test), due to not needing to
spawn and destroy several thousand worker threads.

Co-authored-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-03 23:13:41 +00:00
Shreesh Adiga 22d484f498 avutil/cpu: add static CPU feature flag for AArch64 CRC32 2026-03-03 21:38:00 +00:00
AnandajithS 04fe98482a libswscale/utils: prevent division by zero for chroma width 8 2026-03-03 17:38:01 +00:00
James Almer 264283bd0a avcodec/av1_parser: also decompose Redundant Frame Headers
Ensures samples where a missing Frame Header is handled by a subsequent
Redundant one are parsed correctly.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-03 13:52:58 -03:00
Andreas Rheinhardt 23a58c6c36 avcodec/h264dec,mpeg_er: Move allocating er buffers to ff_er_init()
(This also stops zero-allocating er_temp_buffer for H.264,
reverting back to the behavior from before commit
0a1dc817237b8546189960efd523257b4f62e1ab.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-03 13:07:46 +01:00
Andreas Rheinhardt 49e57c6c85 avcodec/error_resilience: Initialize error resilience context earlier
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-03 13:07:46 +01:00
James Almer 863c748144 avcodec/bsf/extract_extradata: remove extradata blocks from supported LCEVC NALUs
Given we rewrite these NALUs to remove the encoded data blocks to export as extradata,
we need to do the inverse to remove SC, GC and AI blocks to export as filtered data in
packes.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-03 09:05:45 -03:00
James Almer 3607a10dc3 avcodec/bsf/extract_extradata: simplify a switch statement
And use named defines. Will come in handy the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-03 09:05:45 -03:00
James Almer c893117048 avcodec/bsf/extract_extradata: fix writing filtered LCEVC NALUs when removing extradata
write_lcevc_nalu() is meant only for IDR and NON_IDR NALUs. For everything else, just
copy it unchanged.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-03 09:05:45 -03:00
Jun Zhao 7e7d69632d lavc/hevc: optimize qpel H-pass for width>=16 with byte-domain widening multiply
Rewrite ff_hevc_put_hevc_qpel_h16_8_neon and h32 to use byte-domain
widening multiply (umull/umlal/umlsl via calc_qpelb/calc_qpelb2 macros)
instead of the previous int16-domain approach (uxtl + mul/mla).

The byte-domain approach eliminates the uxtl expansion step and halves
the ext stride (1 byte vs 2 bytes per tap), reducing per-row instruction
count from ~32 to ~23. The functions are also inlined, removing bl/ret
call overhead.

This benefits all HV-path callers (hv/uni_hv/bi_hv/uni_w_hv/bi_w_hv)
at widths 16/32/48/64.

checkasm benchmarks on Apple M4 (5-run average):

  H-pass standalone (NEON):
    h16:  34.0 -> 24.4 cycles (1.39x speedup)
    h32: 132.0 -> 95.0 cycles (1.39x speedup)
    h64: 521.8 -> 373.9 cycles (1.40x speedup)

  HV compound paths geometric mean speedup (NEON, width >= 16):
    qpel_hv:      1.144x (4 functions)
    qpel_bi_hv:   1.158x (4 functions)
    qpel_uni_hv:  1.188x (4 functions)
    qpel_uni_w_hv: 1.158x (3 functions)
    Overall:       1.162x (15 functions)

VVC qpel h16/h32 are separated into self-contained functions retaining
the int16-domain approach, as VVC filters have arbitrary coefficients
incompatible with the hardcoded sign pattern in calc_qpelb.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-03 12:04:14 +00:00
Jun Zhao 23b7005d98 lavc/vvc: remove duplicate 'mov mx, x30' in VVC qpel h16/h32
The VVC qpel h16 and h32 functions had a redundant 'mov mx, x30'
instruction. The first one was placed before vvc_load_filter had
finished using mx (the filter pointer argument), making it a dead
store immediately overwritten by the second 'mov mx, x30'.

Remove the first instance and reorder so that 'sub src, src, #3'
comes before 'mov mx, x30', ensuring the filter pointer in mx is
fully consumed by vvc_load_filter before being overwritten with the
link register.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-03 12:04:14 +00:00
Michael Niedermayer e392fb8c9c avformat/mov: use 64bit in CENC subsample bounds checks
Found-by: Quang Luong <oss@engineer.ink>
Found-by: PrymEvol
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 11:49:10 +00:00
Michael Niedermayer 5554d9d555 avutil/eval: Store *prng_state / var only in root AVExpr
AFter this, depth and the root element flag is stored in space
needed for alignment and thus does not increase the AVExpr size

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 03:28:37 +01:00
Michael Niedermayer 1528ccb6a1 avutil/eval: use anonymous union
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 03:28:37 +01:00
Michael Niedermayer ed5040e6f5 avutil/eval: Check depth of AVExpr
we already check the depth of the parser but the AVExpr tree differs

Fixes: stack exhaustion
Fixes: YWH-PGM40646-39

Found-by: jpraveenrao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 03:28:37 +01:00
Michael Niedermayer 32e4ddeda3 avformat/vividas: Reset n_audio_subpackets on error
Fixes: signed integer overflow: -63 - 2147483594 cannot be represented in type 'int'
Fixes: 486530208/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-4694818252193792

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 03:28:03 +01:00
Michael Niedermayer 87c371e2ff avcodec/vp9: Fix memleak
Fixes: 485523353/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP9_fuzzer-4582329227214848

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 02:13:58 +00:00
Michael Niedermayer a4d40f853a avformat/matroskadec: Check that end_time_ns >= start_time_ns
Fixes: signed integer overflow: -8659510451449931520 - 2205846422852077376 cannot be represented in type 'int64_t' (aka 'long')
Fixes: 486358507/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-4896911086911488

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 02:41:56 +01:00
Michael Niedermayer 228b846407 avcodec/vp3: Sanity check cropping
Fixes: Timeout
Fixes: 476179563/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-5231013478596608

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 02:41:05 +01:00
Michael Niedermayer 65fd516768 avcodec/adpcm: handle ADPCM_IMA_MAGIX like other similar codecs
Fixes: out of array access
Fixes: 471509958/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_MAGIX_DEC_fuzzer-4847227777646592

We ask for a mono sample because the implementation for mono is incomplete

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 01:10:09 +01:00
Michael Niedermayer 927ae7a0d5 avformat/dhav: Check avio_seek() return
Fixes: infinite loop
Fixes: 472567148/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-4520943574908928

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 01:04:37 +01:00
Michael Niedermayer b2f1657087 avformat/segafilm: dont read uninitialized value
scratch[20] doesnt exist in version 0

Fixes: use of uninitialized memory
Fixes: 471664627/clusterfuzz-testcase-minimized-ffmpeg_dem_SEGAFILM_fuzzer-4738726971637760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2026-03-03 00:48:38 +01:00
Michael Niedermayer 8eecba02c7 avcodec/mpegvideo_enc: Restructure ff_h263_encode_gob_header() relation to update_mb_info()
Fixes: out of array access

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 00:47:21 +01:00
Michael Niedermayer c5ccc13fe0 avcodec/exr: check tile_attr.x/ySize
Fixes: division by zero
Fixes: 473579863/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_DEC_fuzzer-5105281257504768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 00:35:35 +01:00
Michael Niedermayer fa2aec73ed avcodec/jpeg2000dec: fix integer overflow in dequantization_int_97()
Fixes: signed integer overflow: 2147483640 + 32 cannot be represented in type 'int'
Fixes: 473569764/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_DEC_fuzzer-5377306970619904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 00:35:21 +01:00
stevxiao 8429aec5e4 avfilter: add d3d12 deinterlace filter deinterlace_d3d12
This commit introduces a video filter `deinterlace_d3d12` that provides
hardware-accelerated deinterlacing using the D3D12 Video Processor.

The filter supports:
 - bob and custom (motion-adaptive)deinterlace modes
 - frame-rate and field-rate output
 - automatic interlace detection

Sample command lines:

1. Software decode with hwupload:

    ffmpeg -init_hw_device d3d12va=d3d12 -i interlaced.ts \
      -vf "format=nv12,hwupload,deinterlace_d3d12=mode=default,hwdownload,format=nv12" \
      -c:v libx264 output.mp4

2. Full hardware pipeline:

    ffmpeg -hwaccel d3d12va -hwaccel_output_format d3d12 -i interlaced.ts \
      -vf "deinterlace_d3d12=mode=custom:rate=field" \
      -c:v h264_d3d12va output.mp4

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-03-02 16:59:32 -05:00
Andreas Rheinhardt 576d5aaf5d configure: Remove vf_spp->me_cmp dependency
It is not used for anything. In fact, me_cmp is not exported at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-02 21:53:48 +01:00
Michael Niedermayer 0465a9bb8f avformat/demux: Fix integer overflows in select_from_pts_buffer()
Fixes: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long long'); cast to an unsigned type to negate this value to itself
Fixes: 473334102/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-5109540931829760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 19:04:26 +01:00
Michael Niedermayer 09ab2d18ed avcodec/snowdec: fix mconly
Fixes non repeatable checksums

This also avoids allocating the mc only buffer when its not used

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 19:01:46 +01:00
Michael Niedermayer fb3012269e avcodec/golomb: Fix get_ur_golomb_jpegls() with esclen = 0
If there is no escape case then reaching that branch is an error

Fixes: shift exponent 32 is too large for 32-bit type 'uint32_t' (aka 'unsigned int')
Fixes: 472335543/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DST_fuzzer-6682453243920384

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 18:41:13 +01:00
Michael Niedermayer bdea5aec2d avcodec/jpeg2000dec: Handle M_b = -1
Fixes: runtime error: shift exponent -1 is negative
Fixes: runtime error: shift exponent 32 is too large for 32-bit type 'int'
Fixes: 471846062/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_DEC_fuzzer-5835290976780288

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 18:12:40 +01:00
Michael Niedermayer 17cad7ac75 swresample/resample_template: add casts to avoid undefined overflows
resample_linear can produce overflows with craftet input,
The added casts should have no effect on the binary output or the operations they
just change things to a defined regime

Fixes: signed integer overflow: 2069416960 + 78151680 cannot be represented in type 'int'
Fixes: 472047214/clusterfuzz-testcase-minimized-ffmpeg_SWR_fuzzer-6374046976770048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 18:11:58 +01:00
Michael Niedermayer 30a6b78bd4 avcodec/h264_parser: Check pts for overflow
Fixes: signed integer overflow: 9223372036854775807 + 3546086691638400 cannot be represented in type 'int64_t' (aka 'long')
Fixes: 471723681/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-4841032488648704

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 17:51:45 +01:00
Michael Niedermayer 0c7e0ed35b avcodec/adpcm: fix integer overflow in N64
Fixes: signed integer overflow: 1077919680 + 1077936128 cannot be represented in type 'int'
Fixes: 471686763/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_N64_DEC_fuzzer-6493712281829376

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 17:49:23 +01:00
Michael Niedermayer 92f8dd1ea1 tests/fate/mov: add quotes to some map arguments
Fixes failures for the tests/data/mov-mp4-iamf-7_1_4-video-first.mp4 target on some systems.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-02 13:05:18 -03:00
Raja-89 27cdf70086 avfilter/dnn: implement asynchronous execution for LibTorch backend
This patch implements the DNNAsyncExecModule for the LibTorch backend,
enabling non-blocking inference using the common infrastructure instead
of custom threading (th_async_module_submit) to align with the
TensorFlow and OpenVINO backends.

The implementation uses ff_dnn_start_inference_async which provides
unified async logic across all DNN backends, eliminating the need for
backend-specific threading code.

Verified with:
  ffmpeg -f lavfi -i testsrc=duration=5:size=320x240:rate=30 -vf dnn_processing=dnn_backend=torch:model=model.pt -y output.mp4

Signed-off-by: Raja Rathour <imraja729@gmail.com>
2026-03-02 21:35:17 +08:00
David Christle 8f567d5cab tests/checkasm/sw_yuv2rgb: test multi-row conversion with padded strides
Increase test height from 2 to 4 rows and add 32 bytes of source stride
padding. This exercises chroma row sharing across multiple luma row pairs
in YUV420P and the stride increment arithmetic in SIMD implementations,
both of which were previously untested.

Signed-off-by: David Christle <dev@christle.is>
2026-03-02 13:14:07 +00:00
David Christle 7fab0becab swscale/aarch64: add NEON YUV420P/YUV422P/YUVA420P to RGB conversion
Add ARM64 NEON-accelerated unscaled YUV-to-RGB conversion for planar
YUV input formats. This extends the existing NV12/NV21 NEON paths with
YUV420P, YUV422P, and YUVA420P support for all packed RGB output
formats (ARGB, RGBA, ABGR, BGRA, RGB24, BGR24) and planar GBRP.

Register with ff_yuv2rgb_init_aarch64() to also cover the scaled path.

checkasm: all 42 sw_yuv2rgb tests pass.
Speedup vs C at 1920px width (Apple M3 Max, avg of 20 runs):
  yuv420p->rgb24:   4.3x    yuv420p->argb:   3.1x
  yuv422p->rgb24:   5.5x    yuv422p->argb:   4.1x
  yuva420p->argb:   3.5x    yuva420p->rgba:  3.5x

Signed-off-by: David Christle <dev@christle.is>
2026-03-02 13:14:07 +00:00
David Christle 8e591af32b swscale/loongarch: fix LASX YUV2RGB residual for multi-row slices
The res variable (pixel residual count for widths not divisible by 16)
is computed once before the row loop, but DEALYUV2RGBLINERES and
DEALYUV2RGBLINERES32 destructively subtract 8 from it inside the loop
body. When srcSliceH > 2, subsequent row pairs get an incorrect
residual count, producing wrong output for the tail pixels.

Fix by recomputing res from the constant c->opts.dst_w at the top of
each row-pair iteration.

Signed-off-by: David Christle <dev@christle.is>
2026-03-02 13:14:07 +00:00
James Almer 40e60a7db0 tests/fate/mov: add tests to demux specific streams within a IAMF Track
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-02 09:28:36 -03:00
Andreas Rheinhardt 5315d12139 avcodec/encode: Don't issue emms after encode callback
It is no longer necessary: Most encoders don't use any MMX code
at all any more and the ones that do issue emms on their own.
Instead add an ff_asser1_fpu() to check that it stays that way.

To add some more information, only the halfpel (and fullpel),
qpel and motion estimation APIs use MMX in addition to the
SBC and Snow specific dsp code. halfpel is used by the
mpegvideo encoders, SVQ1 and Snow encoders. The same
encoders in addition to the AC-3 ones and dvvideo use me_cmp.
qpel is only used by the MPEG4 encoder which is part of
mpegvideo. None of these codecs need the generic emms_c (even on
errors):

a) The AC-3 encoders only use a width 16 me_cmp function which
can no longer use MMX since d91b1559e0.
b) dvvideo and SBC emit emms on their own and have no error paths
after the start of the part that can use MMX.
c) SVQ1 calls emms_c() on its own, even on all error paths
that need it.
d) Snow calls emms_c() on its ordinary (success) return path;
it has only one error path in the part of the code that uses MMX,
but even it is fine as ratecontrol_1pass() always calls emms_c()
itself.
e) For mpegvideo, the MMX code is almost confined to the part
of the code reachable from the worker threads (if slice threading
is in use). The exception to this is in skip_check() which always
calls emms_c() itself. Because encode_picture() always calls
emms_c() itself after executing the worker threads and before any
error condition, the floating point state is clean upon exit from
encode_picture().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-02 12:01:15 +01:00
Andreas Rheinhardt ac46514327 avutil/emms: Add ff_assert[01]_fpu()
These will be used to mark and check parts of the code
where the floating point state is supposed to be not
clobbered. They are an improvement on the (deprecated)
av_assert0_fpu() because of proper file and line number
information; they also reset the floating point state
if the assert is actually triggered.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-02 11:55:30 +01:00
Andreas Rheinhardt 7763155395 avcodec/snowenc: Add emms_c before allocations
Needed for the allocations in ff_snow_common_init_after_header()
(as well as for calculate_visual_weight() if
spatial_decomposition_count could change).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-02 11:55:30 +01:00
Andreas Rheinhardt bd481ac6c1 avcodec/mpegvideo_enc: Remove redundant emms_c
It is unnecessary since d91b1559e0
(before that the sad_cmp[0] call in get_intra_count() may
have clobbered the floating point state without cleaning it up
itself).

Also remove some commented out emms_c from places where
the floating point state is guaranteed not to have been clobbered
by us.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-02 11:55:30 +01:00
Andreas Rheinhardt 862338fe31 swscale/rgb2rgb: Remove set-but-unused functions
yuy2toyv12, vu9_to_vu12 and yvu9_to_yuy2 are unused. Removing
them saved 7808B of .text and 102B of .text.unlikely
as well as 24B of .bss here.
Thanks to James Almer for pointing out that yuy2toyv12 is unused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 23:45:11 +00:00
Andreas Rheinhardt ecd11abcc9 swscale/rgb2rgb_template: Remove unused uyvytoyv12_c()
Added in 81c0590e6c,
but it seems to have always been unused.
See also 5421dee0e7.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 23:45:11 +00:00
Niklas Haas 5375cfd9c7 swscale/vulkan/ops: fix typo
Checks src.interlaced twice.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-01 21:57:53 +00:00
Niklas Haas b2266d6656 swscale/graph: correctly adjust field height for interlaced frames
This is a pre-existing bug from 67f3627267.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-01 21:57:53 +00:00
Niklas Haas 02e4b45f7f swscale/graph: reintroduce SwsFrame
AVFrame just really doesn't have the semantics we want. However, there a
tangible benefit to having SwsFrame act as a carbon copy of a (subset of)
AVFrame.

This partially reverts commit 67f3627267.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-01 21:57:53 +00:00
Andreas Rheinhardt 561f37c023 avcodec/x86/huffyuvencdsp_init: Remove pointless av_unused
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 12:04:14 +01:00
Andreas Rheinhardt d345e902d2 avcodec/x86/huffyuvencdsp: Remove MMX sub_hfyu_median_pred_int16
Superseded by SSE2 and AVX2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 12:04:14 +01:00
Andreas Rheinhardt 154bcd1054 avcodec/x86/huffyuvencdsp: Add AVX2 sub_hfyu_median_pred_int16
This version can also process 16bpp.

Benchmarks:
sub_hfyu_median_pred_int16_9bpp_c:                   12667.7 ( 1.00x)
sub_hfyu_median_pred_int16_9bpp_mmxext:               1966.5 ( 6.44x)
sub_hfyu_median_pred_int16_9bpp_sse2:                  997.6 (12.70x)
sub_hfyu_median_pred_int16_9bpp_avx2:                  474.8 (26.68x)
sub_hfyu_median_pred_int16_9bpp_aligned_c:           12604.6 ( 1.00x)
sub_hfyu_median_pred_int16_9bpp_aligned_mmxext:       1964.6 ( 6.42x)
sub_hfyu_median_pred_int16_9bpp_aligned_sse2:          981.9 (12.84x)
sub_hfyu_median_pred_int16_9bpp_aligned_avx2:          462.6 (27.25x)
sub_hfyu_median_pred_int16_16bpp_c:                  12592.5 ( 1.00x)
sub_hfyu_median_pred_int16_16bpp_avx2:                 465.6 (27.04x)
sub_hfyu_median_pred_int16_16bpp_aligned_c:          12587.5 ( 1.00x)
sub_hfyu_median_pred_int16_16bpp_aligned_avx2:         462.5 (27.22x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 12:04:14 +01:00
Andreas Rheinhardt e575c2d496 avcodec/x86/huffyuvencdsp: Add SSE2 sub_hfyu_median_pred_int16
Contrary to the MMXEXT version this version does not overread at all
(the MMXEXT version processes the input of 2*w bytes in eight byte
chunks and overreads by a further six bytes, because it loads
the next left and left top values at the end of the loop,
i.e. it reads FFALIGN(2*w,8)+6 bytes instead of 2*w).

Benchmarks:
sub_hfyu_median_pred_int16_9bpp_c:                   12673.6 ( 1.00x)
sub_hfyu_median_pred_int16_9bpp_mmxext:               1947.7 ( 6.51x)
sub_hfyu_median_pred_int16_9bpp_sse2:                  993.9 (12.75x)
sub_hfyu_median_pred_int16_9bpp_aligned_c:           12596.1 ( 1.00x)
sub_hfyu_median_pred_int16_9bpp_aligned_mmxext:       1956.1 ( 6.44x)
sub_hfyu_median_pred_int16_9bpp_aligned_sse2:          989.4 (12.73x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 12:03:55 +01:00
Andreas Rheinhardt 6834762d7b avcodec/huffyuvencdsp: Add width parameter to init
This allows to only use certain functions using wide registers
if there is enough work to do and if one can even read a whole
register wide without overreading.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 11:58:16 +01:00
Andreas Rheinhardt 2b910f71bb tests/checkasm: Fix huffyuvdsp test criterion
Use CONFIG_HUFFYUVDSP, not CONFIG_HUFFYUV_DECODER
(although they are equivalent).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 11:56:57 +01:00
Andreas Rheinhardt fd44e277c8 tests/checkasm: Add huffyuvencdsp test
Only covers sub_hfyu_median_pred_int16 for now.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 11:56:57 +01:00
Andreas Rheinhardt 2268ba89f0 avcodec/huffyuvencdsp: Pass bpp, not AVPixelFormat for init
Avoids having to get a pixel format descriptor.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 11:56:57 +01:00
Andreas Rheinhardt 5de95f7731 avcodec/huffyuvenc: Mark unreachable code as such
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 11:56:57 +01:00
Andreas Rheinhardt 1fa48a8b5b avcodec/huffyuvenc: Calculate mask only once
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 11:56:57 +01:00
Jack Lau 80d5fb2ee9 avformat/whip: use av_dict_set_int() for payload_type and ssrc
Now WHIP can directly pass SSRC as UINT32 instead of
converting it as INT for match wrong rtpenc option
range Since 69568479a9.

And Converting SSRC from UINT32 to INT64 is safe to
pass by av_dict_set_int().

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-03-01 07:02:34 +00:00
Steven Liu 2559f263ea tests/fate/flvenc: add vvc in enhanced flv test case 2026-03-01 04:21:45 +00:00
Steven Liu 93be3e37db avformat/rtmpproto: add vvc1 string into enhanced_codecs list
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2026-03-01 04:21:45 +00:00
Steven Liu 0de45f556c avformat/flvdec: support demux vvc in enhanced flv
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2026-03-01 04:21:45 +00:00
Steven Liu 9ceb932c36 avformat/flvenc: support mux vvc in enhanced flv
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2026-03-01 04:21:45 +00:00
James Almer e869426a8c avcodec/bsf/extract_extradata: remove dead code
Applied accidentally in 3dba9eb806.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-28 19:42:06 -03:00
James Almer e245f4d5cf avcodec/bsf: add a LCEVC metadata bitstream filter
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-28 16:14:40 -03:00
James Almer 0390793dc3 avcodec/cbs: add support for LCEVC bitstreams
As defined in ISO/IEC 23094-2:2021/FDAM 1:2023

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-28 16:12:33 -03:00
James Almer 2d8c55b057 avcodec/h2645_parse: add support for LCEVC
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-28 16:12:33 -03:00
James Almer 3dba9eb806 avcodec/bsf/extract_extradata: add support for LCEVC
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-28 16:12:33 -03:00
Kacper Michajłow 4e32fb4c2a fftools/cmdutils: constify string
Fixes:
warning: initializing 'char *' with an expression of type 'const char *'
discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-28 13:42:01 +01:00
Weixie Cui 743df5ded9 avfilter/buffersink: use correct enum for alpha_modes
Signed-off-by: Weixie Cui <cuiweixie@gmail.com>
2026-02-28 12:13:02 +00:00
Andreas Rheinhardt f570fa787a swscale/swscale_internal: Move altivec parts to ppc/
Up until now, several altivec-specific fields are directly
put into SwsInternal #if HAVE_ALTIVEC is true. These fields
are of altivec-specific vector types and therefore
require altivec specific headers to be included.

Unfortunately, said altivec specific headers redefine
bool in a manner that is incompatible with stdbool.
swscale/ops.h uses bool and this led graph.c and ops.c
to disagree about the layout of structures from ops.h,
leading to heap corruption [1], [2] in the sws-unscaled
FATE test.

Fix this by moving the altivec-specific parts out of SwsInternal
and into a structure that extends SwsInternal and is allocated
jointly with it. Said structure is local to yuv2rgb_altivec.c,
because this is the only file accessing said fields. Should
more files need them, an altivec-specific swscale header would
need to be added.

Thanks to jfiusdq <jfiusdq@proton.me> for analyzing the issue.

[1]: https://fate.ffmpeg.org/report.cgi?slot=ppc64-linux-gcc-14.3-asan&time=20260224065643
[2]: https://fate.ffmpeg.org/report.cgi?slot=ppc64-linux-gcc-14.3&time=20260224051615

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-28 09:56:01 +01:00
Andreas Rheinhardt 76cb5691e8 swscale/utils: Move altivec init/free code to yuv2rgb_altivec.c
This is in preparation for removing the util_altivec.h inclusion
in swscale_internal.h, which causes problems (on PPC) because
it redefines bool to something different from stdbool.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-28 09:56:01 +01:00
Adrien Guinet da9a6d51f5 avformat/mov: add support for multiple decryption keys
This commit introduces new options to support more than one decryption
keys:
* add a decryption_keys option to MOV, that supports a dictionary of
  KID=>key (in hex), using AV_OPT_TYPE_DICT
* add the corresponding cenc_decryption_keys option to DASH

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-28 04:01:08 +01:00
Neko Asakura 69568479a9 avformat/rtpenc: use unsigned type for ssrc option
The ssrc option used AV_OPT_TYPE_INT with range [INT_MIN, INT_MAX],
but the underlying struct field is uint32_t and RFC 3550 defines SSRC
as a 32-bit identifier covering the full [0, UINT32_MAX] range. This
caused ffmpeg to reject any SSRC value above INT_MAX (~2.1 billion),
which is roughly half of all valid values.

The auto-generated fallback path (av_get_random_seed()) already
returns uint32_t and can produce values above INT_MAX, creating an
inconsistency where the automatic path succeeds but the explicit
-ssrc option rejects the same value.

Change the option to AV_OPT_TYPE_UINT with range [0, UINT32_MAX]
to match the field type and allow the full identifier space.

Fixes ticket #9080.

Signed-off-by: Neko Asakura <neko.asakura@outlook.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-28 01:23:12 +00:00
Andreas Rheinhardt aa483bc422 avcodec/x86/bswapdsp: Avoid aligned vs unaligned codepaths for AVX2
For modern cpus (like those supporting AVX2) loads and stores
using the unaligned versions of instructions are as fast
as aligned ones if the address is aligned, so remove
the aligned AVX2 version (and the alignment check) and just
use the unaligned one.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-27 18:25:43 +01:00
Andreas Rheinhardt 55afe49dd0 avcodec/x86/bswapdsp: combine shifting, avoid check for AVX2
This avoids a check and a shift if >=8 elements are processed;
it adds a check if < 8 elements are processed (which should
be rare).
No change in benchmarks here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-27 18:25:31 +01:00
Andreas Rheinhardt 3e6fa5153e avcodec/x86/bswapdsp: Avoid register copies
No change in benchmarks here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-27 18:25:01 +01:00
Niklas Haas 335ca9c4f4 tests/checkasm: Fix whitespace cosmetics
This line was left misaligned in
b863b81500.
2026-02-27 17:08:46 +00:00
Martin Storsjö 5693b07839 tests/checkasm/sw_ops: Switch to opaques for deciding when to test
This uses the new mechanisms introduced in
cf7e2b6773, as used by the crc test
in 0629ebb5ff.
2026-02-27 17:08:31 +00:00
Ramiro Polla 23bb7c3907 swscale/ops_backend: mark unreachable branch
The pixel format for the process loops have already been checked at
this point to be valid.

The switch added in e4abfb8e51 returns AVERROR(EINVAL) in the default
case without calling ff_sws_op_chain_free(chain), but there's no need
to free it since we mark this branch as unreachable.
2026-02-27 16:44:19 +00:00
Niklas Haas 67f3627267 swscale/graph: nuke SwsImg
This has now become fully redundant with AVFrame, especially since the
existence of SwsPassBuffer. Delete it, simplifying a lot of things and
avoiding reinventing the wheel everywhere.

Also generally reduces overhead, since there is less redundant copying
going on.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas 4d7b1c3685 swscale/graph: move frame->field init logic to SwsGraph
And have ff_sws_graph_run() just take a bare AVFrame. This will help with
an upcoming change, aside from being a bit friendlier towards API users
in general.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas 846823b174 swscale/graph: don't pointlessly align data buffers
Since d67d81a374, enabling asm explicitly requires aligned malloc,
so this FFALIGN accomplishes nothing.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas 5121665463 swscale/graph: use AVFrame to track internal allocation
This commit replaces the AVBufferRef inside SwsPassBuffer by an AVFrame, in
anticipation of the SwsImg removal.

Incidentally, we could also now just use av_frame_get_buffer() here, but
at the cost of breaking the 1:1 relationship between planes and buffers,
which is required for per-plane refcopies.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas e9d1ed3fdc swscale/graph: avoid stack copies of SwsImg
In the process of nuking this abstraction in favor of AVFrame.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas d89765eb28 swscale/graph: simplify output buffer management
This function was originally written to support the use case of e.g.
partially allocated planes that implicitly reference the original input
image, but I've decided that this is stupid and doesn't currently work
anyways.

Plus, I have plans to kill SwsImg, so we need to simplify this mess.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas 363779a4bb swscale/ops: don't set src/dst_frame_ptr in op_pass_run()
Already set by setup().

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas 62dc591a80 swscale/ops: correctly shift pointers for last row handling
The current logic didn't take into account the possible plane shift. Just
re-compute the correctly shifted pointers using the row position.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas bca806d4f9 swscale/ops: avoid stack copies of SwsImg
Instead, precompute the correctly swizzled data and stride in setup()
and just reference the SwsOpExec fields directly.

To avoid the stack copies in handle_tail() we can introduce a temporary
array to hold just the pointers.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas 79334c8ca1 swscale/ops: add subsampling shift to SwsOpExec
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
James Almer 16ee3d8d99 avformat/mov: fix cases where we discard iamf packets from enabled streams
Given the entire iamf struct is inside a single Track, if the first iamf stream
(which is the one sharing the index and id from the Track) was to be disabled,
then packets from every iamf stream would be discarded.
Fix this by actually going through the entire iamf Sample and discarding those
from the disabled streams only.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-27 11:01:25 -03:00
James Almer 51aef95ba1 avformat/mov: fix setting iamf stream id offsets
If we were to add the highest id of a non iamf stream as offset to iamf stream
ids, and one of the latter was 0, then an id overlap would ocurr.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-27 11:00:58 -03:00
Jack Lau 7505cea0e9 avformat/whip: skip the unmatch nack packet through ssrc
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-27 12:42:05 +00:00
Jack Lau 7e48c0afc9 avformat/whip: add missing ":" in "a=rtcp-fb" when generate sdp
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-27 12:42:05 +00:00
Jack Lau d7820156f9 avformat/whip: add RTX support
See https://datatracker.ietf.org/doc/html/rfc4588

Parse sequence number from NACKs, then create RTX
packet and send it.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>

avformat/whip: set NACK logs as DEBUG

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-27 12:42:05 +00:00
Jack Lau e7757d8f2e avformat/whip: add rtp history store and find method
This patch aims to enable rtp history store for RTX

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-02-27 12:42:05 +00:00
Niklas Haas 2e7078cda6 avformat/http: add -request-size option
It has come to my attention that a way to limit the request range size
would be useful in general, for reasons beyond just speeding up initial
header parsing.

This patch generalizez -initial_request_size to -request_size. I decided
to continue allowing both options to be used simultaneously, so users can
e.g. set -request_size to something large like 10 MiB, but still use a smaller
size for initial header parsing (e.g. 256 KiB).

Fixes: https://github.com/mpv-player/mpv/issues/8655
2026-02-27 09:20:33 +00:00
Niklas Haas 3c03048837 swscale/x86/ops: fix MSVC compiler error
src/libswscale/x86/ops.c(534): error C2099: initializer is not a constant
src/libswscale/x86/ops.c(535): error C2099: initializer is not a constant
src/libswscale/x86/ops.c(536): error C2099: initializer is not a constant
src/libswscale/x86/ops.c(537): error C2099: initializer is not a constant
src/libswscale/x86/ops.c(539): error C2099: initializer is not a constant
src/libswscale/x86/ops.c(540): error C2099: initializer is not a constant

Fixes: ec959e20c5
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 09:00:04 +01:00
Jack Lau bc63000741 configure: add pkg-config check for amr related libs
This patch doesn't break previous approach, just add
one possible valid method to find the lib.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-27 01:51:09 +00:00
Nariman-Sayed 477bf79b06 avformat/tls_openssl: use SHA-256 instead of SHA-1 for self-signed cert
SHA-1 is deprecated and considered cryptographically weak.
Replace EVP_sha1() with EVP_sha256() when signing self-generated
certificates to comply with modern security standards.
2026-02-26 22:25:29 +00:00
Ramiro Polla f436d885fc swscale/swscale: fix typos 2026-02-26 18:36:46 +00:00
Niklas Haas ecb707f7e0 swscale/format: add assertion to guard UB
AVRational still can't handle 32-bit values...

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 18:08:49 +00:00
Niklas Haas d4202809da swscale/format: check pixel type in ff_sws_encode/decode_colors()
This would otherwise generate illegal ops and undefined behavior, for
pixel formats without any supported corresponding pixel type.

This didn't cause any issues previously because the following
`ff_sws_encode_pixfmt` would normally fail for such formats, and the UB
was ignored in practice.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 18:08:49 +00:00
Niklas Haas 096e20b4b8 swscale/ops: reorder fields in SwsOpList
For some reason, this avoids triggering a compiler bug in gcc-15 on PowerPC,
that was introduced with commit da47951bd7.
2026-02-26 18:08:49 +00:00
Niklas Haas b7bbcccbfe tests/swscale: disable fate-sws-ops-list on BE platforms
The issue is that every le/be pair ends up with a swapped op list:

 rgb24 -> rgb48be:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> u16 (expand)
-  [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
-  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
+  [u16 ...X -> +++X] SWS_OP_WRITE        : 3 elem(s) packed >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)
 rgb24 -> rgb48le:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> u16 (expand)
-  [u16 ...X -> +++X] SWS_OP_WRITE        : 3 elem(s) packed >> 0
+  [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
+  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)

I'm not sure of a good work-around that's not needlessly difficult to
implement, so just disable it on BE platforms for now. The actual underlying
conversions should still be covered by the sws-unscaled test.
2026-02-26 18:08:49 +00:00
Niklas Haas 841ca7a2cb swscale/format: pass SwsFormat by ref instead of by value where possible
The one exception is in adapt_colors(), which mutates these structs on
its own stack anyways.
2026-02-26 18:08:49 +00:00
Niklas Haas 4e36265dea swscale/format: don't mark single byte formats as byte swapped
Fixes a bug where all format lists contained redundant byte swapped
annotations on big-endian platforms, even for single-byte formats.
2026-02-26 18:08:49 +00:00
Michael Niedermayer 86ddc8b438 swscale/output: Fix some integer overflows in yuv2rgba64_full*()
Fixes: integer overflows
Fixes: 471587361/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5015347829997568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-26 17:21:46 +00:00
Lynne 47e87ed722 Changelog: add entry about swscale Vulkan support
The SW in swscale can stand for something else now.

Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:22 +01:00
Lynne bd24abfb6c swscale/vulkan: initialize GLSL compilation and shader execution
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:22 +01:00
Lynne 362414afba swscale: add support for processing hardware frames
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:22 +01:00
Lynne 1d2e616d5f swscale: add a Vulkan backend for ops.c
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:22 +01:00
Lynne ad452205b6 swscale/ops: add SwsOpBackend.hw_format
Allows to filter hardware formats.

Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:22 +01:00
Lynne c911295f09 swscale: forward original frame pointers to ops.c backend
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:21 +01:00
Lynne 00907e1244 swscale/ops: realign after adding slice_align
This is a separate commit since it makes it easier to see the changes.

Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:21 +01:00
Lynne 9c51aa1824 swscale: add SwsCompiledOp.slice_align
Certain backends may not support (or need) slices, since they
would handle slicing themselves.

Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:21 +01:00
Lynne 5bc08e259d swscale: add SwsFormat.hw_format and populate it
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:21 +01:00
Lynne d80d5b4ee7 vulkan_spirv: reduce shader print level from TRACE to DEBUG
The issue was that FFv1 concat'd a lot of separate files, each with
a license header, inflating the total shader size to over 3000 lines.

As all codec shaders were rewritten for compile-time SPIR-V, this became
unnencessarily restrictive.

Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:21 +01:00
Lynne 0c34fcf0a8 vulkan: constify FFVulkanShader arg in ff_vk_exec_bind_shader
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:21 +01:00
Lynne 6c5dc2011b vulkan: reset exec context when uninitializing
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:19 +01:00
Niklas Haas 26d6ac56c1 swscale: add sws_test_hw_format()
Allows users to test if a given hardware pixel format is supported by swscale.
This is only a rough heuristic anyways, because the actual support may
depend on the specific *combination* of frame attributes, and ultimately
is better served by the `sws_test_frame` and `sws_frame_setup()` APIs anyways.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 14:09:46 +01:00
Niklas Haas 43f1189af7 swscale/ops_optimizer: eliminate unnecessary dither indices
Generates a lot of incremental diffs due to things like ignored alpha
planes or chroma planes that are not actually modified.

e.g.

 bgr24 -> gbrap10be:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> f32
   [f32 ...X -> ...X] SWS_OP_SCALE        : * 341/85
-  [f32 ...X -> ...X] SWS_OP_DITHER       : 16x16 matrix + {2 3 0 5}
+  [f32 ...X -> ...X] SWS_OP_DITHER       : 16x16 matrix + {2 3 0 -1}
   [f32 ...X -> ...X] SWS_OP_MIN          : x <= {1023 1023 1023 1023}
   [f32 ...X -> +++X] SWS_OP_CONVERT      : f32 -> u16
   [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
   [u16 ...X -> zzzX] SWS_OP_SWIZZLE      : 1023
   [u16 ...X -> zzz+] SWS_OP_CLEAR        : {_ _ _ 65283}
   [u16 .... -> zzz+] SWS_OP_WRITE        : 4 elem(s) planar >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 13:09:14 +00:00
Niklas Haas ce096aa4ee swscale/x86/ops: add support for optional dither indices
Instead of defining multiple patterns for the dither ops, just define a
single generic function that branches internally. The branch is well-predicted
and ridiculously cheap. At least on my end, within margin of error.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 13:09:14 +00:00
Niklas Haas 48ab318f5c swscale/x86/ops: don't preload dither weights
This doesn't actually gain any performance but makes the code needlessly
complicated. Just directly add the indirect address as needed.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 13:09:14 +00:00
Niklas Haas 1ec8e6e3ce swscale/x86/ops: split off dither0 special case
I want to rewrite the dither kernel a bit, and this special case is a bit
too annoying and gets in the way.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 13:09:14 +00:00
Niklas Haas 8b346363aa swscale/ops_backend: implement support for optional dither indices
If you place the branch inside the loop, gcc at least reverts back to scalar
code, so better to just split up and guard the entire loop.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 13:09:14 +00:00
Niklas Haas ef4a597ad8 swscale/ops: allow excluding components from SWS_OP_DITHER
We often need to dither only a subset of the components. Previously this
was not possible, but we can just use the special value -1 for this.

The main motivating factor is actually the fact that "unnecessary" dither ops
would otherwise frequently prevent plane splitting, since e.g. a copied
alpha plane has to come along for the ride through the whole F32/dither
pipeline.

Additionally, it somewhat simplifies implementations.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 13:09:14 +00:00
Adrien Destugues 5425be53b5 configure: re-enable memalign for Haiku
This had been disabled in 2011:
https://lists.ffmpeg.org/pipermail/ffmpeg-cvslog/2011-June/038362.html

If there are still problems with it we should rather fix them on Haiku
side.

Signed-off-by: Niklas Haas <git@haasn.dev>
See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22233
2026-02-26 10:16:11 +00:00
Niklas Haas d67d81a374 configure: don't support asm without memalign
I tried it, and it broke horribly. We should definitively rule out this.

Unfortunately, it's not as easy as just setting `disable asm` here, because
asm having been enabled will already have affected the build process further
upstream - conversely, we don't know whether or not memalign exists until
fairly late in the build process, and I'm not about to go destroying
the current organization of the file just to work around this.

So an error message it is.
2026-02-26 10:16:11 +00:00
Niklas Haas 5fa2a65c11 swscale/unscaled: fix rgbToRgbWrapper for YUVX
This code calculates the pixel step using c->dstFormatBpp, which is wrong;
should use the pixdesc step instead. (dstFormatBpp is 3 for YUVX, but
the actual pixel step is 4 bytes)

This bug was mostly hidden by the fact that the same bug actually disabled
the fast path for the (common) case of strStride == dstStride. Uncovered while
making changes to the swscale.c allocation code.

Reproduced by modifying libswscale in such a way that the dst buffer stride
happened to be exactly 4/3 larger than the src buffer stride, e.g. by adding
extra padding to each dst buffer line, but reproducible in principle by any
API user.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas a22189101b swscale/unscaled: fix packedCopyWrapper for bitstream formats
The assumption that w < stride is not held for such formats. Rather than
this brittle logic we can just always copy the smaller of the two strides.
This is unlikely to affect anything in practice, since usually AVFrames with
the same size and format have matching linesizes, and so the fast path should
be taken. However, in the unlikely case that they don't agree, this fixes an
assertion failure when copying monow to monow.

Reproduced by modifying libswscale to pick a larger-than-normal dst buffer
alignment (and corresponding linesize), but reproducible in principle by any
API user.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas 5649ac2b4d swscale/ops: avoid UB in handle_tail()
Stupid NULL + 0 rule.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas e4abfb8e51 swscale/ops_backend: avoid UB from incorrect function signature
Annoying C-ism; we can't overload the function type even though they will
always be pointers. We can't even get away with using (void *) in the
function signature, despite casts to void * being technically valid.

Avoid the issue altogether by just moving the process loop into the
type-specific template altogether, and just referring to the correct
compiled process function at runtime. Hopefully, the compiler should be
able to optimize these into a single implementation. GCC, at least, compiles
these down into a single implementation plus three stubs that just jmp
to the correct one.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas ec959e20c5 swscale/x86/ops: add special case for expanding bits to bytes/words
Not super useful but also not expensive to carry.

monob -> gbrp:
 Before: time=84 us, ref=137 us, speedup=1.618x faster
 After:  time=23 us, ref=185 us, speedup=7.773x faster

monob -> gray16le:
 Before: time=75 us, ref=108 us, speedup=1.440x faster
 After:  time=20 us, ref=108 us, speedup=5.192x faster

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas 3a5b1d762f swscale/ops_chain: add ability to match fixed scale factor
This is useful especially for the special case of scaling by common
not-quite-power-of-two constants like 255 or 1023.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas a71c115b77 swscale/x86/ops: allow matching planar rw against 1-element packed fmt
Otherwise, the x86 backend fails to serve e.g. rgb565le.

For -src rgb565le:
 Before: Overall speedup=2.210x faster, min=0.256x max=60.465x
 After:  Overall speedup=4.929x faster, min=0.638x max=181.260x

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas 83af1a2977 swscale/x86/ops: properly mark SWS_OP_SCALE as flexible 2026-02-26 10:15:52 +00:00
Niklas Haas 9adfe25ead swscale/ops_chain: properly mark unreachable branch
By breaking to the `av_unreachable` below. This branch is unreachable because
of the `if (entry->flexible)` branch further above.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Lynne 6695528af6 Changelog: add entry for recent Vulkan compute codec optimizations
All the compute codecs were ported to compile-time SPIR-V, thoroughly
debugged, and optimized. They're ready for prime-time.
2026-02-26 10:32:39 +01:00
Jack Lau 8bf74556a1 doc/developer: Add Forgejo as a way to send patches
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-26 04:13:25 +00:00
Zhao Zhili 6b949407cb avfilter: use int instead of enum for AVOption fields
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-26 11:40:16 +08:00
Zhao Zhili fddf881c06 avformat: use int instead of enum for AVOption fields
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-26 11:40:16 +08:00
Zhao Zhili 86d2fae59f avcodec: use int instead of enum for AVOption fields
AVOption with AV_OPT_TYPE_INT assumes the field is int (4 bytes),
but enum size is implementation-defined and may be smaller.
This can cause memory corruption when AVOption writes 4 bytes
to a field that is only 1-2 bytes, potentially overwriting
adjacent struct members.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-26 11:40:09 +08:00
Ling, Edison 00d3417b71 avcodec/d3d12va_encode: Add H264 entropy coder parameter support
Add parameter `coder` for users to select entropy coding in D3D12 H264
encoding.

Named constants `cabac` (1) and `cavlc` (0) are supported.
Default is CABAC (1). If the driver does not support CABAC, a warning is
logged and encoding falls back to CAVLC.

Usage:
  CABAC (default): `-coder cabac`  or  `-coder 1`
  CAVLC:           `-coder cavlc`  or  `-coder 0`

Sample command line:
```
  ffmpeg -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v h264_d3d12va -coder cavlc -y output.mp4
```
2026-02-26 02:19:21 +00:00
Werner Robitza 5ba2525c7a avcodec/libsvtav1: enable 2-pass encoding
This patch enables two-pass encoding for libsvtav1 by implementing
support for AV_CODEC_FLAG_PASS1 and AV_CODEC_FLAG_PASS2.

Previously, users requiring two-pass encoding with SVT-AV1 had to use
the standalone SvtAv1EncApp tool. This patch allows 2-pass encoding
directly through FFmpeg.

Based on patch by Fredrik Lundkvist, with review feedback from James
Almer and Andreas Rheinhardt.
See: https://ffmpeg.org/pipermail/ffmpeg-devel/2024-May/327452.html

Changes:

- Use AV_BASE64_DECODE_SIZE macro for buffer size calculation
- Allocate own buffer for rc_stats_buffer (non-ownership pointer)
- Error handling with buffer cleanup

Signed-off-by: Werner Robitza <werner.robitza@gmail.com>
2026-02-25 16:43:53 +01:00
Andreas Rheinhardt 13e95746ea tests/checkasm/h264chroma: Don't overalign
The input only needs to have natural alignment
(i.e. 1 in the 8bpp case, 2 otherwise), the output
only needs to have 16 (namely in the width 8 >8bpp case).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-25 12:42:22 +01:00
Andreas Rheinhardt e9c2f19e01 tests/checkasm/h264chroma: Add bit depth to error output
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-25 12:42:19 +01:00
Andreas Rheinhardt 34cf7790ef tests/checkasm/h264chroma: Fix initialization, range of values
This commit fixes four related bugs:
1. The >8bpp codepath only initializes half the buffer.
The remaining half used leftover samples from the 8bpp codepath
which initialized the complete buffer.
2. The 8bpp codepath tests only 2 bit inputs (&3). This means
that the second half of the buffer only uses 10 bits (in fact,
only values of the form 000000xx000000xxb) when treated as uint16_t
in the >8bpp test. Due to 1., using more bits in the 8bpp test
would make the >8bpp tests fail (the intermediates would no longer
fit into 16bits).
3. For the >8bpp tests, the first half of the buffer would
only be tested with 8bpp input.
4. The 8bpp codepath initializes the whole buffer, but only
uses half of it.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-25 12:41:13 +01:00
Andreas Rheinhardt dc65dcec22 avcodec/vvc/inter: Combine offsets early
For bi-predicted weighted averages, only the sum
of the two offsets is ever used, so add the two early.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-25 12:08:33 +01:00
stevxiao fc7c38f9da avcodec/d3d12va_encode: add detailed ValidationFlags error reporting for video encoders check feature support
Improves error diagnostics for D3D12 video encoders check feature support by adding
detailed ValidationFlags reporting when driver validation fails.

This made it easy for users to identify which specific feature was
unsupported without manually decoding the flags.

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-02-25 08:47:14 +00:00
Jack Lau 659892cda6 avformat/tls_mbedtls: generate self-signed cert and key when none is provided in listen mode
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-25 03:27:03 +00:00
Jack Lau 55f5cfafeb avformat/tls_mbedtls: set dtls remote addr in listen mode
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-25 03:27:03 +00:00
Jack Lau 35ccd5f3de avformat/tls_mbedtls: add dtls support
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-25 03:27:03 +00:00
Jack Lau dc4c798970 avformat: Use ff_*_muxer directly
These muxers already set hard dependencies in
configure so they cannot be enabled unless the
dependencies are enabled.

So these error handling is unreachable.

Directly Using ff_*_muxer is simpler than calling
av_guess_format()

Refer to 289cb3beff

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-25 02:55:43 +00:00
Ramiro Polla c9977acbc6 swscale/ops: clear range values SWS_OP_{MIN,MAX}
This gives partial range values on conversions with floats, after the
values have been clamped.

 gbrpf32be -> rgb8:
   [f32 XXXX -> zzzX] SWS_OP_READ         : 3 elem(s) planar >> 0
   [f32 ...X -> ...X] SWS_OP_SWAP_BYTES
   [f32 ...X -> ...X] SWS_OP_SWIZZLE      : 2013
   [f32 ...X -> ...X] SWS_OP_LINEAR       : diag3 [[7 0 0 0 0] [0 7 0 0 0] [0 0 3 0 0] [0 0 0 1 0]]
   [f32 ...X -> ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
   [f32 ...X -> ...X] SWS_OP_MAX          : {0 0 0 0} <= x
+    min: {0, 0, 0, _}, max: {nan, nan, nan, _}
   [f32 ...X -> ...X] SWS_OP_MIN          : x <= {7 7 3 _}
+    min: {0, 0, 0, _}, max: {7, 7, 3, _}
   [f32 ...X -> +++X] SWS_OP_CONVERT      : f32 -> u8
+    min: {0, 0, 0, _}, max: {7, 7, 3, _}
   [ u8 ...X -> +XXX] SWS_OP_PACK         : {3 3 2 0}
-    min: {0, _, _, _}, max: {0, _, _, _}
+    min: {0, _, _, _}, max: {255, _, _, _}
   [ u8 .XXX -> +XXX] SWS_OP_WRITE        : 1 elem(s) packed >> 0
-    min: {0, _, _, _}, max: {0, _, _, _}
+    min: {0, _, _, _}, max: {255, _, _, _}
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-02-24 20:25:59 +01:00
Ramiro Polla 9fbb03f428 swscale/tests/sws_ops: don't print unused components in the output
Clean up the output by not printing the flags and range values of
unused components in ff_sws_op_list_print().

 rgb24 -> gray16le:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
-    min: {0, 0, 0, nan}, max: {255, 255, 255, nan}
+    min: {0, 0, 0, _}, max: {255, 255, 255, _}
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> f32
-    min: {0, 0, 0, nan}, max: {255, 255, 255, nan}
-  [f32 ...X -> .++X] SWS_OP_LINEAR       : dot3 [[76.843000 150.859000 29.298000 0 0] [0 1 0 0 0] [0 0 1 0 0] [0 0 0 1 0]]
-    min: {0, 0, 0, nan}, max: {65535, 255, 255, nan}
-  [f32 .XXX -> +++X] SWS_OP_CONVERT      : f32 -> u16
-    min: {0, 0, 0, nan}, max: {65535, 255, 255, nan}
-  [u16 .XXX -> +++X] SWS_OP_WRITE        : 1 elem(s) planar >> 0
-    min: {0, 0, 0, nan}, max: {65535, 255, 255, nan}
+    min: {0, 0, 0, _}, max: {255, 255, 255, _}
+  [f32 ...X -> .XXX] SWS_OP_LINEAR       : dot3 [[76.843000 150.859000 29.298000 0 0] [0 1 0 0 0] [0 0 1 0 0] [0 0 0 1 0]]
+    min: {0, _, _, _}, max: {65535, _, _, _}
+  [f32 .XXX -> +XXX] SWS_OP_CONVERT      : f32 -> u16
+    min: {0, _, _, _}, max: {65535, _, _, _}
+  [u16 .XXX -> +XXX] SWS_OP_WRITE        : 1 elem(s) planar >> 0
+    min: {0, _, _, _}, max: {65535, _, _, _}
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-02-24 20:22:12 +01:00
Ramiro Polla c7c8c31302 swscale/tests/sws_ops: print range values in the output
This gives more information about each operation and helps catch issues
earlier on.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-02-24 19:27:51 +01:00
James Almer 145f6e5878 avcodec/cbs_h2645: split into separate files per module
This file is becoming too bloated and hard to read, so split it into separate
files, each having codec specific methods.
This will also speed up compilation when using several concurrent jobs.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-24 10:32:20 -03:00
Michael Niedermayer 989d6ddea0 avformat/wtvdec: Check that language is fully read
Fixes: use-of-uninitialized-value
Fixes: 483856523/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5221422609006592

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-24 10:22:37 +00:00
Nariman-Sayed 186e388716 avformat/whip: use ffurl_closep instead of ffurl_close for dtls_uc 2026-02-24 02:58:34 +00:00
Michael Niedermayer 7761b8fbac avcodec/imm5: Dont pass EAGAIN on as is
Fixes: Assertion consumed != (-(11)) failed at libavcodec/decode.c:465
Fixes: 471587358/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IMM5_fuzzer-4737412376100864

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:58:11 +01:00
Michael Niedermayer 302f198ba5 avcodec/mjpegdec: Check for multiple exif
Fixes: memleak
Fixes: 477993717/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_DEC_fuzzer-4515108431921152

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:52:37 +01:00
Michael Niedermayer 2ab23ec729 avcodec/interplayacm: Check input for fill_block()
Fixes: Timeout
Fixes: 476763877/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INTERPLAY_ACM_fuzzer-4515681843609600

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:50:49 +01:00
Michael Niedermayer 3827b3f1f0 tools/target_dec_fuzzer: Adjust threshold for G2M
Fixes: Timeout
Fixes: 473651750/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G2M_fuzzer-6214373279596544

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:45:14 +01:00
Michael Niedermayer bebea1e8e3 tools/target_dec_fuzzer: Adjust threshold for XAN_WC3
Fixes: Timeout
Fixes: 472673591/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XAN_WC3_fuzzer-6171459778314240

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:37:09 +01:00
Michael Niedermayer ce05529180 tools/target_dec_fuzzer: Adjust threshold for CPIA
Fixes: Timeout
Fixes: 472564084/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CPIA_fuzzer-5597833073065984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:32:47 +01:00
Michael Niedermayer 9c5e6a319c tools/target_dec_fuzzer: Adjust threshold for QOI
Fixes: Timeout
Fixes: 472177584/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QOI_DEC_fuzzer-5417966922694656

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:32:06 +01:00
Michael Niedermayer 538824fd84 avcodec/hdrdec: Check input size before buffer allocation
Fixes: Timeout
Fixes: 471948155/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HDR_DEC_fuzzer-5679690418552832

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:28:09 +01:00
Michael Niedermayer 55bb6e2646 avcodec/tmv: Move space check before buffer allocation
Fixes: Timeout
Fixes: 471664630/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TMV_fuzzer-5291752530706432

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:26:20 +01:00
Michael Niedermayer f81d6479ec tools/target_dec_fuzzer: Adjust threshold for MPC8
Fixes: Timeout
Fixes: 471587345/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPC8_fuzzer-4824233864921088

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:15:19 +01:00
Michael Niedermayer c8b57f0a1e tools/target_dec_fuzzer: Adjust threshold for BFI
Fixes: timeout
Fixes: 471606773/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BFI_fuzzer-6707440390569984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:14:44 +01:00
Michael Niedermayer 4446dfb0e3 avcodec/flashsv: Check for input space before (re)allocating frame
Fixes: Timeout
Fixes: 471605680/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLASHSV2_DEC_fuzzer-6210773459468288
Fixes: 471605920/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLASHSV_DEC_fuzzer-6230719287590912

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 22:59:44 +01:00
Michael Niedermayer 40cafc25cf avcodec/mdec: Check input space vs minimal block size
Fixes: Timeout
Fixes: 481006706/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MDEC_fuzzer-6122832651419648

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 22:54:38 +01:00
Michael Niedermayer 73681f888d avcodec/h264_parser: Check remaining input length in loop in scan_mmco_reset()
Fixes: read of uninitialized memory
Fixes: 476177761/clusterfuzz-testcase-minimized-ffmpeg_dem_H264_fuzzer-6400884824408064

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 22:43:28 +01:00
Niklas Haas b21f1b6482 tests/swscale: don't pass fake object to av_opt_eval_*
This is UB, as the fake object may be used for logging.

Reported-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Fixes: ea791a4ef1
2026-02-23 20:55:27 +00:00
Niklas Haas afdb683a3f swscale: avoid UB on interlaced frames
NULL+0 is UB.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas d918551650 swscale/graph: switch SwsPass.output to refstruct
Allows multiple passes to share a single output buffer reference. We always
allocate an output buffer so that subpasses can share the same output buffer
reference while still allowing that reference to implicitly point to the
final output image.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas cc346b232d swscale/graph: store current pass input instead of global args
The global args to ff_sws_graph_run() really shouldn't matter inside thread
workers. If they ever do, it indicates a leaky abstraction. The only reason
it was needed in the first place was because of the way the input/output
buffers implicitly defaulted to the global args.

However, we can solve this much more elegantly by just calculating it in
ff_sws_graph_run() directly and storing the computed SwsImg inside the
execution state.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas 1e071c8585 swscale/graph: omit memcpy() if src and dst are identical
This allows already referenced planes to be skipped, in the case of e.g.
only some of the output planes being sucessfully referenced. Also avoids
what is technically UB, if the user happens to call ff_sws_graph_run() after
already having ref'd an image.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas b98751b13c swscale/graph: set up palette using current input image
Using the original input image here is completely wrong - the format/palette
could have been set to anything else in the meantime. At best, we would want to
use the original input to add_legacy_sws_pass(), but it's impossible for this
to differ from the per-pass input. The only time legacy subpasses are added
is when using cascaded contexts, but in this case, the only context actually
reading from the palette format would be the first one.

I'm not entirely sure why this code was originally written this way, but
I'm reasonably confident that it's not at all necessary. Tested extensively
on both FATE, the self-test, and real-world files.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas 0b446cdccd swscale/graph: switch to an AVBufferRef per plane
This annoyingly requires recreating some of the logic inside av_img_alloc(),
because there's no good existing current helper accessible from libswscale
that gives per-plane allocations like this.

The new code is based off the calculations inside libavframe/bufferpool.c.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas afa08f4971 swscale/graph: duplicate buffer dimensions in SwsPassBuffer
When multiple passes share a buffer reference, the true buffer dimensions
may be different for each pass, depending on slice alignment. So we can't
rely on the pass dimensions being representative.

Instead, store this information in the SwsPassBuffer itself.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas fe25e54d0f swscale/graph: move output image into separate struct
I want to add more metadata to this and also turn it into a refstruct,
but get the cosmetic diff out of the way first.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas 18060a8820 swscale/graph: simplify ff_sws_graph_run() API
There's little reason not to directly take an SwsImg here; it's already an
internally visible struct.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas e1fd274706 swscale/graph: check output plane pointer instead of pixel format
To see if the output buffers are allocated or not.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Marvin Scholz 64fafd63f0 avformat: remove HLS protocol
The use of this protocol was already discouraged and warned about
for years with the recommendation to use the HLS demuxer instead.
2026-02-23 20:20:20 +01:00
Niklas Haas ea791a4ef1 swscale/tests/swscale: parse flags from string
We don't actually have an SwsContext yet at this point, so just use
AV_OPT_SEARCH_FAKE_OBJ. For the actual evaluation, the signature only
requires that we pass a "pointer to a struct that contains an AVClass as
its first member", so passing a double pointer to the class itself is
sufficient.
2026-02-23 19:23:09 +01:00
Marvin Scholz fba9fc0c6b lavc: wmadec: limit variable scopes
Moves the loop variable declarations to the actual loops,
narrowing their scopes.
2026-02-23 15:29:27 +00:00
Marvin Scholz d219be03d6 lavc: wmadec: assert channels count
This should never exceed MAX_CHANNELS, else there will be several
out of bounds writes.
2026-02-23 15:29:27 +00:00
Lynne 7b15039cdb Changelog: add changelog entry for Mps212 2026-02-23 07:57:57 +01:00
Lynne baad75cafa aacdec_usac: add support for parsing Mpsp212 (MPEG surround)
This commit adds the full bitstream parsing for Mps212.
2026-02-23 07:57:57 +01:00
Lynne 86977fdb6b aacdec_tab: add Mps212 tables
To be used in the following commit.
2026-02-23 07:57:57 +01:00
Lynne a4ab4a98c4 aacdec_tab: split up tables init 2026-02-23 07:57:57 +01:00
James Almer 40e0463113 avformat/mov: free item_name on infe entry parsing failure
Fixes regression since 28c330d0f3.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-22 23:16:15 -03:00
Michael Niedermayer 7e10579f49 avcodec/exr: fix AVERROR typo
Fixes: out of array read
Fixes: 485866440/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_DEC_fuzzer-4520520419966976

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 01:44:49 +00:00
James Almer c3aa28f23d avformat/mov: check for EOF in more loops
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-23 00:43:50 +00:00
James Almer 28c330d0f3 avformat/mov: abort if the queried item doesn't exist instead of overwriting it
The check for item presence was insufficient as it would result in the last
item in the array being overwritten if it existed even if the id didn't match.

Fixes: Assertion ref failed at src/libavformat/mov.c:10649
Fixes: clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5312542695292928
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-23 00:43:50 +00:00
Nariman-Sayed 9bc4109b23 avformat/tls_openssl: fix memory leak in cert_from_pem_string
When PEM_read_bio_X509 fails, BIO was not freed, causing memory leak.
Free BIO before returning NULL to prevent resource leak.
2026-02-22 22:39:43 +00:00
Andreas Rheinhardt 53a9a34e23 avcodec/snow: Reduce sizeof(SnowContext)
Each SubBand currently contains an array of 519 uint8_t[32],
yet most of these are unused: For both the decoder and the
encoder, at most 34 contexts are actually used: The only
variable index is context+2, where context is the result
of av_log2() and therefore in the 0..31 range.

There are also several accesses using compile-time indices,
the highest of which is 30. FATE passes with 31 contexts
and maybe these are enough, but I don't know.

Reducing the number to 34 reduces sizeof(SnowContext)
from 2141664B to 155104B here (on x64).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 22:05:16 +01:00
Andreas Rheinhardt bb92009386 avcodec/snow: Only allocate emu_edge_buffer for encoder
Also allocate it during init and move it to the encoder's context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 22:05:15 +01:00
Michael Niedermayer c7b5f1537d CONTRIBUTING.md: Add Forgejo
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-22 04:39:22 +00:00
Lynne 13e063ceec vulkan/ffv1: properly initialize the linecache 2026-02-22 03:39:23 +01:00
Michael Niedermayer 99515a3342 avcodec/jpeg2000htdec: Check Lcup and Lref
Fixes: use of uninitialized memory
Fixes: 482494999/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_DEC_fuzzer-6467586186608640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-22 02:31:06 +00:00
Andreas Rheinhardt 6c1c1720cf avcodec/x86/vvc/dsp_init: Mark dsp init function as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 01:05:12 +01:00
Andreas Rheinhardt af3f8f5bd2 avcodec/x86/vvc/of: Break dependency chain
Don't extract and update one word of one and the same register
at a time; use separate src and dst registers, so that pextrw
and bsr can be done in parallel. Also use movd instead of pinsrw
for the first word.

Old benchmarks:
apply_bdof_8_8x16_c:                                  3275.2 ( 1.00x)
apply_bdof_8_8x16_avx2:                                487.6 ( 6.72x)
apply_bdof_8_16x8_c:                                  3243.1 ( 1.00x)
apply_bdof_8_16x8_avx2:                                284.4 (11.40x)
apply_bdof_8_16x16_c:                                 6501.8 ( 1.00x)
apply_bdof_8_16x16_avx2:                               570.0 (11.41x)
apply_bdof_10_8x16_c:                                 3286.5 ( 1.00x)
apply_bdof_10_8x16_avx2:                               461.7 ( 7.12x)
apply_bdof_10_16x8_c:                                 3274.5 ( 1.00x)
apply_bdof_10_16x8_avx2:                               271.4 (12.06x)
apply_bdof_10_16x16_c:                                6590.0 ( 1.00x)
apply_bdof_10_16x16_avx2:                              543.9 (12.12x)
apply_bdof_12_8x16_c:                                 3307.6 ( 1.00x)
apply_bdof_12_8x16_avx2:                               462.2 ( 7.16x)
apply_bdof_12_16x8_c:                                 3287.4 ( 1.00x)
apply_bdof_12_16x8_avx2:                               271.8 (12.10x)
apply_bdof_12_16x16_c:                                6465.7 ( 1.00x)
apply_bdof_12_16x16_avx2:                              543.8 (11.89x)

New benchmarks:
apply_bdof_8_8x16_c:                                  3255.7 ( 1.00x)
apply_bdof_8_8x16_avx2:                                349.3 ( 9.32x)
apply_bdof_8_16x8_c:                                  3262.5 ( 1.00x)
apply_bdof_8_16x8_avx2:                                214.8 (15.19x)
apply_bdof_8_16x16_c:                                 6471.6 ( 1.00x)
apply_bdof_8_16x16_avx2:                               429.8 (15.06x)
apply_bdof_10_8x16_c:                                 3227.7 ( 1.00x)
apply_bdof_10_8x16_avx2:                               321.6 (10.04x)
apply_bdof_10_16x8_c:                                 3250.2 ( 1.00x)
apply_bdof_10_16x8_avx2:                               201.2 (16.16x)
apply_bdof_10_16x16_c:                                6476.5 ( 1.00x)
apply_bdof_10_16x16_avx2:                              400.9 (16.16x)
apply_bdof_12_8x16_c:                                 3230.7 ( 1.00x)
apply_bdof_12_8x16_avx2:                               321.8 (10.04x)
apply_bdof_12_16x8_c:                                 3210.5 ( 1.00x)
apply_bdof_12_16x8_avx2:                               200.9 (15.98x)
apply_bdof_12_16x16_c:                                6474.5 ( 1.00x)
apply_bdof_12_16x16_avx2:                              400.2 (16.18x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 01:05:12 +01:00
Andreas Rheinhardt 19dc7b79a4 avcodec/x86/vvc/of: Unify shuffling
One can use the same shuffles for the width 8 and width 16
case if one also changes the permutation in vpermd (that always
follows pshufb for width 16).

This also allows to load it before checking width.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 01:03:22 +01:00
Andreas Rheinhardt 8e82416434 avcodec/x86/vvc/of: Avoid unused register
Avoids a push+pop.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 01:02:20 +01:00
Andreas Rheinhardt 81fb70c833 avcodec/x86/vvc/mc,dsp_init: Avoid pointless wrappers for w_avg
They only add overhead (in form of another function call,
sign-extending some parameters to 64bit (although the upper
bits are not used at all) and rederiving the actual number
of bits (from the maximum value (1<<bpp)-1)).

Old benchmarks:
w_avg_8_2x2_c:                                          16.4 ( 1.00x)
w_avg_8_2x2_avx2:                                       12.9 ( 1.27x)
w_avg_8_4x4_c:                                          48.0 ( 1.00x)
w_avg_8_4x4_avx2:                                       14.9 ( 3.23x)
w_avg_8_8x8_c:                                         168.2 ( 1.00x)
w_avg_8_8x8_avx2:                                       22.4 ( 7.49x)
w_avg_8_16x16_c:                                       396.5 ( 1.00x)
w_avg_8_16x16_avx2:                                     47.9 ( 8.28x)
w_avg_8_32x32_c:                                      1466.3 ( 1.00x)
w_avg_8_32x32_avx2:                                    172.8 ( 8.48x)
w_avg_8_64x64_c:                                      5629.3 ( 1.00x)
w_avg_8_64x64_avx2:                                    678.7 ( 8.29x)
w_avg_8_128x128_c:                                   22122.4 ( 1.00x)
w_avg_8_128x128_avx2:                                 2743.5 ( 8.06x)
w_avg_10_2x2_c:                                         18.7 ( 1.00x)
w_avg_10_2x2_avx2:                                      13.1 ( 1.43x)
w_avg_10_4x4_c:                                         50.3 ( 1.00x)
w_avg_10_4x4_avx2:                                      15.9 ( 3.17x)
w_avg_10_8x8_c:                                        109.3 ( 1.00x)
w_avg_10_8x8_avx2:                                      20.6 ( 5.30x)
w_avg_10_16x16_c:                                      395.5 ( 1.00x)
w_avg_10_16x16_avx2:                                    44.8 ( 8.83x)
w_avg_10_32x32_c:                                     1534.2 ( 1.00x)
w_avg_10_32x32_avx2:                                   141.4 (10.85x)
w_avg_10_64x64_c:                                     6003.6 ( 1.00x)
w_avg_10_64x64_avx2:                                   557.4 (10.77x)
w_avg_10_128x128_c:                                  23722.7 ( 1.00x)
w_avg_10_128x128_avx2:                                2205.0 (10.76x)
w_avg_12_2x2_c:                                         18.6 ( 1.00x)
w_avg_12_2x2_avx2:                                      13.1 ( 1.42x)
w_avg_12_4x4_c:                                         52.2 ( 1.00x)
w_avg_12_4x4_avx2:                                      16.1 ( 3.24x)
w_avg_12_8x8_c:                                        109.2 ( 1.00x)
w_avg_12_8x8_avx2:                                      20.6 ( 5.29x)
w_avg_12_16x16_c:                                      396.1 ( 1.00x)
w_avg_12_16x16_avx2:                                    45.0 ( 8.81x)
w_avg_12_32x32_c:                                     1532.6 ( 1.00x)
w_avg_12_32x32_avx2:                                   142.1 (10.79x)
w_avg_12_64x64_c:                                     6002.2 ( 1.00x)
w_avg_12_64x64_avx2:                                   557.3 (10.77x)
w_avg_12_128x128_c:                                  23748.7 ( 1.00x)
w_avg_12_128x128_avx2:                                2206.4 (10.76x)

New benchmarks:
w_avg_8_2x2_c:                                          16.0 ( 1.00x)
w_avg_8_2x2_avx2:                                        9.3 ( 1.71x)
w_avg_8_4x4_c:                                          48.4 ( 1.00x)
w_avg_8_4x4_avx2:                                       12.4 ( 3.91x)
w_avg_8_8x8_c:                                         168.7 ( 1.00x)
w_avg_8_8x8_avx2:                                       21.1 ( 8.00x)
w_avg_8_16x16_c:                                       394.5 ( 1.00x)
w_avg_8_16x16_avx2:                                     46.2 ( 8.54x)
w_avg_8_32x32_c:                                      1456.3 ( 1.00x)
w_avg_8_32x32_avx2:                                    171.8 ( 8.48x)
w_avg_8_64x64_c:                                      5636.2 ( 1.00x)
w_avg_8_64x64_avx2:                                    676.9 ( 8.33x)
w_avg_8_128x128_c:                                   22129.1 ( 1.00x)
w_avg_8_128x128_avx2:                                 2734.3 ( 8.09x)
w_avg_10_2x2_c:                                         18.7 ( 1.00x)
w_avg_10_2x2_avx2:                                      10.3 ( 1.82x)
w_avg_10_4x4_c:                                         50.8 ( 1.00x)
w_avg_10_4x4_avx2:                                      13.4 ( 3.79x)
w_avg_10_8x8_c:                                        109.7 ( 1.00x)
w_avg_10_8x8_avx2:                                      20.4 ( 5.38x)
w_avg_10_16x16_c:                                      395.2 ( 1.00x)
w_avg_10_16x16_avx2:                                    41.7 ( 9.48x)
w_avg_10_32x32_c:                                     1535.6 ( 1.00x)
w_avg_10_32x32_avx2:                                   137.9 (11.13x)
w_avg_10_64x64_c:                                     6002.1 ( 1.00x)
w_avg_10_64x64_avx2:                                   548.5 (10.94x)
w_avg_10_128x128_c:                                  23742.7 ( 1.00x)
w_avg_10_128x128_avx2:                                2179.8 (10.89x)
w_avg_12_2x2_c:                                         18.9 ( 1.00x)
w_avg_12_2x2_avx2:                                      10.3 ( 1.84x)
w_avg_12_4x4_c:                                         52.4 ( 1.00x)
w_avg_12_4x4_avx2:                                      13.4 ( 3.91x)
w_avg_12_8x8_c:                                        109.2 ( 1.00x)
w_avg_12_8x8_avx2:                                      20.3 ( 5.39x)
w_avg_12_16x16_c:                                      396.3 ( 1.00x)
w_avg_12_16x16_avx2:                                    41.7 ( 9.51x)
w_avg_12_32x32_c:                                     1532.6 ( 1.00x)
w_avg_12_32x32_avx2:                                   138.6 (11.06x)
w_avg_12_64x64_c:                                     5996.7 ( 1.00x)
w_avg_12_64x64_avx2:                                   549.6 (10.91x)
w_avg_12_128x128_c:                                  23738.0 ( 1.00x)
w_avg_12_128x128_avx2:                                2177.2 (10.90x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 01:01:27 +01:00
Andreas Rheinhardt ea78402e9c avcodec/x86/vvc/mc,dsp_init: Avoid pointless wrappers for avg
Up until now, there were two averaging assembly functions,
one for eight bit content and one for <=16 bit content;
there are also three C-wrappers around these functions,
for 8, 10 and 12 bpp. These wrappers simply forward the
maximum permissible value (i.e. (1<<bpp)-1) and promote
some integer values to ptrdiff_t.

Yet these wrappers are absolutely useless: The assembly functions
rederive the bpp from the maximum and only the integer part
of the promoted ptrdiff_t values is ever used. Of course,
these wrappers also entail an additional call (not a tail call,
because the additional maximum parameter is passed on the stack).

Remove the wrappers and add per-bpp assembly functions instead.
Given that the only difference between 10 and 12 bits are some
constants in registers, the main part of these functions can be
shared (given that this code uses a jumptable, it can even
be done without adding any additional jump).

Old benchmarks:
avg_8_2x2_c:                                            11.4 ( 1.00x)
avg_8_2x2_avx2:                                          7.9 ( 1.44x)
avg_8_4x4_c:                                            30.7 ( 1.00x)
avg_8_4x4_avx2:                                         10.4 ( 2.95x)
avg_8_8x8_c:                                           134.5 ( 1.00x)
avg_8_8x8_avx2:                                         16.6 ( 8.12x)
avg_8_16x16_c:                                         255.6 ( 1.00x)
avg_8_16x16_avx2:                                       28.2 ( 9.07x)
avg_8_32x32_c:                                         897.7 ( 1.00x)
avg_8_32x32_avx2:                                       83.9 (10.70x)
avg_8_64x64_c:                                        3320.0 ( 1.00x)
avg_8_64x64_avx2:                                      321.1 (10.34x)
avg_8_128x128_c:                                     12981.8 ( 1.00x)
avg_8_128x128_avx2:                                   1480.1 ( 8.77x)
avg_10_2x2_c:                                           12.0 ( 1.00x)
avg_10_2x2_avx2:                                         8.4 ( 1.43x)
avg_10_4x4_c:                                           34.9 ( 1.00x)
avg_10_4x4_avx2:                                         9.8 ( 3.56x)
avg_10_8x8_c:                                           76.8 ( 1.00x)
avg_10_8x8_avx2:                                        15.1 ( 5.08x)
avg_10_16x16_c:                                        256.6 ( 1.00x)
avg_10_16x16_avx2:                                      25.1 (10.20x)
avg_10_32x32_c:                                        932.9 ( 1.00x)
avg_10_32x32_avx2:                                      73.4 (12.72x)
avg_10_64x64_c:                                       3517.9 ( 1.00x)
avg_10_64x64_avx2:                                     414.8 ( 8.48x)
avg_10_128x128_c:                                    13695.3 ( 1.00x)
avg_10_128x128_avx2:                                  1648.1 ( 8.31x)
avg_12_2x2_c:                                           13.1 ( 1.00x)
avg_12_2x2_avx2:                                         8.6 ( 1.53x)
avg_12_4x4_c:                                           35.4 ( 1.00x)
avg_12_4x4_avx2:                                        10.1 ( 3.49x)
avg_12_8x8_c:                                           76.6 ( 1.00x)
avg_12_8x8_avx2:                                        16.7 ( 4.60x)
avg_12_16x16_c:                                        256.6 ( 1.00x)
avg_12_16x16_avx2:                                      25.5 (10.07x)
avg_12_32x32_c:                                        933.2 ( 1.00x)
avg_12_32x32_avx2:                                      75.7 (12.34x)
avg_12_64x64_c:                                       3519.1 ( 1.00x)
avg_12_64x64_avx2:                                     416.8 ( 8.44x)
avg_12_128x128_c:                                    13695.1 ( 1.00x)
avg_12_128x128_avx2:                                  1651.6 ( 8.29x)

New benchmarks:
avg_8_2x2_c:                                            11.5 ( 1.00x)
avg_8_2x2_avx2:                                          6.0 ( 1.91x)
avg_8_4x4_c:                                            29.7 ( 1.00x)
avg_8_4x4_avx2:                                          8.0 ( 3.72x)
avg_8_8x8_c:                                           131.4 ( 1.00x)
avg_8_8x8_avx2:                                         12.2 (10.74x)
avg_8_16x16_c:                                         254.3 ( 1.00x)
avg_8_16x16_avx2:                                       24.8 (10.25x)
avg_8_32x32_c:                                         897.7 ( 1.00x)
avg_8_32x32_avx2:                                       77.8 (11.54x)
avg_8_64x64_c:                                        3321.3 ( 1.00x)
avg_8_64x64_avx2:                                      318.7 (10.42x)
avg_8_128x128_c:                                     12988.4 ( 1.00x)
avg_8_128x128_avx2:                                   1430.1 ( 9.08x)
avg_10_2x2_c:                                           12.1 ( 1.00x)
avg_10_2x2_avx2:                                         5.7 ( 2.13x)
avg_10_4x4_c:                                           35.0 ( 1.00x)
avg_10_4x4_avx2:                                         9.0 ( 3.88x)
avg_10_8x8_c:                                           77.2 ( 1.00x)
avg_10_8x8_avx2:                                        12.4 ( 6.24x)
avg_10_16x16_c:                                        256.2 ( 1.00x)
avg_10_16x16_avx2:                                      24.3 (10.56x)
avg_10_32x32_c:                                        932.9 ( 1.00x)
avg_10_32x32_avx2:                                      71.9 (12.97x)
avg_10_64x64_c:                                       3516.8 ( 1.00x)
avg_10_64x64_avx2:                                     414.7 ( 8.48x)
avg_10_128x128_c:                                    13693.7 ( 1.00x)
avg_10_128x128_avx2:                                  1609.3 ( 8.51x)
avg_12_2x2_c:                                           14.1 ( 1.00x)
avg_12_2x2_avx2:                                         5.7 ( 2.48x)
avg_12_4x4_c:                                           35.8 ( 1.00x)
avg_12_4x4_avx2:                                         9.0 ( 3.96x)
avg_12_8x8_c:                                           76.9 ( 1.00x)
avg_12_8x8_avx2:                                        12.4 ( 6.22x)
avg_12_16x16_c:                                        256.5 ( 1.00x)
avg_12_16x16_avx2:                                      24.4 (10.50x)
avg_12_32x32_c:                                        934.1 ( 1.00x)
avg_12_32x32_avx2:                                      72.0 (12.97x)
avg_12_64x64_c:                                       3518.2 ( 1.00x)
avg_12_64x64_avx2:                                     414.8 ( 8.48x)
avg_12_128x128_c:                                    13689.5 ( 1.00x)
avg_12_128x128_avx2:                                  1611.1 ( 8.50x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:58:33 +01:00
Andreas Rheinhardt 5a60b3f1a6 avcodec/x86/vvc/mc: Remove always-false branches
The C versions of the average and weighted average functions
contains "FFMAX(3, 15 - BIT_DEPTH)" and the code here followed
this; yet it is only instantiated for bit depths 8, 10 and 12,
for which the above is just 15-BIT_DEPTH. So the comparisons
are unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:57:56 +01:00
Andreas Rheinhardt 59f8ff4c18 avcodec/x86/vvc/mc: Remove unused constants
Also avoid overaligning .rodata.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:57:56 +01:00
Andreas Rheinhardt eabf52e787 avcodec/x86/vvc/mc: Avoid unused work
The high quadword of these registers is zero for width 2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:57:56 +01:00
Andreas Rheinhardt 9317fb2b2e avcodec/x86/vvc/mc: Avoid ymm registers where possible
Widths 2 and 4 fit into xmm registers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:57:56 +01:00
Andreas Rheinhardt caa0ae0cfb avcodec/x86/vvc/mc: Avoid pextr[dq], v{insert,extract}i128
Use mov[dq], movdqu instead if the least significant parts
are set (i.e. if the immediate value is 0x0).

Old benchmarks:
avg_8_2x2_c:                                            11.3 ( 1.00x)
avg_8_2x2_avx2:                                          7.5 ( 1.50x)
avg_8_4x4_c:                                            31.2 ( 1.00x)
avg_8_4x4_avx2:                                         10.7 ( 2.91x)
avg_8_8x8_c:                                           133.5 ( 1.00x)
avg_8_8x8_avx2:                                         21.2 ( 6.30x)
avg_8_16x16_c:                                         254.7 ( 1.00x)
avg_8_16x16_avx2:                                       30.1 ( 8.46x)
avg_8_32x32_c:                                         896.9 ( 1.00x)
avg_8_32x32_avx2:                                      103.9 ( 8.63x)
avg_8_64x64_c:                                        3320.7 ( 1.00x)
avg_8_64x64_avx2:                                      539.4 ( 6.16x)
avg_8_128x128_c:                                     12991.5 ( 1.00x)
avg_8_128x128_avx2:                                   1661.3 ( 7.82x)
avg_10_2x2_c:                                           21.3 ( 1.00x)
avg_10_2x2_avx2:                                         8.3 ( 2.55x)
avg_10_4x4_c:                                           34.9 ( 1.00x)
avg_10_4x4_avx2:                                        10.6 ( 3.28x)
avg_10_8x8_c:                                           76.3 ( 1.00x)
avg_10_8x8_avx2:                                        20.2 ( 3.77x)
avg_10_16x16_c:                                        255.9 ( 1.00x)
avg_10_16x16_avx2:                                      24.1 (10.60x)
avg_10_32x32_c:                                        932.4 ( 1.00x)
avg_10_32x32_avx2:                                      73.3 (12.72x)
avg_10_64x64_c:                                       3516.4 ( 1.00x)
avg_10_64x64_avx2:                                     601.7 ( 5.84x)
avg_10_128x128_c:                                    13690.6 ( 1.00x)
avg_10_128x128_avx2:                                  1613.2 ( 8.49x)
avg_12_2x2_c:                                           14.0 ( 1.00x)
avg_12_2x2_avx2:                                         8.3 ( 1.67x)
avg_12_4x4_c:                                           35.3 ( 1.00x)
avg_12_4x4_avx2:                                        10.9 ( 3.26x)
avg_12_8x8_c:                                           76.5 ( 1.00x)
avg_12_8x8_avx2:                                        20.3 ( 3.77x)
avg_12_16x16_c:                                        256.7 ( 1.00x)
avg_12_16x16_avx2:                                      24.1 (10.63x)
avg_12_32x32_c:                                        932.5 ( 1.00x)
avg_12_32x32_avx2:                                      73.3 (12.72x)
avg_12_64x64_c:                                       3520.5 ( 1.00x)
avg_12_64x64_avx2:                                     602.6 ( 5.84x)
avg_12_128x128_c:                                    13689.6 ( 1.00x)
avg_12_128x128_avx2:                                  1613.1 ( 8.49x)
w_avg_8_2x2_c:                                          16.7 ( 1.00x)
w_avg_8_2x2_avx2:                                       13.4 ( 1.25x)
w_avg_8_4x4_c:                                          44.5 ( 1.00x)
w_avg_8_4x4_avx2:                                       15.9 ( 2.81x)
w_avg_8_8x8_c:                                         166.1 ( 1.00x)
w_avg_8_8x8_avx2:                                       45.7 ( 3.63x)
w_avg_8_16x16_c:                                       392.9 ( 1.00x)
w_avg_8_16x16_avx2:                                     57.8 ( 6.80x)
w_avg_8_32x32_c:                                      1455.5 ( 1.00x)
w_avg_8_32x32_avx2:                                    215.0 ( 6.77x)
w_avg_8_64x64_c:                                      5621.8 ( 1.00x)
w_avg_8_64x64_avx2:                                    875.2 ( 6.42x)
w_avg_8_128x128_c:                                   22131.3 ( 1.00x)
w_avg_8_128x128_avx2:                                 3390.1 ( 6.53x)
w_avg_10_2x2_c:                                         18.0 ( 1.00x)
w_avg_10_2x2_avx2:                                      14.0 ( 1.28x)
w_avg_10_4x4_c:                                         53.9 ( 1.00x)
w_avg_10_4x4_avx2:                                      15.9 ( 3.40x)
w_avg_10_8x8_c:                                        109.5 ( 1.00x)
w_avg_10_8x8_avx2:                                      40.4 ( 2.71x)
w_avg_10_16x16_c:                                      395.7 ( 1.00x)
w_avg_10_16x16_avx2:                                    44.7 ( 8.86x)
w_avg_10_32x32_c:                                     1532.7 ( 1.00x)
w_avg_10_32x32_avx2:                                   142.4 (10.77x)
w_avg_10_64x64_c:                                     6007.7 ( 1.00x)
w_avg_10_64x64_avx2:                                   745.5 ( 8.06x)
w_avg_10_128x128_c:                                  23719.7 ( 1.00x)
w_avg_10_128x128_avx2:                                2217.7 (10.70x)
w_avg_12_2x2_c:                                         18.9 ( 1.00x)
w_avg_12_2x2_avx2:                                      13.6 ( 1.38x)
w_avg_12_4x4_c:                                         47.5 ( 1.00x)
w_avg_12_4x4_avx2:                                      15.9 ( 2.99x)
w_avg_12_8x8_c:                                        109.3 ( 1.00x)
w_avg_12_8x8_avx2:                                      40.9 ( 2.67x)
w_avg_12_16x16_c:                                      395.6 ( 1.00x)
w_avg_12_16x16_avx2:                                    44.8 ( 8.84x)
w_avg_12_32x32_c:                                     1531.0 ( 1.00x)
w_avg_12_32x32_avx2:                                   141.8 (10.80x)
w_avg_12_64x64_c:                                     6016.7 ( 1.00x)
w_avg_12_64x64_avx2:                                   732.8 ( 8.21x)
w_avg_12_128x128_c:                                  23762.2 ( 1.00x)
w_avg_12_128x128_avx2:                                2223.4 (10.69x)

New benchmarks:
avg_8_2x2_c:                                            11.3 ( 1.00x)
avg_8_2x2_avx2:                                          7.6 ( 1.49x)
avg_8_4x4_c:                                            31.2 ( 1.00x)
avg_8_4x4_avx2:                                         10.8 ( 2.89x)
avg_8_8x8_c:                                           131.6 ( 1.00x)
avg_8_8x8_avx2:                                         15.6 ( 8.42x)
avg_8_16x16_c:                                         255.3 ( 1.00x)
avg_8_16x16_avx2:                                       27.9 ( 9.16x)
avg_8_32x32_c:                                         897.9 ( 1.00x)
avg_8_32x32_avx2:                                       81.2 (11.06x)
avg_8_64x64_c:                                        3320.0 ( 1.00x)
avg_8_64x64_avx2:                                      335.1 ( 9.91x)
avg_8_128x128_c:                                     12999.1 ( 1.00x)
avg_8_128x128_avx2:                                   1456.3 ( 8.93x)
avg_10_2x2_c:                                           12.0 ( 1.00x)
avg_10_2x2_avx2:                                         8.6 ( 1.40x)
avg_10_4x4_c:                                           34.9 ( 1.00x)
avg_10_4x4_avx2:                                         9.7 ( 3.61x)
avg_10_8x8_c:                                           76.7 ( 1.00x)
avg_10_8x8_avx2:                                        16.3 ( 4.69x)
avg_10_16x16_c:                                        256.3 ( 1.00x)
avg_10_16x16_avx2:                                      25.2 (10.18x)
avg_10_32x32_c:                                        932.8 ( 1.00x)
avg_10_32x32_avx2:                                      73.3 (12.72x)
avg_10_64x64_c:                                       3518.8 ( 1.00x)
avg_10_64x64_avx2:                                     416.8 ( 8.44x)
avg_10_128x128_c:                                    13691.6 ( 1.00x)
avg_10_128x128_avx2:                                  1612.9 ( 8.49x)
avg_12_2x2_c:                                           14.1 ( 1.00x)
avg_12_2x2_avx2:                                         8.7 ( 1.62x)
avg_12_4x4_c:                                           35.7 ( 1.00x)
avg_12_4x4_avx2:                                         9.7 ( 3.68x)
avg_12_8x8_c:                                           77.0 ( 1.00x)
avg_12_8x8_avx2:                                        16.9 ( 4.57x)
avg_12_16x16_c:                                        256.2 ( 1.00x)
avg_12_16x16_avx2:                                      25.7 ( 9.96x)
avg_12_32x32_c:                                        933.5 ( 1.00x)
avg_12_32x32_avx2:                                      74.0 (12.62x)
avg_12_64x64_c:                                       3516.4 ( 1.00x)
avg_12_64x64_avx2:                                     408.7 ( 8.60x)
avg_12_128x128_c:                                    13691.6 ( 1.00x)
avg_12_128x128_avx2:                                  1613.8 ( 8.48x)
w_avg_8_2x2_c:                                          16.7 ( 1.00x)
w_avg_8_2x2_avx2:                                       14.0 ( 1.19x)
w_avg_8_4x4_c:                                          48.2 ( 1.00x)
w_avg_8_4x4_avx2:                                       16.1 ( 3.00x)
w_avg_8_8x8_c:                                         168.0 ( 1.00x)
w_avg_8_8x8_avx2:                                       22.5 ( 7.47x)
w_avg_8_16x16_c:                                       392.5 ( 1.00x)
w_avg_8_16x16_avx2:                                     47.9 ( 8.19x)
w_avg_8_32x32_c:                                      1453.7 ( 1.00x)
w_avg_8_32x32_avx2:                                    176.1 ( 8.26x)
w_avg_8_64x64_c:                                      5631.4 ( 1.00x)
w_avg_8_64x64_avx2:                                    690.8 ( 8.15x)
w_avg_8_128x128_c:                                   22139.5 ( 1.00x)
w_avg_8_128x128_avx2:                                 2742.4 ( 8.07x)
w_avg_10_2x2_c:                                         18.1 ( 1.00x)
w_avg_10_2x2_avx2:                                      13.8 ( 1.31x)
w_avg_10_4x4_c:                                         47.0 ( 1.00x)
w_avg_10_4x4_avx2:                                      16.4 ( 2.87x)
w_avg_10_8x8_c:                                        110.0 ( 1.00x)
w_avg_10_8x8_avx2:                                      21.6 ( 5.09x)
w_avg_10_16x16_c:                                      395.2 ( 1.00x)
w_avg_10_16x16_avx2:                                    45.4 ( 8.71x)
w_avg_10_32x32_c:                                     1533.8 ( 1.00x)
w_avg_10_32x32_avx2:                                   142.6 (10.76x)
w_avg_10_64x64_c:                                     6004.4 ( 1.00x)
w_avg_10_64x64_avx2:                                   672.8 ( 8.92x)
w_avg_10_128x128_c:                                  23748.5 ( 1.00x)
w_avg_10_128x128_avx2:                                2198.0 (10.80x)
w_avg_12_2x2_c:                                         17.2 ( 1.00x)
w_avg_12_2x2_avx2:                                      13.9 ( 1.24x)
w_avg_12_4x4_c:                                         51.4 ( 1.00x)
w_avg_12_4x4_avx2:                                      16.5 ( 3.11x)
w_avg_12_8x8_c:                                        109.1 ( 1.00x)
w_avg_12_8x8_avx2:                                      22.0 ( 4.96x)
w_avg_12_16x16_c:                                      395.9 ( 1.00x)
w_avg_12_16x16_avx2:                                    44.9 ( 8.81x)
w_avg_12_32x32_c:                                     1533.5 ( 1.00x)
w_avg_12_32x32_avx2:                                   142.3 (10.78x)
w_avg_12_64x64_c:                                     6002.0 ( 1.00x)
w_avg_12_64x64_avx2:                                   557.5 (10.77x)
w_avg_12_128x128_c:                                  23749.5 ( 1.00x)
w_avg_12_128x128_avx2:                                2202.0 (10.79x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:57:56 +01:00
Andreas Rheinhardt 7bf9c1e3f6 avcodec/x86/vvc/mc: Avoid redundant clipping for 8bit
It is already done by packuswb.

Old benchmarks:
avg_8_2x2_c:                                            11.1 ( 1.00x)
avg_8_2x2_avx2:                                          8.6 ( 1.28x)
avg_8_4x4_c:                                            30.0 ( 1.00x)
avg_8_4x4_avx2:                                         10.8 ( 2.78x)
avg_8_8x8_c:                                           132.0 ( 1.00x)
avg_8_8x8_avx2:                                         25.7 ( 5.14x)
avg_8_16x16_c:                                         254.6 ( 1.00x)
avg_8_16x16_avx2:                                       33.2 ( 7.67x)
avg_8_32x32_c:                                         897.5 ( 1.00x)
avg_8_32x32_avx2:                                      115.6 ( 7.76x)
avg_8_64x64_c:                                        3316.9 ( 1.00x)
avg_8_64x64_avx2:                                      626.5 ( 5.29x)
avg_8_128x128_c:                                     12973.6 ( 1.00x)
avg_8_128x128_avx2:                                   1914.0 ( 6.78x)
w_avg_8_2x2_c:                                          16.7 ( 1.00x)
w_avg_8_2x2_avx2:                                       14.4 ( 1.16x)
w_avg_8_4x4_c:                                          48.2 ( 1.00x)
w_avg_8_4x4_avx2:                                       16.5 ( 2.92x)
w_avg_8_8x8_c:                                         168.1 ( 1.00x)
w_avg_8_8x8_avx2:                                       49.7 ( 3.38x)
w_avg_8_16x16_c:                                       392.4 ( 1.00x)
w_avg_8_16x16_avx2:                                     61.1 ( 6.43x)
w_avg_8_32x32_c:                                      1455.3 ( 1.00x)
w_avg_8_32x32_avx2:                                    224.6 ( 6.48x)
w_avg_8_64x64_c:                                      5632.1 ( 1.00x)
w_avg_8_64x64_avx2:                                    896.9 ( 6.28x)
w_avg_8_128x128_c:                                   22136.3 ( 1.00x)
w_avg_8_128x128_avx2:                                 3626.7 ( 6.10x)

New benchmarks:
avg_8_2x2_c:                                            12.3 ( 1.00x)
avg_8_2x2_avx2:                                          8.1 ( 1.52x)
avg_8_4x4_c:                                            30.3 ( 1.00x)
avg_8_4x4_avx2:                                         11.3 ( 2.67x)
avg_8_8x8_c:                                           131.8 ( 1.00x)
avg_8_8x8_avx2:                                         21.3 ( 6.20x)
avg_8_16x16_c:                                         255.0 ( 1.00x)
avg_8_16x16_avx2:                                       30.6 ( 8.33x)
avg_8_32x32_c:                                         898.5 ( 1.00x)
avg_8_32x32_avx2:                                      104.9 ( 8.57x)
avg_8_64x64_c:                                        3317.7 ( 1.00x)
avg_8_64x64_avx2:                                      540.9 ( 6.13x)
avg_8_128x128_c:                                     12986.5 ( 1.00x)
avg_8_128x128_avx2:                                   1663.4 ( 7.81x)
w_avg_8_2x2_c:                                          16.8 ( 1.00x)
w_avg_8_2x2_avx2:                                       13.9 ( 1.21x)
w_avg_8_4x4_c:                                          48.2 ( 1.00x)
w_avg_8_4x4_avx2:                                       16.2 ( 2.98x)
w_avg_8_8x8_c:                                         168.6 ( 1.00x)
w_avg_8_8x8_avx2:                                       46.3 ( 3.64x)
w_avg_8_16x16_c:                                       392.4 ( 1.00x)
w_avg_8_16x16_avx2:                                     57.7 ( 6.80x)
w_avg_8_32x32_c:                                      1454.6 ( 1.00x)
w_avg_8_32x32_avx2:                                    214.6 ( 6.78x)
w_avg_8_64x64_c:                                      5638.4 ( 1.00x)
w_avg_8_64x64_avx2:                                    875.6 ( 6.44x)
w_avg_8_128x128_c:                                   22133.5 ( 1.00x)
w_avg_8_128x128_avx2:                                 3334.3 ( 6.64x)

Also saves 550B of .text here. The improvements will likely
be even better on Win64, because it avoids using two nonvolatile
registers in the weighted average case.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:57:56 +01:00
Andreas Rheinhardt b22b65f2f8 avformat/hlsenc: Return error upon error, fix shadowing
Introduced in 65fc0db581.

Reviewed-by: Marvin Scholz <epirat07@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:23:00 +01:00
Michael Niedermayer c98346ffaa avcodec/libtheoraenc: make keyframe mask unsigned and handle its larger range
Fixes: left shift of 1 by 31 places cannot be represented in type 'int'
Fixes: 473579864/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBTHEORA_fuzzer-5835688160591872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-21 22:43:41 +00:00
Marvin Scholz ca011ee754 avformat: Bump version and add APIChanges entry
Needed after the recent addition of the command APIs.
2026-02-21 20:03:52 +01:00
Andreas Rheinhardt 3be4545b67 avcodec/vvc/inter: Deduplicate applying averaging
Reviewed-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-21 12:48:50 +01:00
Andreas Rheinhardt 324fd0bc46 avcodec/vvc/inter: Remove redundant variable, fix shadowing
Reviewed-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-21 12:48:50 +01:00
Andreas Rheinhardt 6777d5cd48 avcodec/vvc/inter: Remove always-false/true checks
derive_weight() is only called when pred_flag is PF_BI,
which only happens in B slices.

Reviewed-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-21 12:48:50 +01:00
Niklas Haas cff9f29d5b swscale/ops_optimizer: add sanity checks to scale->expand conversion
This only works for integer types.
2026-02-21 11:47:43 +00:00
Niklas Haas 5c661dec61 swscale/ops: avoid UB in ff_sws_pixel_expand()
Restructure the loop slightly to avoid UB in the first loop iteration if
src is 4 bytes, which otherwise computes (0 << 32) | 1. Instead, make
1 the default base case and only shift+add if src < dst.

Add an explicit check to preserve the behavior of returnin 0 if src > dst.
2026-02-21 11:47:43 +00:00
Andreas Rheinhardt f951aa9ef3 avfilter/af_loudnorm: Avoid unchecked allocation
Also deduplicate printing json and summary output.

Reviewed-by: Kyle Swanson <k@ylo.ph>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 20:35:16 +01:00
Ramiro Polla a0b55a0491 avcodec/mjpegdec: fix indentation and some white spaces 2026-02-20 16:32:10 +01:00
Ramiro Polla 0accfde281 avcodec/jpeglsdec: fix decoding of jpegls files with restart markers 2026-02-20 16:32:10 +01:00
Ramiro Polla 80edf78e58 tests/fate/image: add jpegls tests with restart markers
The samples have been generated with:
jpeg -c -ls 0 -z 1 great_wave_128.ppm jpegls/ilv0_rst.jls
jpeg -c -ls 1 -z 1 great_wave_128.ppm jpegls/ilv1_rst.jls

Note: ilv2 is still unsupported
2026-02-20 16:32:10 +01:00
Ramiro Polla 5672c410a6 avcodec/mjpegdec: unescape data for each restart marker individually
Instead of unescaping the entire image data buffer in advance, and then
having to perform heuristics to skip over where the restart markers
would have been, unescape the image data for each restart marker
individually.
2026-02-20 16:32:10 +01:00
Ramiro Polla 22771117a0 avcodec/mjpegdec: move get_bits_left() checks after handling of restart count
This commit doesn't really change much on its own, but it's helpful in
preparation for the following commit.
2026-02-20 16:32:10 +01:00
Ramiro Polla 3783b8f5e1 avcodec/mjpegdec: move vpred initialization out of loop in ljpeg_decode_rgb_scan()
The initialization code was only being run when mb_y was 0, so it could
just as well be moved out of the loop.

I haven't been able to find a bayer sample that has restart markers to
check whether vpred should be reinitialized at every restart. It would
seem logical that it should, but I have left this out until we find a
sample that does have restart markers.
2026-02-20 16:32:10 +01:00
Ramiro Polla 851cb118da avcodec/jpegls: clear more JLSState fields inside ff_jpegls_init_state() 2026-02-20 16:32:10 +01:00
Ramiro Polla 3f2d4b49e6 avcodec/mjpegdec: split mjpeg_find_raw_scan_data() out of mjpeg_unescape_sos() 2026-02-20 16:32:10 +01:00
Ramiro Polla bb48d2dba2 avcodec/mjpegdec: simplify decode_scan codepaths in ff_mjpeg_decode_sos()
This will be helpful for the next commit.
2026-02-20 16:32:10 +01:00
Ramiro Polla 179db32777 avcodec/mjpegdec: move MxPEG parameters from mjpeg_decode_scan() to MJpegDecodeContext 2026-02-20 16:32:10 +01:00
Ramiro Polla 14602cd999 avcodec/mjpegdec: move SOS header fields to MJpegDecodeContext
Use naming for SOS header fields from ISO/IEC 10918-1's non-lossless
mode of operation in ff_mjpeg_decode_sos() instead of mixing JPEG-LS
and lossless names. Each decode function still keeps its correct name
for each field.
2026-02-20 16:32:10 +01:00
Ramiro Polla c1cd31320d avcodec/mjpegdec: find correct sizes for SOS fields
For hwaccel, find_marker() was being used to skip over the image data,
which could include multiple restart markers.

For MJPEG-B and THP, the field size was already correct since the image
data was already unescaped.

For the rest (mjpeg and jpegls), the buffer was being incremented by
the unescaped_buf_size, which could be smaller than the actual buffer
size.

Now the buffer is correctly incremented in all cases.
2026-02-20 16:32:10 +01:00
Ramiro Polla cad555d0a4 avcodec/mjpegdec: improve unescaping of SOS fields
For non-jpegls:

Changes the behaviour to be more in line with IJG's reference implementation:
- optional 0xFF fill bytes in a stuffed zero byte sequence (which is an
  invalid pattern according to the standard) are now discarded:
    "FF (FF)? 00" => "FF" instead of "FF 00"
- sequences with optional 0xFF fill bytes and a marker are no longer copied:
    "FF (FF)? XX" => "" instead of "FF XX"
- a trailing 0xFF byte is no longer issued when a valid "0xFF 0xXX" marker
  is found:
    "FF XX" => "" instead of "FF"

For jpegls:

Changes the behaviour to be more in line with IJG's (non-jpegls) reference
implementation, similar to the changes above:
- optional 0xFF fill bytes in a stuffed zero bit sequence (which is an
  invalid pattern according to the standard) are now discarded:
  "FF (FF)? 0b0xxxxxxx" => "FF 0bxxxxxxx" instead of "FF 7F XX"
- sequences with optional 0xFF fill bytes and a marker are no longer copied:
  "FF (FF)? 0b1xxxxxxx" => "" instead of "FF 7F"

Unescaping for jpegls is now done in one pass instead of two. The first
pass used to detect the length of the buffer, while the second pass would
copy up to the detected length.

Note that jpegls restart markers are still not supported.

There is also a speed up with the new implementations, mostly due to the
usage of memchr() as suggested by Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 16:32:10 +01:00
Ramiro Polla 8abb40a8d8 avcodec/mjpegdec: simplify away mjpeg_unescape_sos()'s parameters
The input is always obtained from s->gB and the output is always used
to initialize s->gb, so we can move that inside the function itself.
2026-02-20 16:32:10 +01:00
Ramiro Polla 3d90949d1e avcodec/mjpegdec: split mjpeg_unescape_sos() out of ff_mjpeg_find_marker()
Now only the image data is unescaped (and not the SOS header). As a
side-effect, this also provides a proper fix for decoding CJPG files
(issue #133).
2026-02-20 16:32:10 +01:00
Ramiro Polla 0ddb3e6af2 avcodec/mjpegdec: improve ff_mjpeg_find_marker() for non-SOS and for THP
There is no need to unescape the buffer for non-SOS fields and for THP.
2026-02-20 16:32:10 +01:00
Ramiro Polla 2d9023564b avcodec/mjpegdec: move handling of AVRn interlaced picture to mjpeg_decode_scan()
AVRn interlaced files are only present in sequential JPEG.
2026-02-20 16:32:10 +01:00
Ramiro Polla 51caa26a86 avcodec/mjpegdec: move initialization of last_dc field to mjpeg_decode_scan()
The last_dc field is only used in sequential JPEG and the DC coefficients
for progressive JPEG.
2026-02-20 16:32:10 +01:00
Ramiro Polla 44fd92c514 avcodec/mjpegdec: improve debug message in find_marker()
Use pointer arithmetic instead of an extra variable to keep track of
skipped bytes.
2026-02-20 16:32:10 +01:00
Ramiro Polla 8a0f1fd6ab avcodec/mjpegdec: remove commented out code 2026-02-20 16:32:10 +01:00
Ramiro Polla fa4c24a8d9 avcodec/mjpegdec: remove unnecessary else 2026-02-20 16:32:10 +01:00
Andreas Rheinhardt 9a7e0f1052 configure: Enable -Wunterminated-string-initialization warning
When an array of pointers to strings is converted into
an array of constant-length strings, one has to find out
the maximum size of the strings. Currently no warning will
be emitted If one forgets to account for the trailing zero,
making this optimization dangerous (think of the scenario
where the array will be modified without adjusting the maximum
size of the strings).

The -Wunterminated-string-initialization warning catches these cases.
It is supported by GCC 15.1 and Clang 21. It only requires to mark
the few instances of arrays initialized via string literals that
are not supposed to be strings with the nonstring attribute; this
has already been done in the previous commit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 11:59:37 +01:00
Andreas Rheinhardt 0b77f79191 avutil/attributes_internal: Add attribute_nonstring
This attribute is used to signal to the compiler
that an array object initialized via a string literal
is not a real string and may lack the space for
the trailing zero, as in char fourcc[4]="FOUR".

This is in preparation for enabling
the -Wunterminated-string-initialization warning.

Reviewed-by: J. Dekker <jdek@itanimul.li>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 11:59:37 +01:00
Andreas Rheinhardt acde43703f avutil/error: Remove size from error_stringtable
This stringtable is a concatenation of strings, with their
own trailing \0. Without an explicit size said stringtable
ends with two \0 (one from the last string and one more
because it is initialized via a string literal); the explicit
size exists to discard the last \0.

Yet this makes GCC (but not Clang) think that this is an
unterminated string, leading to warnings when
-Wunterminated-string-initialization is enabled.
So just remove the explicit size to avoid this.

(An alternative would be to mark this as a non-string
for GCC, but not for Clang, but this has been deemed ugly;
another alternative would be to omit the internal \0 from
the stringtable and use length fields instead, but
the necessary copying code more than outweighs the size benefits
of omitting the \0.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 11:59:37 +01:00
Andreas Rheinhardt 005510501e configure: Make check for accepting warnings stricter
Clang by default allows unknown warnings and merely emits
a Wunknown-warning-option warning which is non-fatal by default,
making it appear as if Clang supported any warning. This patch
rewrites the tests to always add the arguments to error out
in case an unrecognized option is encountered.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 11:59:37 +01:00
Andreas Rheinhardt 05098eef42 configure: Use per-language unknown-warnings-flags
E.g. when CC is clang, the unknown warnings flags
are -Werror=unused-command-line-argument and
-Werror=unknown-warning-option. These flags are currently
also used for testing the C++ and ObjC compilers, yet
g++ does not recognize these flags and errors out because
of them, so that the tests fail and the parentheses,
switch etc. warnings are not disabled for C++.

Fix this by using per-language flags.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 11:59:37 +01:00
Vignesh Venkat 51349e31fc avformat/whip: Avoid uninitialized pointer read
Do not try to free the io context if it was never allocated.

Fixes coverity #1665383

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
2026-02-20 01:12:27 +00:00
Marvin Scholz e8a07be1c2 avformat: rtsp: fix logging of reply sequence number 2026-02-20 01:31:06 +01:00
Marvin Scholz 8d46d88f05 avformat: rtspdec: fix leaks in rtsp_read_command_reply
Reorder to avoid allocation if there is nothing to read and also solve
a memory leak in that case.

Also make sure to free the RTSPMessageHeader, which is not passed
to the caller.
2026-02-20 01:31:06 +01:00
Michael Niedermayer 360a4025fb avcodec/rv60dec: check last_size
Fixes: signed integer overflow: 1878131215 + 2013265920 cannot be represented in type 'int'
Fixes: 472729732/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-4893818005815296

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-19 22:39:35 +00:00
Niklas Haas c9404f5b9c swscale/optimizer: eliminate completely unused operations
e.g. empty read when all components are eventually cleared

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 46d721a69a swscale/optimizer: compress planar reads with unused planes
After plane splitting, we can end up with a situation where a subpass wants
to read only, say, the alpha plane. In this case, we should compress the
planar read by instead swizzling the alpha plane into the correct place
in the src plane order, and then reading only a single plane.

Results in a bunch of benign diffs like:

 yuva444p -> ya8:
-  [ u8 XXXX -> ++++] SWS_OP_READ         : 4 elem(s) planar >> 0
-  [ u8 .XX. -> ++++] SWS_OP_CONVERT      : u8 -> f32
-  [f32 .XX. -> .+++] SWS_OP_LINEAR       : luma [...]
-  [f32 .XX. -> .+++] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
-  [f32 .XX. -> .+++] SWS_OP_MAX          : {0 0 0 0} <= x
-  [f32 .XX. -> .+++] SWS_OP_MIN          : x <= {255 _ _ 255}
-  [f32 .XX. -> ++++] SWS_OP_CONVERT      : f32 -> u8
-  [ u8 .XX. -> ++++] SWS_OP_SWIZZLE      : 0312
-  [ u8 ..XX -> ++++] SWS_OP_WRITE        : 2 elem(s) packed >> 0
+  [ u8 XXXX -> ++XX] SWS_OP_READ         : 2 elem(s) planar >> 0, via {0, 3}
+  [ u8 ..XX -> ++XX] SWS_OP_CONVERT      : u8 -> f32
+  [f32 ..XX -> +XX+] SWS_OP_SWIZZLE      : 0321
+  [f32 .XX. -> .XX+] SWS_OP_LINEAR       : luma [...]
+  [f32 .XX. -> .XX+] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
+  [f32 .XX. -> .XX+] SWS_OP_MAX          : {0 0 0 0} <= x
+  [f32 .XX. -> .XX+] SWS_OP_MIN          : x <= {255 _ _ 255}
+  [f32 .XX. -> +XX+] SWS_OP_CONVERT      : f32 -> u8
+  [ u8 .XX. -> ++XX] SWS_OP_SWIZZLE      : 0312
+  [ u8 ..XX -> ++XX] SWS_OP_WRITE        : 2 elem(s) packed >> 0

This may seem noisy, but really is mostly a result of the fact that the unused
middle components are now marked as garbage instead of as valid data.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas b01236d5fb swscale/optimizer: try pushing all swizzles towards the output
Now that we can directly promote these to plane swizzles, we generally want
to try pushing them in one direction - ideally towards the output, as in the
case of split subpasses, the output is guaranteed to be planar. (And there
may not even be a read)

Results in a lot of diffs, ranging from the benign, e.g.:

 rgb24 -> bgr48be:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> u16 (expand)
-  [u16 ...X -> +++X] SWS_OP_SWIZZLE      : 2103
   [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
+  [u16 ...X -> zzzX] SWS_OP_SWIZZLE      : 2103
   [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) packed >> 0

 rgb24 -> gbrp9be:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> f32
   [f32 ...X -> ...X] SWS_OP_SCALE        : * 511/255
   [f32 ...X -> ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
   [f32 ...X -> ...X] SWS_OP_MIN          : x <= {511 511 511 _}
   [f32 ...X -> +++X] SWS_OP_CONVERT      : f32 -> u16
-  [u16 ...X -> +++X] SWS_OP_SWIZZLE      : 1203
   [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
-  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) planar >> 0, via {2, 0, 1}

To the clear improvements, e.g.:

 bgr24 -> gbrp16be:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
-  [ u8 ...X -> +++X] SWS_OP_SWIZZLE      : 2103
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> u16 (expand)
-  [u16 ...X -> +++X] SWS_OP_SWIZZLE      : 1203
   [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
-  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) planar >> 0, via {1, 0, 2}

The only case worth careful consideration is when there are swizzled inputs
that result in unusual plane patterns, e.g.:

 argb -> gbrp9be:
   [ u8 XXXX -> ++++] SWS_OP_READ         : 4 elem(s) packed >> 0
-  [ u8 X... -> ++++] SWS_OP_SWIZZLE      : 1230
-  [ u8 ...X -> ++++] SWS_OP_CONVERT      : u8 -> f32
-  [f32 ...X -> ....] SWS_OP_SCALE        : * 511/255
-  [f32 ...X -> ....] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
-  [f32 ...X -> ....] SWS_OP_MIN          : x <= {511 511 511 _}
-  [f32 ...X -> ++++] SWS_OP_CONVERT      : f32 -> u16
-  [u16 ...X -> ++++] SWS_OP_SWIZZLE      : 1203
-  [u16 ...X -> zzzz] SWS_OP_SWAP_BYTES
-  [u16 ...X -> zzzz] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+  [ u8 X... -> ++++] SWS_OP_CONVERT      : u8 -> f32
+  [f32 X... -> ....] SWS_OP_SCALE        : * 511/255
+  [f32 X... -> ....] SWS_OP_DITHER       : 16x16 matrix + {0 0 3 2}
+  [f32 X... -> ....] SWS_OP_MIN          : x <= {511 511 511 511}
+  [f32 X... -> ++++] SWS_OP_CONVERT      : f32 -> u16
+  [u16 X... -> zzzz] SWS_OP_SWAP_BYTES
+  [u16 X... -> zzzz] SWS_OP_SWIZZLE      : 3120
+  [u16 ...X -> zzzz] SWS_OP_WRITE        : 3 elem(s) planar >> 0, via {1, 2, 0}
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Observe the change from ...X to X..., which is a pattern that doesn't
necessarily have a fast path and would usually end up falling back to the
generic 4-component implementations (rather than the 3-component ones).

That said, this is not a big deal, since we can ultimately re-align the
set of implementations with what's actually needed; once we're done with
plane splitting and so forth.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas aaa898a2d1 swscale/optimizer: promote component swizzles to plane swizzles
In some cases, we can just directly swizzle the order of input/output
planes, rather than applying a swizzle operation on the data itself.

This can eliminate some such swizzle operations entirely, for example
yuv444p -> vuya is now just a read, clear and write.

Results in a lot of simplifications like this:

 rgb24 -> gbrp:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
-  [ u8 ...X -> +++X] SWS_OP_SWIZZLE      : 1203
-  [ u8 ...X -> +++X] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+  [ u8 ...X -> +++X] SWS_OP_WRITE        : 3 elem(s) planar >> 0, via {2, 0, 1}

 rgb24 -> gbrap16le:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> u16 (expand)
-  [u16 ...X -> +++X] SWS_OP_SWIZZLE      : 1203
   [u16 ...X -> ++++] SWS_OP_CLEAR        : {_ _ _ 65535}
-  [u16 .... -> ++++] SWS_OP_WRITE        : 4 elem(s) planar >> 0
+  [u16 .... -> ++++] SWS_OP_WRITE        : 4 elem(s) planar >> 0, via {2, 0, 1, 3}

 yuv444p -> vuya:
-  [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) planar >> 0
-  [ u8 ...X -> +++X] SWS_OP_SWIZZLE      : 2103
+  [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) planar >> 0, via {2, 1, 0}
   [ u8 ...X -> ++++] SWS_OP_CLEAR        : {_ _ _ 255}
   [ u8 .... -> ++++] SWS_OP_WRITE        : 4 elem(s) packed >> 0

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas a02860a292 swscale/optimizer: don't assume op lists start with read
This was just a minor/pointless optimization in the first place. We keep
the skip on the last component because we can never commute that past the
end of the list.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 6df8174f77 swscale/optimizer: don't reject op lists without read
When splitting planes, some planes can end up without a read operation
altogether, e.g. when just clearing the alpha plane.

Just return ENOTSUP for such lists instead of EINVAL.

Also fixes the !ops->num_ops check to avoid UB.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas e7965e84c5 swscale/optimizer: fix unswizzle optimization
The way this code was written relied on the implicit assumption that no other
row was reading from the same column, which was true in practice so far but
not necessarily true in general. Fix it by precomputing the nonzero component
mask and then adding an explicit check.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 4b8790f107 swscale/optimizer: allow commuting CLEAR past SWAP_BYTES
This requires a bit of a manual check in the 32-bit integer case to
make sure we don't exceed the value range of AVRational; but it still allows
quite a number of optimizations despite that restriction.

e.g.

rgb24 -> yuva444p9be:
-  [u16 ...X -> ++++] SWS_OP_CLEAR        : {_ _ _ 511}
-  [u16 .... -> zzzz] SWS_OP_SWAP_BYTES
-  [u16 .... -> zzzz] SWS_OP_WRITE        : 4 elem(s) planar >> 0
+  [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
+  [u16 ...X -> zzz+] SWS_OP_CLEAR        : {_ _ _ 65281}
+  [u16 .... -> zzz+] SWS_OP_WRITE        : 4 elem(s) planar >> 0

gray -> yuv444p12be:
-  [u16 .XXX -> +++X] SWS_OP_CLEAR        : {_ 2048 2048 _}
-  [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
-  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+  [u16 .XXX -> zzXX] SWS_OP_SWAP_BYTES
+  [u16 .XXX -> z++X] SWS_OP_CLEAR        : {_ 8 8 _}
+  [u16 ...X -> z++X] SWS_OP_WRITE        : 3 elem(s) planar >> 0

Ultimately, the benefit of this will only become relevant once we start
splitting apart planes, since then we can have planes with only CLEAR
operations.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas e729f49645 swscale/ops_backend: allocate block storage up-front
Instead of in each read() function. Not only is this slightly faster, due
to promoting more tail calls, but it also allows us to have operation chains
that don't start with a read.

Also simplifies the implementations.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 7961e3a48f swscale/ops_backend: add float clear patterns
These have no implementation at all otherwise.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 272e7a047b swscale/ops_backend: add clear pattern for ya8 alpha
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas ef4e16ed50 swscale/x86/ops: make the presence of a read op optional
Allows this backend to process op lists without a read, e.g. for pure clear
operations. I decided to change `write` to a pointer as well for symmetry.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas da47951bd7 swscale/ops: lift read op metadata to SwsOpList
Instead of awkwardly preserving these from the `SwsOp` itself. This
interpretation lessens the risk of bugs as a result of changing the plane
swizzle mask without updating the corresponding components.

After this commit, the plane swizzle mask is automatically taken into
account; i.e. the src_comps mask is always interpreted as if the read op
was in-order (unswizzled).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 1940662ac6 swscale/ops: take plane order into account during noop() check
This helper function now also takes into account the plane order, and only
returns true if the SwsOpList is a true no-op (i.e. the input image may be
exactly ref'd to the output, with no change in plane order, etc.)

As pointed out in the code, this is unlikely to actually matter, but still
technically correct.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas d0cb74881c swscale/ops: fix PRINTQ snprintf buffer size
There is no reason to subtract 1 here; snprintf guarantees zero-termination.
2026-02-19 19:44:46 +00:00
Niklas Haas 70d30056dc swscale/ops: also print plane order when swizzled
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 998cffb432 swscale/ops: add input/output plane swizzle mask to SwsOpList
This can be used to have the execution code directly swizzle the plane
pointers, instead of swizzling the data via SWS_OP_SWIZZLE. This can be used
to, for example, extract a subset of the input/output planes for partial
processing of split graphs (e.g. subsampled chroma, or independent alpha),
or just to skip an SWS_OP_SWIZZLE operation.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 2dfde1531d swscale/ops: reset comp flags on SWS_OP_CLEAR
Even if we clear to a non-integer value.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 9662d1fa97 swscale/optimizer: remove read+write optimization
This optimization is lossy, since it removes important information about the
number of planes to be copied. Subsumed by the more correct

Instead, move this code to the new ff_sws_op_list_is_noop().

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas c17a9ba0b8 tests/sws_ops: explicitly skip no-op operation lists
These are not necessarily empty, as a result of the previous changes.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas e96332cb65 swscale/ops: add ff_sws_op_list_is_noop()
And use it in ff_sws_compile_pass() instead of hard-coding the check there.
This check will become more sophisticated in the following commits.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Lynne c91634dfe6 vulkan/ffv1: add current linecache for encode/decode
This avoids needing expensive roundtrips when reading/writing to images,
mainly in the decoder.
2026-02-19 19:42:35 +01:00
Lynne 3f91ff8aa6 ffv1enc_vulkan: perform non-RGB prediction in 16-bits 2026-02-19 19:42:35 +01:00
Lynne 9d5421ad92 vulkan/ffv1: keep track of RCT Ry/By coeffs using vector suffixes
This makes it far easier to read, particularly because when reading
or writing, their order is swapped.
2026-02-19 19:42:35 +01:00
Lynne b9c19c9073 ffv1enc_vulkan: use direct values rather than reading from struct
This saves indirection and allows compilers to eliminate more
code during compilation.
2026-02-19 19:42:35 +01:00
Lynne b19707103e ffv1enc_vulkan: allocate a device-only output buffer if possible
This avoids needing to map HUGE 4GiB chunks of memory.
2026-02-19 19:42:34 +01:00
Lynne 4b6396a49b ffv1enc_vulkan: allocate all results memory upfront
Suballocation is the Vulkan way.
2026-02-19 19:42:34 +01:00
Lynne f32e70ecc9 vulkan/ffv1: unify all constants buffer into a single buffer
Less allocations is always better.
2026-02-19 19:42:34 +01:00
Lynne fc10cc4a52 vulkan/ffv1: optimize get_isymbol 2026-02-19 19:42:34 +01:00
Lynne f32111f3f7 vulkan/ffv1: improve compiler hints
Don't unroll unless needed, don't use const in function arguments,
don't use expect unless actually needed.
2026-02-19 19:42:34 +01:00
Lynne e9645930dd vulkan/ffv1_dec: synchronize image writes when decoding 2026-02-19 19:42:34 +01:00
Lynne fb7700636c vulkan/ffv1: synchronize before/after RCT transform/preload 2026-02-19 19:42:34 +01:00
Lynne 5ac9376763 vulkan/ffv1_dec_setup: roll a put_rac inside a loop
This saves 16KiB of memory.
Yeah, things go large when all compilers inline everything.
2026-02-19 19:42:33 +01:00
Lynne 33525cb6e7 vulkan/rangecoder: don't store pointers in the context 2026-02-19 19:42:33 +01:00
Lynne 5c1b2947a4 ffv1enc_vulkan: only return the encoded size, not its offset
The encoded offset is just a multiple of the index by the max slice size.
2026-02-19 19:42:33 +01:00
Lynne 2c138e2df5 vulkan/ffv1: use loops to encode planes
Every function in SPIR-V gets inlined, always. So use loops.
2026-02-19 19:42:33 +01:00
Lynne 10a26974cd vulkan/ffv1: finalize and initialize slices only in invocation == 0 2026-02-19 19:42:33 +01:00
Lynne bc968bc8b4 vulkan/ffv1_enc: cache state probabilities
4x speedup on AMD.
2026-02-19 19:42:33 +01:00
Lynne 826b72d12f vulkan/ffv1: mark buffers as uniform/readonly when needed
Should be a speedup in most cases.
2026-02-19 19:42:32 +01:00
Lynne 3d74e0e63a ffv1enc_vulkan: fix Golomb encoding
The issue is that the PB buffer address for Golomb may not be aligned
to mod 4.
2026-02-19 19:42:32 +01:00
Lynne fdd0f21f5d vulkan/ffv1_common: use scalar alignment for the base slice structure
Scalar is the fastest for modern GPUs to use.
2026-02-19 19:42:32 +01:00
Lynne 4b00b26e79 vulkan_ffv1: overhaul the synchronization 2026-02-19 19:42:32 +01:00
Lynne 10407de110 vulkan/rangecoder: clean up unused functions and redundant fields 2026-02-19 19:42:32 +01:00
Lynne c8823ec5b2 vulkan_ffv1: unify slice offsets and status into one buffer
Reduces allocations.
2026-02-19 19:42:32 +01:00
Lynne 128ad49c32 ffv1dec: correctly track configured_width/height
The 2 parameters were not synchronized between decoding threads.
2026-02-19 19:42:31 +01:00
Lynne dbc6fa5248 ffv1enc: use local RangeCoder struct 2026-02-19 19:42:31 +01:00
Lynne b756d83e24 vulkan_ffv1: use local RangeCoder struct, refactor overread checking 2026-02-19 19:42:31 +01:00
Lynne 06eb98bc97 ffv1enc_vulkan: remove dead code 2026-02-19 19:42:31 +01:00
Lynne 6971ba9075 vulkan_ffv1: improve decode report results printout 2026-02-19 19:42:31 +01:00
Lynne 3ba81f2af4 vulkan: drop support for descriptor buffers
Descriptor buffers were a neat attempt at organizing descriptors.
Simple, robust, reliable.

Unfortunately, driver support never caught on, and neither did validation
layer support.

Now they're being replaced by descriptor heaps, which promises to be
the future. We'll see how it goes.
2026-02-19 19:42:31 +01:00
Lynne b230ba4db9 ffv1enc_vulkan: use regular descriptors for slice state 2026-02-19 19:42:30 +01:00
Lynne c0a697a1bc vulkan_ffv1: use regular descriptors for slice state
HUGE speedup on AMD, HUGE speedup everywhere.
2026-02-19 19:42:30 +01:00
Lynne da99d3f209 vulkan_ffv1: implement parallel probability adaptation 2026-02-19 19:42:30 +01:00
Lynne 25e8d3d89c vulkan/rangecoder: clean up the type mess slightly 2026-02-19 19:42:30 +01:00
Lynne a9d9f7e1bb ffv1enc: add descriptor information for GBRP
The C encoder does not support GBRP, this just adds info fields
so the Vulkan encoder can use it.
2026-02-19 19:42:30 +01:00
Lynne b3a388e36e ffv1enc_vulkan: overhaul the synchronization
Allows for the setup and reset shaders to run in parallel.
2026-02-19 19:42:30 +01:00
Lynne 3bc265d484 ffv1enc_vulkan: make reset shader independent from the setup shader
Allows them to run in parallel.
2026-02-19 19:42:29 +01:00
Lynne 7234f1b167 ffv1enc_vulkan: use a loop to write slice header symbols
Same as with the decoder.
2026-02-19 19:42:29 +01:00
Lynne fb5d3cf15e vulkan_ffv1: use a loop to decode slice header symbols
All known drivers and implementations inline every single function.
This ends up being faster.
2026-02-19 19:42:29 +01:00
Lynne eff3dad6b7 avcodec: remove support for runtime SPIR-V compilation
Begone.
2026-02-19 19:42:29 +01:00
Lynne c4879dbbda avcodec/vulkan: standardize on .glsl extension
None of the files are strictly compute now.
2026-02-19 19:42:29 +01:00
Lynne b736d1c73e ffv1enc_vulkan: convert encode shader to compile-time SPIR-V generation 2026-02-19 19:42:29 +01:00
Lynne 4038af3da8 ffv1enc_vulkan: convert setup shader to compile-time SPIR-V generation 2026-02-19 19:42:29 +01:00
Lynne 6f4cef26df ffv1enc_vulkan: convert reset shader to compile-time SPIR-V generation 2026-02-19 19:42:28 +01:00
Lynne fdee87d06d ffv1enc_vulkan: convert RCT search shader to compile-time SPIR-V generation 2026-02-19 19:42:28 +01:00
Lynne a548c2f0a3 vulkan_ffv1: move common spec constant setting to ffv1_vulkan.c
It will be shared between encoder and decoder.
2026-02-19 19:42:28 +01:00
Lynne ab2ba27c18 ffv1enc_vulkan: remove golomb gb context from main slice context 2026-02-19 19:42:28 +01:00
Lynne 6c0b2be235 vulkan_ffv1: remove golomb gb context from main slice context 2026-02-19 19:42:28 +01:00
Lynne ea9ae1166b vulkan_ffv1: precalculate bits and use a specialization constant 2026-02-19 19:42:28 +01:00
Lynne 3dceda7769 vulkan_ffv1: convert to compile-time SPIR-V generation 2026-02-19 19:42:27 +01:00
Lynne 82f0818ff2 vulkan/common: add debug shorthand 2026-02-19 19:42:27 +01:00
Lynne 8b447a670a vulkan/dpx: bounds check with image sizes
Prevents out of bounds accesses.
2026-02-19 19:42:27 +01:00
Lynne 61ca28d6e0 hwcontext_vulkan: correctly set stride for host image uploads
Cursed.
2026-02-19 19:42:27 +01:00
Lynne 6452e0c56e hwcontext_vulkan: drop debug=3 (profile)
The mode is useless with pregenerated SPIR-V.
2026-02-19 19:42:27 +01:00
Lynne 6f749ec0a7 hwcontext_vulkan: zero-pad optional_instance_exts
The layer settings extension was enabled since the list was blank,
and some compilers complained about that, and it should have been
always supported on all platforms everywhere.

Unfortunately, some platforms LIE, claim they support it and yet
they error out that the extension is missing.

Juse zero pad the array.
2026-02-19 19:42:27 +01:00
Lynne ee1d5da27f hwcontext_vulkan: enable VK_KHR_shader_relaxed_extended_instruction by default
We compile our shaders with debug information by default.
2026-02-19 19:42:26 +01:00
Lynne eadfbc109d hwcontext_vulkan: disable shader object when debugging 2026-02-19 19:42:26 +01:00
Lynne 67d5e7e86a vulkan_prores_raw: fix a single statement's indentation
Annoying.
2026-02-19 19:42:26 +01:00
Lynne d616269035 vulkan: don't set FFVulkanDescriptorSetBinding.name when not necessary
It just bloats the code with unused strings.
2026-02-19 19:42:26 +01:00
Lynne ae1a227cf6 Makefile: specify GLSL version via command line arguments
GLSL strictly mandates the version must be the very first non-comment
statement, which results in issues when #including for templating.
2026-02-19 19:42:20 +01:00
nyanmisaka c96b0d94eb scale_vulkan: fix descriptor type for non debayer path
fixup 80229c1

[scale_vulkan @ 0000028b1c2c1300] scale:31: error: 'texture' : no matching overloaded function found
scale:31: error: 'return' : cannot convert return value to function return type

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-02-19 18:41:44 +00:00
Marvin Scholz cebdd64981 swscale: gitignore: add sws_ops 2026-02-19 17:25:45 +00:00
Tim Blechmann 2799aaa5af avutil: hwcontext_videotoolbox: support YUYV422 pixel format 2026-02-19 16:52:58 +00:00
Romain Beauxis 0be94a16d6 libavformat/oggdec.c: fix ogg_{save,restore,reset} w.r.t. new_extradata. 2026-02-19 16:45:42 +00:00
Marvin Scholz 8030e3b899 avformat: rtspdec: do not allow SET_PARAMETER command too early 2026-02-19 17:18:12 +01:00
Marvin Scholz da821ec316 avformat: rtspdec: use stored replies for SET_PARAMETER command
Makes the reply reading completely non-blocking and reliably reports
the reply even when interleaved packets are read.
2026-02-19 17:18:12 +01:00
Marvin Scholz b63f69fccf avformat: rtsp: add functions to allow stored replies
This adds the ability to have a stored reply, needed for the
SET_PARAMETERS command feature to reliably report the reply even
while intermediate packets are read.
2026-02-19 17:18:12 +01:00
Marvin Scholz 5daa45fa01 avformat: rtsp: fix log message formatting 2026-02-19 17:18:12 +01:00
Marvin Scholz b59471f8c8 avformat: rtsp: do not skip packets in SET_PARAMETER command handling
Return EAGAIN so the client has a chance to read the pending packets
instead of just silently discarding them internally.
2026-02-19 17:18:12 +01:00
Marvin Scholz 6d8950f046 avformat: rtsp: handle interleaved pending packets
Fixes the behavior when calling ff_rtsp_read_reply again after it
was called at another place with return_on_interleaved_data set to
true. Before, it would result in completely corrupting the internal
state as the $ interleaved packet marker would have already been read
which the next run of ff_rtsp_read_reply would look for but never find
it, trying to read packet data as RTSP message.
2026-02-19 17:18:12 +01:00
Marvin Scholz 44065ea878 avformat/rtspdec: Add SET_PARAMETER command support
Add SET_PARAMETER support, this allows sending SET_PARAMETER requests to
the server using the API.
2026-02-19 17:18:12 +01:00
Marvin Scholz 368ecdd3a4 rtsp: expose rtsp_send_cmd_with_content_async
Add the ff_ prefix and move the declaration to the header, so it can
be used in other places like rtspdec in a future commit.
2026-02-19 17:18:11 +01:00
Marvin Scholz 633dcf71e8 avformat: Add new demuxer command API
This new API adds the ability to send commands to the demuxer and also
receive replies to these commands.

It is useful in cases like the RTSP demuxer, where it might be desirable
for the API user to send commands like SET_PARAMETER or PLAY and PAUSE.

Sending and receiving are decoupled, as to not require waiting for a
reply when sending, as with some demuxers and depending on the command
it could be necessary to process further packets in the meantime
before requesting a reply.
2026-02-19 17:18:11 +01:00
Marvin Scholz cf755be215 lavf: replace read_{play,pause} by a single callback 2026-02-19 17:18:11 +01:00
Andreas Rheinhardt ae60f47a2c tests/fate/{dca,qoa,truehd}: Make fate-audio work
Based on the Makefile variables, "make fate-audio"
is supposed to include the tests for several audio
codecs with their own Makefile. Yet because they are
included after audio.mak*, this doesn't work atm.
Fix this by adding explicit prerequisites.

*: Expansion of variables is not deferred in the context
of prerequisites.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-19 14:35:04 +01:00
Andreas Rheinhardt 166b01aefd tests/fate/dca: Add ffprobe dependency to dca-lossless tests
Forgotten in e1484a30e5.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-19 14:34:45 +01:00
Adam Jensen 059c57a83e avfilter/af_loudnorm: add stats_file option
loudnorm provides stats output that's meant to be used for two-pass
normalization. These stats are often interleaved with ffmpeg's stream
descriptions and other output, making them difficult to parse and pass
to the second pass. The new stats_file option enables writing the stats
to a separate file, or to standard output, for simple parsing and other
programmatic usage.

Signed-off-by: Adam Jensen <adam@acj.sh>
2026-02-19 12:48:58 +00:00
Michael Niedermayer 52b676bb29 avcodec/cfhd: Check transform type before continuing
Fixes: null pointer dereference
Fixes: 471768165/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_DEC_fuzzer-6187504467509248

The first frame allocates buffers with one transform type
the second frame sets up another transform type but the code to reallocate buffers is never triggered

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-18 23:45:28 +00:00
Michael Niedermayer 2263e05e41 avcodec/cfhd: Add CFHDSegment enum and named identifiers
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-18 23:45:28 +00:00
Michael Niedermayer d138169966 avcodec/libvorbisdec: output AV_SAMPLE_FMT_FLTP
This removes the internal sample format convert

Fixes: nan is outside the range of representable values of type 'int'
Fixes: 471946097/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBVORBIS_DEC_fuzzer-4843605174059008

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-18 23:38:16 +00:00
Romain Beauxis 0e89d993c5 libavformat/oggenc.c: re-initialize stream on new metadata. 2026-02-18 16:25:06 +00:00
Michael Niedermayer 5ec37f61b2 avcodec/hevc/ps: Check bit_depth_cm in/out relation
Fixes: Assertion n>0 && n<=25 failed at ./libavcodec/get_bits.h:3
Fixes: 472463689/clusterfuzz-testcase-minimized-ffmpeg_dem_HXVS_fuzzer-6012944883449856

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-18 13:57:28 +00:00
Niklas Haas 4cefbc54c4 avformat/http: add missing check to connection re-use
Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/21685
Fixes: e03b034e45
See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/21693
2026-02-18 12:57:55 +00:00
lompik 38cd91c99a hwdec/vulkan: fix invalid number of planes usage in map_to_drm
This fixes a SIGSEGV happening (for >1 plane images) in drivers as we
are sending a null semaphore for them to wait on.
2026-02-18 13:48:04 +04:00
Michael Niedermayer 237d03717f avformat/icodec: Check size
Fixes: signed integer overflow: 14 + 2147483647 cannot be represented in type 'int'
Fixes: 471688026/clusterfuzz-testcase-minimized-ffmpeg_dem_ICO_fuzzer-5616495813263360

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-18 08:20:10 +00:00
Michael Niedermayer a7a009a3eb tools/target_dec_fuzzer: Adjust threshold for JV
Fixes: Timeout
Fixes: 472108726/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JV_fuzzer-5265024680787968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-18 08:18:44 +00:00
James Almer eb36dce742 avfilter/video: reduce potential amount of pool reinitializations
Given we now align both dimensions when allocating buffers, don't reinitialize
the pool when dealing with dimension changes that will not affect the existing
pool size.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:19:01 -03:00
James Almer 14097ee1cd avfilter/framepool: add a few padding lines by aligning height
Fixes segfaults when handling files with odd chroma subsampled dimensions in
some scenarios like using the hstack filter.

./ffmpeg -lavfi testsrc=s=255x31,format=yuv420p -vframes 1 -y in.jpg && \
./ffmpeg -i in.jpg -i in.jpg -i in.jpg -i in.jpg -filter_complex "xstack=inputs=4:grid=2x2" -y out.png

Fixes issue #21739.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:19:01 -03:00
James Almer 7c877b2e80 avcodec/opus/enc: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer 0aa3a6fe41 avcodec/libvorbisenc: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer 84bb5b0748 avcodec/libopusenc: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer 5863cab885 avcodec/libmp3lame: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer e3061be971 avcodec/libfdk-aacenc: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer dd9756286d avcodec/encode: add a helper to convert from a duration to samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
Diego de Souza cb0f4de1f5 avcodec/nvenc_av1: fix b_ref_mode "middle" help string for AV1
For AV1, NV_ENC_BFRAME_REF_MODE_MIDDLE does not use a single middle
B-frame. Per the NVENC Programming Guide, it sets every other B-frame
as an Altref2 reference except the last B-frame in the Altref interval.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-02-17 16:36:51 +00:00
Marvin Scholz b98ec6d312 configure: remove require_cpp, check_lib_cpp
Remove the improperly named check functions that were added for the
opencolorio detection in 677cf95ea4.
Those are not needed anymore and there are already require_cxx and
check_lib_cxx for this purpose.
2026-02-17 15:17:37 +00:00
Marvin Scholz 8014cc7620 configure: cleanup libopencolorio check
Do a proper pkg-config check instead of just blindly compiling a test
program even if pkg-config doesn't find anything.
2026-02-17 15:17:37 +00:00
Marvin Scholz 84ffb18f77 configure: do not require default-constructible class
When checking for C++ classes in check_class_headers_cxx, the test code
required the class to be default-constructible, which is not always the
case. For the sake of the test, it is enough to check that referencing
the class succeeds.
2026-02-17 15:17:37 +00:00
Marvin Scholz 305c383d94 configure: add {test,check,require}_pkg_config_cxx
This is necessary to check for C++ only pkg-config dependencies
2026-02-17 15:17:37 +00:00
Sam.Richards@taurich.org a1309700ed configure: remove accidentally added library
This was added by accident in 677cf95ea4
but is not actually used by anything.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>
2026-02-17 15:14:22 +00:00
Jack Lau cbdb325424 avformat/tls_openssl: update the outdated comments
Loading CA certificate is supported.

Remove unrelated comments.

The underlying socket can be tcp or udp.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-17 13:58:14 +00:00
Jack Lau 479c40f595 avformat/tls_openssl: use EINVAL when X509_digest failed
This function just calculate and copy the fingerprint
to the provided buf, will not allocate memory.

It fails when the input (such as cert) is invalid.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-17 13:58:14 +00:00
Michael Niedermayer bce0e22133 avformat/lrcdec: Check ss for finiteness
Fixes: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long'); cast to an unsigned type to negate this value to itself
Fixes: 471604230/clusterfuzz-testcase-minimized-ffmpeg_dem_LRC_fuzzer-5474264750030848

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-17 13:49:41 +00:00
Michael Niedermayer 82fbb04d07 avformat/http: Also count redirects from the cache
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-17 13:43:37 +00:00
Michael Niedermayer ba3639bc90 avformat/http: allow adjusting the redirect limit
Idea from: BapToutatis and also curl and wget have equivalent options

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-17 13:43:37 +00:00
Michael Niedermayer 0833dd3665 fftools/ffmpeg_opt: limit recursion of presets
Fixes: stack overflow

This should have limited security impact as it requires access to arbitrary
options.

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-17 13:41:37 +00:00
Jack Lau 1fd128ef3a avformat/tls_gnutls: update the comment since the underlying socket can be TCP or UDP
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-17 13:27:09 +00:00
Jack Lau 546d565d07 avformat/tls_gnutls: limit the written size to data MTU
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-17 13:27:09 +00:00
Marton Balint 33b215d155 avcodec/libvpxenc: add experimental support for alpha pixel formats other than YUV 4:2:0.
I could not find any documentation which disallows the use of transparency for
pixel formats other than YUV 4:2:0, so this patch adds support for transparency
using 4:2:2, 4:4:4, RGB, and their high bit depth variants.

It is not quite clear if the alpha channel should be encoded using the
same pixel format as the normal channels, or it should be always YUV 4:2:0. I
sticked to 4:2:0.

Unfortunately the browsers I tested (chrome, firefox) only support 4:2:0
properly, so let's require an experimental flag to generate files with the new,
more exotic pixel formats.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-15 20:28:31 +01:00
Marton Balint d373dfe157 avcodec/libvpxdec: add support for decoding pixel formats other than YUV420 with alpha
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-15 20:28:31 +01:00
Marton Balint 693ca902c1 avformat/matroskaenc: write AlphaMode flag for all VP8 and VP9 pixel formats with alpha
Let's check the pixel format descriptor flags instead of hardcoding a specific
pixel format.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-15 20:28:31 +01:00
Marton Balint 9515cb236b avformat/matroskaenc: only write AlphaMode for VP8 and VP9
AlphaMode should indicate whether the BlockAdditional Element with BlockAddID
of "1" contains Alpha data, as defined by to the Codec Mapping for the `CodecID`.

Only VP8 and VP9 Codec Mappings define this, so writing it for all codecs with
a pixel format of YUVA420P, or for codecs other than VP8/VP9 (if the alpha_mode
metadata entry was set) was wrong.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-15 20:28:31 +01:00
Michael Niedermayer 3ec03b847b swscale/rgb2rgb_template: fix signed shift into sign bit
Fixes: left shift of 255 by 24 places cannot be represented in type 'int'
Fixes: 471591904/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5141341165387776

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 19:26:27 +00:00
Michael Niedermayer 0e3ac1f4f9 swresample: Check ch layouts in swr_alloc_set_opts2()
This way we can error out earlier

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 20:16:12 +01:00
Michael Niedermayer 906e3edc70 swresample: Check user chlayout in swr_set_matrix()
All callers in FFmpeg check this already, but it is a public
function that can plausibly be given more channels.
In which case out of array writes would occur

This is likely a regression from when channel layouts where extended
to support more than 64 channels

Found-by: 이동준 <ldj6192@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 20:16:11 +01:00
Michael Niedermayer 0d59620bff avcodec/bmp: Move picture allocation after some checks
Fixes: Timeout
Fixes: 479872424/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BMP_DEC_fuzzer-5311478919135232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 20:09:54 +01:00
Michael Niedermayer 50adb62670 avcodec/bmp: fix indention
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 20:09:54 +01:00
Michael Niedermayer 33b3dbaf15 avcodec/exr: Handle axmax like bxmin in 04d7a6d3db
Fixes: out of array access
Fixes: 418335931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_DEC_fuzzer-6718455383654400
Fixes: 471611870/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_DEC_fuzzer-6645447302381568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 19:57:42 +01:00
Michael Niedermayer 6ee3e59ce2 avformat/flvdec: Check *size in cts parsing
Fixes: Assertion buf_size >= 0 failed
Fixes: 471553942/clusterfuzz-testcase-minimized-ffmpeg_dem_KUX_fuzzer-5982849812725760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 06:37:19 +00:00
Andreas Rheinhardt 61b1fb1d00 .forgejo/workflows: Test hardcoded tables
Should detect breakages like the one caused by commit
d8ffec5bf9
(fixed in 1d47ae65bf).

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-14 20:15:13 +01:00
Andreas Rheinhardt 4ef5efc2b6 avcodec/aacps_tablegen_template: Fix hardcoded tables with assert-level 2
In this case an av_assert2 in lavu/softfloat.h pulls in
a dependency on av_log(), which is not available at all,
because the tablegen tools are created for and run on
the host, not the target. This leads to linking failures.

Fix this by undefining ASSERT_LEVEL before the inclusion
of avassert.h.

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-14 20:14:47 +01:00
Michael Niedermayer be1fd6d9d4 avcodec/prores_raw: Tiles of width less than 16 result in undefined behavior
Fixes: passing zero to __builtin_clz(), which is not a valid argument
Fixes: 471569982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PRORES_RAW_DEC_fuzzer-5832576221904896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-14 18:53:08 +00:00
Michael Niedermayer 2ad078b589 avcodec/exif: Check that the values read exist in the input
Fixes: Timeout
Fixes: 471568865/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-4864048211755008
Fixes: 471951381/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_DEC_fuzzer-5069855998148608
Fixes: 471472005/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_DEC_fuzzer-4660042365468672
Fixes: 471591900/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WEBP_fuzzer-5083936243122176
Fixes: 471593729/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_DEC_fuzzer-5401314998943744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-14 18:52:43 +00:00
Valerii Zapodovnikov 4eca335d94 avcodec/hevc/hevcdec: take into account YUV400 in block length
Also move some definitions around.

Signed-off-by: Valerii Zapodovnikov <val.zapod.vz@gmail.com>
2026-02-14 16:23:16 +00:00
Stéphane Cerveau a2489b3ac6 configure: provide vulkan incflags
This patch allows to use pkgconfig cflags
for vulkan in check_cpp_condition as the vulkan
sdk might be installed in different place than
system wide.

See https://vulkan.lunarg.com/doc/sdk/latest/linux/getting_started.html
2026-02-14 12:24:39 +00:00
Sam.Richards@taurich.org 677cf95ea4 Initial checkin of OCIO filter.
Initial checkin of OCIO filter.

Initial checkin of OCIO filter.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Change for the right C++ library, should work on linux too.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding inverse when using display/view.

Removed comments.

Removed code that was setting the CICP values. Hopefully this can be done through OCIO at some point.

Config cleanup - need a modified require_cpp to handle namespacing.

Switch to using require_cpp so that namespace can be used.

Adding documentation.

Sadly a bit of linting went in here, but more importantly added a threads option to split the image into horizontal tiles, since OCIO was running rather slow.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding context parameters.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Add the OCIO config parameter.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Make the min threads 1 for now, reserve 0 for later if we can automatically pick something.
Also added a few comments.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

This is using ffmpeg-slicing.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding OCIO filetransform.

Making sure everything is using av_log rather than std::cerr.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Updating the tests so they would work without additional files.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding the file-transform documentation.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding copyright/license info.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Removing tests, since this is optional code.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Code cleanup.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Typo.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

I went the wrong way, av_log is expecting \n

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Fix indenting to 4 spaces.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Fixing lint issues and a spelling mistake.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Code formatting cleanup to match conventions.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Whitespace removal.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>
2026-02-14 12:21:10 +00:00
James Almer a7522f3fef avcodec/libvorbisenc: export padding samples if needed
Based on code from libopus encoder wrapper.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-13 11:50:32 -03:00
James Almer 23dce39d5a avcodec/libvorbisenc: export initial padding during init()
Priming samples don't depend on the contents of the first frame passed to the
encoder but rather on encoder configuration, so use dummy vorbis_dsp_state and
vorbis_block with the main encoder vorbis_info to generate a packet we can then
parse to derive the initial padding.

Muxers will now be aware of the initial padding before receiving packets, which
will allow them to write proper container headers during init without any extra
considerations like having to do a second pass or rewrite during write_trailer.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-13 11:50:32 -03:00
Andreas Rheinhardt 0a629df0a8 avcodec/ratecontrol: Move emms_c() to the only callsite needing it
Namely to one of the three callsites in snowenc.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt 059654a73b avcodec/ratecontrol: Remove unnecessary emms_c()
ff_rate_control_init/uninit() are only called during
codec init or close and no DSP calls happen in these,
so there is no need to reset the floating point state.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt fe1742618d avcodec/snowenc: Remove redundant emms_c()
This emms_c() has been superseded by the one added
a few lines above in 2c1d38d1e1.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt c5d9711be4 avcodec/mpegvideoenc: Remove MMX from comment
The MMX code has been removed in 5ef613bcb0
and MMX was not used for most cpus even before then.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt fe0d8cb3e4 avcodec/x86/dirac_dwt: Remove MMX in comment
Forgotten in 5e332fe35c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt 2e843c0e9a doc/optimization: Fix incorrect statement
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt 509be049b6 swresample/{audioconvert,rematrix}: Don't check for HAVE_MMX
There are no MMX functions left in all of libswresample, so checking
for it makes no sense. Notice that configure currently disables x86asm
if mmx is disabled, so the check is also redundant.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt 374b3ab03c swresample/x86/audio_convert: Remove remnants of MMX
Forgotten in 2b94f23b06.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt 66766bb1c7 avutil/avassert: Deprecate av_assert0_fpu()
Said function has presumably been added in order to check
that we have successfully reset the floating point state
after having violated the ABI/calling convention by not
issuing emms in our MMX DSP routines.

Yet the ability to check this should not have been made public,
because there is no external need for it and because the
function does not even always achieve what its documentation
claims to do: It only works when inline assembly is available.
It should have been implemented in emms.h like emms_c()
(which is where a replacement should be put if there is still
ABI-violating MMX code when av_assert0_fpu() is removed).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:02 +01:00
stevxiao 680f32c4c9 avfilter/dnn: add PyTorch version check for XPU initialization in torch backend
Starting with PyTorch 2.6, the hooks API was redesigned so it no longer depends on the device type.

As part of this change, the XPU initialization function was renamed from initXPU() to init().

Add version check to support both old and new LibTorch versions.

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-02-12 10:48:58 -05:00
stevxiao 57fe259773 avfilter/dnn: add synchronous execution path in torch backend
When using `dnn_processing` filter with torch backend, FFmpeg hangs indefinitely because no inference is actually performed.
Resolve this problem by add "else" branch for synchronous execution path.

Usage:
    ffmpeg -i input.mp4 -vf scale=224:224,format=rgb24,dnn_processing=dnn_backend=torch:model=sr_model_torch.pt:device=cpu output.mp4
2026-02-12 20:30:53 +08:00
James Almer ff98352c3d avcodec: set skip_samples in generic code
Decoders should only worry about exporting AVCodeContext->delay during init.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-12 09:59:54 -03:00
James Almer e1484a30e5 avformat/dtshddec: properly support priming and padding samples
Don't just export initial_padding, but also take it into account for timestamps
by adjusting the stream's start_time. Also, export the padding samples in a way
that's actually supported, as currently trailing_padding is unused so no user
will look at it.

For the sake of not reducing coverage and because the lossy tests have reference
files that contain the priming samples, add the skip_manual flags2 to the tests
so we still output them. A new ffprobe call will ensure the demuxer behavior is
tested too.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-12 09:59:54 -03:00
James Almer 70f0ddd2ca tests/fate/dca: use stream_demux for lossless tests
Unlike md5, the adler32 hash shows the frames with priming samples, which will
be useful in the following commits.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-12 09:59:54 -03:00
Andreas Rheinhardt afb374f109 avcodec/dpcm: Remove unnecessary flush callbacks
{INTERPLAY,ROQ,XAN}_DPCM does not use the stored samples at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 11:06:33 +01:00
Andreas Rheinhardt e3ec6322bb avcodec/dpcm: Avoid trailing '_' in macro parameters
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 11:06:33 +01:00
Andreas Rheinhardt 66c7bf3bf8 avcodec/adpcmenc: Don't advertise ineffective options
ADPCM_ARGO, ADPCM_IMA_QT and ADPCM_SWF don't use
the block_size option at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 10:34:19 +01:00
Andreas Rheinhardt b764f40eaa avcodec/adpcmenc: Check sample rates, ch layouts generically
This also advertises the supported sample rates/channel layouts.
For ADPCM_IMA_AMV, it actually fixes the advertised channel layouts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 10:34:19 +01:00
Andreas Rheinhardt 77d7891052 avcodec/adpcmenc: Mark unreachable code as such
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 10:34:19 +01:00
James Almer 10acab8df5 avcodec/hevc/hevcdec: report unparsed unknown NALUs types at verbose level
Reduces spamming at default log level.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-11 21:57:20 -03:00
Kacper Michajłow 3b4281e919 avcodec/hevc/hevcdec: skip logging 'Skipping NAL unit 63'
We know that this is Dolby Vision Enhancement Layer and while it's not
handled, we can just reduce log spam for this, as it's if fact
recognized.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-12 00:56:21 +00:00
Kacper Michajłow fa36645f7e avcodec/bsf/dovi_rpu: fix typo
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-12 00:56:21 +00:00
Kacper Michajłow 590e2b1894 vf_libplacebo: sync peak detection parameters with upstream
Fixes peak detection for samples like in https://github.com/haasn/libplacebo/issues/358

This might introduce flickering on some other samples, but was agreed
upstream that they are better overall.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-12 00:12:48 +00:00
Rost Kurylo d07d2a4ee1 doc/protocols: Document type option for unix domain sockets
Signed-off-by: Rost Kurylo <rost.kurylo@netint.ca>
2026-02-11 20:41:49 +00:00
Rost Kurylo 95101ecc65 avformat/unix: Fix 'operation unsupported' error when reading from unixgram sockets
Sockets of type SOCK_DGRAM don't support listen(), so it was
impossible to read from "unixgram" sockets in ffmpeg.

Signed-off-by: Rost Kurylo <rost.kurylo@netint.ca>
2026-02-11 20:41:49 +00:00
Nicolas Gaullier f9bf45b8fd avformat/isom_tags: add specific fourccs for in24/in32 LE
Add support for decoding 42ni and 23ni in mov/mp4.

Note that in24/in32 can be either LE or BE thanks to enda atom,
so this patch leaves the muxer unchanged.

Fixes #21445.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-02-11 20:39:31 +00:00
John Chadwick 8b9b71494b tests/fate/image: Add psd-rgbxx
This is an rgb test image with two auxilliary channels and no alpha
channels.
2026-02-11 20:35:20 +00:00
John Chadwick a469598191 avcodec/psd: Support auxiliary channels
Photoshop documents can contain additional "auxiliary" channels that
don't take part in layer compositing, therefore, using the channel count
to determine the presence of an alpha channel in the merged image is
incorrect. Instead, as per the PSD specification, use the sign of the
layer count (present in the layers and masks section) to determine if
there is an alpha channel, then determine the number of primary channels
using both the presence of the alpha channel and the pixel format.
2026-02-11 20:35:20 +00:00
Andreas Rheinhardt 7e3781e3ca avcodec/libcodec2: Remove always-false checks
Already checked via CODEC_SAMPLERATES and CODEC_SAMPLEFMTS.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 12:07:38 +01:00
Andreas Rheinhardt 12c2a4e117 avcodec: Don't set AVCodec.sample_fmts,ch_layouts for decoders
It is pointless for them given that these values will
be overridden by the decoder lateron anyway.
The only exceptions to this are scenarios where the decoder
actually checks request_sample_fmt or where there are both
fixed- and floating point decoders.

(IMO something like get_format() for audio would be better for
both cases.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 12:07:35 +01:00
Andreas Rheinhardt 028d9d3997 avcodec/sbcdec: Don't set encoder-only fields
ch_layouts, sample_fmts and supported_samplerates
are of no use for a decoder, so don't set them.
In this case this fixes an inconsistency:
ch_layouts contained mono and stereo, yet lateron
the AVCodecContext's ch_layout is always populated
with an AV_CHANNEL_ORDER_UNSPEC layout.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 12:07:31 +01:00
Andreas Rheinhardt f648dd0e8a avcodec/adpcm: Don't set AVCodec.sample_fmts
It is unnecessary for a decoder (the sample fmt is
set lateron during init and the user has no choice
over this (even for the decoders where sample_fmts
contains two entries).

(This also fixes the ADPCM_DECODER macro: It's second
and third parameters were called "name" and "sample_fmts",
yet the second argument always contained the sample fmts.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 12:07:07 +01:00
Andreas Rheinhardt 3a7c09eb39 avcodec/x86/mpegvideoencdsp_init: Port draw_edges to SSSE3
Benchmarks:
draw_edges_8_1724_4_c:                                2672.2 ( 1.00x)
draw_edges_8_1724_4_mmx:                              3191.5 ( 0.84x)
draw_edges_8_1724_4_ssse3:                            2179.6 ( 1.23x)
draw_edges_8_1724_8_c:                                2852.3 ( 1.00x)
draw_edges_8_1724_8_mmx:                              3683.0 ( 0.77x)
draw_edges_8_1724_8_ssse3:                            2225.7 ( 1.28x)
draw_edges_8_1724_16_c:                               4169.4 ( 1.00x)
draw_edges_8_1724_16_mmx:                             4665.9 ( 0.89x)
draw_edges_8_1724_16_ssse3:                           2765.8 ( 1.51x)
draw_edges_128_407_4_c:                               1126.6 ( 1.00x)
draw_edges_128_407_4_mmx:                              943.9 ( 1.19x)
draw_edges_128_407_4_ssse3:                            925.7 ( 1.22x)
draw_edges_128_407_8_c:                               1208.8 ( 1.00x)
draw_edges_128_407_8_mmx:                             1119.1 ( 1.08x)
draw_edges_128_407_8_ssse3:                            997.8 ( 1.21x)
draw_edges_128_407_16_c:                              1352.4 ( 1.00x)
draw_edges_128_407_16_mmx:                            1368.7 ( 0.99x)
draw_edges_128_407_16_ssse3:                          1148.3 ( 1.18x)
draw_edges_1080_31_4_c:                                228.5 ( 1.00x)
draw_edges_1080_31_4_mmx:                              240.8 ( 0.95x)
draw_edges_1080_31_4_ssse3:                            226.7 ( 1.01x)
draw_edges_1080_31_8_c:                                411.1 ( 1.00x)
draw_edges_1080_31_8_mmx:                              432.9 ( 0.95x)
draw_edges_1080_31_8_ssse3:                            403.2 ( 1.02x)
draw_edges_1080_31_16_c:                              1121.2 ( 1.00x)
draw_edges_1080_31_16_mmx:                            1124.9 ( 1.00x)
draw_edges_1080_31_16_ssse3:                          1125.4 ( 1.00x)
draw_edges_1920_4_4_c:                                 310.8 ( 1.00x)
draw_edges_1920_4_4_mmx:                               311.6 ( 1.00x)
draw_edges_1920_4_4_ssse3:                             311.6 ( 1.00x)
draw_edges_1920_4_4_negstride_c:                       307.0 ( 1.00x)
draw_edges_1920_4_4_negstride_mmx:                     306.7 ( 1.00x)
draw_edges_1920_4_4_negstride_ssse3:                   306.7 ( 1.00x)
draw_edges_1920_4_8_c:                                 724.2 ( 1.00x)
draw_edges_1920_4_8_mmx:                               724.9 ( 1.00x)
draw_edges_1920_4_8_ssse3:                             717.3 ( 1.01x)
draw_edges_1920_4_8_negstride_c:                       719.2 ( 1.00x)
draw_edges_1920_4_8_negstride_mmx:                     717.1 ( 1.00x)
draw_edges_1920_4_8_negstride_ssse3:                   710.9 ( 1.01x)
draw_edges_1920_4_16_c:                               1752.9 ( 1.00x)
draw_edges_1920_4_16_mmx:                             1754.6 ( 1.00x)
draw_edges_1920_4_16_ssse3:                           1751.1 ( 1.00x)
draw_edges_1920_4_16_negstride_c:                     1783.2 ( 1.00x)
draw_edges_1920_4_16_negstride_mmx:                   1778.2 ( 1.00x)
draw_edges_1920_4_16_negstride_ssse3:                 1768.3 ( 1.01x)

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 11:15:06 +01:00
Michael Niedermayer 4f97e52042 avformat/cafdec: Check nb_entries in read_info_chunk()
Fixes: Timeout
Fixes: 477315122/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-5274792315125760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-11 01:17:30 +00:00
Andreas Rheinhardt f6d89a7bed avformat/spdif: Make enum IEC61937DataType at least 16bits
Fixes the spdif-dca-master FATE-test when compiling with
-fshort-enums.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt f0392c908c avcodec/flacenc: Use int for AV_OPT_TYPE_INT
Necessary for -fshort-enums.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt b08e849af8 avfilter/lavfutils: Avoid AVDictionary
Set thread_type directly instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt 373c86bac8 swscale/utils: Improve type-safety
SwsContext.{src,dst}_format is int (but uses enum AVPixelFormat)
values, so the accesses need to be performed using an int
for -fshort-enums support.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt fb8a12db17 avutil/opt: Improve type-safety
In particular, make this code -fshort-enums compatible.
The branch can be optimized away by compilers when
sizeof(enum AVPixelFormat) == sizeof(enum AVSampleFormat).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt 2273902be8 avfilter/lavfutils: Avoid copying frame in ff_load_image()
Return the data in an AVFrame instead. This is what several users
({find,cover}_rect*) want anyway. This also avoids accessing
AVFrame.format (an int) via an enum AVPixelFormat*.

*: This commit actually avoids two frame copies For find_rect:
av_frame_clone() contained an implicit alloc+copy.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt 31173f148c avfilter/vf_removelogo: Properly handle allocation error
Don't rely on av_image_copy_plane() handling a NULL dst
gracefully.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt 0c7424e817 avfilter/filters: Restrict ff_fmt_is_in() to enum AVPixelFormat
Also rename it to ff_pixfmt_is_in(). This is more type-safe;
in particular, it is required to support -fshort-enum.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:43 +01:00
Andreas Rheinhardt bf44a683eb fftools/ffmpeg_mux_init: Improve type-safety
This makes fftools -fshort-enums compatible.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 16:36:58 +01:00
Andreas Rheinhardt fcfb33922f avformat/cafenc: don't keep track of nb packets ourselves
Just reuse AVStream.nb_frames.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 11:32:56 +01:00
Andreas Rheinhardt 96475bfa21 avformat/cafenc: Simplify writing pakt box
Assemble it already in caf_write_packet(). This has the advantage
of reducing the amount of buffers used; it also allows to avoid
a seek when writing the trailer and avoids function call overhead
(for the avio_w8(); it also reduces codesize).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 11:31:17 +01:00
Michael Niedermayer 38230db7b9 avcodec/vp9: Reallocate on resolution change which does not change tile_cols
Fixes: out of array access on resolution change with slices threads
Fixes: VULN-10/poc.ivf

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-10 01:30:42 +01:00
Michael Niedermayer 521d18cea3 avformat/img2dec: Check avio_size() for failure
More complete fix for #YWH-PGM40646-32

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-10 01:19:00 +01:00
Michael Niedermayer 19c78cd6d9 avformat/mpegtsenc: Check remaining space in SDT
Fixes: out of array access
Fixes: VULN-8

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-10 01:07:19 +01:00
Michael Niedermayer ca1c1f29ce avformat/img2enc: Check split planes packet size
Fixes: out of array read
Fixes: VULN-6/poc.raw

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-10 00:54:41 +01:00
Michael Niedermayer b740b85872 avformat/yuv4mpegen: Sanity check input packet frame dimensions
Fixes: out of array access if a filter-graph is used the injects changing dimensions

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-10 00:40:52 +01:00
Ramiro Polla 9ee6136ece avcodec/mjpegdec: remove start_code field from MJpegDecodeContext
Instead, pass it as a parameter to the only function that uses it.
2026-02-09 17:52:01 +00:00
Andreas Rheinhardt 1218a8a922 avcodec/rangecoder: Fix indentation
Forgotten after 832649986c
and d147b3d7ec.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-09 17:36:40 +00:00
James Almer 2e79453549 tests/fate/id3v2: don't use a reference file for fate-id3v2-invalid-tags
This fixes running the test under Valgrind, where more, unrelated lines are
printed, making the comparison fail.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-09 14:04:22 +00:00
Niklas Haas be88553fc8 fftools/ffmpeg_demux: mirror DemuxStream name to AVFormatContext
Results in basically the same name, except less ambiguous because
it includes the input index.
2026-02-09 14:01:14 +00:00
Niklas Haas f2b13f783a avformat: add AVFormatContext.name
Analog to AVFilterContext. May be used to set a custom logging name to
disambiguate multiple AVFormatContext instances in the logs.
2026-02-09 14:01:14 +00:00
Michael Niedermayer 9bfa1635ae avformat/iff: Error out with 0 channel loudspeaker configuration
Fixes: division by 0
Fixes: 478005965/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-5748337088462848
Fixes: 472226169/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-4528777763028992

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-09 04:25:04 +00:00
Ted Meyer a58cb16e27 Fix overflow in STSD parser
Reset `sc->stsd_count` before parsing entries. This number doesn't get
reset, which means that multiple parse passes can increment it past the
`sc->extradata` array end and cause OOB writes.
2026-02-09 02:38:16 +00:00
James Almer 303fd126a8 avformat/iamf: replace av_assert0(0) with av_unreachable
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-08 21:58:06 -03:00
James Almer 8665748584 avformat/iamf_reader: sanitize block and subblock durations and count
Abort earlier if subblock durations are inconsistent with their containing block,
and ensure each subblock duration is at least 1.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-08 21:58:06 -03:00
James Almer 34ac6f6b07 avformat/iamf_parse: sanitize block and subblock durations and count
Abort earlier if subblock durations are inconsistent with their containing block,
and ensure each subblock duration is at least 1.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-08 21:58:06 -03:00
James Almer 706d4e4736 avutil/iamf: stop setting parameter definition block defaults
It was done for the sake of having subblock_duration not be zero as the spec
forbids that value, but harcoding it to any arbitrary value is no better
considering the user is meant to fill the entire structure.

This helps speeding up the function when trying to allocate a struct with a
huge amount of blocks.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-08 21:58:06 -03:00
Hassan Hany 273b161a98 avcodec/exif: skip EXIF entries with invalid TIFF field type 0
EXIF IFD entries with TIFF field type 0 are invalid per the specification.
Without a check, exif_read_values() fails to allocate entry->value,
causing an out of memory error.

This patch skips such entries early during parsing, allowing decoding
to continue normally.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/21623
2026-02-08 19:56:20 +00:00
Michael Niedermayer 5f84a7263e avcodec/adpcm: Check input buffer size
Larger values will lead to integer overflows in intermediates
No testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-08 14:46:56 +00:00
Michael Niedermayer a5007428e8 avformat/scd: Use ffio_read_size()
Fixes: use of uninitialized memory
Fixes: 471771529/clusterfuzz-testcase-minimized-ffmpeg_dem_SCD_fuzzer-5328203515494400

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-08 02:25:14 +01:00
Niklas Haas b8daba42cd avformat/http: report connection statistics
Helpful to track the impact of options like -multiple_requests, -probing_size
or -short_seek_size.
2026-02-07 10:02:36 +00:00
Niklas Haas 4f5d91e43f avformat/http: allow limiting initial request size
Sometimes, HTTP sources require a lot of seeking during probing / header
parsing (especially for formats like MXF). Currently, we need to completely
tear down and re-establish the connection most times this happens, which puts
a lot of stress on the network stack and also results in transmission of
possibly many unnecessary bytes.

This patch adds an option to allow FFmpeg to request partial ranges during
the initialization stage. This is done until the initial request size is fully
read, after which we fall back to the normal behavior (i.e. infinite streaming
via an unbounded request).

The usefulness of this is limited without also specifying -multiple_requests 1,
since otherwise there is little point to requesting partial ranges to begin
with. (However, it is semantically independent, so we keep it that way.)
2026-02-07 10:02:36 +00:00
Niklas Haas e03b034e45 avformat/http: re-use keep-alive connection for small seeks
When the previous reply was a partial response (e.g. due to a seek to the
end of the file), and the remaining data from that partial response is
below the short seek size threshold, we can serve this seek by just draining
that data and re-using the existing connection.

This can currently only happen when using keep-alive connections
(-multiple_requests 1) and seeking from the end of the file to somewhere
else, in which case the file's tail can be drained and the connection re-used.

Under other circumstances, however, we still need to force a reconnection,
because we do not yet send partial range requests. (This will be changed in the
following commit)

We need to take special care not to regress the existing fallback logic
for when `http_open_cnx` fails, so here is a quick case analysis:

non-drain path:
- identical to the current

soft drain fails: (ffurl_read error path)
- s->hd = old_hd = NULL
- http_open_cnx() always opens a new connection
- on failure, old buffer is restored and s->hd remains NULL

soft drain succeeds, http_open_cnx() fails:
- s->hd is set to NULL by http_open_cnx() failure path
- old_hd was never set, so remains NULL
- old buffer is restored, s->hd remains NULL

In either case, the outcome that any (previously valid) buffer is left as-is,
the offset is unchanged, and the connection ends up closed (s->hd == NULL).
This is okay to do after the previous change to http_buf_read, which allows
it to internally re-open the connection if needed.
2026-02-07 10:02:36 +00:00
Niklas Haas bf1722a9c6 avformat/http: request more data after partial response
If the Content-Range indicates a smaller range than what we expected,
we should send a new request for the remainder before attempting to read
more.

Again, this commit is theoretically non-functional on its own, since any
conforming HTTP server should give us the entire range we asked for in the
first place, but it is semantically independent from and prepares us for the
following changes.
2026-02-07 10:02:36 +00:00
Niklas Haas 6336fa3335 avformat/http: return EIO if s->hd is NULL
This could conceivably happen currently if the user tries reading more
bytes after the last chunk has already been received. In this case,
we currently segfault - but simply returning AVERROR(EIO) seems more
reasonable and lets the higher end retry the connection in this case.
2026-02-07 10:02:36 +00:00
Niklas Haas ca2c5ff412 avformat/http: parse range size from Content-Range header
In the event that the range returned is smaller than the true filesize, we
should only expect to receive that many bytes - not the entire rest of the
file.

This commit is theoretically non-functional on its own, since any conforming
HTTP server will always return us the full file range, but I wanted to split
it off from the subsequent changes in order to make review easier.
2026-02-07 10:02:36 +00:00
Niklas Haas 19cae9151c avformat/http: print error on HTTP response failure
This currently fails silently with zero indication of what the problem might
be, which tripped me up a bit while debugging.
2026-02-07 10:02:36 +00:00
Niklas Haas 5f95a1e714 avformat/http: fix noop seek check
This fails to consider the case of whence == SEEK_END and the resulting
offset happening to exactly match the current position.

Reorder the check to compute the target position first, then compare.
2026-02-07 10:02:36 +00:00
Brad Smith c352a9ab02 avutil/cpu: add CPU feature detection for AArch64 CRC32 on OpenBSD
Signed-off-by: Brad Smith <brad@comstyle.com>
2026-02-06 14:24:01 -05:00
Andreas Rheinhardt 0fefecd53f Revert "avcodec/opus/parse: export the packet and extradata parsing functions"
This reverts commit aa20d7b3e8.

Adding these avpriv functions is absolutely overblown: Muxers
can get the desired duration in a few lines themselves.
In particular, using the parse functions from this file
necessitated parsing the extradata (and entailed exporting
the parsing function), although it was only used to know
whether the frames are self-delimiting, but everything of
interest to a muxer does not depend on this at all.

The commit to be reverted also made several structures
part of the ABI, which should be avoided in general.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-06 14:09:15 +01:00
Andreas Rheinhardt 12747e6296 avformat/matroskaenc: Parse Opus packet durations ourselves
This avoids avpriv functions from lavc/opus/parse.c
(which parse way more than we need, necessitating
parsing the extradata).
It furthermore makes the output of the muxer consistent,
i.e. no longer depending upon whether the Opus parser
or decoder are enabled (the avpriv functions would just
return AVERROR(ENOSYS)).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-06 14:05:14 +01:00
Andreas Rheinhardt 853843d86f avcodec/opus/parse: Move frame_duration tab into a file of its own
This is in preparation for duplicating it into libavformat.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-06 14:04:50 +01:00
James Almer 3ab8b976c1 avformat/matroskaenc: parse Opus packets to write proper durations
Before this patch, the last packet in the affected fate test would be written
without a BlockDuration element despite the packet's duration being shorter
than the Opus frame size.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
James Almer aa20d7b3e8 avcodec/opus/parse: export the packet and extradata parsing functions
Needed for the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
James Almer 11e9a325ec tests/fate/matroska: remove copyts from audio tests
It's not needed after the previous commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
James Almer 0880458e4c avformat/matroskadec: take into account priming samples in audio tracks
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
James Almer 1dd8547193 avformat/demux: don't overwrite already set packet durations with parser ones
Following up on b613eebe78, if a demuxer that exports complete frames sets a
duration, don't overwrite it from the output of the parser.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
Michael Niedermayer 8f57b04fe5 avcodec/hevc/sei: Use get_bits64() in decode_nal_sei_3d_reference_displays_info()
Fixes: Assertion n>=0 && n<=32 failed at ./libavcodec/get_bits.h:426
Fixes: 468435217/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4644127078940672

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 20:20:08 +00:00
Michael Niedermayer f112ae503e avformat/hls: Check for integer overflow with #EXTINF:
Found-by: 이동준 <ldj6192@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 17:59:29 +00:00
Michael Niedermayer af86f0ffcc avcodec/dca_xll: Clear padding in ff_dca_xll_parse()
Fixes: Use of uninitialized memory
Fixes: 472020020/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DCA_DEC_fuzzer-6433045331902464

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 18:12:46 +01:00
Michael Niedermayer 00b4d67812 avformat/demux: Allow non opened codec in has_decode_delay_been_guessed()
Fixes: assertion failure
Fixes: 472097507/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6016386662203392

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 18:01:31 +01:00
Michael Niedermayer 5fa7d588f5 avformat/flvdec: Check need_context_update when audio codec changes
We did check video codecs but not audio
Fixes: Assertion failure (on codec_id) in parser.c
Fixes: 472097507/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6016386662203392

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 18:01:31 +01:00
Michael Niedermayer c6c6874c44 avfilter/vf_find_rect: Check x/y min/max
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 17:08:30 +01:00
Michael Niedermayer 12321e5eba vfilter/vf_find_rect: Clamp x/y min/max to valid values
Fixes: #YWH-PGM40646-15
Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 17:08:30 +01:00
Michael Niedermayer ee7a15f0a2 tools/target_dec_fuzzer: adjust threshold for MAGICYUV
Fixes: Timeout
Fixes: 471975516/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_DEC_fuzzer-5987279668838400

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 16:50:26 +01:00
Michael Niedermayer 189bc0aaf5 avcodec/dxv: Clear tex_data padding on reallocation
dxv assumes that newly reallocated memory in tex_data is not uninitialized
thus we have to do that too in case of reallocation in ff_lzf_uncompress()

Fixes: 475000819/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5571269310611456

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 16:29:08 +01:00
Michael Niedermayer 0f35146e27 avcodec/lzf: Remove size messing from ff_lzf_uncompress()
size represents the output size
randomly changing it but not reseting it on errors leaks uninitialized memory.

Fixes: 475000819/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5571269310611456

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 16:29:08 +01:00
Michael Niedermayer 5db50e8775 avcodec/ffv1enc: refine end condition
In the case where the last sorted value was -1u and we where on the first
pass of run1 we failed to fill the last few values of bitmap

No real world testcase is known

Fixes: use of uninitialized memory
Fixes: 460333808/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-6370167888347136

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 16:07:13 +01:00
Michael Niedermayer 11a5afea31 avcodec/dca_xll: Check get_rice_array()
Fixes: use of uninitialized memory
Fixes: 451655450/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DCA_DEC_fuzzer-6527248623796224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 14:37:59 +01:00
Zane van Iperen b628cafd48 libavformat/argo_brp: fix incorrect ASF chunk header read
Was inadvertently broken in the switch to ffio_read_size().

Fixes: 6dd83fab44

PR: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21650

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2026-02-05 22:19:48 +10:00
Anthony Bajoua 627da1111c libavformat/movenc: Uses dynamic buffers for fragmented chunks 2026-02-04 18:45:15 -08:00
Jun Zhao 27dd2f1c70 lavc/hevc: fix missing # in ldrsw immediate offset
The ldrsw instruction requires immediate offset with # prefix.
This fixes the syntax error introduced in commit 26752368f0
(aarch64/h26x: Add put_hevc_pel_bi_w_pixels) where the
load_bi_w_pixels_param macro was added.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-02-05 09:13:22 +08:00
WyattBlue e48eaa8c62 avfilter/af_whisper: Add max_len parameter 2026-02-04 21:26:02 +00:00
Marton Balint 75f5d79f6a fftools/ffprobe: add base64 data dump format
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Marton Balint ca6f3f3c17 fftools/ffprobe: use an AVTextFormatOptions struct in AVTextFormatContext
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Marton Balint b1f14cbd0e fftools/ffprobe: fatorize dumping hexdump as data dump
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Marton Balint 30be62b711 fftools/ffprobe: print AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL id and data
Data is only printed if -show_data is used.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Michael Niedermayer d1a43f1486 avutil/dovi_meta: Document valid range for index of av_dovi_get_ext()
Every use case in libavcodec already checks the index

Found-by: 이동준 <ldj6192@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-04 15:25:18 +00:00
Andreas Rheinhardt 462fac0e0f tests/checkasm/vc1dsp: Use correct function argument
Fixes a stack-buffer overflow (detected by ASAN) when benching
vc1dsp.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-04 13:28:49 +01:00
Zhao Zhili e250854ecf aarch64/h264pred: disable inefficient functions
These assembly optimizations have been identified as "performance
regressions." Due to advancements in modern CPU micro-architectures
and compiler optimization the C implementations now consistently
outperform these handwritten routines.

Test Name          	 A55-clang       M1             A76-gcc-14      A510-clang      A715-clang      X3-clang
--------------------------------------------------------------------------------------------------------------------
pred8x8_dc_8_neon        55.9 ( 0.79x)!  0.2 ( 0.31x)!  35.7 ( 0.63x)!  98.3 ( 0.37x)!  35.9 ( 0.45x)!  33.6 ( 0.38x)!
pred8x8_dc_10_neon       57.0 ( 1.04x)   0.3 ( 0.36x)!  35.9 ( 0.94x)!  98.2 ( 0.53x)!  35.8 ( 0.58x)!  33.2 ( 0.50x)!
pred8x8_dc_128_8_neon    26.0 ( 0.69x)!  0.1 ( 0.43x)!  15.3 ( 0.73x)!  46.4 ( 0.36x)!  10.6 ( 0.48x)!  10.3 ( 1.09x)
pred8x8_dc_128_10_neon   25.3 ( 0.99x)!  0.1 ( 0.42x)!  19.3 ( 0.48x)!  44.5 ( 0.42x)!  10.0 ( 0.61x)!  11.0 ( 1.00x)
pred8x8_left_dc_8_neon   46.9 ( 0.72x)!  0.2 ( 0.26x)!  30.2 ( 0.49x)!  71.4 ( 0.39x)!  29.8 ( 0.35x)!  26.5 ( 0.44x)!
pred8x8_left_dc_10_neon  45.4 ( 0.82x)!  0.2 ( 0.29x)!  28.1 ( 0.67x)!  70.2 ( 0.47x)!  30.0 ( 0.38x)!  26.5 ( 0.43x)!
pred16x16_dc_8_neon      74.4 ( 1.34x)   0.3 ( 0.62x)!  44.7 ( 0.89x)!  128.0 ( 0.79x)! 48.5 ( 0.67x)!  39.4 ( 0.71x)!
pred16x16_dc_128_8_neon  37.9 ( 0.79x)!  0.1 ( 0.60x)!  20.1 ( 0.80x)!  41.8 ( 0.46x)!  16.2 ( 0.81x)!  12.8 ( 0.95x)!
pred16x16_left_dc_8_neon 69.9 ( 1.19x)   0.3 ( 0.46x)!  49.6 ( 0.54x)!  116.8 ( 0.62x)! 52.8 ( 0.45x)!  44.2 ( 0.51x)!
pred8x8_hori_8_neon      30.6 ( 1.39x)   0.1 ( 0.45x)!  19.4 ( 0.81x)!  71.0 ( 0.50x)!  15.9 ( 0.55x)!  12.2 ( 0.94x)!
pred8x8_hori_10_neon*    29.3 ( 1.82x)   0.1 ( 0.59x)!  18.5 ( 1.56x)   68.9 ( 0.64x)!  15.8 ( 0.62x)!  11.8 ( 0.97x)!
pred8x8_top_dc_8_neon    35.8 ( 0.96x)!  0.1 ( 0.59x)!  16.8 ( 0.81x)!  58.9 ( 0.44x)!  11.3 ( 0.89x)!  11.4 ( 0.99x)!
pred8x8_top_dc_10_neon   37.4 ( 1.24x)   0.1 ( 0.92x)!  20.4 ( 0.81x)!  59.5 ( 0.69x)!  10.5 ( 1.48x)   11.8 ( 1.02x)
pred8x8_vertical_8_neon  18.3 ( 1.08x)   0.1 ( 0.54x)!  12.8 ( 0.89x)!  37.2 ( 0.40x)!   8.3 ( 0.77x)!  11.2 ( 1.00x)
pred8x8_vertical_10_neon 19.0 ( 1.24x)   0.1 ( 0.55x)!  15.3 ( 0.62x)!  39.7 ( 0.50x)!   8.2 ( 0.91x)!  11.1 ( 0.99x)!

- pred8x8_horizontal_10 also underperforms on new architectures, but useful on A55 and A76.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-04 09:06:37 +00:00
Zhao Zhili f54841d375 avcodec/aarch64: add pngdsp
Test Name                    A55-gcc-11        M1-clang           A76-gcc-12          A510-clang        X3-clang
-------------------------------------------------------------------------------------------------------------------
add_bytes_l2_4096_neon        1807.2 ( 2.01x)    1.6 ( 1.94x)    333.0 ( 6.35x)   1058.2 ( 2.34x)    214.3 ( 1.99x)
add_paeth_prediction_3_neon  33036.1 ( 2.41x)  145.1 ( 1.66x)  20443.3 ( 1.97x)  35225.1 ( 1.23x)  19420.8 ( 1.05x)
add_paeth_prediction_4_neon  24368.6 ( 3.26x)  106.7 ( 2.01x)  15163.8 ( 2.77x)  26454.7 ( 1.62x)  14319.0 ( 1.35x)
add_paeth_prediction_6_neon  17900.6 ( 4.44x)   72.0 ( 2.70x)  10214.3 ( 4.20x)  18296.9 ( 2.27x)   9693.1 ( 1.97x)
add_paeth_prediction_8_neon  12615.4 ( 6.31x)   54.1 ( 2.58x)   7706.0 ( 5.45x)  13733.3 ( 2.94x)   7272.6 ( 2.63x)

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-04 12:05:35 +08:00
Zhao Zhili a0d4c07b86 tests/checkasm: add test for png
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-04 12:05:35 +08:00
Zhao Zhili 9ebfd68096 swscale/swscale: force SwsDither and SwsAlphaBlend to 32 bits
The 'sws_dither' and 'alphablend' options access 'SwsDither' and
'SwsAlphaBlend' enum fields as integers. This is unsafe when the
code is compiled with -fshort-enums, as the enum size might be
smaller than an int.

Since the 'dither' and 'alpha_blend' struct members are part of the
public API, their types cannot be easily changed.

To ensure safe integer access and maintain ABI compatibility across
different compiler settings, a MAX_ENUM value is added to force the
enums to a 32-bit underlying type.
2026-02-04 04:00:53 +00:00
Jack Lau 36b23092f9 avformat/rtsp: replace the deprecated localport with localrtpport
The `localport` already deprecated in 3a29702cb6

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-04 00:26:26 +00:00
Michael Niedermayer 1fd718c6a9 avformat/mpegts: Check program_info_length
Fixes: overread
No testcase

Found-by: Marton Balint
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-04 00:04:41 +00:00
Michael Niedermayer 5975149603 avformat/mpegts: Check IOD_DESCRIPTOR len
Fixes: out of array read
Fixes: VULN-7/poc.ts

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-04 00:04:41 +00:00
Jack Lau 5c6c12acb1 avformat/rtpenc: fix memleak when sdp create failed
Fix #20712

When print_sdp() fails during rtp streaming, sch_start()
returns error code without calling wirte_trailer, causing
a memory leak.

The avformat_free_context() will call the mux->deinit, so
we should add a rtp_deinit() to free all internal allocations.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-03 23:31:17 +00:00
zhanghongyuan 52f9e8c205 fftools/opt_common: Make -sources/-sinks options work without arguments
The -sources and -sinks options were defined with OPT_FUNC_ARG flag,
which requires an argument. This caused "Missing argument for option
'sources'" error when running ffprobe -sources without arguments.
Removing OPT_FUNC_ARG flag allows these options to work without
arguments, listing all available devices, while still supporting
optional device name argument for filtering specific devices.
2026-02-03 23:22:03 +00:00
WyattBlue 065c2582c0 avfilter/af_whisper: Add newline for txt format 2026-02-03 21:45:43 +00:00
Ruikai Peng 55d5b2b507 avfilter/drawvg: limit VGS parser recursion depth 2026-02-03 21:07:29 +00:00
Oliver Chang a795ca89fa avcodec/qdm2: fix heap-use-after-free in qdm2_decode_frame
The `sub_packet` index in `QDM2Context` was not reset to 0 when
`qdm2_decode_frame` started processing a new packet. If an error
occurred during the decoding of a previous packet, `sub_packet` would
retain a non-zero value.

In subsequent calls to `qdm2_decode_frame` with a new packet, this
non-zero `sub_packet` value caused `qdm2_decode` to skip
`qdm2_decode_super_block`. This function is responsible for initializing
packet lists with pointers to the current packet's data. Skipping it led
to the use of stale pointers from the previous (freed) packet, resulting
in a heap-use-after-free vulnerability.

This patch explicitly resets `s->sub_packet = 0` at the beginning of
`qdm2_decode_frame`, ensuring correct initialization for each new
packet.

Fixes: OSS-Fuzz issue 476179569
(https://issues.oss-fuzz.com/issues/476179569).
2026-02-03 18:17:32 +00:00
Jun Zhao 17d89757cd checkasm/hevc_pel: rename loop variable 'size' to 'idx' to avoid confusion
The variable 'size' is used as a loop index for the 'sizes' array.
This naming similarity is error-prone and recently led to a typo where
'size[sizes]' was written instead of 'sizes[size]'.

Rename the loop index variable from 'size' to 'idx' across all 10 test
functions to make the code more readable and prevent similar typos.

Additionally, replace the hardcoded loop upper bound '10' with
'FF_ARRAY_ELEMS(sizes)' for better maintainability.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-02-03 14:39:31 +00:00
Jun Zhao 2801d5eafe checkasm/hevc_pel: fix typo size[sizes] -> sizes[size]
Commit 4d4b301e4a introduced a typo where `size[sizes]` was used
instead of `sizes[size]` in 10 places within checkasm_check_pixel_padded
calls.

Since `sizes` is an array and `size` is the loop index, `size[sizes]`
interprets the array pointer as an index, resulting in undefined behavior
and causing AddressSanitizer to detect buffer overflows during testing.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-02-03 14:39:31 +00:00
Michael Niedermayer 2df0ef601a avcodec/jpeg2000dec: allow bpno of -1
Fixes: tickets/4663/levels30.jp2

The file decodes without error messages and no integer overflows
The file before the broader M_b check did decode with error messages and integer overflows but also no visual artifacts

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 12:39:32 +01:00
Michael Niedermayer e1472a4e0c avcodec/jpeg2000dec: allow M_b == 31
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 12:39:32 +01:00
Michael Niedermayer 8a3c7c9c32 avcodec/jpeg2000dec: Print bpno level when erroring out
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 12:39:32 +01:00
Michael Niedermayer 2efffa9ecd avcodec/jpeg2000dec: Print M_b value when asking for a sample
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 12:39:31 +01:00
Michael Niedermayer 65fc0db581 avformat/hlsenc: fix format string vulnerability in parse_playlist
Found-by: Sarthak Munshi <sarthakmunshi@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 11:26:23 +00:00
Niklas Haas 8dc025c706 fftools/ffmpeg_sched: drop unneeded atomic
No longer needed now that this code is always locked.
2026-02-03 12:00:31 +01:00
Niklas Haas 41bd67b9fd fftools/ffmpeg_sched: fix race on SchFilterIn.send_finished
This logic was previously added to the scheduler. That commit added locking
(and rescheduling) when updating the corresponding `receive_finished` flag,
but missed doing the same for `send_finished`.

Fixes: fd1fd5850d
2026-02-03 12:00:31 +01:00
Andreas Rheinhardt 836d34e3ba avformat/tests/movenc: Make objects static
(This also fixes a symbol name collision with libssh,
which has a nonstatic function called md5.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-02 23:06:57 +01:00
James Almer b613eebe78 avformat/demux: don't overwrite packet durations with parser ones if unset
Prevents loss of values taken from the demuxer when the underlying parser
doesn't set durations.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-02 12:52:02 -03:00
James Almer 3fc7e39eb8 avformat/cafenc: disable muxing Opus streams
We're not writing a kuki chunk because its contents for Opus are currently
unknown, so it's best if we don't allow the creation of non spec compliant
files.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-02 12:52:02 -03:00
James Almer bec16c0bd3 avformat/cafdec: export Opus extradata
Given the contents of the Opus kuki are not fully clear, generate it
using know values from the desc and pakt chunks.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-02 12:52:02 -03:00
James Almer d151c904df avformat/cafdec: take into account priming samples in timestamps
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-02 12:52:02 -03:00
stevxiao 7e9fe341df avfilter: version bump for filter mestimate_d3d12
Bump library version for filter 'mestimate_d3d12'.

This is the follow-up for commit https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21217/commits

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-02-02 04:16:50 +00:00
stevxiao 8fbd31e715 doc/filters: add entry for mestimate_d3d12
Add documentation for the filter "mestimate_d3d12" to the filters documentation.

This is the follow-up for commit https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21217/commits

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-02-01 09:53:35 -05:00
Frank Plowman 364d5dda91 lavc/vvc: Fix unchecked error codes from add_reconstructed_area 2026-01-31 13:46:13 +00:00
Frank Plowman f9740eb969 lavc/vvc: Fix unchecked error codes from set_qp_y
Fixes: clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-4957602162475008
2026-01-31 13:46:13 +00:00
Gyan Doshi 50bcc96a75 avformat/cafdec: parse non-intra streams
Needed to set KF flags so that they can be streamcopied using CLI.
2026-01-30 16:59:53 +00:00
Andreas Rheinhardt 39661f9295 fftools/ffmpeg_{filter,mux_init}: Improve type-safety
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-30 15:20:08 +01:00
Andreas Rheinhardt 67c87cde99 avfilter/formats,vsrc_testsrc: use type-safe formats functions
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-30 15:20:08 +01:00
Andreas Rheinhardt de3f99d74b avformat/cafenc: Truncate values for avio_w8()
Fixes triggering av_assert2() in avio_w8().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-30 13:24:06 +01:00
Andreas Rheinhardt 4367c055b6 avformat/cafenc: Fix segfault upon error, avoid indirection
caf_write_deinit() would segfault if the CAFStreamContext
couldn't be allocated. Fix this by moving everything from
CAFStreamContext to the ordinary CAFContext; the separation
doesn't make sense for a format with only one stream anyway
and removing it also avoids an indirection.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-30 11:30:30 +01:00
Martin Storsjö 7ebb6c54eb tools: Lowercase more patterns in aarch64 assembly
Match more SVE/SME specific details.

Also lowercase all register names. As this matches many cases
of code comments that refer to variables elsewhere, not specific
registers, we only apply this tranformation on the part of lines
before a potential comment.
2026-01-30 05:21:27 +00:00
Martin Storsjö f74c551eaa aarch64: Fix indentation of a few instructions
This file is excempt from the indent checker script, as there
are a few other bits in it that the script wants to reformat
into slightly worse form, or which might not warrant being
reformatted.

But these instructions should indeed be indented this way.
2026-01-30 05:21:27 +00:00
James Almer 277f9cb5d8 avformat/cafenc: add init and deinit callbacks
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:03 -03:00
James Almer 2d5556b082 avformat/cafenc: reindent after the previous changes
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:03 -03:00
James Almer 7581abdcb1 avformat/cafenc: support writing Packet Table Chunk Header if there are priming or remainder frames
If a codec has fixed block_align and frame_size but a given sample has either
priming or remainder frames, a pakt chunk can be written declaring zero packets
and no table, reporting only the samples to be discarded.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer 6ff12c4f6c avformat/cafenc: add support for variable frame size codecs
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer 7600d12383 avformat/cafenc: define a structure to store stream private fields
Will be useful in the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer 8d1f247ec1 avformat/cafenc: fix setting frame count fields in Packet Table Description
st->duration is not guaranteed to be set, so store the sum of packet durations instead.
Also, set mPrimingFrames and mRemainderFrames to correct values.

Based on a patch by Jun Zhao.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer f5ea09afe8 avformat/cafdec: export frame size when present
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer c52b287ba9 avformat/cafdec: fix setting stream and packet durations
Take into account priming frames, exported as start time, and remainder frames,
substracted from the stream duration as well as exported as discard padding
side data in the last packet.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer 041d108958 avcodec/opus/enc: don't remove more samples than needed from the last packet
The hardcoded extra 120 samples results in the side data reporting the need to
discard the entire packet rather than the padding samples.
This is in line with the behavior of the libopus encoder.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer c3aea7628c avcodec/opus/enc: set avctx->frame_size to a better guess based on encoder configuration
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
Andreas Rheinhardt 5b4ba2e1ac avfilter/vsrc_amf: Remove unused-but-set variable
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 22:33:33 +01:00
Andreas Rheinhardt ca5504fb5c avcodec/liblc3dec: Simplify sample fmt selection
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 14:08:15 +01:00
Andreas Rheinhardt ba1aea762b avcodec/liblc3{dec,enc}: Simplify sample_size, is_planar check
Sample size is always sizeof(float), is planar is a simple if
given that these codecs only support float and planar float.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 14:08:15 +01:00
Jack Lau 3c902f68d7 configure: update whip dependences
The dtls_protocol is ffmpeg component, should
be included by whip_muxer_select

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-29 12:19:17 +00:00
Jack Lau 2a0a32c42b avformat/whip: remove the confused option buffer_size
See https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20965#issuecomment-22815

The buffer_size isn't inlcuded in release/8.0,
directly use new option ts_buffer_size to replace
buffer_size shoule be okay.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-29 12:18:22 +00:00
Andreas Rheinhardt fc0e0ef022 tests/checkasm/hevc_dequant: Only init buffer when needed
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 12:25:33 +01:00
Andreas Rheinhardt 436b74b725 avcodec/x86/hevc/dequant: Add SSSE3 dequant ASM function
hevc_dequant_4x4_8_c (GCC):                             20.2 ( 1.00x)
hevc_dequant_4x4_8_c (Clang):                           21.7 ( 1.00x)
hevc_dequant_4x4_8_ssse3:                                5.8 ( 3.51x)
hevc_dequant_8x8_8_c (GCC):                             32.9 ( 1.00x)
hevc_dequant_8x8_8_c (Clang):                           78.7 ( 1.00x)
hevc_dequant_8x8_8_ssse3:                                6.8 ( 4.83x)
hevc_dequant_16x16_8_c (GCC):                          105.1 ( 1.00x)
hevc_dequant_16x16_8_c (Clang):                        151.1 ( 1.00x)
hevc_dequant_16x16_8_ssse3:                             19.3 ( 5.45x)
hevc_dequant_32x32_8_c (GCC):                          415.7 ( 1.00x)
hevc_dequant_32x32_8_c (Clang):                        602.3 ( 1.00x)
hevc_dequant_32x32_8_ssse3:                             78.2 ( 5.32x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 12:25:33 +01:00
Andreas Rheinhardt cf359a7907 avcodec/hevc/dsp: Add alignment for dequant
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 12:25:33 +01:00
Andreas Rheinhardt 0c7f87b136 avcodec/hevc/dsp_template: Optimize impossible branches away
Saves 1856B of .text here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 12:25:33 +01:00
Andreas Rheinhardt 2729c52988 avcodec/x86/hevc/deblock: Reduce usage of GPRs
Don't use two GPRs to store two words from xmm registers;
shuffle these words so that they are fit into one GPR.
This reduces the amount of GPRs used and leads to tiny speedups
here. Also avoid rex prefixes whenever possible (for lines
that needed to be modified anyway).

Old benchmarks:
hevc_h_loop_filter_luma8_skip_c:                        23.8 ( 1.00x)
hevc_h_loop_filter_luma8_skip_sse2:                      8.5 ( 2.80x)
hevc_h_loop_filter_luma8_skip_ssse3:                     7.2 ( 3.29x)
hevc_h_loop_filter_luma8_skip_avx:                       6.4 ( 3.71x)
hevc_h_loop_filter_luma8_strong_c:                     150.4 ( 1.00x)
hevc_h_loop_filter_luma8_strong_sse2:                   34.4 ( 4.37x)
hevc_h_loop_filter_luma8_strong_ssse3:                  34.5 ( 4.36x)
hevc_h_loop_filter_luma8_strong_avx:                    32.3 ( 4.65x)
hevc_h_loop_filter_luma8_weak_c:                       103.2 ( 1.00x)
hevc_h_loop_filter_luma8_weak_sse2:                     34.5 ( 2.99x)
hevc_h_loop_filter_luma8_weak_ssse3:                     7.3 (14.22x)
hevc_h_loop_filter_luma8_weak_avx:                      32.4 ( 3.18x)
hevc_h_loop_filter_luma10_skip_c:                       23.5 ( 1.00x)
hevc_h_loop_filter_luma10_skip_sse2:                     6.6 ( 3.58x)
hevc_h_loop_filter_luma10_skip_ssse3:                    6.1 ( 3.86x)
hevc_h_loop_filter_luma10_skip_avx:                      5.4 ( 4.34x)
hevc_h_loop_filter_luma10_strong_c:                    161.8 ( 1.00x)
hevc_h_loop_filter_luma10_strong_sse2:                  32.2 ( 5.03x)
hevc_h_loop_filter_luma10_strong_ssse3:                 30.4 ( 5.33x)
hevc_h_loop_filter_luma10_strong_avx:                   30.3 ( 5.33x)
hevc_h_loop_filter_luma10_weak_c:                       23.5 ( 1.00x)
hevc_h_loop_filter_luma10_weak_sse2:                     6.6 ( 3.58x)
hevc_h_loop_filter_luma10_weak_ssse3:                    6.1 ( 3.85x)
hevc_h_loop_filter_luma10_weak_avx:                      5.4 ( 4.35x)
hevc_h_loop_filter_luma12_skip_c:                       18.8 ( 1.00x)
hevc_h_loop_filter_luma12_skip_sse2:                     6.6 ( 2.87x)
hevc_h_loop_filter_luma12_skip_ssse3:                    6.1 ( 3.08x)
hevc_h_loop_filter_luma12_skip_avx:                      6.2 ( 3.06x)
hevc_h_loop_filter_luma12_strong_c:                    159.0 ( 1.00x)
hevc_h_loop_filter_luma12_strong_sse2:                  36.3 ( 4.38x)
hevc_h_loop_filter_luma12_strong_ssse3:                 36.1 ( 4.40x)
hevc_h_loop_filter_luma12_strong_avx:                   33.5 ( 4.75x)
hevc_h_loop_filter_luma12_weak_c:                       40.1 ( 1.00x)
hevc_h_loop_filter_luma12_weak_sse2:                    35.5 ( 1.13x)
hevc_h_loop_filter_luma12_weak_ssse3:                   36.1 ( 1.11x)
hevc_h_loop_filter_luma12_weak_avx:                      6.2 ( 6.52x)
hevc_v_loop_filter_luma8_skip_c:                        25.5 ( 1.00x)
hevc_v_loop_filter_luma8_skip_sse2:                     10.6 ( 2.40x)
hevc_v_loop_filter_luma8_skip_ssse3:                    11.4 ( 2.24x)
hevc_v_loop_filter_luma8_skip_avx:                       8.3 ( 3.07x)
hevc_v_loop_filter_luma8_strong_c:                     146.8 ( 1.00x)
hevc_v_loop_filter_luma8_strong_sse2:                   43.9 ( 3.35x)
hevc_v_loop_filter_luma8_strong_ssse3:                  43.7 ( 3.36x)
hevc_v_loop_filter_luma8_strong_avx:                    42.3 ( 3.47x)
hevc_v_loop_filter_luma8_weak_c:                        25.5 ( 1.00x)
hevc_v_loop_filter_luma8_weak_sse2:                     10.6 ( 2.40x)
hevc_v_loop_filter_luma8_weak_ssse3:                    44.0 ( 0.58x)
hevc_v_loop_filter_luma8_weak_avx:                       8.3 ( 3.09x)
hevc_v_loop_filter_luma10_skip_c:                       20.0 ( 1.00x)
hevc_v_loop_filter_luma10_skip_sse2:                    11.3 ( 1.77x)
hevc_v_loop_filter_luma10_skip_ssse3:                   11.0 ( 1.82x)
hevc_v_loop_filter_luma10_skip_avx:                      9.3 ( 2.15x)
hevc_v_loop_filter_luma10_strong_c:                    193.5 ( 1.00x)
hevc_v_loop_filter_luma10_strong_sse2:                  46.1 ( 4.19x)
hevc_v_loop_filter_luma10_strong_ssse3:                 44.2 ( 4.38x)
hevc_v_loop_filter_luma10_strong_avx:                   44.4 ( 4.35x)
hevc_v_loop_filter_luma10_weak_c:                       90.3 ( 1.00x)
hevc_v_loop_filter_luma10_weak_sse2:                    46.3 ( 1.95x)
hevc_v_loop_filter_luma10_weak_ssse3:                   10.8 ( 8.37x)
hevc_v_loop_filter_luma10_weak_avx:                     44.4 ( 2.03x)
hevc_v_loop_filter_luma12_skip_c:                       16.8 ( 1.00x)
hevc_v_loop_filter_luma12_skip_sse2:                    11.8 ( 1.42x)
hevc_v_loop_filter_luma12_skip_ssse3:                   11.7 ( 1.43x)
hevc_v_loop_filter_luma12_skip_avx:                      8.7 ( 1.93x)
hevc_v_loop_filter_luma12_strong_c:                    159.3 ( 1.00x)
hevc_v_loop_filter_luma12_strong_sse2:                  45.3 ( 3.52x)
hevc_v_loop_filter_luma12_strong_ssse3:                 60.3 ( 2.64x)
hevc_v_loop_filter_luma12_strong_avx:                   44.1 ( 3.61x)
hevc_v_loop_filter_luma12_weak_c:                       63.6 ( 1.00x)
hevc_v_loop_filter_luma12_weak_sse2:                    45.3 ( 1.40x)
hevc_v_loop_filter_luma12_weak_ssse3:                   11.7 ( 5.41x)
hevc_v_loop_filter_luma12_weak_avx:                     43.9 ( 1.45x)

New benchmarks:
hevc_h_loop_filter_luma8_skip_c:                        24.2 ( 1.00x)
hevc_h_loop_filter_luma8_skip_sse2:                      8.6 ( 2.82x)
hevc_h_loop_filter_luma8_skip_ssse3:                     7.0 ( 3.46x)
hevc_h_loop_filter_luma8_skip_avx:                       6.8 ( 3.54x)
hevc_h_loop_filter_luma8_strong_c:                     150.4 ( 1.00x)
hevc_h_loop_filter_luma8_strong_sse2:                   33.3 ( 4.52x)
hevc_h_loop_filter_luma8_strong_ssse3:                  32.7 ( 4.61x)
hevc_h_loop_filter_luma8_strong_avx:                    32.7 ( 4.60x)
hevc_h_loop_filter_luma8_weak_c:                       104.0 ( 1.00x)
hevc_h_loop_filter_luma8_weak_sse2:                     33.2 ( 3.13x)
hevc_h_loop_filter_luma8_weak_ssse3:                     7.0 (14.91x)
hevc_h_loop_filter_luma8_weak_avx:                      31.3 ( 3.32x)
hevc_h_loop_filter_luma10_skip_c:                       19.2 ( 1.00x)
hevc_h_loop_filter_luma10_skip_sse2:                     6.2 ( 3.08x)
hevc_h_loop_filter_luma10_skip_ssse3:                    6.2 ( 3.08x)
hevc_h_loop_filter_luma10_skip_avx:                      5.0 ( 3.85x)
hevc_h_loop_filter_luma10_strong_c:                    159.8 ( 1.00x)
hevc_h_loop_filter_luma10_strong_sse2:                  30.0 ( 5.32x)
hevc_h_loop_filter_luma10_strong_ssse3:                 29.2 ( 5.48x)
hevc_h_loop_filter_luma10_strong_avx:                   28.6 ( 5.58x)
hevc_h_loop_filter_luma10_weak_c:                       19.2 ( 1.00x)
hevc_h_loop_filter_luma10_weak_sse2:                     6.2 ( 3.09x)
hevc_h_loop_filter_luma10_weak_ssse3:                    6.2 ( 3.09x)
hevc_h_loop_filter_luma10_weak_avx:                      5.0 ( 3.88x)
hevc_h_loop_filter_luma12_skip_c:                       18.7 ( 1.00x)
hevc_h_loop_filter_luma12_skip_sse2:                     6.2 ( 3.00x)
hevc_h_loop_filter_luma12_skip_ssse3:                    5.7 ( 3.27x)
hevc_h_loop_filter_luma12_skip_avx:                      5.2 ( 3.61x)
hevc_h_loop_filter_luma12_strong_c:                    160.2 ( 1.00x)
hevc_h_loop_filter_luma12_strong_sse2:                  34.2 ( 4.68x)
hevc_h_loop_filter_luma12_strong_ssse3:                 29.3 ( 5.48x)
hevc_h_loop_filter_luma12_strong_avx:                   31.4 ( 5.10x)
hevc_h_loop_filter_luma12_weak_c:                       40.2 ( 1.00x)
hevc_h_loop_filter_luma12_weak_sse2:                    35.2 ( 1.14x)
hevc_h_loop_filter_luma12_weak_ssse3:                   29.3 ( 1.37x)
hevc_h_loop_filter_luma12_weak_avx:                      5.0 ( 8.09x)
hevc_v_loop_filter_luma8_skip_c:                        25.6 ( 1.00x)
hevc_v_loop_filter_luma8_skip_sse2:                     10.2 ( 2.52x)
hevc_v_loop_filter_luma8_skip_ssse3:                    10.5 ( 2.45x)
hevc_v_loop_filter_luma8_skip_avx:                       8.2 ( 3.11x)
hevc_v_loop_filter_luma8_strong_c:                     147.1 ( 1.00x)
hevc_v_loop_filter_luma8_strong_sse2:                   42.6 ( 3.45x)
hevc_v_loop_filter_luma8_strong_ssse3:                  42.4 ( 3.47x)
hevc_v_loop_filter_luma8_strong_avx:                    40.1 ( 3.67x)
hevc_v_loop_filter_luma8_weak_c:                        25.6 ( 1.00x)
hevc_v_loop_filter_luma8_weak_sse2:                     10.6 ( 2.42x)
hevc_v_loop_filter_luma8_weak_ssse3:                    42.7 ( 0.60x)
hevc_v_loop_filter_luma8_weak_avx:                       8.2 ( 3.11x)
hevc_v_loop_filter_luma10_skip_c:                       16.7 ( 1.00x)
hevc_v_loop_filter_luma10_skip_sse2:                    11.0 ( 1.52x)
hevc_v_loop_filter_luma10_skip_ssse3:                   10.5 ( 1.59x)
hevc_v_loop_filter_luma10_skip_avx:                      9.6 ( 1.74x)
hevc_v_loop_filter_luma10_strong_c:                    190.0 ( 1.00x)
hevc_v_loop_filter_luma10_strong_sse2:                  44.8 ( 4.24x)
hevc_v_loop_filter_luma10_strong_ssse3:                 42.3 ( 4.49x)
hevc_v_loop_filter_luma10_strong_avx:                   42.5 ( 4.47x)
hevc_v_loop_filter_luma10_weak_c:                       88.3 ( 1.00x)
hevc_v_loop_filter_luma10_weak_sse2:                    45.7 ( 1.93x)
hevc_v_loop_filter_luma10_weak_ssse3:                   10.5 ( 8.40x)
hevc_v_loop_filter_luma10_weak_avx:                     42.4 ( 2.09x)
hevc_v_loop_filter_luma12_skip_c:                       16.7 ( 1.00x)
hevc_v_loop_filter_luma12_skip_sse2:                    11.7 ( 1.42x)
hevc_v_loop_filter_luma12_skip_ssse3:                   10.5 ( 1.59x)
hevc_v_loop_filter_luma12_skip_avx:                      8.8 ( 1.90x)
hevc_v_loop_filter_luma12_strong_c:                    159.4 ( 1.00x)
hevc_v_loop_filter_luma12_strong_sse2:                  45.2 ( 3.53x)
hevc_v_loop_filter_luma12_strong_ssse3:                 59.3 ( 2.69x)
hevc_v_loop_filter_luma12_strong_avx:                   41.7 ( 3.82x)
hevc_v_loop_filter_luma12_weak_c:                       63.3 ( 1.00x)
hevc_v_loop_filter_luma12_weak_sse2:                    44.9 ( 1.41x)
hevc_v_loop_filter_luma12_weak_ssse3:                   10.5 ( 6.02x)
hevc_v_loop_filter_luma12_weak_avx:                     41.7 ( 1.52x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 11:54:57 +01:00
Andreas Rheinhardt 0843252229 avcodec/x86/hevc/deblock: avoid unused GPR
r12 is unused, so use it instead of r13 to reduce
the amount of push/pops.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 11:54:57 +01:00
Andreas Rheinhardt 0aad8b860a avcodec/x86/hevc/deblock: Avoid vmovdqa
(It would even be possible to avoid a clobbering m10 in
MASKED_COPY and the mask register (%3) in MASKED_COPY2
when VEX encoding is in use.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 11:54:57 +01:00
Andreas Rheinhardt c940128fff avcodec/x86/vp9lpf: Avoid vmovdqa
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 11:54:57 +01:00
Andreas Rheinhardt c898ddb8fe avcodec/x86/cfhddsp: Reduce number of xmm registers used
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 01:33:40 +01:00
Andreas Rheinhardt 848c3ca772 avcodec/x86/cfhddsp: Avoid pmaddwd
The result of using pmaddwd with the coefficients 1,-1,...,1,-1
is just the negative of using pmaddwd with the coefficients
-1,1,...,-1,1, so avoid one pmaddwd.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 01:33:37 +01:00
Andreas Rheinhardt 6224445753 avcodec/x86/cfhdencdsp: Avoid += x, -= x
Avoid incrementing lowq and highq inside the loop by using
complex addressing modes, avoiding to undo said modification
at the end of the horizontal loop.
For inputq, modify istrideq outside of the loop so that
it is only modified once at the end of the horizontal loop.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 01:33:34 +01:00
Andreas Rheinhardt 7dd6487800 avcodec/x86/cfhdencdsp: Don't load twice
Sign extend the integer arguments directly from the stack
instead of loading qwords, followed by sign-extending the
lower half.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 01:33:30 +01:00
Andreas Rheinhardt 91c7710412 avcodec/x86/cfhdencdsp: Avoid unnecessary constants
Up until now, cfhdencdsp used constants consisting
of -1, 1, ...,-1,1 words and 1, -1,...,1,-1 words
for use as constants in pmaddwd. But one can use
the same constants if one shuffles the words in
a dword the opposite order. Similarly for some other
constants. This also allowed to avoid a register in
chfdenc_vert_filter.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 01:33:23 +01:00
Andreas Rheinhardt cd3d8116fb avcodec/x86/cfhdencdsp: Avoid load of -1
It can be easily generated at runtime.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 01:32:57 +01:00
Jack Lau 4ad20a2c09 avformat/tls_gnutls: set key and cert when they're PEM string
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-28 10:47:07 +00:00
Jack Lau 28fb3f5e9e avformat/tls_gnutls: set srtp profile when it is enabled
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-28 10:47:07 +00:00
Jack Lau 8f9825cf41 avformat/tls_gnutls: add check for s->external_sock
When s->external_sock is enabled, the underlying sock
will be set after tls_open(), so it should not open a
sock and handshake.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-28 10:47:07 +00:00
Jack Lau 7f9d8b0c16 avformat/tls_gnutls: enable dtls build
Implement ff_ssl_*_key_cert()

Generate self-signed cert and key in server
mode if there're no key and cert input.

Implement ff_tls_set_external_socket() and
ff_dtls_export_materials()

Add gnutls as dtls protocol deps.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-28 10:47:07 +00:00
Zhao Zhili f4ca7950d8 avfilter/vf_mestimate_d3d12: remove redundant mb_size constants
A constant named 8 has value 8 is redundant. These constants cannot
prevent user from setting other vaues. Just describe valid values
in the help message.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-27 17:05:27 +00:00
Kasidis Arunruangsirilert e9e8a32b29 avcodec/nvenc: add 4-way multi nvenc split frame encoding support 2026-01-27 12:58:46 +00:00
Diego de Souza 499b5f5f92 avcodec/nvenc: add b_adapt option for HEVC encoder
The b_adapt option allows users to control adaptive B-frame decision
when lookahead is enabled in HEVC encoding. This feature was already
available for H.264 and AV1 encoders, but was missing from HEVC.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-01-27 12:58:08 +00:00
Steven Liu a97632827d avformat/dashdec: check value valid after read value from mpd xml
before this commit ffmpeg get Heap Buffer Overflow in DASH Demuxer
via Negative Start Number.
Check the value from mpd xml, set the value to 0 if get negative value.

Fixes: heap buffer overflow
Found-by: Zhenpeng (Leo) Lin from depthfirst
2026-01-27 08:28:43 +00:00
Andreas Rheinhardt d9e8c85617 swscale/x86/ops_int: Check for cpuflag instead of avx_enabled
This would make this code compatible with forcing VEX encodings
for the SSE4 codepath and is also more correct, because avx_enabled
would be enabled for AVX, although the instructions used in these
codepaths require AVX2.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-26 13:10:15 +01:00
stevxiao 451ff239e6 avfilter: d3d12 motion estimation filter support
This commit introduces a video filter `mestimate_d3d12` that provides hardware-accelerated motion estimation using DirectX 12 Video Encoding APIs. The filter leverages GPU hardware motion estimation capabilities to achieve significant performance improvements over the existing software-based mestimate filter.

Sample Command Line:

1. Basic mestimate_d3d12 functionality
```
	ffmpeg_g.exe -hwaccel d3d12va -i test.mp4 -vf mestimate_d3d12=mb_size=16 -f null -
```
2. Motion vector visualization
```
	ffmpeg -hwaccel d3d12va -i input.mp4 -vf "mestimate_d3d12,hwdownload,format=nv12,codecview=mv=pf" -c:v libx264 output.mp4
```
2026-01-26 11:31:48 +00:00
Dmitrii Ovchinnikov 714152dd9a avutil/hwcontext_d3d11va: added resource and heap flags to DeviceContext 2026-01-26 10:39:10 +00:00
Gyan Doshi fe0813d6e2 ffmpeg_demux: fix readrate to respect initial burst
Fixes #21510
2026-01-26 15:37:22 +05:30
Kacper Michajłow 10db62d205 swscale/utils: zero init filter memory as before
Commit 795bb37a39 removed zeroing of those
buffers, without mention, which introduces corrupted output.

Fixes: 795bb37a39
Fixes: https://github.com/mpv-player/mpv/issues/17317
2026-01-26 09:45:16 +00:00
Andreas Rheinhardt bf4d5037b4 avcodec/h264dsp: Remove redundant h264 from H264DSPCtx member names
These names are a remnant of dsputil when all the DSP functions
from all codecs were part of DSPcontext.

Reviewed-by: Rémi Denis-Courmont <remi@remlab.net>
Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:25 +01:00
Andreas Rheinhardt 489aaf4e1c avcodec/x86/h264_deblock: Don't sign-extend stride
Unnecessary (and wrong) since d5d699ab6e.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt db66e057eb avcodec/x86/h264_deblock: Avoid reload
Old benchmarks:
h264_h_loop_filter_luma_8bpp_c:                         60.0 ( 1.00x)
h264_h_loop_filter_luma_8bpp_sse2:                      65.4 ( 0.92x)
h264_h_loop_filter_luma_8bpp_avx:                       65.3 ( 0.92x)

New benchmarks:
h264_h_loop_filter_luma_8bpp_c:                         60.4 ( 1.00x)
h264_h_loop_filter_luma_8bpp_sse2:                      62.0 ( 0.97x)
h264_h_loop_filter_luma_8bpp_avx:                       61.7 ( 0.98x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt 8428a412bc avcodec/x86/h264_deblock: Avoid MMX in deblock_h_luma_8
Old benchmarks:
h264_h_loop_filter_luma_8bpp_c:                         59.9 ( 1.00x)
h264_h_loop_filter_luma_8bpp_sse2:                      67.9 ( 0.88x)
h264_h_loop_filter_luma_8bpp_avx:                       67.4 ( 0.89x)

New benchmarks:
h264_h_loop_filter_luma_8bpp_c:                         60.0 ( 1.00x)
h264_h_loop_filter_luma_8bpp_sse2:                      65.4 ( 0.92x)
h264_h_loop_filter_luma_8bpp_avx:                       65.3 ( 0.92x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt 9882973935 avcodec/x86/h264_deblock: Avoid reloading constant
No change in benchmarks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt eaaf45fd79 avcodec/x86/h264_deblock_10bit: Simplify r0+4*r1
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt aab0946eae avcodec/x86/h264_deblock_10bit: Remove mmxext functions
Now that the SSE2/AVX functions are no longer restricted
to those systems having an aligned stack, the MMXEXT functions
are always overridden (except for ancient systems without
SSE2), so remove them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt dbdf514c17 avcodec/x86/h264_deblock_10bit: Remove custom stack allocation code
Allocate it via cglobal as usual. This makes the SSE2/AVX functions
available when HAVE_ALIGNED_STACK is false; it also avoids
modifying rsp unnecessarily in the deblock_h_luma_intra_10 functions
on Win64.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt b1140d3c98 avcodec/x86/h264_deblock: Remove obsolete macro parameters
They are a remnant of the MMX functions (which processed
only eight pixels at a time, so that it was called twice
via a wrapper; the actual MMX function had "v8" in its name
instead of simply v) which have been removed in commit
4618f36a24.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt 899475326b avcodec/x86/h264_deblock: Simplify splatting
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt a22149ab3d avcodec/x86/h264_deblock: Remove always-false branches
These functions are always called with alpha and beta > 0.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt d53ff30215 tests/checkasm/h264dsp: Don't test loop filter strength 0
These functions are not used with these parameters;
see the filter_mb_* functions in h264_loopfilter.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt 982244818b avcodec/x86/h264_deblock: Remove unused macros
Forgotten in 4618f36a24.
Also remove a PASS8ROWS wrapper that seems to have been always
unused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt 6e65d1c945 avcodec/motion_est: Fix left shifts of negative numbers
Fixes ticket #21486.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:46:39 +01:00
Jun Zhao 8966101fa6 lavc/hevc: add aarch64 neon for 12-bit dequant
Implement NEON optimization for HEVC dequant at 12-bit depth.

For 12-bit: shift = 15 - 12 - log2_size = 3 - log2_size. When shift
is negative, we use shl (shift left) instead of srshr.

Performance benchmark on Apple M4:
./tests/checkasm/checkasm --test=hevc_dequant --bench
hevc_dequant_4x4_12_c:                                   9.9 ( 1.00x)
hevc_dequant_4x4_12_neon:                                5.7 ( 1.74x)

hevc_dequant_8x8_12_c:                                   1.7 ( 1.00x)
hevc_dequant_8x8_12_neon:                                1.3 ( 1.30x)

hevc_dequant_16x16_12_c:                               131.1 ( 1.00x)
hevc_dequant_16x16_12_neon:                              7.9 (16.52x)

hevc_dequant_32x32_12_c:                                69.7 ( 1.00x)
hevc_dequant_32x32_12_neon:                             28.4 ( 2.46x)

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-25 06:55:26 +00:00
Jun Zhao ce89d974c8 lavc/hevc: add aarch64 neon for 10-bit dequant
Implement NEON optimization for HEVC dequant at 10-bit depth.

For 10-bit: shift = 15 - 10 - log2_size = 5 - log2_size

Performance benchmark on Apple M4:
./tests/checkasm/checkasm --test=hevc_dequant --bench
hevc_dequant_4x4_10_c:                                  16.6 ( 1.00x)
hevc_dequant_4x4_10_neon:                                7.4 ( 2.23x)

hevc_dequant_8x8_10_c:                                  39.7 ( 1.00x)
hevc_dequant_8x8_10_neon:                                7.5 ( 5.28x)

hevc_dequant_16x16_10_c:                               168.7 ( 1.00x)
hevc_dequant_16x16_10_neon:                             10.2 (16.56x)

hevc_dequant_32x32_10_c:                                 1.9 ( 1.00x)
hevc_dequant_32x32_10_neon:                              1.9 ( 1.01x)

Note: 32x32 shift=0 is identity transform (no-op), so NEON has no
advantage over C which is also optimized away by the compiler.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-25 06:55:26 +00:00
Jun Zhao 24f296c7a1 lavc/hevc: optimize dequant for shift=0 case (identity transform)
The HEVC dequantization uses:
  shift = 15 - bit_depth - log2_size

When shift equals 0, the operation becomes an identity transform:
  - For shift > 0: output = (input + offset) >> shift
  - For shift < 0: output = input << (-shift)
  - For shift = 0: output = input << 0 = input (no change)

This occurs in the following cases:
  - 10-bit, 32x32 block: shift = 15 - 10 - 5 = 0
  - 12-bit, 8x8 block:   shift = 15 - 12 - 3 = 0

Previously, the code would still iterate through all coefficients
and perform redundant read-modify-write operations even when shift=0.

This patch adds an early return for shift=0, avoiding unnecessary
memory operations. checkasm benchmarks on Apple M4 show:
  - 10-bit 32x32: 69.1 -> 1.6 cycles (43x faster)
  - 12-bit 8x8:   30.9 -> 1.7 cycles (18x faster)

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-25 06:55:26 +00:00
Jun Zhao 0886e50c6b lavc/hevc: add aarch64 neon for 8-bit dequant
Implement NEON optimization for HEVC dequant at 8-bit depth.

The NEON implementation uses srshr (Signed Rounding Shift Right) which
does both the add with offset and right shift in a single instruction.

Optimization details:
- 4x4 (16 coeffs): Single load-process-store sequence
- 8x8 (64 coeffs): Fully unrolled, no loop overhead
- 16x16 (256 coeffs): Pipelined load/compute/store to hide memory latency
- 32x32 (1024 coeffs): Pipelined with all available NEON registers

Performance benchmark on Apple M4:
./tests/checkasm/checkasm --test=hevc_dequant --bench
hevc_dequant_4x4_8_c:                                   11.3 ( 1.00x)
hevc_dequant_4x4_8_neon:                                 6.3 ( 1.78x)

hevc_dequant_8x8_8_c:                                   33.9 ( 1.00x)
hevc_dequant_8x8_8_neon:                                 6.6 ( 5.11x)

hevc_dequant_16x16_8_c:                                153.8 ( 1.00x)
hevc_dequant_16x16_8_neon:                               9.0 (17.02x)

hevc_dequant_32x32_8_c:                                 78.1 ( 1.00x)
hevc_dequant_32x32_8_neon:                              31.9 ( 2.45x)

Note on Performance Anomaly:
The observation that hevc_dequant_32x32_8_c is faster than 16x16 (78.1 vs 153.8)
is due to Clang auto-vectorizing only for sizes >= 32x32.
Compiler: Apple clang version 17.0.0 (clang-1700.6.3.2)

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-25 06:55:26 +00:00
Zhao Zhili 1e1dde8798 avcodec/libx265: map ffmpeg log level to x265 log level
Previously x265 encoder used its default log level regardless of
FFmpeg's log level setting. Note the log level can be overwritten
by x265-params.

Fix #21462

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-25 13:09:30 +08:00
Ruikai Peng 905a432403 libavfilter/showcwt: fix OOB write for DU/RL position init
In config_output() for direction=DU/RL, the position
is initialized to s->sono_size, which equals h or w
when bar=0. That position is later used as an
in-bounds pixel coordinate without clamping in draw(),
causing writes past the end of the output planes.

Repro:
ffmpeg -f lavfi -i sine=frequency=1000:sample_rate=44100 \
  -filter_complex "[0:a]showcwt=s=640x512:bar=0:direction=du[v]" \
  -map "[v]" -frames:v 1 -f null -

AddressSanitizer: heap-buffer-overflow ... WRITE of size 1

Initialize and wrap the DU/RL position to sono_size - 1
(or 0 when empty), preventing out-of-bounds row/column
writes when bar=0 while preserving existing slide behavior.
2026-01-24 22:05:34 +00:00
Rost Kurylo 4c9953592f avformat/udp: don't bind sockets to 0.0.0.0 by default for unicast UDP inputs 2026-01-24 20:26:24 +00:00
Carl Eugen Hoyos aab0c23cb8 lavc/j2kdec: Do not ignore colour association for packed formats
Fixes ticket #9468.

Signed-off-by: Carl Eugen Hoyos <ceffmpeg@gmail.com
2026-01-24 20:25:05 +00:00
Timo Rothenpieler 4f77473b46 forgejo/workflows: update actions 2026-01-24 20:05:07 +00:00
GeoffreyAA ff63d4865b avfilter/vf_libplacebo: add chroma_location option
Add chroma_location option so that, in the subsampled-to-subsampled case, the destination's chroma siting can be changed from the source's without having to use other filters. Useful, for example, when converting BT.2020 to BT.709, where the former customarily uses "top left" and the latter "left."

Update documentation.

Closes: #21185
2026-01-24 11:01:34 +00:00
niyinghao ec8e0b3592 libavfilter: Use type-safe format negotiation functions with enum parameters
Replace generic format functions with type-safe variants to prevent undefined
behavior with -fshort-enums compiler flag.

- 44/20 filters: ff_set_common_formats_from_list2 -> ff_set_*_formats_from_list2 (sample/pixel)
- 16/41 filters: ff_make_format_list → ff_make_*_format_list (sample/pixel)

Signed-off-by: niyinghao <niyinghao@xiaomi.com>
2026-01-24 08:11:19 +00:00
Christopher Degawa a5d4c398b4 avcodec/libsvtav1: rename aq_mode for v4.0.0
Signed-off-by: Christopher Degawa <ccom@randomderp.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-23 23:07:18 -03:00
Michael Niedermayer 404775a141 swscale/utils: Sanity check sizeFactor
Fixes: multiple integer overflows
Fixes: out of array access

The PoC modifies filter parameters generally inaccessable to an attacker

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-23 17:53:33 +00:00
Michael Niedermayer 795bb37a39 swscale/utils: Avoid FF_ALLOC_TYPED_ARRAY() and use av_malloc_array() directly
Fixes: multiple integer overflows
Fixes: out of array access

Regression since: a408d03ee6

The PoC modifies filter parameters generally inaccessable to an attacker

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-23 17:53:33 +00:00
Lynne 8349565d52 aacsbr_template: fix SBR USAC coupling
This issue hid under the radar since the codebooks between coupling
modes very often result in identical bit counts regardless of the encoded
data, leading to no frame-level bitstream desyncs except in rare cases.

AAC Mps212 data is parsed immediately after the SBR data, where a loss
of sync in SBR will result in Mps212 being wildly different.
2026-01-23 14:40:52 +01:00
Ling, Edison a93cb79da2 avcodec/d3d12va_encode: Bug fix and refactor for motion estimation precision initialization
Move motion estimation precision check from standalone
`d3d12va_encode_init_motion_estimation_precision()` function into each
codec's init_sequence_params() to reuse existing feature support
queries.

 - fixes AV1 using wrong support structure (SUPPORT instead of SUPPORT1)
 - eliminates duplicate setup code
 - removes redundant CheckFeatureSupport API call
 - no intended functional changes other than bug fix
2026-01-23 13:25:55 +00:00
James Almer dd2976b9e1 avcodec/mlp: don't duplicate the AV_CRC_8_EBU table
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-22 17:44:46 -03:00
wangbin 4561fc5e48 configure: probe glslang
if shaderc is not installed and --glslc is not set
2026-01-22 03:05:01 +00:00
Marton Balint 0c3afc7e56 Revert "lavfi: make sure frame SAR matches the link value"
This reverts commit fcc33ada47.

It breaks playback of files with changing aspect ratio in ffplay, such as [1],
because the filter chain is initialized with the initial aspect ratio, so any
change is overwritten.

[1] https://samples.ffmpeg.org/archive/container/mpegts/mpegts+mpeg2video+mp2++aspect.ts
2026-01-21 22:06:12 +00:00
Marton Balint a275ae8d64 avfilter: do not overwrite frame aspect ratio with source frame props in histogram and vectorscrope
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:06:12 +00:00
Marton Balint 0ba9e272fa fftools/ffplay: add support for rendering without alpha
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:02:50 +00:00
Marton Balint e76c73afaf fftools/ffplay: add video_bg and aspect ratio support to vulkan renderer
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:02:50 +00:00
Marton Balint 50671a018d fftools/ffplay: add a new -video_bg option for transparent video
It allows controlling the background of a transparent video. Default is a
checker board pattern.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:02:50 +00:00
Lynne e2f9861036 hwcontext_vulkan: fix stride for host image copy uploads
Can this cursed extension ever bloody ever even work!?!
2026-01-21 21:21:32 +01:00
Hyunjun Ko b637624046 avcodec/vulkan_av1: fix mi_col_starts and mi_row_starts units
The spec says:
   pMiColStarts is a pointer to an array of TileCols number
   of unsigned integers that corresponds to MiColStarts
   defined in section 6.8.14 of the [AV1 Specification]

And the unit of MiColStarts is MI(mode info).

So is pMiRowStarts.
2026-01-21 10:42:02 +00:00
Jack Lau ba3cbc2b4a avformat/whip: fix hard code in SDP BUNDLE
In early code, the BUNDLE always has two stream
id "a=group:BUNDLE 0 1" even though there's only
one stream.

This patch aims to dynamically set BUNDLE value.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 09:18:59 +00:00
Jack Lau 69b6af0e68 avformat/whip: remove redundant NONBLOCK set for dtls
DTLS handshake already force set BLOCK mode.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jack Lau bbd63b5a82 avformat/whip: handle the error of dtls_initialize
Correct the log level to AV_LOG_ERROR when dtls fails

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jack Lau 42596578ee avformat/whip: put dtls init code into dtls_initialize
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jack Lau ddf3e56514 avformat/whip: correct the ice time log
The ICE handshake actually finished after recieve
and handle binding request from peer when the peer
is not ice lite mode.

Log the ice status when it really done.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Ramiro Polla 96d8e19720 avcodec/mjpegdec: fix segfault on extern_huff and no extradata
Regression since 1debadd58e.
2026-01-21 03:26:02 +00:00
Jun Zhao 33dd3485ba lavf/format: skip multiple consecutive ID3v2 tags in probe
Files with multiple consecutive ID3v2 tags were getting low probe
scores (1) because av_probe_input_format3 only skipped the first tag,
leaving subsequent tags to be treated as non-audio data.

Fix by looping to skip all consecutive ID3v2 tags before probing.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-21 02:37:43 +00:00
James Almer 41a2eb735c avformat/iamf_parse: stop trying to parse files that report an unknown layout
Exporting unknown layouts as unspec type is pointless in a format that expects
the user to remix the channels in location specific ways.
This simplifies assumptions and reduces the chances of heap buffer overflows.

Fixes: heap-buffer-overflow
Fixes: clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6363647720095744
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-21 00:02:58 +00:00
Kyle Swanson 402676f130 .forgejo/CODEOWNERS: Add myself for libvmaf 2026-01-20 20:24:55 +00:00
realies c6c11b0b6d avfilter/af_loudnorm: fix limiter buffer over-allocation
The limiter_buf was being allocated with buf_size (3000ms worth of
samples) instead of limiter_buf_size (210ms worth of samples).

This resulted in allocating approximately 14x more memory than needed
for the limiter buffer. At 192kHz stereo:
- buf_size: 1,152,000 samples = 9.2 MB
- limiter_buf_size: 80,640 samples = 0.6 MB
- Wasted: ~8.2 MB per filter instance

The bug was introduced when the limiter buffer was added but the
wrong size variable was used in av_malloc_array().
2026-01-20 20:24:36 +00:00
Werner Robitza d25d133df3 avcodec/libx265: add pass and x265-stats option
Add support for standard -pass and -passlogfile options, matching the behavior
of libx264.
Add the -x265-stats option to specify the stats filename.
Update documentation.

Signed-off-by: Werner Robitza <werner.robitza@gmail.com>
2026-01-20 10:10:26 +00:00
Manuel Lauss d244d438c3 avcodec/sanm: fix BL16 c1/7 source overread
Fix the required size calculation.

Reported-by: Ruikai Peng <ruikai@pwno.io>
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2026-01-20 09:47:47 +00:00
Michael Niedermayer 70298ba1c7 .forgejo/CODEOWNERS: Add myself to MAINTAINERS
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-20 02:04:22 +00:00
Michael Niedermayer 3679341110 .forgejo/CODEOWNERS: Add myself as maintainer of CODEOWNERS
Noone is reviewing my pr for .forgejo/CODEOWNERS

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-20 02:04:22 +00:00
Andreas Rheinhardt 94b7385592 avcodec/mlpenc: Mark unreachable cases as such
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-20 00:38:35 +00:00
Ramiro Polla e960f0aa01 avcodec/mjpegdec: remove qscale_table field from MJpegDecodeContext
This field has been unused since 759001c534.
2026-01-19 22:42:09 +00:00
Michael Niedermayer 4d411d155a .forgejo/CODEOWNERS: Add Kyle for libavfilter/af_loudnorm.*
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-19 22:41:16 +00:00
Marton Balint 387a522106 avcodec/libvpxdec: use codec capabilities to determine if external frame buffer can be used
Previously we used the codec or at the time of decoding fb_priv for this, but
fb_priv can be nonzero even if an external frame buffer is not set, so it's
cleaner to use the capability flag directly.

Also check the result of vpx_codec_set_frame_buffer_functions.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-19 21:32:00 +00:00
Marton Balint a2688827f4 avcodec/libvpxdec: cache the decoder interface
This saves us some #ifdefry.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-19 21:32:00 +00:00
Marton Balint a6069092af avcodec/libvpxenc: log the error message from the correct encoder
It is possible that the error happens with the alpha encoder, not the normal
one, so let's always pass the affected encoder to the logging function.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-19 21:32:00 +00:00
Michael Niedermayer fc8a614f3d avcodec/omx: Check extradata size and nFilledLen
No testcase, its unknown if this is a real issue

Reported-by: Peter Teoh <htmldeveloper@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-19 20:47:22 +00:00
Michael Niedermayer 09ec2b397a avcodec/exr: use av_realloc_array()
Related to: #YWH-PGM40646-33
See: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21347
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-19 20:41:04 +00:00
Lynne 3ccafa5906 ffv1_vulkan: generate a CRC table during runtime
Since the recent CRC changes, get_table returns arch-dependent tables.
2026-01-19 16:37:17 +01:00
Lynne e3a96a69cb vulkan_dpx: remove host image upload path
The main reason this was written was due to Nvidia. Nvidia always
has a fickle upload path, and seemed to have a shortcut for the
host image upload path. This seems to have been patched out of
recent driver versions.

This upload path relies on the driver keeping the same layout,
down to the stride for the images. Which is an assumption that's
not portable.

Rather than relying on this fickle upload path, what we'd like when
we want pure bandwidth is to decouple uploads to a separate queue,
and let the GPU pull the data from RAM via uploads.

It'll be slower with a single-threaded decoder, but currently all
of our compute-based decoders and the decoders that sit underneath
them support frame threading.
2026-01-19 16:37:17 +01:00
Lynne 713e3c4f91 vulkan_decode: do not align single-plane images to subsampling
Unlike multiplane images, single-plane images do not need to be
aligned to chroma width.
Saves a bit of memory.
2026-01-19 16:37:16 +01:00
Lynne 8dcf02ac63 vulkan: remove IS_WITHIN macro
This is the more correct GLSL solution.
2026-01-19 16:37:15 +01:00
Araz Iusubov 850436a517 avcodec/amfenc: fix async_depth deadlock with lookahead
AMF encoders may deadlock when lookahead > async_depth.
Automatically adjust async_depth to lookahead + 1 to prevent hangs.
2026-01-19 15:36:37 +00:00
Zhao Zhili e35b9e7c5c configure: fix scale_vulkan_filter dependency
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-19 13:59:39 +00:00
Jack Lau 8bd5594a0f avformat/whip: fix potential out of bound read in is_dtls_packet
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:37:17 +08:00
Jack Lau 5bc9e76ec6 avformat/whip: fix parameter order of ELAPSED
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:37:17 +08:00
Jack Lau 5e73027099 avfotmat/whip: remove ssl_error_message since it's no longer in use
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:37:17 +08:00
Jack Lau d15a9d5961 avformat/whip: fix memleak when avio_alloc_context() fails
The buffer is prepared for avio, so we need to free
the buffer at the end when avio_alloc_context() fails,
otherwise, it will cause memleak.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:34:43 +08:00
Gyan Doshi 43dbc011fa avcodec/bsf/setts: add option prescale
When prescale is enabled, time fields are converted to the output
timebase before expression evaluation. This allows option specification
even if the input timebase is unknown.
2026-01-19 16:51:47 +05:30
Gyan Doshi 1ccd2f6243 avcodec/bsf/setts: rescale TS when changing TB
The setts bsf has an option to change TB. However the filter only
changed the TB and did not rescale the ts and duration, so it
effectively and silently stretched or squeezed the stream.

The pts, dts and duration are now rescaled to maintain temporal fidelity.
2026-01-19 16:51:31 +05:30
Dmitrii Ovchinnikov 6972b127de avfilter: Add vsrc_amf - AMF based screen capture
This patch adds screen capture support via AMF vsrc_amf:
ffmpeg -y \
    -filter_complex "vsrc_amf=framerate=120:capture_mode=keep_framerate" \
    -c:v hevc_amf \
    -frames:v 300 \
    output_grab.mp4

If the HW frames pool is insufficient,
increase extra_hw_frames in filter_complex.
2026-01-19 10:16:37 +00:00
niyinghao a5091f6d66 avfilter/formats: add type-safe functions for AVSampleFormat/AVPixelFormat lists
This avoids undefined behavior when -fshort-enums is enabled, where accessing enum arrays through int pointers causes incorrect memory reads.

Signed-off-by: niyinghao <niyinghao@xiaomi.com>
2026-01-19 09:33:49 +00:00
Zhao Zhili 8f9700bff0 avcodec/d3d12va_encode_h264: simplify deblock option to bool type
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-19 09:14:06 +00:00
Andreas Rheinhardt 063684efec avcodec/mlp: Don't use internals of CRC API
ff_mlp_restart_checksum() used the (undocumented) layout
of the CRC tables and therefore broke on x86 when the
clmul implementation added in dc03cffe9c
is used. This commit fixes this (and issue #21506).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-19 00:30:20 +01:00
Timo Rothenpieler 7379539685 avcodec/prores_raw: use av_popcount instead of limited lookup table
The calculation can yield bigger values than the lookup table provides.
So just use actual popcount instead.

Fixes #21503
2026-01-18 18:52:55 +01:00
Jack Lau cc8f392136 avformat/whip: add new option ts_buffer_size to deprecate buffer_size
See https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20965#issuecomment-15854

The old option name `buffer_size` maybe confusing because there're some
protocols and muxer using this.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-18 03:42:05 +00:00
AnandajithS ed085692d9 doc: fix typos
Fix trivial grammatical errors.

Signed-off-by: AnandajithS <anandajiths2006@gmail.com>
2026-01-18 03:33:04 +00:00
Jack Lau 3b4ff18efe avformat/tls_gnutls: fix build error on linux
The fd_set need <sys/select.h> on linux, but it's
not included in os_support.h, it's included in os_support.c

So this patch use poll() to replace select() to avoid
this issue and simplify the code.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-18 01:58:37 +00:00
Jack Lau 74bc79e475 avformat/tls_gnutls: fix build error on linux
The fd_set need <sys/select.h> on linux, but it's
not included in os_support.h, it's included in os_support.c

So this patch use poll() to replace select() to avoid
this issue and simplify the code.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-18 01:57:56 +00:00
James Almer 685ceebd42 avcodec/vc1dec: fix memory leak on error
Regression since 8a1c2779a0.

Fixes CID 732271.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 17:56:06 -03:00
James Almer 5ec31dac94 avformat/mov: fix memory leak on error
Regression since 52b1977353.

Fixes CID 1680454.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 17:52:52 -03:00
James Almer c1a7c79624 avformat/hcom: check that all extradata bytes were read from the input
Fixes issue #21493.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 17:42:06 -03:00
averne 3829f4ba6a vulkan/prores: reduce push constants size
The VK specs only mandates 128B, and some platforms
don't actually implement more.  This moves the quantization
matrices to the per-frame buffer.
2026-01-17 17:33:31 +00:00
James Almer 52b1977353 avformat/mov: add overflow checks to item offset values
Fixes issue #21478.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 13:02:49 -03:00
James Almer f8e39f6c73 avcodec/hevc/ps: add missing check for profile tier level count
Fixes issue #21488.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 12:37:47 -03:00
James Almer f311969c03 avcodec/qdm2: propagate error values in the entire decoder
And add missing error value checks.

Fixes the rest of of issue #21476.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 12:03:51 -03:00
James Almer 1ffcd07400 avcodec/mimic: check return value of init_get_bits()
Fixes part of issue #21476.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 12:02:31 -03:00
James Almer bb29b51876 avcodec/vc1dec: don't overwrite error codes returned by init_get_bits8()
Done by mistake in 8a1c2779a0.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 11:01:21 -03:00
Ling, Edison c3d3377fe1 avcodec/d3d12va_encode: Add H264 deblock filter parameter support
add parameter `deblock` for users to explicitly enable/disable deblocking filter in d3d12 H264 encoding

usage:
-deblock enable or -deblock 1
-deblock disable or -deblock 0
-deblock auto or -deblock -1

sample command line:
```
.\ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v h264_d3d12va -deblock enable -y output.mp4
```
2026-01-16 07:03:37 +00:00
Ruikai Peng be82aef7cc lavc/aacdec_usac: fix CPE channel index in ff_aac_usac_reset_state()
fix a simple index bug in ff_aac_usac_reset_state()
that writes past the end of ChannelElement.ch[2] for CPE

ff_aac_usac_reset_state() loops over channels with j < ch, but
incorrectly takes &che->ch[ch]. For CPE (ch == 2) this becomes
che->ch[2], which is one past the end of ChannelElement.ch[2], and the
subsequent memset() causes an intra-object out-of-bounds write.

index the channel element with the loop variable (j).
2026-01-15 19:32:52 +00:00
James Almer 8a1c2779a0 avcodec/vc1dec: check return values of all init_get_bits() calls
And replace them with init_get_bits8, to prevent integer overflows on huge
values.

Fixes issue #21463.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-15 16:07:46 -03:00
Michael Niedermayer 14ec28df5f tools/target_dec_fuzzer: Adjust threshold for ZMBV
Fixes: Timeout
Fixes: 464041539/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZMBV_DEC_fuzzer-4758337414823936

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-15 19:49:43 +01:00
Raja Rathour 408dbf3c74 avfilter/vf_blackframe: add slice threading using stdatomic
Signed-off-by: Raja Rathour <imraja729@gmail.com>
2026-01-15 16:26:09 +00:00
Zhao Zhili e8daa03fee arm/timer: disable PMCCNTR timer for Android
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-15 16:06:13 +00:00
Zhao Zhili 9bb5ae3a42 avutil/hwcontext_vulkan: fix vulkan callback function prototype
Fix -Wincompatible-function-pointer-types.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-15 16:05:56 +00:00
Jun Zhao 6c878f8b82 lavf/movenc: fix missing padding for AV1 extradata
The extradata allocated in mov_write_single_packet() for AV1 was missing
the required AV_INPUT_BUFFER_PADDING_SIZE padding bytes. This could lead
to out-of-bounds reads when the extradata is parsed by bitstream readers.

Replace av_memdup() with av_malloc() + memset() + memcpy() to ensure
proper padding is present and zeroed.

Reproduced with:
./ffmpeg -y -f lavfi -i "testsrc=duration=1:size=320x240:rate=30" -c:v libaom-av1 -cpu-used 8 -crf 50 test-av1.mp4

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-14 23:56:39 +00:00
Jun Zhao b326b3a08d lavc/av1_parser: Extract SAR from render_size
Extract the Sample Aspect Ratio (SAR) from render_width_minus_1 and
render_height_minus_1 in the sequence header.

The AV1 specification defines the render dimensions, which can be used
in conjunction with the coded dimensions to determine the pixel aspect
ratio. This ensures consistent aspect ratio handling for AV1 streams
encapsulated in containers like MP4 or MKV, as observed in the updated
FATE tests where SAR changes from 0/1 to 1/1.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-14 23:56:39 +00:00
Lynne e51c549f6e vulkan/dpx: drop using the nontemporal extension
Its rarely respected by implementations, its fairly new (1 year old),
and it has a scuffed define (neither glslc nor glslang enable the
"GL_EXT_nontemporal_keyword" define if its enabled, unlike all other extensions).
2026-01-14 16:13:22 +01:00
Michael Niedermayer 805931dfc8 avfilter/scale_eval: Avoid undefined behavior with double to int cast
We use INT32_MIN/MAX so as to ensure we dont have to deal with 64bit width or height
on a int is int64 system. int64 width would overflow in a system where we assume the product of 2
values fit in int64

Fixes: #YWH-PGM40646-14
Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-13 22:25:53 +00:00
Michael Niedermayer 5bbc8f828e avfilter/scale_eval: Use 64bit for factor_w/h
Avoids truncation and overflows

Fixes: #YWH-PGM40646-14
Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-13 22:25:53 +00:00
Michael Niedermayer 23c8123d5b avformat/http: Check white and blacklists on redirects
Noticed while fixing the previous

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-13 21:56:14 +00:00
Michael Niedermayer b9227d49ea avformat/http: Check that the protocol of redirects is http or https
Fixes: #YWH-PGM40646-10

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-13 21:56:14 +00:00
James Almer 80a3ba7d79 configure: add missing vulkan_1_4 check
Removed in f2affdfafb by mistake.
Also, fix the logic in probe_glslc() so it doesn't return false when debug is disabled.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-13 13:28:23 -03:00
James Almer f897bcd122 configure: fix glslc checks and add missing dependencies to relevant modules
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-12 18:20:01 -03:00
Lynne ab66bc5776 Makefile: add missing vpath for glsl/spv
Similar to CUDA. Fixes building on some systems.
2026-01-12 19:18:36 +01:00
Michael Niedermayer 7e9f99ef41 doc/mailing-list-faq.texi: Fix typo in link anchor
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-12 18:00:14 +00:00
Michael Niedermayer aa0a3e6223 .forgejo/CODEOWNERS: get notified for vf_find_rect
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-12 17:50:30 +00:00
Lynne 80229c161b scale_vulkan: use compile-time SPIR-V generation for debayering 2026-01-12 17:28:43 +01:00
Lynne f2a55af9a4 vulkan_dpx: switch to compile-time SPIR-V generation 2026-01-12 17:28:43 +01:00
Lynne 0f4667fc11 vulkan_prores_raw: clean up and optimize 2026-01-12 17:28:42 +01:00
averne 771b58c0b6 vulkan/prores: fix buffer alignments 2026-01-12 17:28:42 +01:00
Lynne 23ab1b1a66 vulkan/dct: embed DCT scaling values during SPIR-V generation
Instead of relying on rounded off values, use specialization constants
to bake the DCT values into the shader when its compiled.
2026-01-12 17:28:42 +01:00
Lynne e27b510da8 vulkan_prores: generate SPIR-V at compile-time 2026-01-12 17:28:42 +01:00
Lynne 026e94e339 vulkan_prores_raw: use compile-time SPIR-V generation 2026-01-12 17:28:42 +01:00
Lynne f3b0ca4f2c avgblur_vulkan: generate SPIR-V during compilation 2026-01-12 17:28:42 +01:00
Lynne a6391168f2 bwdif_vulkan: use compile-time SPIR-V 2026-01-12 17:28:42 +01:00
Lynne e32cb94258 hwcontext_vulkan: enable long vector extension
This enables us to do some neat tricks.
2026-01-12 17:28:41 +01:00
Lynne 95a23820f7 hwcontext_vulkan: enable non-uniform features we were already using 2026-01-12 17:28:41 +01:00
Lynne cf0ce1b7e4 hwcontext_vulkan: enable the VK_EXT_shader_replicated_composites extension
Its required to use certain features in SPIR-V that glslang uses.
2026-01-12 17:28:41 +01:00
Lynne dd69ebc9a8 vulkan_filter: don't use lg_size[2] as the number of workgroup.z
This was put there because who knows why, but it's wrong, this
ends up having double dispatches in the z direction if non-1.
2026-01-12 17:28:41 +01:00
Lynne e844b43776 vulkan: support shader compression 2026-01-12 17:28:41 +01:00
Lynne 7ce22b085e cuda/load_helper: move zlib decompression into a separate file
Allows it to be reused for Vulkan
2026-01-12 17:28:41 +01:00
Lynne 35235c762c configure: add zlib to suggests for shader_compression 2026-01-12 17:28:40 +01:00
Lynne 5996a9ad3d configure: rename PTX_COMPRESSION to SHADER_COMPRESSION
Its useful for GLSL and Metal as well.
2026-01-12 17:28:40 +01:00
Lynne 540c4df5c7 vulkan: add support for precompiled shaders 2026-01-12 17:28:40 +01:00
Lynne f2affdfafb configure/make: support compile-time SPIR-V generation 2026-01-12 17:28:40 +01:00
Lynne 17f9a64860 configure: rename spirv_compiler to spirv_library
More accurate.
2026-01-12 17:28:40 +01:00
Lynne f11aa29df8 configure: remove unused X86ASM dependency flag variables 2026-01-12 17:28:40 +01:00
Lynne 40edf7d75d vulkan: switch to static allocation for temporary descriptor data
Simplifies management, and the hardware is limited to 4 descriptor sets
and whatever bindings.
2026-01-12 17:28:35 +01:00
Soham ecfabc25c2 avcodec/get_bits: mark unused VLC parameters
This commit marks unused parameters in get_vlc_multi() to fix
-Wunused-parameter warnings when building with -Wall/-Wextra.

No functional changes intended.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-12 14:03:25 +01:00
stevxiao 21a3e44fbe avcodec/d3d12va_encode: add Region of Interest (ROI) support
This commit implements ROI (Region of Interest) encoding support for D3D12VA hardware encoders, enabling spatially-adaptive quality control for H.264, HEVC, and AV1 encoders.

Query for `D3D12_VIDEO_ENCODER_RATE_CONTROL_FLAG_ENABLE_DELTA_QP` support during initialization to check whether the hardware support delta QP. If delta QP is supported, then process `AV_FRAME_DATA_REGIONS_OF_INTEREST` side data and generate delta QP maps for each frame.

Sample command line:
ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -vf addroi=x=480:y=270:w=960:h=540:qoffset=-1/5 -c:v hevc_d3d12va output.mp4
2026-01-12 02:45:48 +00:00
Michael Niedermayer f99df7dbb3 avfilter/vf_find_rect: Fix handling odd sized images
Fixes: out of array read
Fixes: #YWH-PGM40646-17

Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-12 02:05:11 +00:00
Raja Rathour 06d799ce1a avfilter/dnn_backend_torch: handle lifecycle of worker thread
Initialize async resources in dnn_load_model_th and ensure proper cleanup and thread joining in dnn_free_model_th.

Signed-off-by: Raja Rathour <imraja729@gmail.com>
Reviewed-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2026-01-12 08:53:42 +08:00
Raja Rathour 5e8ad5c39b avfilter/dnn_backend_torch: implement async execution logic
Update execute_model_th to support asynchronous execution by pushing tasks to the pending queue and notifying the worker thread.

Signed-off-by: Raja Rathour <imraja729@gmail.com>
Reviewed-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2026-01-12 08:53:42 +08:00
Raja Rathour 910270b179 avfilter/dnn_backend_torch: add async infrastructure
Add worker thread, mutex, and condition variable to THModel.

Signed-off-by: Raja Rathour <imraja729@gmail.com>
Reviewed-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2026-01-12 08:53:42 +08:00
James Almer cd03e0a001 libavformat/evcdec.c: add a check to ensure evc_frame_merge_bsf is present
While the inclusion of the bsf is forced by a configure check, it's better to not
just have the code here assume filter will never be NULL.

Fixes Coverity issue CID 1680305.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-12 01:43:21 +00:00
Marton Balint 96e8f3b8cc avformat/vorbiscomment: fix writing huge chapter numbers and time offets to vorbiscomment
Previous code truncated chapter numbers more than 999 and and time offsets more
than 99 hours.

The Vorbis comment format only allows 1000 chapters, so cap the number of
written chapters there.

This also fixes the GCC warnings for truncated strings.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-12 00:47:20 +01:00
Marton Balint b2e077ad69 avformat/vorbiscomment: use null buf to calculate vorbis comment length
Also check possible failures when calculating length, and change return type to
int as bigger return values are no longer possible.
2026-01-12 00:47:20 +01:00
Marton Balint c80d3b35ae avformat/aviobuf: return error for ffio_close_null_buf() if written bytes exceed INT_MAX
Also check return value where it is used.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-12 00:47:20 +01:00
James Almer af136db1c3 avfilter/vf_lcevc: attach a reference to the source frame to each passed in base picture
And free them once they are guaranteed to be no longer needed, instead of freeing them
when returned with an enhanced output.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-11 17:59:15 -03:00
James Almer 188521c7ad avcodec/lcevc: attach a reference to the source frame to each passed in base picture
This way we can ensure a frame reference will always exists for as long as the
external library needs the base picture.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-11 17:59:15 -03:00
Jack Lau 24213d5db3 MAINTAINERS: add myself as whip maintainer
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-11 04:24:55 +00:00
Jack Lau b0fe52ba4e avformat/tls_gnutls: add gnutls_pull_timeout() for dtls
See https://gnutls.org/manual/gnutls.html#index-gnutls_005ftransport_005fset_005fpull_005ftimeout_005ffunction

This callback is necessary for enforcing the DTLS mode timeouts when in blocking mode.

Otherwise the dtls pull function won't work.

The gnutls_pull_timeout() implementation refers to gnutls example:
https://gnutls.org/manual/gnutls.html#DTLS-echo-server-with-X_002e509-authentication-1

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-11 04:24:26 +00:00
Hassan Hany 202b7d29e8 avcodec/pngenc: disable background disposal for non-alpha formats 2026-01-11 00:47:17 +00:00
Andreas Rheinhardt 685011003f avcodec/x86/pngdsp: Remove MMXEXT function overridden by SSSE3
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-10 22:47:22 +01:00
Andreas Rheinhardt 31daa7cd87 avcodec/pngdsp: Use proper prefix ff_add_png->ff_png_add
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-10 22:47:22 +01:00
Andreas Rheinhardt 5f15c067fe avcodec/pngdsp: Constify
Also constify ff_png_filter_row().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-10 22:47:22 +01:00
Andreas Rheinhardt 3bbb3269a1 avcodec/pngdec: Move ff_add_png_paeth_prediction() to pngdsp.c
Also rename it to ff_png_add_paeth_prediction() so that it
has a proper prefix.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-10 22:47:22 +01:00
Zhao Zhili 8777fa60e6 avcodec/bswapdsp: improve performance by remove manually unroll
Manually unrolling loops increases code size, which can sometimes
improve performance, but more often than not, it degrades performance.
Keep the C version simple, and add assembly optimizations when needed.

                 x86-clang    x86-gcc-arch-native  x86-msvc     m1-clang      rpi5-clang       pi5-gcc-14
-------------------------------------------------------------------------------------------------------------
bswap_buf_c      57.3 ( 1.00x)  19.4 ( 1.00x)   55.4 ( 1.00x)   0.5 ( 1.00x)  143.5 ( 1.00x)   59.8 ( 1.00x)
bswap_buf_this*  49.0 ( 1.17x)  12.5 ( 1.56x)   17.7 ( 3.13x)   0.3 ( 2.04x)   57.9 ( 2.48x)   73.5 ( 0.81x)
bswap_buf_sse2   28.4 ( 2.02x)  24.3 ( 0.80x)   25.5 ( 2.18x)   -              -               -
bswap_buf_ssse3  24.6 ( 2.32x)  16.0 ( 1.22x)   19.0 ( 2.92x)   -              -               -
bswap_buf_avx2   21.2 ( 2.70x)  11.1 ( 1.74x)   11.2 ( 4.95x)   -              -               -

bswap_buf_c: C implementation before this patch
bswap_buf_this: C implementation after this patch

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-10 18:56:26 +00:00
Rémi Denis-Courmont bba42ce036 checkasm/riscv: add call checks for riscv32 2026-01-10 17:20:07 +02:00
Rémi Denis-Courmont 83477e2e18 checkasm/riscv: handle other float ABIs than double
This splits out the integer and floating point handling to add
support for software, single and quad float ABI's.
2026-01-10 17:20:07 +02:00
Rémi Denis-Courmont 2fb827bd38 checkasm/riscv: print clobbered register name
checkasm_fail_func takes a format string, so we can.
2026-01-10 17:20:07 +02:00
Rémi Denis-Courmont 68f3c1735e checkasm/riscv: restore stack before failure reporting
The faiure handling code is C and requires correct stack, global and
thread pointers. This restores them before returning to C. At the same
time, we no longer need to abort() afterwards.
2026-01-10 17:20:07 +02:00
Rémi Denis-Courmont c7dad004f3 checkasm/riscv: factor out the vector clobbers
No functional changes.
2026-01-10 17:20:07 +02:00
Jack Lau 6f2d23a009 avformat/tls_gnutls: implement dtls handshake logic
Get and set remote addr when dtls server mode.
(Refer to url_bio_bread in tls_openssl.c)

add tls_handshake function to handle the dtls
or tls handshake

TODO:
add gnutls_pull_timeout function to make dtls
handshake really work.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-10 05:30:50 +00:00
Timo Rothenpieler 69773c404a forgejo/workflows: don't cancel concurrent CI builds for non-PR pushes 2026-01-10 01:53:48 +00:00
0xBat f59968720c doc/examples/extract_mvs: fix memory leak in codec context initialization
Ensure the allocated AVCodecContext is properly freed if avcodec_parameters_to_context fails.

Signed-off-by: 0xBat <monsterbat02@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-09 23:45:07 +01:00
0xBat 786e245e80 doc/examples/qsv_transcode: check for allocation failure
Validate return value of av_malloc for dynamic_setting to avoid null pointer dereference.

Signed-off-by: 0xBat <monsterbat02@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-09 23:44:59 +01:00
0xBat 3b0409dd13 doc/examples/hw_decode: fix memory leak in codec context initialization
Properly free decoder_ctx on failure to prevent a memory leak during initialization.

Signed-off-by: 0xBat <monsterbat02@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-09 23:44:58 +01:00
Jun Zhao 91ae6d10ab lavfi/nlmeans: add aarch64 neon for compute_weights_line
Implement NEON optimization for compute_weights_line.

Also update the function signature to use ptrdiff_t for stack arguments
(max_meaningful_diff, startx, endx). This is done to unify the stack
layout between Apple platforms (which pack 32-bit stack arguments tightly)
and the generic AAPCS64 ABI (which requires 8-byte stack slots for 32-bit
arguments). Using ptrdiff_t ensures 8-byte slots are used on all AArch64
platforms, avoiding ABI mismatches with the assembly implementation.

The x86 AVX2 prototype is updated to match the new signature.

Performance benchmark (AArch64) in MacOS M4:
./tests/checkasm/checkasm --test=vf_nlmeans --bench
compute_weights_line_c:     151.1 ( 1.00x)
compute_weights_line_neon:  62.6 ( 2.42x)

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-09 16:10:10 +00:00
Desmond Liu 48c9c38684 fftools/ffmpeg_demux: Fix readrate sleep calculation
Calculation of max_pts and limit_pts may overflow because adding
(int64_t + int64_t + float) results in a float that easily
overflows. This can trigger a very long av_usleep().
2026-01-09 01:28:45 +00:00
Ramiro Polla 272c273d30 Revert "avcodec/jpeglsdec: Check get_bits_left() before decoding a picture"
This check has been made redundant by f80224ed19 and fe7fbf3a22.

This reverts commit 4bc3008d04.
2026-01-08 23:05:28 +00:00
Ramiro Polla 2170f397ea Revert "avcodec/mjpegdec: Check for for the bitstream end in mjpeg_decode_scan_progressive_ac()"
This commit has been made redundant by 909faca929, which is run more
often (once per mb instead of once per line).

This reverts commit 3782656631.
2026-01-08 22:33:01 +00:00
Georgii Zagoruiko 8acdffa22c aarch64/vvc: Optimisations of put_luma_v() functions for 10/12-bit
RPi4 (auto-vectorisation is on)
put_luma_v_10_4x4_c:                                   303.3 ( 1.00x)
put_luma_v_10_4x4_neon:                                 55.7 ( 5.45x)
put_luma_v_10_8x8_c:                                  1106.7 ( 1.00x)
put_luma_v_10_8x8_neon:                                163.8 ( 6.76x)
put_luma_v_10_16x16_c:                                2242.1 ( 1.00x)
put_luma_v_10_16x16_neon:                              672.7 ( 3.33x)
put_luma_v_10_32x32_c:                                7057.3 ( 1.00x)
put_luma_v_10_32x32_neon:                             2731.3 ( 2.58x)
put_luma_v_10_64x64_c:                               25699.8 ( 1.00x)
put_luma_v_10_64x64_neon:                            12145.6 ( 2.12x)
put_luma_v_10_128x128_c:                             90694.6 ( 1.00x)
put_luma_v_10_128x128_neon:                          44862.4 ( 2.02x)
put_luma_v_12_4x4_c:                                   304.4 ( 1.00x)
put_luma_v_12_4x4_neon:                                 55.6 ( 5.47x)
put_luma_v_12_8x8_c:                                  1107.4 ( 1.00x)
put_luma_v_12_8x8_neon:                                164.7 ( 6.72x)
put_luma_v_12_16x16_c:                                2235.8 ( 1.00x)
put_luma_v_12_16x16_neon:                              672.5 ( 3.32x)
put_luma_v_12_32x32_c:                                7049.2 ( 1.00x)
put_luma_v_12_32x32_neon:                             2731.6 ( 2.58x)
put_luma_v_12_64x64_c:                               25706.5 ( 1.00x)
put_luma_v_12_64x64_neon:                            12145.0 ( 2.12x)
put_luma_v_12_128x128_c:                             90672.5 ( 1.00x)
put_luma_v_12_128x128_neon:                          44857.1 ( 2.02x)

Apple M4 (auto-vectorisation is on):
put_luma_v_10_4x4_c:                                    25.6 ( 1.00x)
put_luma_v_10_4x4_neon:                                  3.1 ( 8.18x)
put_luma_v_10_8x8_c:                                    34.7 ( 1.00x)
put_luma_v_10_8x8_neon:                                 10.5 ( 3.32x)
put_luma_v_10_16x16_c:                                 103.9 ( 1.00x)
put_luma_v_10_16x16_neon:                               42.3 ( 2.45x)
put_luma_v_10_32x32_c:                                 399.7 ( 1.00x)
put_luma_v_10_32x32_neon:                              161.8 ( 2.47x)
put_luma_v_10_64x64_c:                                1276.7 ( 1.00x)
put_luma_v_10_64x64_neon:                              840.1 ( 1.52x)
put_luma_v_10_128x128_c:                              4981.3 ( 1.00x)
put_luma_v_10_128x128_neon:                           3008.0 ( 1.66x)
put_luma_v_12_4x4_c:                                    23.6 ( 1.00x)
put_luma_v_12_4x4_neon:                                  2.0 (11.84x)
put_luma_v_12_8x8_c:                                    31.8 ( 1.00x)
put_luma_v_12_8x8_neon:                                 12.4 ( 2.55x)
put_luma_v_12_16x16_c:                                 100.8 ( 1.00x)
put_luma_v_12_16x16_neon:                               44.9 ( 2.25x)
put_luma_v_12_32x32_c:                                 331.1 ( 1.00x)
put_luma_v_12_32x32_neon:                              175.2 ( 1.89x)
put_luma_v_12_64x64_c:                                1227.1 ( 1.00x)
put_luma_v_12_64x64_neon:                              712.7 ( 1.72x)
put_luma_v_12_128x128_c:                              5149.1 ( 1.00x)
put_luma_v_12_128x128_neon:                           2809.3 ( 1.83x)
2026-01-08 17:35:55 +00:00
Ramiro Polla 165448f7d1 avcodec/mjpegdec: remove buggy_avid field from MJpegDecodeContext
This field has been unused since b6c04b6821.
2026-01-08 16:29:32 +00:00
Nicolas Gaullier af6a1dd0b2 avformat/demux: duplicate side_data in parse_packet()
If an input packet results in several output packets, the side data will be
exported only by the first output packet, and be missing from the rest.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-07 20:25:18 -03:00
James Almer 0cca125a94 avformat/demux: prevent the loss of packet side data when using an parser
Many parsers will request data until they find what will be the start of the
next assembled packet in order to decide where to cut the current one. If this
happens, the loop in demux.c will, in case the demuxer exports already fully
assembled packets as is sometimes the case for MPEG-TS, discard the already
handled first input packet before it tries to move its side data to the output.

The affected FATE tests reflect this change by no longer dropping the side data
from the first input packet, nor exporting every other side data in the wrong
output packet.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-07 20:25:18 -03:00
James Almer 70d84bdd84 avformat/demux: use a stream specific temporary packet for the parser
This will be useful for the next commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-07 20:25:17 -03:00
Ruikai Peng f1dbef3e38 avcodec/mjpegdec: avoid negative len in APP parser
The APP parser can read a fixed number of bytes without checking len,
making len negative and passing it to bytestream2_skipu(), which takes
an unsigned size. This can advance the buffer by a huge amount and
results in undefined behavior.

Add small len guards in the fixed-size AVI1/LJIF paths and only skip
the tail if len > 0.

Signed-off-by: Ruikai Peng <ruikai@pwno.io>
2026-01-07 17:33:02 +00:00
Andreas Rheinhardt 1461dfcde7 avcodec/amfdec: Check correct value, return error upon error
Found via an unused-variable warning from GCC.
Also just forward the error from amf_init_frames_context().

This bug has been introduced in
4479d28103.

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Reviewed-by: Mikhail Mironov <mikhail.mironov@amd.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 17:32:06 +01:00
Andreas Rheinhardt d595a18287 fftools/graph/graphprint: Replace always-false check by assert
This check makes no sense, as the pointer arithmetic involved
in &fg->graph_print_buf would be UB if fg were NULL.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 16:36:07 +01:00
Andreas Rheinhardt 9f77cb3a98 fftools/graph/graphprint: Remove always-false checks
init_graphprint() already returns an error upon allocation
failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 16:36:07 +01:00
Andreas Rheinhardt 9baf1b2f82 fftools/textformat/avtextformat: Move avtext_print_integers to ffprobe.c
This is its only user and because this function is so specialised
it is very likely to stay that way. So move it back to ffprobe.c
(where it already was before d7a3f68fea).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 16:36:07 +01:00
Andreas Rheinhardt 60684932fb fftools/textformat/avtextformat: Separate mutable and immutable data
Only two fields of AVTextFormatSection are ever modified:
entries_to_show and show_all_entries (they are only used
by ffprobe; the graph printing code always prints everything).
These fields do not belong into AVTextFormatSection, they are
more ffprobe-internal (and if the graph printing code ever
made use of them, these fields could very well be
per GraphPrintContext).

This commit therefore moves them out of AVTextFormatSection
and adds a callback to AVTextFormatContext to decide which
elements to discard. This also allows to make the AVTextFormatSections
const.

This also fixes a race when initializing the sections
for graphprint.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 16:36:07 +01:00
Vann Harl 41342aea22 configure: bump CONFIG_THIS_YEAR to 2026 2026-01-07 15:07:09 +01:00
Cosmin Stejerean 3474ec01e7 avutil/dovi_meta - fix L11 dovi metadata definition
deprecate the incorrect fields in AVDOVIDmLevel11 and schedule them
for removal
2026-01-07 13:14:11 +00:00
Cosmin Stejerean 56bc8fd0a1 avcodec/dovi_rpu(enc|dec) - fix parsing and writing of L11 DoVi metadata
sharpness, noise_reduction, mpeg_noise_reduction,
frame_rate_conversion, brightness and color are not actual fields in
L11 metadata, this appears to be based on perhaps an out of date
patent specification. Instead the two bytes are considered
reserved.

Drop reading them and write out 0s, the fields will be deprecated from
the struct in a future commit and scheduled for removal.
2026-01-07 13:14:11 +00:00
Leo Izen ec42a0aec0 avcodec/exif: avoid overflow with supplemental extra IFDs
If extra IFDs occur outside of the top level, we don't allocate enough
buffer space for them. This commit changes our calculation to include
their size always, and then we shrink the allocated buffer once every
IFD is written (by at most 192 bytes).

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-01-07 04:01:51 -05:00
cae e21a51b203 .forgejo/CODEOWNERS: Add myself for jpeg2000htdec
Original author

Signed-off-by: cae <etemesicaleb@gmail.com>
2026-01-06 15:32:32 +00:00
Gyan Doshi 03541f0026 avformat/hls: show stream IDs
The subdemuxer may be MPEG-TS which sets stream id, and users may
want to see it for stream selection.
2026-01-06 04:05:47 +00:00
Michael Niedermayer 6c68cbfa92 .forgejo/CODEOWNERS: Add myself for mjpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-06 00:25:25 +00:00
Andreas Rheinhardt 90920a645e avcodec/vc1dec: Reduce size of allocation
blk_mv_type is only set for block 0-3, not for chroma blocks,
so it only needs four elements per MB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-06 00:02:16 +01:00
Nicolas Gaullier 931b26528c avfilter/src_movie: fix support multiple frames per packet
Do not output more than one frame in one activate callback, though.

Fixes #20827.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-01-05 20:41:59 +00:00
stevxiao b9d49a333f forgejo/CODEOWNERS: add myself to d3d12va related files 2026-01-05 10:44:22 -05:00
Timo Rothenpieler b5d6cfd55b avcodec/notchlc: zero-initialize history buffer
Otherwise a specially crafted bitstream can potentially read
uninitialized stack memory.

Fixes #YWH-PGM40646-37
2026-01-05 13:30:38 +00:00
Timo Rothenpieler 7f44dcfbfb avcodec/notchlc: actually use HISTORY_SIZE to initialize history 2026-01-05 13:30:38 +00:00
Ramiro Polla 1debadd58e avcodec/mjpegdec: use GetByteContext instead of GetBitContext where possible
JPEG is mostly byte-aligned. We only really need GetBitContext while
decoding the image data.

Suggested-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-05 13:14:15 +00:00
Ramiro Polla 6f6826d2e0 avcodec/mxpegdec: remove unnecessary scope and indentation 2026-01-05 13:14:15 +00:00
Ramiro Polla fdff03425b avcodec/mjpegdec: fix indentation for previous commit 2026-01-05 13:14:15 +00:00
Ramiro Polla a84627aca9 avcodec/mjpegdec: add mjpeg_parse_len() helper
And check for length field in a consistent manner.
2026-01-05 13:14:15 +00:00
Ramiro Polla abb0247017 avcodec/mjpegdec: improve check for length in ff_mjpeg_decode_dqt() 2026-01-05 13:14:15 +00:00
wangwenchao10 2892815c45 avformat/pcmdec: Mark raw PCM stream as having no timestamps
Signed-off-by: wangwenchao10 <wangwenchao10@xiaomi.com>
2026-01-05 01:23:17 +00:00
Andreas Rheinhardt f4a1243481 doc/APIchanges: Fix typo
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 20:21:25 +01:00
Zhao Zhili 66f7e9db71 avutil/crc: use arm64 crc32 instruction
On rpi5 A76
crc_32_ieee_le_c:                       23146.3 ( 1.00x)
crc_32_ieee_le_crc:                      1060.1 (21.83x)

On RK3566 A55
crc_32_ieee_le_c:                       28773.8 ( 1.00x)
crc_32_ieee_le_crc:                      2602.4 (11.06x)

Co-authored-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 15:49:30 +01:00
Zhao Zhili 0645c48453 avutil/cpu: add CPU feature flag for arm crc32
Co-Authored-by: Martin Storsjö <martin@martin.st>
2026-01-04 15:49:30 +01:00
Martin Storsjö 3dcbcce80c configure: Check for the AArch64 CRC extension
Name the feature "arm_crc" rather than plain "crc", to make it
clear that this is about a CPU feature extension, not CRC
implementations in general.

This requires dealing with the extension slightly differently
than other extensions, as the name of the feature and the
".arch_extension" extension name differ.

Naming it with an "arm" prefix rather than "aarch64", as the
CPU extension also is available in 32 bit ARM form, even though
we don't intend to use it there.
2026-01-04 15:49:30 +01:00
Martin Storsjö 34784c89bf configure: Support aarch64 arch_extension with a different name than the feature
This allows naming the ffmpeg wide feature with a different (more
elaborate) name than the raw cpu extension as it is spelled in
the ".arch_extension" directives.
2026-01-04 15:49:30 +01:00
Martin Storsjö d4e5c08e18 configure: Use a different aarch64 feature in Clang workaround
We use a dummy aarch64 feature to work around an issue in older
Clang, where an .arch line such as ".arch armv8.2-a" doesn't take
effect immediately, while one like ".arch armv8.2-a+feature" works.

Previously, we used "crc" for this dummy feature to add (as an
old feature that would be supported widely by old toolchains).
But as we may want to actually use crc features and detect whether
they are supported, we may want to switch to another feature.

Use the "fp" feature instead, for the purposes of this extra
feature in the .arch lines. (The "fp" feature indicates floating
point support, which is implicitly part of the baseline feature
set anyway.)
2026-01-04 15:49:30 +01:00
Andreas Rheinhardt dc03cffe9c avutil/crc: Use x86 clmul for CRC when available
Observed near 10x speedup on AMD Zen4 7950x:
av_crc_c:                                            22057.0 ( 1.00x)
av_crc_clmul:                                         2202.8 (10.01x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 15:49:30 +01:00
Shreesh Adiga 1b6571c765 avutil/crc: add x86 SSE4.2 clmul SIMD implementation for av_crc
Implemented the algorithm described in the paper titled
"Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction"
by Intel.
It is not used yet; the integration will be added in a separate commit.

Observed near 10x speedup on AMD Zen4 7950x:
av_crc_c:                                            22057.0 ( 1.00x)
av_crc_clmul:                                         2202.8 (10.01x)
2026-01-04 15:49:30 +01:00
Andreas Rheinhardt 0629ebb5ff tests/checkasm: Add CRC test
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 15:49:30 +01:00
Andreas Rheinhardt cf7e2b6773 tests/checkasm: Add support for using opaques to decide whether to test
This is in preparation for adding checkasm support for av_crc(),
which will always call the same function, but uses different CRC
tables to distinguish different implementations.
This reuses checkasm_check_func() for this; one could also add
a new function or use unions. This would allow to avoid casting
const away in the crc test to be added. It would also allow
to avoid converting function pointers to void* (which ISO C
does not allow).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 15:49:30 +01:00
Andreas Rheinhardt 52190efade avutil/crc: Don't assert AVCRCId to be valid
This function is supposed to return NULL on failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 15:49:30 +01:00
Shreesh Adiga e382772e4a avutil/cpu: add x86 CPU feature flag for clmul
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 15:49:30 +01:00
Ayose 120987543a avfilter/tests/drawvg: fix warnings on WIN32
The compiler was emitting a warning on every Cairo function replaced by
the `MOCK_FN_n` macros:

    warning: 'cairo_...': redeclared without dllimport attribute after
    being referenced with dll linkage

The macro `CAIRO_WIN32_STATIC_BUILD` prevents the attribute `dllimport` on
the declarations for these functions.

Signed-off-by: Ayose <ayosec@gmail.com>
2026-01-04 13:42:20 +00:00
Ayose 1333ee5294 doc/drawvg-reference: changes on color syntax.
Colors expressions (like `#RRGGBB`) can now be used as arguments for `setvar`
and `call`.

The trick of setting a variable with a `0xRRGGBBAA` value is not valid anymore.

Signed-off-by: Ayose <ayosec@gmail.com>
2026-01-04 13:42:20 +00:00
Ayose c7a2646bc7 avfilter/vf_drawvg: values from the p() function can be used as colors.
To be able to reuse colors from the original frame, the last value returned by
`p()` is tracked in the eval state, and if it is assigned to a variable, the
original color components are copied to `color_vars`. Thus, commands like
`setcolor` and `colorstop` can use those variables:

    setvar pixel (p(0, 0))
    ...
    setcolor pixel

`fate-filter-drawvg-video` now also verifies the `p()` function.

Signed-off-by: Ayose <ayosec@gmail.com>
2026-01-04 13:42:20 +00:00
Ayose 46c9584dc5 avfilter/vf_drawvg: support color expressions as setvar/call arguments.
The arguments for `setvar` and `call` commands can be colors (like `#rrggbb`).
This replaces the previous trick of using `0xRRGGBBAA` values to use colors as
procedure arguments.

The parser stores colors as the value expected by Cairo (a `double[4]`). This
array is allocated on the heap so the size of the union in `VGSArgument` is
not increased (i.e. it is still 8 bytes, instead of 32).

Signed-off-by: Ayose <ayosec@gmail.com>
2026-01-04 13:42:20 +00:00
Ayose 6300e340d3 avfilter/vf_drawvg: skip conversions when a color is assigned to a variable.
In libcairo, colors are defined as 4 separate components, and each one is double
between 0 and 1. Before this commit, colors stored in variables (like `defhsla`)
were converted to a `0xRRGGBBAA` value, which introduced some issues due to
rounding errors.

Now, when a color is assigned to a variable, the original values (a `double[4]`)
are stored in a dedicated array (`color_vars`), so no conversion is needed.

This change also reduces the cost of reading a color from a variable (no need
for `av_be2ne32`, or the `color[i] / 255` operations).

Signed-off-by: Ayose <ayosec@gmail.com>
2026-01-04 13:42:20 +00:00
Zhao Zhili 840183d823 aarch64/hpeldsp_neon: fix out-of-bounds read
Fix #21141

The performance improved a little bit.
On A76:
                              Before            After
put_pixels_tab[0][1]_neon:    32.4 ( 3.91x)     31.6 ( 3.99x)
put_pixels_tab[0][3]_neon:    88.0 ( 4.50x)     74.6 ( 5.31x)
put_pixels_tab[1][1]_neon:    33.5 ( 2.52x)     31.2 ( 2.71x)
put_pixels_tab[1][3]_neon:    30.5 ( 3.61x)     21.7 ( 5.08x)

On A55:
                             Before            After
put_pixels_tab[0][1]_neon:   175.2 ( 2.41x)    138.7 ( 3.04x)
put_pixels_tab[0][3]_neon:   334.3 ( 2.71x)    296.1 ( 3.07x)
put_pixels_tab[1][1]_neon:   168.3 ( 1.78x)     94.1 ( 3.19x)
put_pixels_tab[1][3]_neon:   112.3 ( 2.20x)     90.0 ( 2.74x)
2026-01-04 03:22:55 +00:00
James Almer 4fad136704 avfilter/vf_stack: add checks for the final canvas dimensions
Prevents potential integer overflows when trying to stitch absurdly huge images together.

Fixes #YWH-PGM40646-38.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-03 21:31:30 -03:00
Andreas Rheinhardt 649a4e98f4 tests/fate/demux: Fix dependencies of jxs-concat-demux test
It uses ffmpeg, not ffprobe.
Fixes https://fate.ffmpeg.org/report.cgi?time=20260102215443&slot=x86_64-archlinux-gcc-disableavfilter

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-03 01:27:53 +01:00
Andreas Rheinhardt 25c7f91256 tests/checkasm: Add report to tests missing them
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-03 00:04:05 +01:00
Andreas Rheinhardt 10b9984e59 tests/fate/checkasm: Run vvc_sao test during FATE
Forgotten in 45bea45c7b.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 19:48:23 +01:00
Andreas Rheinhardt fb72a3d567 avcodec/vc1_block: Simplify vc1_coded_block_pred()
Make it already apply the prediction, avoiding the pointer indirection.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt 0d2ab41ec8 avcodec/h261: Remove H261Context
It only contains a single field, so add this directly to MPVContext
and remove private_ctx. This avoids an indirection in
ff_h261_loop_filter().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt 3946e57797 avcodec/mpegvideo: Move permutated_intra scans to {H263Dec,MPVEnc}Ctx
Only used by these two.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt c9c452688b avcodec/wmv2dec: Avoid indirection
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt 90191e8ab9 avcodec/wmv2: Remove WMV2Context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt f02f948ed0 avcodec/wmv2dsp: Modify IDCTDSPContext directly
This allows to remove ff_wmv2_common_init() altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt 34c9438bbe avcodec/wmv2dsp: Move mspel motion functions out of WMV2DSPContext
They are only used by the decoder (which has them twice, because
the IntraX8Context contains a WMV2DSPContext whose put_mspel_pixels
functions were unused), so move them there.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt 956bfec115 avcodec/wmv2: Move ff_msmpel_motion() to the decoder
mspel is not supported by the encoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt 70b58e770d avcodec/msmpeg4: Mark unreachable code as unreachable
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:22 +01:00
Andreas Rheinhardt 1674ff14e9 avcodec/wmv2dec: Mark unreachable code as unreachable
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt 224473b676 avcodec/wmv2dec: Don't put skip_type in context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt 11b32b780f avcodec/msmpeg4: Avoid branch
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt 4f4cbed928 avcodec/msmpeg4: Initialize WMV2 generically
WMV1 and WMV2 use other scantables and therefore
ff_msmpeg4_common_init() reinitializes them. Yet WMV2
also uses a different IDCT overwriting the ordinary one,
so that the IDCT permutation changes and therefore
ff_wmv2_common_init() (called after ff_msmpeg4_common_init())
needs to reinitialize the scantables again.

Avoid this by calling ff_wmv2_common_init() in
ff_msmpeg4_common_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt 15e1e61888 avcodec/wmv2: Don't initialize BlockDSPContext redundantly
ff_mpv_common_init() already does it for us.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt 0e4a333683 tests/fate/checkasm: Run vf_idet tests during FATE
Forgotten in 00e05bcd68.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 16:58:55 +00:00
Timo Rothenpieler e6184bce67 forgejo/workflows: explicitly name all workflows and jobs 2026-01-02 16:56:03 +00:00
Zhao Zhili 85b5927083 avfilter/vf_libopencv: fix null pointer dereference
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-02 23:46:42 +08:00
Zhao Zhili 35eebc5045 avfilter/vf_libopencv: use av_unreachable
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-02 23:46:19 +08:00
Zhao Zhili 4d46eeed02 avfilter/vf_libopencv: fix memleak
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-02 23:45:52 +08:00
Ramiro Polla ee5d6e7ee1 avcodec/jpeglsdec: propagate error from ff_jpegls_decode_picture()
Fixes fe7fbf3a22
2026-01-01 23:57:08 +00:00
Marton Balint 8579037b6c avformat/file: respect pkt_size even in streaming mode
Also clarify the documentation a bit.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-01 18:20:58 +00:00
Russell Greene 38e89fe502 hwcontext_vulkan: add support for implict DRM sync for export
When a frame is exported to DRM, it may be written to to read to in an asyncronous fashion. Make sure, on unmap of a Vulkan frame that was mapped to DRM, to import any fences that were put on the dmabuf
2025-12-31 15:53:20 +00:00
Timo Rothenpieler f6a95c7eb7 avformat/img2dec: reject input images too big to fit into a single packet
Not entirely sure if it should instead use some entirely different
approach here, given that images exceeding 2GB don't seem that crazy
to me, but so far processing such images results in a heap overflow,
since the size addition overflows and a much too small packet is
allocated and its size never checked again when writing into it.

Fixes #YWH-PGM40646-32
2025-12-31 14:37:58 +00:00
Lynne 58bd5ad630 vulkan/prores_raw_idct: use the same prores_idct method for loading coeffs
This saves 2 barriers.
Also implement workbank avoidance.
2025-12-31 15:00:47 +01:00
Lynne 7f2783dcef vulkan_prores_raw: avoid long lines
Just some tidying up.
2025-12-31 15:00:47 +01:00
Lynne c3530d9a70 vulkan: remove FFVkBuffer.stage and access
Keeping global state for every buffer is unncessary and possibly
suboptimal.
2025-12-31 15:00:47 +01:00
Lynne c3e117670d vulkan_prores: use ff_vk_buf_barrier() 2025-12-31 15:00:47 +01:00
Lynne f956e9817c ffv1enc_vulkan: use ff_vk_buf_barrier() 2025-12-31 15:00:46 +01:00
Lynne 9ab3e962b4 nlmeans_vulkan: use ff_vk_buf_barrier() 2025-12-31 15:00:46 +01:00
Lynne eeeae0e0af vulkan_ffv1: use ff_vk_buf_barrier() 2025-12-31 15:00:46 +01:00
Lynne 95baff9b61 vulkan: add ff_vk_buf_barrier()
This is a shorthand way of writing buffer barrier structures.
2025-12-31 15:00:46 +01:00
Lynne b7d2469e4c vulkan_functions: add vkCmdDispatchBase
Its useful for multi-stage operations.
2025-12-31 15:00:46 +01:00
Lynne 9f3a04d2f6 vulkan: use HOST_CACHED memory flag only if such a heap exists
NVK does not offer such, so our code failed to allocate memory.
2025-12-31 15:00:46 +01:00
Lynne bb30126349 hwcontext_vulkan: enable the explicit shader workgroup extension
Its useful as it allows us to alias memory in shaders.
2025-12-31 15:00:45 +01:00
Lynne d70c6cb511 hwcontext_vulkan: enable subgroup extended types
We were already using them, but had forgotten to enable them.
2025-12-31 15:00:12 +01:00
Kacper Michajłow eea648ef1d avutil/hwcontext_vulkan: fix logic error when checking for encode support
Both FF_VK_EXT_VIDEO_ENCODE_QUEUE and FF_VK_EXT_VIDEO_MAINTENANCE_1 are
required, not only one of them.

Found by VVL.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-31 10:30:36 +00:00
Kacper Michajłow 20ac8c3688 avfilter/vulkan_filter: fix logic error when checking for encode support
Both FF_VK_EXT_VIDEO_ENCODE_QUEUE and FF_VK_EXT_VIDEO_MAINTENANCE_1 are
required, not only one of them.

Found by VVL.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-31 10:30:36 +00:00
Kacper Michajłow 0a8b915b04 avcodec/vulkan_decode: fix logic error when checking for encode support
Both FF_VK_EXT_VIDEO_ENCODE_QUEUE and FF_VK_EXT_VIDEO_MAINTENANCE_1 are
required, not only one of them.

Found by VVL.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-31 10:30:36 +00:00
hajin-chung 991ba3fbac avcodec/qsvdec: fix refcount leak in two-stage QSV init
The temporary hw_frames_ctx created for header parsing was not being
fully released, leading to a leak. Explicitly unreference the temporary
context after use to resolve the leak.

Signed-off-by: hajin-chung <hajinchung1@gmail.com>
2025-12-31 08:06:48 +00:00
Leo Izen 4bfac71ecd avcodec/exif.c: avoid buffer overflow with extra IFDs
Maliciously constructed input EXIF blocks could use the extra IFDs we
set aside in noncontinugous ways, which will cause them to be written
as subdirectories of IFD0 rather than existing IFDs. The base tag size
is (correctly) excluded from the size calculation, but if they are
being written as additional tags, the allocation will be too small and
a write may overflow.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-30 20:43:49 -05:00
James Almer d7ee7ac20f avutil/iamf: remove default value from demixing_matrix_def
It's not required sice the previous commit, and fixes memleaks introduced by
a6e5fa3fbb.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-30 20:15:32 -03:00
James Almer c6e7243f11 avutil/opt: fix av_opt_is_set_to_default() for array options with no default value
If AVOptionArrayDef.def is NULL, av_opt_is_set_to_default() should return true
when the field in the object is NULL.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-30 20:14:56 -03:00
Benjamin Cheng 2298978b47 hwcontext_vulkan: Remove unnecessary validation filters
With the latest changes, I can no longer get these to show up.
2025-12-30 14:39:19 -05:00
Benjamin Cheng 531e184944 lavc/vulkan_video: Drop sampler
With the limiting of video usages on the image views, we no longer need
a yuv sampler, since no multi-plane image will be created with the
SAMPLED usage bit.
2025-12-30 14:39:08 -05:00
Benjamin Cheng b8de254e8c lavc/vulkan_video: Restrict usages for image views
These image views are used only internally for video coding, so they do
not need all the usages of the image it's created from.
2025-12-30 14:38:37 -05:00
Benjamin Cheng 24db09a881 lavc/vulkan_video: Restrict usages for image views
These image views are used only internally for video coding, so they do
not need all the usages of the image it's created from.
2025-12-30 14:15:46 -05:00
Benjamin Cheng e41e21a1ec avutil/hwcontext_vulkan: Limit usages for lone DPBs
Lone DPBs will only be requested when the implementation requires
a separate DPB. These images are never given out, and are never used for
anything other than a DPB. Also most implementations requiring these
won't support any other usages on DPBs, so limiting the usages would fix
some validation errors.
2025-12-30 14:15:43 -05:00
Ramiro Polla aa80a7880b avcodec/jpegls: rename SOF48 to SOF55
SOF48 (0xf0) was used in a public draft of the standard (FCD 14495).
In the final specification it is called SOF55 (0xf7).
2025-12-30 17:30:45 +00:00
Frank Plowman 72a38c12e5 lavc/vvc: Prevent OOB write to slice_top_left_ctu_x in PPS CBS
Prior to the fix, in the case of a tile containing multiple slices
(pps_num_exp_slices_in_tile != 0) the number of slices was temporarily
allowed to exceed pps_num_slices_in_pic_minus1+1 and therefore
VVC_MAX_SLICES.  The number of slices was later verified, but while the
current slice index was higher than expected it was used to write to a
array of size VVC_MAX_SLICES, leading to an OOB write.

To rectify this, the patch adds some checks at an earlier stage, to
ensure that the slice index i + j at no point exceeds
pps_num_slices_in_pic_minus1.

Fixes #YWH-PGM40646-30
2025-12-30 13:39:40 +00:00
Zhao Zhili ee2eb6ced8 fftools/ffmpeg_filter: fix access private API of libavcodec
Firstly, mathops.h is a private header of libavcodec and should not be used
in fftools. It may reference libavcodec internal symbols, causing link
error with dynamic library, e.g.,

fftools/ffmpeg_filter.c:2687: undefined reference to `ff_rv_zbb_supported'

Secondly, mid_pred operates on int types, while current use case is
int64_t.
2025-12-30 07:40:15 +00:00
caifan3 82144fea48 libavformat/file: apply pkt_size option to read mode
Previously, the pkt_size option only affected write buffering in the file
protocol. This change extends its effect to read mode as well.

On embedded systems with limited RAM, users can now reduce I/O buffer
memory by setting a smaller pkt_size.

Signed-off-by: caifan3 <caifan3@xiaomi.com>
2025-12-30 00:49:13 +00:00
Ramiro Polla 7dda7f3b99 avcodec/mjpegdec: speed up find_marker()
Minimize number of reads and simplify conditionals.

Also use memchr(), as suggested by Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-29 21:44:07 +00:00
Ramiro Polla 254124f869 avcodec/mjpegdec: fix some error return codes 2025-12-29 17:22:34 +01:00
James Almer 6223b7fa0b tests/fate/iamf: add tests for Projection mode ambisonic Audio Elements
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:02:53 -03:00
James Almer 9c5a37388b fftools/ffprobe: print demixing_matrix in Projection mode ambisonic IAMF Audio Element groups
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:02:40 -03:00
James Almer 129744ac72 avformat/iamf_writer: reindent after the previous change
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:02:10 -03:00
James Almer 8cd4d4cb0b avformat/iamf_writer: add support for Projection mode ambisonic Audio elements
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:02:02 -03:00
James Almer a0fc454871 avformat/iamf_writer: check that stream count is consistent for ambisonic Audio Elements
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:00:01 -03:00
James Almer 21ff60d2cf avformat/iamf_writer: fix writting some ambisonics fields in Audio Elements
The fields are defined as 8 bit long unsigned ints. Fortunately, writing most sane values
as leb is equivalent, which is why no tests are affected.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:00:01 -03:00
James Almer e3498c8051 avformat/iamf_parse: set AVIAMFLayer.nb_demixing_matrix
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:00:01 -03:00
James Almer 03a981445e avformat/iamf_parse: fix setting denominator in AVIAMFLayer.demixing_matrix
The format of demixing_matrix is Q15 fixed point values.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:00:01 -03:00
James Almer a6e5fa3fbb avutil/iamf: add an AVOption for AVIAMFLayer.demixing_matrix
Plus a length field, to fulfill the requirements of AV_OPT_TYPE_FLAG_ARRAY options.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 11:59:36 -03:00
tangsha d28250eada avcodec/adpcm: Fix step_index decoding by skipping padding byte
The bug was caused by incorrect reading of the step_index field: the original
code read a 16-bit value (including a padding byte) instead of the correct
8-bit step_index as defined by the ADPCM format. This led to distorted audio
or incorrect step calculations when decoding specific ADPCM-encoded files.

Fix by:
1. Reading step_index as an 8-bit unsigned byte via bytestream2_get_byteu()
2. Skipping the subsequent 8-bit padding byte with bytestream2_skip()
2025-12-29 14:18:35 +00:00
Michael Niedermayer ecd2919174 avcodec/mjpegdec: only test the size bound in sequential mjpeg
The original fix was intended only for sequential mjpeg, but it was also used for progressive
which broke. This commit fixes this regression

Fixes: issue21225

The testcase 6381/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-5665032743419904 still exits within 240ms

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-29 13:57:33 +00:00
Martin Storsjö 78bfcf003b libavformat: Fix the docs for av_mime_codec_str and ff_make_codec_str
The doxygen comments were missed as these functions were updated
during review; they don't take separate pointer/length parameters
but use an AVBPrint struct now instead.

Also clarify that ff_make_codec_str doesn't log if the logctx
parameter is NULL.
2025-12-29 12:05:14 +00:00
Michael Niedermayer 9ab2a437a1 .forgejo/CODEOWNERS: maintain tools/target_dec_fuzzer.c
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-28 21:58:02 +00:00
James Almer fc5f45bd42 avcodec/libdav1d: only consider colorspace when choosing between YUV and GBR
Several files use values for primaries and transfer characteristics other than
BT709 and IEC_61966 respectively, while still being GBR.
Also always set color_range while at it. It's always coded in the bistream.

Fixes part of #21304.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-28 15:32:57 -03:00
James Almer a8f1c2366e avcodec/libaomdec: don't overwrite color information from the container if unset in the bitstream
Fixes part of #21304.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-28 15:31:13 -03:00
James Almer afeff1c729 avcodec/interplayacm: add a flush callback function
Should prevent potential buffer overflows if passing new packets after seeking.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-28 12:55:59 -03:00
Michael Niedermayer 224b3ff82a avcodec/jpeg2000htdec: Check pLSB
Fixes: negative shift and other undefined shifts
Fixes: 462335934/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_DEC_fuzzer-4538493775970304

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-27 21:42:20 +00:00
nikitalita 0629780cf6 avfilter/vf_libplacebo: replace preproc directive in function-like macros
MSVC build was failing due to preprocessor directives being used within function-like macro argument lists, which is undefined behavior according to the C11 spec. Fixed by replacing the directive blocks with macro definitions outside of the macro invocations.
2025-12-27 18:13:13 +00:00
James Almer f8e6f8f0a2 avformat/iamf_parse: check layer channel count and stream count for consistency
A layer could define a loudspeaker_layout that corresponds to a certain channel layout,
but then report an amount of substream_count and coupled_substream_count that might not
match the expected channel count.

Fixes: Invalid write of size 4
Fixes: clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6687125346254848

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-27 15:16:49 +00:00
Frank Plowman 90f1f797aa lavc/vvc: Error on inter slice with no reference pics
The semantics of sh_num_ref_idx_active_minus1[ i ] state that

When the current slice is a P slice, the value of NumRefIdxActive[ 0 ] shall be greater than 0.
When the current slice is a B slice, both NumRefIdxActive[ 0 ] and NumRefIdxActive[ 1 ] shall be greater than 0.

Fixes: use of uninitialized memory
Fixes: 449549597/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-5600497089445888

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reported-by: Michael Niedermayer michael@niedermayer.cc
2025-12-27 15:14:16 +00:00
Ramiro Polla 0dfaed77a6 swscale/tests/sws_ops: add optional -src and -dst parameters 2025-12-26 13:14:28 +00:00
Niklas Haas abb1524138 Revert "swscale/ops: clarify SwsOpList.src/dst semantics"
This reverts commit c94e8afe5d.

These are now actually purely informational.
2025-12-24 16:37:22 +00:00
Niklas Haas c0f49db53d swscale/ops: remove broken value range assumption hack
This information is now pre-filled automatically for SWS_OP_READ when
relevant.

yuv444p10msbbe -> rgb24:
   [u16 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) planar >> 0
   [u16 ...X -> +++X] SWS_OP_SWAP_BYTES
   [u16 ...X -> +++X] SWS_OP_RSHIFT       : >> 6
   [u16 ...X -> +++X] SWS_OP_CONVERT      : u16 -> f32
   [f32 ...X -> ...X] SWS_OP_LINEAR       : matrix3+off3 [...]
   [f32 ...X -> ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
   [f32 ...X -> ...X] SWS_OP_MAX          : {0 0 0 0} <= x
+  [f32 ...X -> ...X] SWS_OP_MIN          : x <= {255 255 255 _}
   [f32 ...X -> +++X] SWS_OP_CONVERT      : f32 -> u8
   [ u8 ...X -> +++X] SWS_OP_WRITE        : 3 elem(s) packed >> 0
    (X = unused, + = exact, 0 = zero)

(This clamp is needed and was incorrectly optimized away before, because the
`SWS_OP_RSHIFT` incorrectly distorted the value range assertion)
2025-12-24 16:37:22 +00:00
Niklas Haas ede8318e9f swscale/ops: explicitly reset value range after SWS_OP_UNPACK
The current logic implicitly pulled the new value range out of SwsComps using
ff_sws_apply_op_q(), but this was quite ill-formed and not very robust. In
particular, it only worked because of the implicit assumption that the value
range was always set to 0b1111...111.

This actually poses a serious problem for 32-bit packed formats, whose
value range actually does not fit into AVRational. In the past, it only
worked because the value would implicitly overflow to -1, which SWS_OP_UNPACK
would then correctly extract the bits out from again.

In general, it's cleaner (and sufficient) to just explicitly reset the value
range on SWS_OP_UNPACK again.
2025-12-24 16:37:22 +00:00
Niklas Haas a0032fb40f swscale/ops: use switch/case for updating SwsComps ranges
A bit more readable and makes it clear what the special cases are.
2025-12-24 16:37:22 +00:00
Niklas Haas 5f1be98f62 swscale/ops: add SWS_COMP_SWAPPED
This flag keeps track of whether a pixel is currently byte-swapped or
not. Not needed by current backends, but informative and useful for
catching potential endianness errors.

Updates a lot of FATE tests with a cosmetic diff like this:

 rgb24 -> gray16be:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> f32
   [f32 ...X -> .++X] SWS_OP_LINEAR       : dot3 [...]
   [f32 .XXX -> +++X] SWS_OP_CONVERT      : f32 -> u16
-  [u16 .XXX -> +++X] SWS_OP_SWAP_BYTES
-  [u16 .XXX -> +++X] SWS_OP_WRITE        : 1 elem(s) planar >> 0
-    (X = unused, + = exact, 0 = zero)
+  [u16 .XXX -> zzzX] SWS_OP_SWAP_BYTES
+  [u16 .XXX -> zzzX] SWS_OP_WRITE        : 1 elem(s) planar >> 0
+    (X = unused, z = byteswapped, + = exact, 0 = zero)

(The choice of `z` to represent swapped integers is arbitrary, but I think
it's visually evocative and distinct from the other symbols)
2025-12-24 16:37:22 +00:00
Niklas Haas 5a6602e959 swscale/format: add pixel range metadata to SWS_OP_READ 2025-12-24 16:37:22 +00:00
Niklas Haas 9586b81373 swscale/ops: don't strip SwsComps from SWS_OP_READ
The current behavior of assuming the value range implicitly on SWS_OP_READ
has a number of serious drawbacks and shortcomings:

- It ignored the effects of SWS_OP_RSHIFT, such as for p010 and related
  MSB-aligned formats. (This is actually a bug)

- It adds a needless dependency on the "purely informative" src/dst fields
  inside SwsOpList.

- It is difficult to reason about when acted upon by SWS_OP_SWAP_BYTES, and
  the existing hack of simply ignoring SWAP_BYTES on the value range is not
  a very good solution here.

Instead, we need a more principled way for the op list generating code
to communicate extra metadata about the operations read to the optimizer.

I think the simplest way of doing this is to allow the SwsComps field attached
to SWS_OP_READ to carry additional, user-provided information about the values
read.

This requires changing ff_sws_op_list_update_comps() slightly to not completely
overwrite SwsComps on SWS_OP_READ, but instead merge the implicit information
with the explictly provided one.
2025-12-24 16:37:22 +00:00
Niklas Haas 61eca588dc swscale/ops: move ff_sws_op_list_update_comps() to ops.c
I think this is ultimately a better home, since the semantics of this are
not really tied to optimization itself; and because I want to make it an
explicitly suported part of the user-facing API (rather than just an
internal-use field).

The secondary motivating reason here is that I intend to use internal
helpers of `ops.c` inside the next commit. (Though this is a weak reason
on its own, and not sufficient to justify this move by itself.)
2025-12-24 16:37:22 +00:00
James Almer fe1dae1e18 avcodec/lcevcdec: free pictures on error
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:23:37 -03:00
James Almer 4f86ebfe94 avcodec/lcevcdec: fix input dimensions for the base picture
Fixes crashes with some samples.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:23:37 -03:00
James Almer b392d75cf7 avcodec/lcevcdec: avoid copying the input frame
Based on the lcevc filter implementation.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:23:37 -03:00
James Almer 3e91d82292 avcodec/cbs_apv: use av_unreachable instead of av_assert0(0) at the end of a non-void function
Fixes compilation with gcc-tsan and --disable-optimizations

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:21:39 -03:00
James Almer 64be23153e fftools/ffmpeg_sched: use av_unreachable instead of av_assert0(0) at the end of a non-void function
Fixes compilation with gcc-tsan and --disable-optimizations

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:21:39 -03:00
James Almer 2678482c10 fftools/ffmpeg_enc: use av_unreachable instead of av_assert0(0) at the end of a non-void function
Fixes compilation with gcc-tsan and --disable-optimizations

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:21:39 -03:00
Michael Niedermayer 9e974b2c45 avformat/hls: fix double space
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 14:14:45 +01:00
Michael Niedermayer 548b28d5b1 avformat/hls: Fix arguments of handle_rendition_args()
Fixes: call to function handle_rendition_args through pointer to incorrect function type 'void (*)(void *, const char *, int, char **, int *)'
Fixes: 464965411/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-4790164406992896

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 12:04:07 +00:00
Michael Niedermayer d1985442e1 avformat/hls: Check seg size and offset for overflow
Fixes: integer overflow
Fixes: signed integer overflow: 9223372036854775807 + 2039324394 cannot be represented in type 'int64_t' (aka 'long')

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 12:04:07 +00:00
Michael Niedermayer 8ac6325143 avcodec/adpcm: check block_align for PSXC
Fixes: division by 0
Fixes: 457634826/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_PSXC_DEC_fuzzer-4903668521697280

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 02:51:20 +00:00
Jack Lau 13c91c97d1 avcodec/libjxldec: goto SUCCESS when frame is completed
Fix #21260

The early code didn't reset the JxlDecoder. If the
caller re-send the same packet to JxlDecoder after
avcodec_flush_buffers() (free ctx->frame). It will
directly hit SUCCESS event (skip all EVENTs).

In this case, the ctx->frame already flushed by
avcodec_flush_buffers, so the received frame
will be invalid (has no private_ref) that causes
assertion in decode_receive_frame_internal().

MPV meet this issue because it seek the jxl image
(second read the same pkt) when it does crop
through config `C vf toggle crop=in_w:in_w/2.4`.

This patch make sure hit the entire SUCCESS event
(contains reset the JxlDecoder) when frame_complete
is true.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2025-12-24 02:43:50 +00:00
Michael Niedermayer d60c1d72c1 avcodec/jpeg2000dec: Make M_b check broader
Fixes: shift exponent -1 is negative
Fixes: 429330004/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_DEC_fuzzer-4733213845291008

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-23 20:11:29 +00:00
Lynne e5eef271a5 vulkan: set .decode_extension to 0 for compute-based decoders
They require no special video decode extension. The push descriptor
extension was a placeholder for when the check was performed inside
the init function.
2025-12-23 15:42:24 +01:00
Damitha Gunawardena bb769d9d90 avcodec/gifenc: avoid redundant local color table when global palette is used
Addressing the fact that first frame has a LCT when global pallette is used for pal8.
issue: #20896
2025-12-23 14:34:13 +00:00
Andreas Rheinhardt 26a7fc2ac4 avfilter/vf_waveform: Avoid relocations
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-23 11:02:04 +01:00
Andreas Rheinhardt 6460d3bc81 avfilter/vf_waveform: don't cast const away
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-23 11:01:42 +01:00
Michael Niedermayer d41b8d95a7 swscale/output: Use 64bit in addition in yuv2gbrp16_full_X_c() for RGB + Y
Fixes: signed integer overflow: -1159988356 + -1082982400 cannot be represented in type 'int'
Fixes: 461519938/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-4777382021234688

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-23 09:14:44 +00:00
Zhao Zhili 09d8300779 avutil/imgutils: use AV_CEIL_RSHIFT 2025-12-23 03:39:16 +00:00
Zhao Zhili 260f5a47a5 avformat/rawvideodec: add stride option to skip line padding
Some tools like v4l2-ctl dump data without skip padding. If the
padding size is not an integer multiple of the number of pixel
bytes, we cannot handle it by using a larger width, e.g.,, for
RGB24 image with 32 bytes padding in each line.
2025-12-23 03:20:34 +00:00
Zhao Zhili 49a15e70be avformat/rawvideodec: use AV_OPT_TYPE_PIXEL_FMT instead of parse from string manually 2025-12-23 03:20:34 +00:00
Romain Beauxis 5ae21f06a3 tests/fate/id3v2.mak: Use run wrapper in fate-id3v2-invalid-tags 2025-12-22 22:34:48 +00:00
Niklas Haas fafd72ef04 swscale/ops_internal: fix ff_sws_pack_op_decode()
This function was assuming that the bits are MSB-aligned, but they are
LSB-aligned in both practice (and in the actual backend).

Also update the documentation of SwsPackOp to make this clearer.

Fixes an incorrect omission of a clamp after decoding e.g. rgb4, since
the max value range was incorrectly determined as 0 as a result of unpacking
the MSB bits instead of the LSB bits:

 bgr4 -> gray:
   [ u8 XXXX -> +XXX] SWS_OP_READ         : 1 elem(s) packed >> 1
   [ u8 .XXX -> +++X] SWS_OP_UNPACK       : {1 2 1 0}
   [ u8 ...X -> +++X] SWS_OP_SWIZZLE      : 2103
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> f32
   [f32 ...X -> .++X] SWS_OP_LINEAR       : dot3 [...]
   [f32 .XXX -> .++X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
+  [f32 .XXX -> .++X] SWS_OP_MIN          : x <= {255 _ _ _}
   [f32 .XXX -> +++X] SWS_OP_CONVERT      : f32 -> u8
   [ u8 .XXX -> +++X] SWS_OP_WRITE        : 1 elem(s) planar >> 0
     (X = unused, + = exact, 0 = zero)
2025-12-22 20:14:31 +00:00
Lynne 6656b11a7b hwcontext_vulkan: disable host transfers on MoltenVK
https://github.com/KhronosGroup/MoltenVK/issues/2618
2025-12-22 19:46:27 +01:00
Lynne d33bf66519 vulkan_functions: add vkCmdUpdateBuffer
It embeds the data to be uploaded directly into the command buffer,
which makes it useful for uploading transient data.
2025-12-22 19:46:27 +01:00
Lynne 8db6947700 vulkan_prores_raw: reduce zigzag table size
No need for full 32-bits.
2025-12-22 19:46:27 +01:00
Lynne cfcf52a08c vulkan: deduplicate shorthand casting defines to common.comp 2025-12-22 19:46:27 +01:00
Lynne 6eced88188 vulkan: merge ProRes and ProRes RAW iDCTs
This cleans up the code a bit, and reduces binary size.
2025-12-22 19:46:26 +01:00
Lynne ea14f8a28f vulkan_prores: split up shader creation functions
Its more mess that it has to be.
2025-12-22 19:46:26 +01:00
Rémi Denis-Courmont eb3b632b48 lavc/h264qpel: fix RISC-V stack usage
The function violated the ABI requirement not to write below SP
(this breaks asynchronous signal handling). On RV32, it also broke
did not align SP to 16 bytes and did not restore it correctly.

No changes to benchmarks as this patch only changes a few immediate
offsets.
2025-12-22 18:55:20 +02:00
Rémi Denis-Courmont 65018b3e83 lavu/float_dsp: fix R-V V scalarpdocut_double with ILP32 ABI 2025-12-22 18:55:16 +02:00
Rémi Denis-Courmont 435623cbda lavu/float_dsp: fix R-V V vector_dmul_scalar with ILP32 ABI 2025-12-22 18:55:16 +02:00
Rémi Denis-Courmont 56d933b0a7 lavu/float_dsp: fix R-V V vector_dmac_scalar with ILP32 ABI 2025-12-22 18:55:16 +02:00
Rémi Denis-Courmont a583639bf0 lavu/fixed_dsp: fix scalarproduct on riscv32
On riscv32, the result must be narrowed from 63 to 32 bit before being
moved to the scalar side.
2025-12-22 18:55:13 +02:00
Araz Iusubov 4479d28103 avcodec/avfilter_amf: correct handling of AMF errors
Fix several AMF-related issues.

Check the return value of amf_init_frames_context() correctly in amfdec,
as it returns int rather than AMF_RESULT.

Handle possible NULL surfaces returned from QueryInterface() in
vf_amf_common to avoid passing invalid data to amf_amfsurface_to_avframe().

Remove FILTER_SINGLE_PIXFMT from vf_sr_amf since it must not be used
together with a query formats function.
2025-12-22 14:58:59 +00:00
Romain Beauxis b43645b2ef libavformat/id3v2.c: return valid string in decode_str for empty strings
with no bom. Fixes: #YWH-PGM40646-12
2025-12-22 13:44:42 +00:00
Kacper Michajłow c50e5c7778 avcodec/libaomenc: remove enum type from codecctl_* functions
aom_codec_control() takes control id as int. It could be AV1E_ or common
AV1_ enum in encoder, and AV1D_ for decoder.

While upstream provides AOM_CODEC_CONTROL_TYPECHECKED() macro to check
the provided enum value, we wrap those calls in codecctl_ functions,
which makes it not feasible to use.

To avoid complicating this needlessly, just use int.

Fixes: warning: implicit conversion from enumeration type 'enum aom_com_control_id' to different enumeration type 'enum aome_enc_control_id'
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-22 07:05:58 +01:00
Kacper Michajłow 96afe665ef avcodec/libaomenc: remove UENUM1BYTE check
AOM had a short-lived API breakage introduced in commit [1], which was
workedaround in commit [2]. The original change, however, was reverted
shortly afterward in commit [3]. Since we require at least v2.0.0, there
is no need to keep this workaround.

[1] https://aomedia.googlesource.com/aom/+/4667aa1a373566e9c124afcd58c71731ab0d7377
[2] aaf9171574
[3] https://aomedia.googlesource.com/aom/+/9b1252eab0616d2c1f6d7990c6256441c0b6483f

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-22 07:05:58 +01:00
stevxiao 64b9be2dc5 avcodec/d3d12va_encode: support motion estimation precision mode
By default, the D3D12 video encoder uses MAXIMUM, which means no restriction—it uses the highest precision supported by the driver.

Applications may want to reduce precision to improve speed or reduce power consumption. This requires the encoder to support user-defined motion estimation precision modes.

D3D12_VIDEO_ENCODER_MOTION_ESTIMATION_PRECISION_MODE defines several precision modes:

maximum: No restriction, uses the maximum precision supported by the driver.
full_pixel: Allows only full-pixel precision.
half_pixel: Allows half-pixel precision.
quarter-pixel: Allows quarter-pixel precision.
eighth-pixel: Allows eighth-pixel precision (introduced in Windows 11).

Sample Command Line:

ffmpeg -hwaccel d3d12va -hwaccel_output_format d3d12 -extra_hw_frames 20 -i input.mp4 -an -c:v h264_d3d12va -me_precision half_pixel out.mp4
2025-12-22 05:35:04 +00:00
Gyan Doshi 1fcb201ab1 configure: update dependencies
These muxers - hls, tee, whip - open other muxers.
In addition, whip requires http protocol.
2025-12-21 04:16:10 +00:00
Leo Izen 784aa09fa8 avcodec/exif: parse additional EXIF IFDs
Most EXIF metadata is in IFD0 and most EXIF payloads only contain
one IFD, but it is possible for there to be more IFDs after the
existing trailing one. exiftool and similar software report these IFDs
as IFD1, IFD2, etc. This commit reads those additional IFDs and attaches
them as dummy entries in the top-level IFD ranging from 0xFFFC down to
0xFFED, which are unused by the EXIF spec. The EXIF API is only able to
return and work with a single IFD, so by attaching it as a subdirectory
this metadata can be preserved.

This is done transparently through the read/write process. Upon parsing
an additional IFD1, it will be attached, but it will be written with
av_exif_write after IFD0 rather than as a subdirectory, as intended.

Existing files without more than one IFD, i.e. most files, will be unaffected
by this change, as well as API clients looking to parse specific fields, but
now more metadata is parsed and written, rather than simply being discarded
as trailing data.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-20 11:53:23 -05:00
Leo Izen 105b6fcd9c avcodec/exif: avoid leaking EXIF metadata upon parse failure
Before this commit, exif_parse_ifd_list didn't free *ifd upon failure,
relying on the caller to do so instead. We only guarded some of the
calls against this function, not all of them, so sometimes it leaked.

This commit fixes this, so exif_parse_ifd_list freeds *ifd upon failure
so callers do not have to guard its invocation with a free wrapper.

Fixes: ossfuzz 440747118: Integer-overflow in av_strerror

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-20 11:53:21 -05:00
Niklas Haas 7505264b6a swscale/ops: update comment on SWS_COMP_EXACT
That the integer is "in-range" is implied by the min/max range tracking,
not the flag itself.
2025-12-20 13:52:45 +00:00
Niklas Haas 1d0fd7fabf swscale/ops: categorize ops by type compatibility
This is a more useful grouping than the previous, somewhat arbitrary one.
2025-12-20 13:52:45 +00:00
Niklas Haas 94777ed2eb swscale/ops_chain: fix comment 2025-12-20 13:52:45 +00:00
Niklas Haas 75ba2bf457 swscale/ops: correctly truncate on ff_sws_apply_op_q(SWS_OP_RSHIFT)
Instead of using a "precise" division, simulate the actual truncation.

Note that the division by `den` is unneeded in principle because the
denominator *should* always be 1 for an integer, but this way we don't
explode if the user should happen to pass `4/2` or something.

Fixes a lot of unnecessary clamps w.r.t. xv36, e.g.:

 xv36be -> yuv444p12be:
   [u16 XXXX -> ++++] SWS_OP_READ         : 4 elem(s) packed >> 0
   [u16 ...X -> ++++] SWS_OP_SWAP_BYTES
   [u16 ...X -> ++++] SWS_OP_SWIZZLE      : 1023
   [u16 ...X -> ++++] SWS_OP_RSHIFT       : >> 4
-  [u16 ...X -> ++++] SWS_OP_CONVERT      : u16 -> f32
-  [f32 ...X -> ++++] SWS_OP_MIN          : x <= {4095 4095 4095 _}
-  [f32 ...X -> ++++] SWS_OP_CONVERT      : f32 -> u16
   [u16 ...X -> ++++] SWS_OP_SWAP_BYTES
   [u16 ...X -> ++++] SWS_OP_WRITE        : 3 elem(s) planar >> 0
     (X = unused, + = exact, 0 = zero)
2025-12-20 13:52:45 +00:00
Niklas Haas d1eaea1a03 swscale/ops: add type assertions to ff_sws_apply_op_q() 2025-12-20 13:52:45 +00:00
Niklas Haas 258dbfdbc9 swscale/format: only generate SHIFT ops when needed
Otherwise, we may spuriously generate illegal combinations like
SWS_OP_LSHIFT on SWS_PIXEL_F32.
2025-12-20 13:52:45 +00:00
Niklas Haas c31f3926d1 swscale/ops_optimizer: simplify loop slightly (cosmetic)
We always `goto retry` whenever an optimization case is hit, so we don't
need to defer the increment of `n`.
2025-12-20 13:52:45 +00:00
Niklas Haas 900d91b541 swscale/ops_optimizer: apply optimizations in a more predictable order
Instead of blindly interleaving re-ordering and minimizing optimizations,
separate this loop into several passes - the first pass will minimize the
operation list in-place as much as possible, and the second pass will apply any
desired re-orderings. (We also want to try pushing clear back before any other
re-orderings, as this can trigger more phase 1 optimizations)

This restructuring leads to significantly more predictable and stable behavior,
especially when introducing more operation types going forwards. Does not
actually affect the current results, but matters with some upcoming changes
I have planned.
2025-12-20 13:52:45 +00:00
Niklas Haas c51c63058c swscale/ops_optimizer: don't commute clear with itself
These would normally be merged, not swapped.
2025-12-20 13:52:45 +00:00
Andreas Rheinhardt b934dd1d4b avformat/whip: Fix leak of dtls_fingerprint
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Jack Lau <jacklau1222gm@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 21:45:24 +01:00
Andreas Rheinhardt 34bc95ddfc avformat/whip: Check number of audio/video streams generically
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Jack Lau <jacklau1222gm@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 21:45:21 +01:00
Andreas Rheinhardt e252bc0c3d avformat/whip: Remove dead code
This is checked generically after
6070ea29de.
Also set AVOutputFormat.subtitle_codec explicitly in order
not to rely on AV_CODEC_ID_NONE to be zero.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Jack Lau <jacklau1222gm@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 21:42:27 +01:00
Andreas Rheinhardt 6177af5acc avcodec/x86/lossless_videodsp: Avoid unnecessary reg push,pop
Happens on Win64.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:56:09 +01:00
Andreas Rheinhardt 9314d5cae8 avcodec/x86/lossless_videodsp: Avoid aligned/unaligned versions
For AVX2, movdqu is as fast as movdqa when used on aligned addresses,
so don't instantiate aligned/unaligned versions.

(The check was btw overtly strict: The AVX2 code only uses 16 byte
stores, so it would be enough for dst to be 16-byte aligned.)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:55:53 +01:00
Andreas Rheinhardt 6368d2baae avcodec/x86/lossless_videodsp: Don't store in eight byte chunks
Use movu (movdqu) instead of movq+movhps.

Old benchmarks:
add_left_pred_int16_c:                                2265.5 ( 1.00x)
add_left_pred_int16_ssse3:                             595.4 ( 3.81x)
add_left_pred_rnd_acc_c:                              1255.0 ( 1.00x)
add_left_pred_rnd_acc_ssse3:                           326.2 ( 3.85x)
add_left_pred_rnd_acc_avx2:                            279.0 ( 4.50x)
add_left_pred_zero_c:                                 1249.5 ( 1.00x)
add_left_pred_zero_ssse3:                              326.1 ( 3.83x)
add_left_pred_zero_avx2:                               277.0 ( 4.51x)

New benchmarks:
add_left_pred_int16_c:                                2266.9 ( 1.00x)
add_left_pred_int16_ssse3:                             509.9 ( 4.45x)
add_left_pred_rnd_acc_c:                              1251.4 ( 1.00x)
add_left_pred_rnd_acc_ssse3:                           282.6 ( 4.43x)
add_left_pred_rnd_acc_avx2:                            208.9 ( 5.99x)
add_left_pred_zero_c:                                 1253.7 ( 1.00x)
add_left_pred_zero_ssse3:                              280.0 ( 4.48x)
add_left_pred_zero_avx2:                               206.8 ( 6.06x)

The checkasm test has been modified to use an unaligned destination
for this test.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:55:37 +01:00
Andreas Rheinhardt bb523a2d3f tests/checkasm/llviddsp: Reindent after the previous commit
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:55:33 +01:00
Andreas Rheinhardt b2dea09de1 tests/checkasm/llviddsp: Avoid unnecessary initializations, allocs
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:55:20 +01:00
Andreas Rheinhardt a6b8939e1e avcodec/x86/lossless_videodsp: Remove SSSE3 functions using MMX regs
These functions are only used on Conroe (they are overwritten
by SSSE3 functions using xmm registers if the SSSE3SLOW is not set)
which is very old (introduced in 2006), so remove them.

Btw: The checkasm test (which uses declare_func and not
declare_func_emms since cd8a33bcce)
would fail on a Conroe, yet no one ever reported any such failure.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:54:44 +01:00
Martin Storsjö cf608f6b65 checkasm: Use av_strlcatf for appending SME info after SVE
If we had SVE enabled and formatted info about its vector lengths,
it would be overwritten by the SME info.
2025-12-19 18:42:10 +00:00
Martin Storsjö ec2ceefcfa fate.sh: Allow specifying --ar through a separate variable
This avoids needing to use the extra_conf variable. That variable
is problematic for setting a value that contains spaces.

This adds options for another tool in the same fashion as other
tools were added in 523d688c2b.
2025-12-19 18:41:23 +00:00
Martin Storsjö 06a17fdafc tests: Fix fate-run.sh to handle busybox-w32 absolute paths
Busybox-w32 uses regular Windows style paths with drive letters,
but with forward slashes; thus an absolute path starts with "c:/".

Make the target_path() function in fate-run.sh (which converts a
potentially relative path to an absolute one, under the target_path
prefix) handle this case.

With this in place, running fate tests almost works in
busybox-w32 - only one issue remains. A patch [1] has been sent to
upstream busybox for fixing that issue (which also is present if
running fate tests on busybox on Linux), but it hasn't been
responded to yet.

[1] https://lists.busybox.net/pipermail/busybox/2025-December/091851.html
2025-12-19 18:38:33 +00:00
Martin Storsjö 6149ceadeb configure: Recognize uname "Windows_NT" as using an .exe suffix
Busybox-w32 [1] works for building ffmpeg on Windows (as an
alternative to msys2, cygwin or WSL).

On busybox-w32, "uname" returns "Windows_NT"; recognize this
in exesuf() as having an .exe suffix.

If building in this environment with a mingw toolchain, one has
to explicitly set --target-os=mingw32. (We probably don't
want to imply that this uname, set as target_os_default, would
default to mingw?) But despite what is set with --target-os,
one can't override the configure variable "host_os", which
exesuf() has to recognize.

[1] https://github.com/rmyorston/busybox-w32
2025-12-19 18:38:33 +00:00
Rémi Denis-Courmont 55200f999c lavc/mathops: R-V B optimisation for mid_pred
If Zbb is enabled at compilation (e.g. Ubuntu), the compiler should
compile the new C mid_pred() function correctly. But if Zbb is *not*
enabled (e.g. Debian), then we can at least fallback at run-time.

On SiFive-U74, before:
sub_median_pred_c:                                    1331.9 ( 1.00x)
sub_median_pred_rvb_b:                                 881.8 ( 1.51x)

After:
sub_median_pred_c:                                    1133.1 ( 1.00x)
sub_median_pred_rvb_b:                                 875.7 ( 1.29x)
2025-12-19 19:56:13 +02:00
Rémi Denis-Courmont ccd7e66f9e lavc/mathops: remove bespoke Arm mid_pred()
The C codegen is as good if not slightly better than the assembler at
this point.
2025-12-19 19:56:13 +02:00
Rémi Denis-Courmont 8dccb380cf lavc/mathops: simplify mid_pred()
This reduces the minimum instruction emission for mid_pred()
(i.e. median of 3) down to:
- 3 comparisons and 4 conditional moves, or
- 4 min/max.

With that the compiler can eliminate any branch. This optimal
situation is attainable with Clang 21 on Arm64, RVA22 and x86,
with GCC 15 on Arm64 and x86 (RVA22 goes from 2 to 1 branch).
These optimisations also work on Arm32 and LoongArch.

The same algorithm is already implemented via inline assembler for some
architectures such as x86 and Arm32, but notably not Arm64 and RVA22.
Besides, using C code allows the compiler to schedule instruction
properly.

Even on architectures with neither conditional moves nor min/max, this
leads to a visible performance improvement for C code, as seen here for
RVA20 code running on SiFive-U74:

Before:
sub_median_pred_c:                                    1657.5 ( 1.00x)
sub_median_pred_rvb_b:                                 875.9 ( 1.89x)

After:
sub_median_pred_c:                                    1331.9 ( 1.00x)
sub_median_pred_rvb_b:                                 881.8 ( 1.51x)

Note that this commit leaves the x86 and Arm32 code intact so it has
no effects on those ISA's.
2025-12-19 19:50:56 +02:00
Harishmcw 5946d2eadc compat: Fix .def file generation for ARM64EC builds on Windows
When building DLLs on ARM64EC, the default use of `dumpbin
-linkermember:1` fails because ARM64EC static libraries use a
different linker member format. Use `-linkermember:32` for ARM64EC
to correctly extract symbols.

Additionally, MSVC inserts $exit_thunk and $entry_thunk symbols
for ARM64EC to handle x64 ↔ ARM64 transitions. These are internal
thunks and must not be exported. Filter them out when generating
the .def file to avoid unresolved symbols or invalid exports.

Trim out the leading '#' on ARM64EC function symbols. This is only
relevant on ARM64EC, but it is benign to do that filtering on
all architectures (such symbols aren't expected on other
architectures).

Simplify the sed command by removing the symbol address with a
sed expression instead of a later "cut" command.

This ensures correct symbol extraction and stable DLL generation
on ARM64EC targets, while keeping behavior unchanged for other
Windows architectures.
2025-12-19 10:01:16 +00:00
Martin Storsjö 087f46674a doc: Document our stance on Windows ARM64EC
Explicitly spell it out that we are not going to modify the
individual libraries for the purposes of improving conformance
to ARM64EC.

We may (or may not) accept build system patches for making such
a build succeed, provided that it does not require changes to
the actual library code.
2025-12-19 10:01:16 +00:00
Andreas Rheinhardt 1c35a1b79b avformat/flvdec: Fix leak of channel layout map
Fixes: memleak
Fixes: 418396714/clusterfuzz-testcase-minimized-ffmpeg_dem_KUX_fuzzer-4595253332213760

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 08:02:52 +01:00
Andreas Rheinhardt 4aed9db83c avformat/flac_picture: Correct check
Since af97c9865f,
the return value of avio_read() has been compared against
an uint32_t, so that the int is promoted to uint32_t for
the comparison (on common systems with 32bit ints). The upshot was
that errors returned from avio_read() were ignored, so that
the buffer could be uninitialized on success.

Fix this by using ffio_read_size() instead.

Fixes: MemorySanitizer: use-of-uninitialized-value
Fixes: 443923343/clusterfuzz-testcase-minimized-ffmpeg_dem_FLAC_fuzzer-5458132865449984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 07:32:01 +01:00
Gyan Doshi 6070ea29de lavf/whip: add flag for default codecs only
The muxer does not accept any other codecs.
2025-12-19 04:13:34 +00:00
Gyan Doshi fdce17953c lavf/supenc: add flag for default codecs only
The muxer does not accept any other codecs.
2025-12-19 04:13:34 +00:00
Gyan Doshi 20b671f651 lavf/dvenc: add flag for default codecs only
The muxer does not accept any other codecs.
2025-12-19 04:13:34 +00:00
James Almer 78c75d546a avcodec/apv_parser: add support for AU assembly
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-18 01:24:35 +00:00
Timo Rothenpieler 0d7b8d8913 forgejo/workflows: fix error handling of configure result 2025-12-17 13:28:21 +00:00
Timo Rothenpieler 0be989edcb forgejo/workflows: cat .err files after running fate 2025-12-17 13:28:21 +00:00
Timo Rothenpieler 5e8dcd6db1 forgejo/workflows: run windows fate tests through wine 2025-12-17 13:28:21 +00:00
James Almer d828183d2d doc: add missing JPEG-XS details
Forgotten in 3332b2db84

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-17 00:20:41 -03:00
Timo Rothenpieler 4bb9b46486 avcodec/demux: validate avctx state in has_decode_delay_been_guessed 2025-12-16 22:45:17 -03:00
James Almer c9c95f6f32 avformat/demux: ensure avformat_find_stream_info updates internal stream contexts
read_frame_internal() may result in a stream being modified without also
returning a packet from it. Given said function only bothered to update the
internal stream context for the returned packet, the result would be a desync
between the stream's AVCodecParameters and the internal AVCodecContext.

This change makes sure all streams are updated within the
avformat_find_stream_info() loop.

Fixes #YWH-PGM40646-20

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-16 22:45:17 -03:00
Dariusz Marcinkiewicz c41155e614 libavcodec: support frame dropping in libvpxenc
vp8 encoder can be configured to drop frames, when e.g. bitrate
overshoot is detected. At present the code responsible for
managing an internal fifo assumes that we will get an output frame per
each frame fed into encoder. That is not the case if the encoder can
decide to drop frames.

Running:
ffmpeg -stream_loop 100 -i dash_video3.webm -c:v libvpx -b:v 50k
-drop-threshold 20 -screen-content-mode 2 output.webm

results in lots of warnings like:
[libvpx @ 0x563fd8aba100] Mismatching timestamps: libvpx 2187 queued
2185; this is a bug, please report it
[libvpx @ 0x563fd8aba100] Mismatching timestamps: libvpx 2189 queued
2186; this is a bug, please report it

followed by:
[vost#0:0/libvpx @ 0x563fd8ab9b40] [enc:libvpx @ 0x563fd8aba080] Error
submitting video frame to the encoder
[vost#0:0/libvpx @ 0x563fd8ab9b40] [enc:libvpx @ 0x563fd8aba080] Error
encoding a frame: No space left on device
[vost#0:0/libvpx @ 0x563fd8ab9b40] Task finished with error code: -28
(No space left on device)
[vost#0:0/libvpx @ 0x563fd8ab9b40] Terminating thread with return code
-28 (No space left on device)

The reason for the above error is that each dropped frame leaves an
extra item in the fifo, which eventually overflows.

The proposed fix is to keep popping elements from the fifo until the
one with the matching pts is found. A side effect of this change is that
the code no longer considers pts mismatch to be a bug.

This has likely regressed around 5bda4ec6c3
when fifo started to be universally used.

Signed-off-by: Dariusz Marcinkiewicz <darekm@google.com>
2025-12-16 21:53:10 +00:00
Rémi Denis-Courmont 7ee5c907e5 lavfi/vf_blackdetect: R-V V count_pixels_16
SpacemiT X60:
blackdetect16_c:                                      7171.0 ( 1.00x)
blackdetect16_rvv_i32:                                 383.6 (18.69x)
2025-12-16 17:30:29 +02:00
Rémi Denis-Courmont 570908af09 lavfi/vf_blackdetect: R-V V count_pixels_8
SpacemiT X60:
blackdetect8_c:                                      14911.0 ( 1.00x)
blackdetect8_rvv_i32:                                  369.5 (40.35x)
2025-12-16 17:30:23 +02:00
James Almer 1d662641c5 tests/fate/demux: add a raw JPEG-XS demux test
Use the concat protocol, to test the parser's capabilities to differentiate between
EOC maker before SOC marker, on top of false EOC marker positives and EOC maker on EOF.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-16 10:38:56 -03:00
James Almer 1c804b349e avcodec/jpegxs_parser: fix bitstream assembly logic
JPEG-XS streams can have the bytes corresponding to certain markers as part of
slice data, and no considerations were made for it, so we need to add checks
for false positives.

This fixes assembling several samples.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-16 10:38:56 -03:00
Martin Storsjö 477e2dbc39 checkasm: Add a comment about adding new tests to checkasm.mak 2025-12-16 09:47:05 +00:00
rcombs d1962881ae swscale: use configured YUV matrix with paletted-RGB inputs
This replaces hardcoded BT601.
2025-12-16 01:24:40 +00:00
Rémi Denis-Courmont 29185f708f lavc/riscv: fix dependency for llvidencdsp 2025-12-15 18:40:13 +02:00
Rémi Denis-Courmont 468eca2854 checkasm: test all plane configurations with sub_left_predict
The original code didn't really make sense, never iterating the loop
and never testing non-first plane configurations.
2025-12-15 18:39:53 +02:00
Rémi Denis-Courmont acb38d320b lavc/llvidencdsp: fix R-V V sub_left_predict
The code assumed that the destination buffer was zeroed, a misbehaviour
with which checkasm is bug-compatible as it zeroes the destination
buffer. The fixed code is even faster:

SpacemiT X60:
sub_left_predict_c:                                  51792.5 ( 1.00x)
sub_left_predict_rvv_i32:                             3504.4 (14.78x)
2025-12-15 18:35:58 +02:00
Niklas Haas 18edb246c8 swscale/ops_optimizer: correctly commute swizzles with dither ops
This requires updating the order of the dither matrix offsets as well. In
particular, this can only be done cleanly if the dither matrix offsets are
compatible between duplicated channels; but this should be guaranteed after
the previous commits.

As a side note, this also fixes a bug where we pushed SWS_OP_SWIZZLE past
SWS_OP_DITHER even for very low bit depth output (e.g. rgb4), which led to
a big loss in accuracy due to loss of per-channel dither noise.

Improves loss of e.g. gray -> rgb444 from 0.00358659 to 0.00261414,
now beating legacy swscale in these cases as well.
2025-12-15 14:31:58 +00:00
Niklas Haas 7bce47cc63 swscale/ops_optimizer: only commute swizzle ops if coefficients are identical
Otherwise, this is invalid; as the result of applying the next operation
after channel duplication may not commute with the result of duplicating
the result of applying the next operation on only one channel.

In practice, this was using the last seen channel's coefficients.

Note that this did not actually affect anything in practice, because the only
relevant ops (MIN/MAX) were always generated with identical coefficients for
identical channel ranges.

However, it will matter moving forwards, as e.g. dither ops may not be
commuted freely if their matrix offsets differ per channel.
2025-12-15 14:31:58 +00:00
Niklas Haas 1cc4c2b236 swscale/ops_optimizer: rework ambiguous op_type_is_independent()
The current usage is ambiguous between "affects each component equally" and
"affects each component independently" - and arguably, the current behavior
was a bug (since SWS_OP_DITHER should not commute with a SWIZZLE, at least
from a bit-exactness PoV).

However, when trying to define cleaner replacements for these concepts, I
realized there are too many special cases; and given that we only have two
use sites, I decided to just split them directly into "commute" functions
for those particular usage cases.

As an added benefit, this moves the commutation logic out of the already-long
ff_sws_ops_list_optimize().
2025-12-15 14:31:58 +00:00
Niklas Haas 6184924892 swscale/format: don't add chroma noise when dithering grayscale content
On the surface, this trades a tiny bit of PSNR for not introducing chroma
noise into grayscale images. However, the main reason for this change is
actually motivated by a desire to avoid regressing the status quo of
duplicating swizzles being able to be commuted past dither ops.
2025-12-15 14:31:58 +00:00
Niklas Haas d5174f9e5b swscale/format: add source format info to ff_sws_encode_colors()
Specifically, I need access to this for generating a better dither matrix.
2025-12-15 14:31:58 +00:00
Niklas Haas 3f7e3cedb5 swscale/x86/ops_float: store and load per row dither offset directly
Instead of computing y + N with a hard-coded index offset, calculate the
relative offset as a 16-bit integer in C and add that to the pointer directly.
Since we no longer mask the resulting combined address, this may result in
overread, but that's fine since we over-provisioned the array in the previous
commit.
2025-12-15 14:31:58 +00:00
Niklas Haas 0744260ff0 swscale/x86/ops: over-allocate dither matrix
I want to change the way offsets are calculated inside the dither asm;
and the cleanest way to solve that problem is to just over-allocate the
entire dither matrix based on the maximum offset range we expected.
2025-12-15 14:31:58 +00:00
Niklas Haas b1c96b99fa swscale/x86/ops_float: remove special case for 2x2 matrix
This is an exceptionally unlikely (in fact, currently impossible) case to
actually hit, and not worth micro-optimizing for. More specifically, having
this special case prevents me from easily adding per-row offsets.
2025-12-15 14:31:58 +00:00
Niklas Haas d62102d679 swscale/ops_tmpl_float: actually skip allocation for !size_log2 case
This check was wrong; 1 << 0 = 1. The intent was to skip allocating a 1x1
matrix by assuming it is a constant 0.5. But as written, the check never
actually executed.

This did not affect the runtime performance, nor did it leak memory; but it
did mean we didn't hit the intended `assert`.
2025-12-15 14:31:58 +00:00
Niklas Haas 58f933798f swscale/ops_tmpl_float: respect specified dither matrix offsets
Since we only need 8 bytes to store the dither matrix pointer, we actually
still have 8 bytes left-over. That means we could either store the 8-bit
row offset directly, or alternatively compute a 16-bit pointer offsets.

I have chosen to do the former for the C backend, in the interest of
simplicity.

The one downside of this approach is that it would fail on hypothetical
128-bit platforms; although I seriously hope that this code does not live
long enough to see the need for 128-bit addressable memory.
2025-12-15 14:31:58 +00:00
Niklas Haas 960cf3015e swscale/ops: add explicit row offset to SwsDitherOp
To improve decorrelation between components, we offset the dither matrix
slightly for each component. This is currently done by adding a hard-coded
offset of {0, 3, 2, 5} to each of the four components, respectively.

However, this represents a serious challenge when re-ordering SwsDitherOp
past a swizzle, or when splitting an SwsOpList into multiple sub-operations
(e.g. for decoupling luma from subsampled chroma when they are independent).

To fix this on a fundamental level, we have to keep track of the offset per
channel as part of the SwsDitherOp metadata, and respect those values at
runtime.

This commit merely adds the metadata; the update to the underlying backends
will come in a follow-up commit. The FATE change is merely due to the
added offsets in the op list print-out.
2025-12-15 14:31:58 +00:00
averne b9078c0939 vulkan/prores: copy constant tables to shared memory
The shader needs ~3 loads per DCT coeff.
This data was not observed to get efficiently stored
in the upper cached levels, loading it explicitely in
shared memory fixes that.

Also reduce code size by moving the bitstream
initialization outside of the switch/case.
2025-12-15 12:29:00 +00:00
averne 00914cc3ef vulkan/prores: increase bitstream caching
Now caches 64B of data when the reader hits the refill codepath
2025-12-15 12:29:00 +00:00
averne a2475d16ed lavc/vulkan/common: allow configurable bitstream caching in shared memory 2025-12-15 12:29:00 +00:00
Niklas Haas 4ac3b3a6da avfilter/vf_libplacebo: rotate all input frames, not just reference
In commit 6e0034ab7e, the image crop adjustment
was moved after the fitting logic. However, this moved the adjustment inside the
`if (src == ref)` branch, thus missing applying the same un-rotation to input
frames that are *not* the reference frame.

Fix this by pulling the logic back out of the branch again. While we could just
move it after the fitting logic, I think it's more clear to the intent of the
code to just preserve the (rotated) crop rect as a separate variable
`crop_orig`.

Fixes: 6e0034ab7e
2025-12-15 11:29:58 +01:00
James Almer 3332b2db84 doc: add entries for SVT-JPEG-XS
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:47:08 -03:00
James Almer 35e68c6492 avcodec/libsvtjpegxsdec: only return AVERROR codes
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:22:04 -03:00
James Almer 4269d69df1 avcodec/libsvtjpegxsdec: use AVCodecContext.lowres instead of a private option
It was evidently an oversight.

Found-by: Andreas Rheinhardt.
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:22:04 -03:00
James Almer 330984579b avcodec/libsvtjpegxsdec: move some stack structs to the private decoder context
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:22:04 -03:00
James Almer 2903a3c1ec avcodec/libsvtjpegxsdec: reindent after the previous changes
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:22:04 -03:00
James Almer 4e9f5e2f3d avcodec/libsvtjpegxsdec: support parameter changes
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:22:03 -03:00
James Almer 7bd793c647 avcodec/libsvtjpegxsdec: remove chunk decoding code
That's the job of the parser.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:22:03 -03:00
James Almer 695b717944 avcodec/libsvtjpegxsdec: Replace divisions by shifts
Based on a patch by Andreas Rheinhardt

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:21:58 -03:00
James Almer c639ea5eeb avcodec/libsvtjpegxsenc: set bitrate to a sane default if unset
Better than failing with an impossibly low bitrate.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 17:34:57 -03:00
Andreas Rheinhardt 6f9849cbe5 avcodec/libsvtjpegxsenc: Replace divisions by shifts
Also simplify setting alloc_size.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 21:06:03 +01:00
Andreas Rheinhardt 7efd09813f avcodec/libsvtjpegxsenc: Don't copy unnecessarily
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 21:06:00 +01:00
Andreas Rheinhardt af70b24692 avcodec/libsvtjpegxs{dec,enc}: Don't call av_cpu_count() multiple times
(Like the old code, the new code limits the number of threads to 64,
even when the user explicitly set a higher thread count. I don't know
whether it is intentional to apply this limit even when the user
explicitly supplied the number of threads.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 21:05:57 +01:00
Andreas Rheinhardt 47179c3452 avcodec/libsvtjpegxsenc: Remove dead code
The pixel format has already been checked generically.
This also fixes the bug that the earlier code ignored
the return value of set_pix_fmt().

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 21:05:54 +01:00
Andreas Rheinhardt 9ed64db6a5 avcodec/libsvtjpegxs{dec,enc}: Don't get log level multiple times
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 21:05:33 +01:00
Ruikai Peng 16f89d342e avformat/mpegts: bounds-check JPEG-XS header_size before padding
Regression since: 536475ea05.

The JPEG-XS PES path trusted header_size from the payload and advanced
pkt->data/pkt->size without validation, so the trailing memset could
write out of bounds when header_size > pkt->size. Reject such packets,
marking them corrupt and returning an error to avoid the OOB write.

Repro (ASan):
ASAN_OPTIONS=halt_on_error=1:detect_leaks=0   ./ffmpeg -v debug -nostdin -i poc-jpegxs.ts -copy_unknown -map 0   -c copy -f null /dev/null

Crash in new_pes_packet memset on crafted TS with stream_id 0xbd,
stream_type 0x32, header_size 0xFFFFFF00, payload starting with jxes.

Found-by: Pwno
2025-12-14 17:42:59 +00:00
Marton Balint 131a33c808 avformat/xmv: do not set audio pts values
The format does not contain audio timestamps and the calculated audio pts
values were only correct for compressed audio. It is better to remove PTS
calculation entirely and let the generic code handle it.

Fixes ticket #8595.
Fixes #20983.

Fate test changes are because of the different audio time base which is now
always 1/sample_rate.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-12-14 17:08:37 +00:00
Andreas Rheinhardt b802eeabff avformat/Makefile: Add jpegxs->img2dec.o dependency
Forgotten in 3b1214a897.

Reported-by: Jamaika1 <lukaszcz18@wp.pl>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 14:27:46 +01:00
Andreas Rheinhardt 4715b9bac2 tests/checkasm/llviddspenc: Rename to llvidencdsp
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:48 +01:00
Andreas Rheinhardt f96829b5bf avcodec/x86/lossless_videoencdsp_init: Remove pointless av_unused
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:46 +01:00
Andreas Rheinhardt abe6ba17fa avcodec/x86/lossless_videoencdsp: Port sub_median_pred to NASM
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:43 +01:00
Andreas Rheinhardt 9ba33cc198 avcodec/x86/lossless_videoencdsp_init: Avoid special-casing first pixel
Old benchmarks:
sub_median_pred_c:                                     404.1 ( 1.00x)
sub_median_pred_sse2:                                   20.5 (19.67x)

New benchmarks:
sub_median_pred_c:                                     408.5 ( 1.00x)
sub_median_pred_sse2:                                   19.2 (21.27x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:40 +01:00
Andreas Rheinhardt 3a3e7080f1 avcodec/x86/lossless_videoencdsp_init: Port sub_median_pred to SSE2
Old benchmarks:
sub_median_pred_c:                                     405.7 ( 1.00x)
sub_median_pred_mmxext:                                 35.1 (11.57x)

New benchmarks:
sub_median_pred_c:                                     404.1 ( 1.00x)
sub_median_pred_sse2:                                   20.5 (19.67x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:35 +01:00
Andreas Rheinhardt 56b8769a1c tests/checkasm/llviddspenc: Add test for sub_median_pred
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:32 +01:00
Andreas Rheinhardt 3144652588 avcodec/x86/lossless_videoencdsp_init: Don't read too often
sub_median_pred_mmxext() calculates a predictor from the left, top
and topleft pixel values. The topleft values need to be initialized
differently for the first loop initialization than for the others
in order to avoid reading ptr[-1]. So it has been initialized before
the loop and then read again at the end of the loop, so that the last
value read was never used. Yet this can lead to reads beyond the end
of the buffer, e.g. with
ffmpeg -cpuflags mmx+mmxext -f lavfi -i "color=size=64x4,format=yuv420p" \
-vf vflip -c:v ffvhuff -pred median -frames 1 -f null -

Fix this by not reading the value at the end of the loop.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:29 +01:00
Andreas Rheinhardt 2b9aea7756 avcodec/x86/lossless_videoencdsp_init: Don't read from before the buffer
sub_median_pred_mmxext() calculates a predictor from the left, top
and topleft pixel values. The left value is simply read via
ptr[-1], although this is not guaranteed to be inside the buffer
in case of negative strides. This happens e.g. with

ffmpeg -i fate-suite/mpeg2/dvd_single_frame.vob -vf vflip \
       -c:v magicyuv -pred median -f null -

Fix this by reading the first value like the topleft value.
Also change the documentation of sub_median_pred to reflect this
change (and the one from 791b5954bc).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:25 +01:00
Andreas Rheinhardt f8a06da4ec fate/vcodec: Test median prediction in ffvhuff,huffyuv
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:13:29 +01:00
Rémi Denis-Courmont 71db4f3cc1 lavc/llvidencdsp: R-V V sub_median_pred
SpacemiT X60:
sub_median_pred_c:                                  297862.8 ( 1.00x)
sub_median_pred_rvb_b:                              101992.2 ( 2.92x)
sub_median_pred_rvv_i32:                              4820.0 (61.80x)
2025-12-14 10:33:40 +02:00
Rémi Denis-Courmont 87190fff6e lavc/llvidencdsp: R-V B sub_median_pred
SiFive U74:
sub_median_pred_c:                                  238947.3 ( 1.00x)
sub_median_pred_rvb_b:                              106686.9 ( 2.24x)

SpacemiT X60:
sub_median_pred_c:                                  297862.8 ( 1.00x)
sub_median_pred_rvb_b:                              101992.2 ( 2.92x)
2025-12-14 10:33:40 +02:00
Gyan Doshi 48d63b47bf doc/filters: list side data types
Doc readers may not have access to, or be able to read source code.
2025-12-14 12:41:00 +05:30
Gyan Doshi b89f1581b0 lavfi/sidedata: fix typo
S12M_TIMECOD --> S12M_TIMECODE

Old version is marked deprecated.
Should be removed at lavfi bump to 12.
2025-12-14 12:41:00 +05:30
James Almer b8ee68cffe doc/APIchanges: add an entry for JPEG-XS codec id
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 19:04:46 -03:00
jess 536475ea05 avformat/mpegts: add support for JPEG-XS streams
Co-Authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 19:03:43 -03:00
James Almer 3b1214a897 avformat: add a raw JPEG-XS muxer and demuxer
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 19:03:36 -03:00
Tomasz Szumski 08db850159 avcodec: add JPEG-XS decoder and encoder using libsvtjpegxs
Co-Authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 19:00:35 -03:00
James Almer 52c097065c avcodec: add a JPEG-XS parser
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 18:45:17 -03:00
Tomasz Szumski 4243e6c870 avcodec/codec_id: add JPEG-XS
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 18:45:17 -03:00
James Almer 5fac8addc5 avutil/log: use atomics to load and store logging level, flags and callback pointer
Based on code setting cpu flags in libavutil/cpu.c

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 21:33:11 +00:00
Lynne 9e8e34d475 vulkan_ffv1: remove unused RCT shader files
The 2 files were made redundant when the RCT was merged into encode/decode.
2025-12-13 22:12:26 +01:00
Lynne 5bb9cd23b7 vulkan_dpx: fix GRAY16BE and big-endian marked 8-bit samples 2025-12-13 21:35:56 +01:00
Lynne c3291993eb vulkan_ffv1: use proper rounded divisions for plane width and height
Fixes #20314
2025-12-13 19:12:24 +01:00
Lynne 91deb96d3c vulkan_decode: don't set unnecessary function pointers for FFHWAccel
Invalidate is not used for SDR decoders, since they don't use session
parameters.
2025-12-13 19:12:24 +01:00
Lynne 72e83b42d1 vulkan_decode: clean up decoder initialization
Now that we don't reset on every seek, we can simplify it.
2025-12-13 19:12:24 +01:00
Lynne 018ba6b612 vulkan_decode: do not reset the decoder when flushing
The issue is that .flush gets called asynchronously, and modifies the
video session state while its being used for decoding. This did not
result in issues since all known vendors do not keep important state
there, but its not compliant with the specs.

Its not necessary to flush the decoder at all when seeking,
so simply don't.

Fixes #20487
2025-12-13 19:12:20 +01:00
Zhao Zhili 1e2d86201f Revert "avutil/tx_template: extend to 2M"
This reverts commit 8f48a62, 9af8782, and bd3e71b.

Commit 8f48a62 extends tx to 2M, resulting in the tx_float bss
section reaching a size of 4M.

This isn't a issue on devices with normal memory sizes and OS
supporting virtual memory. But it's a real issue for embedded devices
with realtime OS, which may not support virtual memory, e.g., Nuttx.
This 4M of bss section map to physical memory directly, which is a
scarce resource on embedded devices.
2025-12-13 15:14:38 +00:00
Andreas Rheinhardt 3da2a21710 avcodec/hq_hqadata: Avoid relocations for HQProfiles
Reviewed-by: Marton Balint <cus@passwd.hu>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-13 05:57:47 +01:00
Andreas Rheinhardt 2718874724 avcodec/hq_hqadata: Remove padding from tables
Each table needs only tab_w*tab_h*2 entries.

Reviewed-by: Marton Balint <cus@passwd.hu>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-13 05:55:44 +01:00
Andreas Rheinhardt 0cf187471f avcodec/hq_hqa: Don't rederive value
perm gets incremented in the loop in such a manner that
it already has the value it is set to here except for
the first loop iteration.

Reviewed-by: Marton Balint <cus@passwd.hu>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-13 05:55:20 +01:00
Jack Lau ec0173ab59 avformat/amr: add P bits check to avoid mis-detects
Fix #21056

Refer to RFC 3267 Section 4.4.2:

A ToC entry takes the following format in octet-aligned mode:

 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|F|  FT   |Q|P|P|
+-+-+-+-+-+-+-+-+

P bits: padding bits, MUST be set to zero.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2025-12-12 20:17:00 +00:00
Ruikai Peng c48b8ebbbb avcodec/vulkan: fix DPX unpack offset
The DPX Vulkan unpack shader computes a word offset as

    uint off = (line_off + pix_off >> 5);

Due to GLSL operator precedence this is evaluated as
line_off + (pix_off >> 5) rather than (line_off + pix_off) >> 5.
Since line_off is in bits while off is a 32-bit word index,
scanlines beyond y=0 use an inflated offset and the shader reads
past the end of the DPX slice buffer.

Parenthesize the expression so that the sum is shifted as intended:

    uint off = (line_off + pix_off) >> 5;

This corrects the unpacked data and removes the CRC mismatch
observed between the software and Vulkan DPX decoders for
mispacked 12-bit DPX samples. The GPU OOB read itself is only
observable indirectly via this corruption since it occurs inside
the shader.

Repro on x86_64 with Vulkan/llvmpipe (531ce713a0):

    ./configure --cc=clang --disable-optimizations --disable-stripping \
        --enable-debug=3 --disable-doc --disable-ffplay \
        --enable-vulkan --enable-libshaderc \
        --enable-hwaccel=dpx_vulkan \
        --extra-cflags='-fsanitize=address -fno-omit-frame-pointer' \
        --extra-ldflags='-fsanitize=address' && make

    VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.json

PoC: packed 12-bit DPX with the packing flag cleared so the unpack
shader runs (4x64 gbrp12le), e.g. poc12_packed0.dpx.

Software decode:

    ./ffmpeg -v error -i poc12_packed0.dpx -f framecrc -
    -> 0, ..., 1536, 0x26cf81c2

Vulkan hwaccel decode:

    VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.json \
    ./ffmpeg -v error -init_hw_device vulkan \
        -hwaccel vulkan -hwaccel_output_format vulkan \
        -i poc12_packed0.dpx \
        -vf hwdownload,format=gbrp12le -f framecrc -
    -> 0, ..., 1536, 0x71e10a51

The only difference between the two runs is the Vulkan unpack
shader, and the stable CRC mismatch indicates that it is reading
past the intended DPX slice region.

Regression since: 531ce713a0
Found-by: Pwno
2025-12-12 20:13:16 +00:00
Ruikai Peng cc43670268 avfilter/x86/vf_noise: Use unaligned access
Regression since: 3ba570de8b (port from MMX to SSE2).

The SSE2 inline asm in libavfilter/x86/vf_noise.c (line_noise_sse2 and
line_noise_avg_sse2) uses aligned loads/stores (movdqa, movntdq) but never
checks pointer alignment. When the filter reuses an input frame (common
path when av_frame_is_writable() is true), it may receive misaligned data
from upstream filters that adjust frame->data[i] in place, notably vf_crop:

- vf_crop adjusts plane pointers by arbitrary byte offsets
(frame->data[plane] += ...), so an x offset of 1 on 8-bit formats produces
a 1‑byte misalignment.
- The noise filter then calls the SSE2 path directly on those pointers
without realigning or falling back.

Repro on x86_64/SSE2 (current HEAD at that commit):

./ffmpeg -v error -f lavfi -i testsrc=s=320x240:rate=1 \
-vf "format=yuv420p,crop=w=319:x=1:h=240:exact=1,noise=alls=50" \
-frames:v 1 -f null -

This crashes with SIGSEGV at the aligned load in line_noise_sse2 (movdqa
(%r9,%rax),%xmm0; effective address misaligned by 1 byte).

Impact: denial of service via crafted filtergraphs (e.g., crop + noise).
Applies to planar 8-bit formats where upstream filters can shift data
pointers without reallocating.

Found-by: Pwno OSS Team
2025-12-12 19:25:21 +00:00
James Almer 9c14527f1a avcodec/vvc/refs: export in-band LCEVC side data in frames
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-12 15:21:49 -03:00
James Almer 94c491287c avcodec/vvc/sei: parse Registered and Unregistered SEI messages
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-12 15:21:48 -03:00
James Almer 6dad70507f avcodec/cbs_sei: store a pointer to the start of Registered and Unregistered SEI messages
Required for the following commit, where a parsing function expects the buffer
to include the country code bytes.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-12 15:21:48 -03:00
James Almer b6655e9594 avcodec/dpx: make the lack of break in a switch case explicit
Should fix CID 1676036

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-12 18:18:46 +00:00
Martin Storsjö 86f1ee1842 ffprobe: Include the RFC 4281 "mime codec string" in show_stream output 2025-12-12 18:40:01 +02:00
Martin Storsjö c9b5e145b7 avformat: Add av_mime_codec_str public API
Add a public API for producing RFC 4281/6381 codecs trings for
MIME types.

This can be required for providing alternative video files to
a web browser, letting the browser pick the best file it supports.
Such strings also allow querying a browser whether it supports
a certain codec combination.

Finally, if implementing a DASH/HLS segmenter outside of libavformat,
one also has to generate such strings.

Generating such strings for H264/AAC is very simple, but for
more modern codecs, it can require a lot of nontrivial codec
specific parsing of extradata.

As libavformat already implements this, expose it for users as well.

The old, internal function ff_make_codec_str is kept and used by
the HLS and DASH muxers; the old function takes a logging context
which can be used for logging auxillary info about how the string
generation worked out.
2025-12-12 18:40:00 +02:00
Martin Storsjö 360fda56cd avformat: Skip logging in ff_make_codec_str if logctx == NULL
This is in preparation for reusing the same codepaths for a public
API, where we don't want it to print various diagnostic logging.
2025-12-12 18:39:34 +02:00
Cameron Gutman 0637a28dc0 lavc/vulkan_video: fix leak on CreateVideoSessionKHR failure
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-12 12:43:00 +00:00
Cameron Gutman 4e4677bf58 lavc/vulkan_video: fix double-free if ff_vk_decode_init() fails
ff_vk_video_common_init() calls ff_vk_video_common_uninit() on failure
which leaves dangling object handles. Those get freed again when the
destructor of FFVulkanDecodeShared calls ff_vk_video_common_uninit()
again.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-12 12:43:00 +00:00
Andreas Rheinhardt a72e01b4ec avcodec/ppc/vc1dsp_altivec: Don't read too much data
vc1_inv_trans_8x4_altivec() is supposed to process a block
of 8x4 words, yet it read and processed eight lines. This led
to ASAN failures (see [1]) that this commit intends to fix.
It should also lead to performance improvements, but I don't have
real hardware to bench it.

[1]: https://fate.ffmpeg.org/report.cgi?time=20251207214004&slot=ppc64-linux-gcc-14.3-asan

Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-12 09:44:01 +01:00
Martin Storsjö 6258e61c4d configure: Fix detection of SME
Older versions of Clang (Xcode 14, llvm.org Clang 13 and 14)
do support and recognize SME, but when enabled through
".arch_extension sme" it fails to transitively enable support
for Streaming SVE; this was fixed in [1].

This issue results in those versions currently detecting support
for SME, but later failing to build cpu_sme.s with errors like
"error: instruction requires: sve or sme" or "error: instruction
requires: streaming-sve or sve", on the "cntb x0" instruction.

Extend the check for this instruction set extension, to test
with two instructions, both specifically a SME instruction
(smstart) and an instruction that is available in Streaming SVE
mode (cntb).

For the configure check, add an extra parameter to
check_archext_insn for an optional second instruction to check.

It would be tempting to just pass both instructions through
the same parameter, as "smstart; cntb x0". However, Darwin
targets use a different token (%%) for starting a new
instruction on the same line - those targets interpret ";"
as the start of a comment. Due to that, such a check would
entirely ignore the second instruction on Darwin targets.

To avoid dealing with the variability in passing multiple
instructions on one line, just pass the optional second
instruction on a separate line.

[1] https://github.com/llvm/llvm-project/commit/ff3f3a54e2d1b05c36943bf88ae0be7475d622ed
2025-12-12 08:15:12 +00:00
James Almer 04df80f973 avcodec/cavs_parser: check return value of init_get_bits8
Fixes Coverity issue CID 1676035

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-11 20:01:01 -03:00
Jan Ekström e54bd7065d fate/ffmpeg: remove comparison against ref from fix_sub_duration_heartbeat
After the full ffmpeg CLI multithreading changes went in, this
test started depending on how far the input side read and decoded
the input compared to how quickly the output encoded things, causing
spurious failures on the CI.

To my knowledge all of the failures have so far been valid correct
results, but unfortunately FATE's built in checks mostly consist of
whether there is a difference against an exact result.

This way we still get the CI and valgrind running of the code,
but stop its comparison. Reference file is left around so that
the previous reference is still available.
2025-12-11 22:48:26 +02:00
Ruikai Peng bb424927db avformat/sierravmd: fix header read error check
The header read check stored the comparison result into ret, so read
failures became ret=1 and were treated as success, leaving the VMD header
uninitialized and letting parsing continue with bogus state.

Regression since: ee623a43e3.
Found-by: Pwno
2025-12-11 16:26:17 +00:00
Rémi Denis-Courmont a4cb6c724b lavc/llvidencdsp: R-V V sub_left_predict
SpacemiT X60:
sub_left_predict_c:                                  51836.0 ( 1.00x)
sub_left_predict_rvv_i32:                             5843.1 ( 8.87x)
2025-12-11 17:24:38 +02:00
Leo Izen 37858dc6bd avcodec/libjxlenc: add EXIF box to output
We already parse the EXIF side data to extract the orientation, so we
should add it to the output file as an EXIF box.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-11 05:38:36 -05:00
Leo Izen e349118b4c avcodec/libjxlenc: avoid calling functions inside if statements
It leads to messier, less readable code, and can also lead to bugs.
I prefer this code style.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-11 05:38:35 -05:00
Leo Izen 6ec4b3a9cb avcodec/libjxlenc: give display matrix sidedata priority
Before this commit, we ignore the display matrix side data if any EXIF
side data is present, even if that side data contains no orientation
tag. This allows us to calculate the orientation from the display
matrix sidedata first, if present. Ideally the decoder will have
removed the orientation tag upon decoding and attached the data as
display matrix side data instead, so this makes our orientation code
respect this behavior.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-11 05:38:33 -05:00
James Almer 4f947880bd tests/fate/filter-video: add missing lavfi_indev dependency to fate-filter-feedback-hflip
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-10 22:07:05 -03:00
James Almer 44862a9d68 avutil/aarch64/cpu: fix check for SME on Linux
SME is a AT_HWCAP2 entry, not AT_HWCAP.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-10 21:51:11 -03:00
Kacper Michajłow f8929c4510 configure: make --disable-optimizations work on MSVC/ICC
_cflags_noopt was previously set to optimize for size as a workaround
for issues in MSVC builds without any optimizations. Specifically the
lack of DCE and constant merging. This is no longer needed, as those
issues have been fixed in our codebase.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-10 23:19:54 +00:00
Hyunjun Ko 6726359326 vulkan_vp9: fix subsampling source and show_frame flag 2025-12-10 18:41:20 +00:00
Georgii Zagoruiko cdb14bc74d configure: add detection of assembler support for SME
All changes are made during development/testing of SVE/SME for ffmpeg (vvc). Tested on Apple M4
2025-12-09 21:38:38 +00:00
Georgii Zagoruiko 2251ede69e Makefile: add missing variables in Makefile 2025-12-09 21:38:38 +00:00
Niklas Haas 440d58f5b1 avfilter/avfiltergraph: add missing newlines to format printing 2025-12-09 21:31:58 +00:00
Niklas Haas 978a0821ee avfilter/avfiltergraph: always retry format negotiation after auto-filters
There is an edge case not covered by the current logic: If there is only
a single auto-filter inserted, but the auto-inserted filter is incompatible
with a *different* format attribute (after settling the previous formats),
we may need a second auto-filter (e.g. `scale`) to settle the newly introduced
incompatibility.

A regression test demonstrating the issue is added.
2025-12-09 21:31:58 +00:00
James Almer 16050a1cef avformat/iamf_writer: ensure expanded_loudspeaker_layout is only written when using a single scalable layout layer
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-09 17:54:11 -03:00
James Almer 5cdc1cad77 avformat/iamf_parse: add a few extra sanity checks
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-09 17:54:11 -03:00
James Almer 2d5abf27e5 avformat/iamf_parse: fix parsing of Scalable layouts with Mono and Stereo layers
An ASAN heap-buffer-overflow in scalable_channel_layout_config was caused by an
unchecked assumption that the channel layout of a scalable audio layer is a
superset of the previous layer's channel layout.

scalable_channel_layout_config constructs a channel layout map by copying
channels from the previous layer and adding new ones. The memory allocation is
based on the target loudspeaker_layout. However, if the target layout doesn't
encompass all previous channels (e.g., Mono to Stereo), copying previous
channels followed by adding current ones could exceed the allocated size,
causing a heap buffer overflow.

This commit adds an exception for the know case of Mono -> Stereo, and a check
to ensure the previous layer's channel layout is a subset of the current
layer's layout by comparing their masks. If the condition isn't met,
an error is returned.

Fixes: https://issues.oss-fuzz.com/issues/464965414

Co-authored-by: Oliver Chang <ochang@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-09 17:54:11 -03:00
Cameron Gutman 8eae9d3310 fftools/ffplay_renderer: use new Vulkan extension API
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-09 19:13:50 +00:00
Cameron Gutman 95c81cc1f9 hwcontext_vulkan: add APIs to get optional extensions
These provide a way for apps that initialize Vulkan themselves to know
which extensions we may be able to use without having to hardcode it.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-09 19:13:50 +00:00
Niklas Haas 7b773aba82 swscale/format: merge fmt_* helpers into a single fmt_analyze()
Handles the split between "regular" and "irregular" pixel formats in a single
place, and opens up the door for more complicated formats.
2025-12-09 09:47:48 +00:00
Niklas Haas a8dc3a543c swscale/format: consolidate format information into a single struct
I use a switch/case instead of an array because this is only needed for
irregular formats, which are very sparse.
2025-12-09 09:47:48 +00:00
Niklas Haas 3160ace20a swscale/format: derive fmt_read_write() for regular formats 2025-12-09 09:47:48 +00:00
Niklas Haas 004127f00b swscale/format: explicitly test for unsupported subsampled formats
This includes semiplanar formats. Note that the first check typically
subsumes the second check, but I decided to keep both for clarity.
2025-12-09 09:47:48 +00:00
Niklas Haas 748855b227 swscale/format: derive fmt_shift() from AVPixFmtDescriptor
XV36 is the odd one out, being a byte-shifted packed format whose components
don't actually cross any byte boundaries.
2025-12-09 09:47:48 +00:00
Niklas Haas 2feb848252 swscale/format: derive fmt_swizzle() from AVPixFmtDescriptor when possible
Unfortunately, this is exceptionally difficult to handle in the general case,
when packed/bitstream formats come into play - the actual interpretation of
the offset, shift etc. are so difficult to deal with in a general case that
I think it's simpler to continue falling back to a static table of variants
for these exceptions. They are fortunately small in number.
2025-12-09 09:47:48 +00:00
Niklas Haas 83d572e6f6 swscale/format: check SwsPixelType in fmt_read_write()
This is the only function that actually has the ability to return an
error, so just move the pixel type assignment here and add a check to
ensure a valid pixel type is found.
2025-12-09 09:47:48 +00:00
Niklas Haas ef2ce57c31 swscale/format: exclude U32 from sws_pixel_type()
This function is supposed to give us representable pixel types; but U32 is not
representable (due only to the AVRational range limit).
2025-12-09 09:47:48 +00:00
Gyan Doshi 9507695d06 doc/htmlxref.cnf: add drawvg-reference
Fixes #21125
2025-12-09 10:22:36 +05:30
Andreas Rheinhardt 4baa5e638b tests/checkasm/checkasm: Don't test 3dnow
The last 3dnow functions have been removed in commit
5ef613bcb0, so don't test
it in checkasm.

(This will affect only one test, namely scalarproduct_and_madd_int16
from lossless_audiodsp: It does not use an SSSE3 function when
the 3dnow flag is set. So for old AMDs (which advertise support for
3dnow), said SSSE3 function is never tested. Now it will.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-09 03:03:07 +00:00
Andreas Rheinhardt fb20009f47 tests/ref/fate/source: Fix fate-source after last commit
Broken in ac9552bebf.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 23:33:47 +00:00
Cameron Gutman 45bf925d54 fftools/ffplay_renderer: use new Vulkan extension API
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-08 23:22:31 +00:00
Cameron Gutman 212eb8413a hwcontext_vulkan: add APIs to get optional extensions
These provide a way for apps that initialize Vulkan themselves to know
which extensions we may be able to use without having to hardcode it.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-08 23:22:31 +00:00
James Almer ac9552bebf avformat/cbs: add missing license headers
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-08 20:07:45 -03:00
Kacper Michajłow 04a46a2ae4 avcodec/d3d12va_encode_av1: don't ignore return value
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow f4fc14fb38 avcodec/d3d12va_encode_av1: fix size_t format specifier 2025-12-08 21:31:13 +00:00
Kacper Michajłow 5b2bd6f88d avcodec/d3d12va_encode_av1: remove unused variables
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow 6083c9bb8c avutil/hwcontext_vaapi: mark try_all with av_unused to suppres warning
Fixes: warning: variable 'try_all' set but not used [-Wunused-but-set-variable]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow 018041f150 swresample/soxr_resample: pass initialized data to soxr_process() in flush()
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow 1f7182a991 avcodec/libx265: add explicit enum cast to suppress compiler warnings
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow eaa2b3d4be avcodec/libsvtav1: add explicit enum cast to suppress compiler warnings
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow 490af2d4cf avcodec/libaomdec: add explicit enum cast to suppress compiler warnings
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow cca872b6fd avfilter/vf_libopencv: make sure there is space for null-terminator in shape_str
Fixes: warning: 'sscanf' may overflow; destination buffer in argument 7 has size 32, but the corresponding specifier may require size 33 [-Wfortify-source]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow 1fa5e001bc avfilter/vf_neighbor_opencl: add error condition when filter name doesn't match
This cannot really happen, but to suppress compiler warnings, we can
just return AVERROR_BUG here.

Fixes: warning: variable 'kernel_name' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Martin Storsjö 69b4474367 swscale/tests: Fix fate-sws-ops-list on Windows
Set stdout to binary mode, to avoid platform specific differences
in the output that is hashed.
2025-12-08 23:02:30 +02:00
Niklas Haas c94e8afe5d swscale/ops: clarify SwsOpList.src/dst semantics
Turns out these are not, in fact, purely informative - but the optimizer
can take them into account. This should be documented properly.

I tried to think of a way to avoid needing this in the optimizer, but any
way I could think of would require shoving this to SwsReadWriteOp, which I
am particularly unwilling to do.
2025-12-08 20:09:37 +00:00
Niklas Haas f39fe6380c swscale/ops_optimizer: set correct value range for subpixel reads
e.g. rgb4 only reads values up to 15, not 255.

Setting this correctly eliminates a number of redundant clamps in cases
like e.g. rgb4 -> monow.
2025-12-08 20:09:37 +00:00
Andreas Rheinhardt dc843cdd9a avcodec/x86/vp9mc: Reindent after the previous commit
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:35:07 +01:00
Andreas Rheinhardt 65e71b0837 avcodec/x86/vp9mc: Deduplicate coefficient tables
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:35:01 +01:00
Andreas Rheinhardt 38e2174ce4 avcodec/x86/vp9mc: Avoid MMX regs in width 4 hor 8tap funcs
Using wider registers (and pshufb) allows to halve the number of
pmaddubsw used. It is also ABI compliant (no more missing emms).

Old benchmarks:
vp9_avg_8tap_smooth_4h_8bpp_c:                          97.6 ( 1.00x)
vp9_avg_8tap_smooth_4h_8bpp_ssse3:                      15.0 ( 6.52x)
vp9_avg_8tap_smooth_4hv_8bpp_c:                        342.9 ( 1.00x)
vp9_avg_8tap_smooth_4hv_8bpp_ssse3:                     54.0 ( 6.35x)
vp9_put_8tap_smooth_4h_8bpp_c:                          94.9 ( 1.00x)
vp9_put_8tap_smooth_4h_8bpp_ssse3:                      14.2 ( 6.67x)
vp9_put_8tap_smooth_4hv_8bpp_c:                        325.9 ( 1.00x)
vp9_put_8tap_smooth_4hv_8bpp_ssse3:                     52.5 ( 6.20x)

New benchmarks:
vp9_avg_8tap_smooth_4h_8bpp_c:                          97.6 ( 1.00x)
vp9_avg_8tap_smooth_4h_8bpp_ssse3:                      10.8 ( 9.08x)
vp9_avg_8tap_smooth_4hv_8bpp_c:                        342.4 ( 1.00x)
vp9_avg_8tap_smooth_4hv_8bpp_ssse3:                     38.8 ( 8.82x)
vp9_put_8tap_smooth_4h_8bpp_c:                          94.7 ( 1.00x)
vp9_put_8tap_smooth_4h_8bpp_ssse3:                       9.7 ( 9.75x)
vp9_put_8tap_smooth_4hv_8bpp_c:                        321.7 ( 1.00x)
vp9_put_8tap_smooth_4hv_8bpp_ssse3:                     37.0 ( 8.69x)

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:34:35 +01:00
Andreas Rheinhardt dd5dc254ff avcodec/x86/vp9mc: Avoid reloads, MMX regs in width 4 vert 8tap func
Four rows of four bytes fit into one xmm register; therefore
one can arrange the rows as follows (A,B,C: first, second, third etc.
row)

xmm0: ABABABAB BCBCBCBC
xmm1: CDCDCDCD DEDEDEDE
xmm2: EFEFEFEF FGFGFGFG
xmm3: GHGHGHGH HIHIHIHI

and use four pmaddubsw to calculate two rows in parallel. The history
fits into four registers, making this possible even on 32bit systems.

Old benchmarks (Unix 64):
vp9_avg_8tap_smooth_4v_8bpp_c:                         105.5 ( 1.00x)
vp9_avg_8tap_smooth_4v_8bpp_ssse3:                      16.4 ( 6.44x)
vp9_put_8tap_smooth_4v_8bpp_c:                          99.3 ( 1.00x)
vp9_put_8tap_smooth_4v_8bpp_ssse3:                      15.4 ( 6.44x)

New benchmarks (Unix 64):
vp9_avg_8tap_smooth_4v_8bpp_c:                         105.0 ( 1.00x)
vp9_avg_8tap_smooth_4v_8bpp_ssse3:                      11.8 ( 8.90x)
vp9_put_8tap_smooth_4v_8bpp_c:                          99.7 ( 1.00x)
vp9_put_8tap_smooth_4v_8bpp_ssse3:                      10.7 ( 9.30x)

Old benchmarks (x86-32):
vp9_avg_8tap_smooth_4v_8bpp_c:                         138.2 ( 1.00x)
vp9_avg_8tap_smooth_4v_8bpp_ssse3:                      28.0 ( 4.93x)
vp9_put_8tap_smooth_4v_8bpp_c:                         123.6 ( 1.00x)
vp9_put_8tap_smooth_4v_8bpp_ssse3:                      28.0 ( 4.41x)

New benchmarks (x86-32):
vp9_avg_8tap_smooth_4v_8bpp_c:                         139.0 ( 1.00x)
vp9_avg_8tap_smooth_4v_8bpp_ssse3:                      20.1 ( 6.92x)
vp9_put_8tap_smooth_4v_8bpp_c:                         124.5 ( 1.00x)
vp9_put_8tap_smooth_4v_8bpp_ssse3:                      19.9 ( 6.26x)

Loading the constants into registers did not turn out to be advantageous
here (not to mention Win64, where this would necessitate saving
and restoring ever more register); probably because there are only two
loop iterations.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:31:59 +01:00
Andreas Rheinhardt 7bc35b8426 tests/checkasm/vp9dsp: Allow to run only a subset of tests
Make it possible to run only a subset of the VP9 tests
in addition to all of them (via the vp9dsp test). This
reduces noise and speeds up testing.
FATE continues to use vp9dsp.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:27:56 +01:00
Andreas Rheinhardt 36204fbc3c avcodec/vp9itxfm{,_16bpp}: Remove MMXEXT functions overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMXEXT functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:27:51 +01:00
Andreas Rheinhardt ea37f49aed avcodec/vp9intrapred: Remove MMXEXT functions overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMXEXT functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:27:44 +01:00
Andreas Rheinhardt 6e418af810 avcodec/vp9mc: Remove MMXEXT functions overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMXEXT functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:27:05 +01:00
Kacper Michajłow a8df08f628 swscale/x86/yuv2yuvX: don't use deprecated hexadecimal prefix
Fixes: warning: $ prefix for hexadecimal is deprecated [-w+number-deprecated-hex]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 17:43:29 +00:00
Kacper Michajłow 5b5d51cbc1 avcodec/x86/h264_idct: fix version check for NASM 3 and newer
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 17:43:29 +00:00
Niklas Haas fddeb84fb2 tests/fate: add fate-sws-ops-list test
This one uses the test framework added in the previous commit to add a
light-weight regression test to ensure the generated SwsOpsList is identical.

Only compare the md5sum, to make the reference file significantly smaller
(down from ~10 MB).
2025-12-08 16:58:53 +00:00
Niklas Haas 016749f2e1 swscale/tests: add new test for generated operation lists
This is similar to swscale/tests/swscale.c, but significantly cheaper - it
merely prints the generated (optimized) operation list for every format
conversion.

Mostly useful for my own purposes as a regression test when making changes
to the ops optimizer. Note the distinction between this and tests/swscale.c,
the latter of which tests the result of *applying* an operation list for
equality.

There is an argument to be made that the two tests could be merged, but
I think the amount of overlap is small enough to not be worth the amount
of differences.
2025-12-08 16:58:53 +00:00
Niklas Haas d54090fe9f swscale/format: add assertion to prevent nan/inf matrix coeffs 2025-12-08 16:58:53 +00:00
Niklas Haas 868426814a swscale/format: handle YA format swizzles more robustly
This code was previously broken; since YAF32BE/LE were not included as
part of the format enumeration. However, since we *always* know the correct
swizzle for YA formats, we can just special-case this by the number of
components instead.
2025-12-08 16:58:53 +00:00
Timo Rothenpieler 338889c0d9 avfilter/vf_scale_d3d12: fix integer overflow in input framerate calculation
Also removes pointless intermediate variables that caused
the overflow and truncation to happen in the first place.

Fixes #YWH-PGM40646-1
2025-12-08 14:22:16 +01:00
Araz Iusubov c4d22f2d2c avfilter: D3D12 scale video filter support
This filter allows scaling of video frames using Direct3D 12 acceleration.

Example:
    ffmpeg -hwaccel d3d12va -hwaccel_output_format d3d12 \
           -i input.mp4 -vf scale_d3d12=1920:1280 \
           -c:v hevc_d3d12va -y output_1920x1280.mp4
2025-12-07 21:22:23 +00:00
Lynne 3ed8c1eb8a forgejo/labeler: automatically flag Vulkan-related commits #20118 2025-12-07 19:41:58 +00:00
Oliver Chang 9849a274df avcodec/dpx: Fix heap-buffer-overflow in 16-bit decoding
Fixes a heap-buffer-overflow in `libavcodec/dpx.c` triggered by a stale
`unpadded_10bit` flag in the `DPXDecContext`. This flag, set for 10-bit
unpadded frames, persisted across `decode_frame` calls. If a subsequent
frame was 16-bit, the stale flag caused incorrect buffer size
validation, allowing truncated buffers to pass checks designed for
smaller 10-bit packed data. This led to an out-of-bounds read in
`av_image_copy_plane` during 16-bit decoding.

The fix explicitly resets `dpx->unpadded_10bit = 0` at the start of
`decode_frame` to ensure correct validation for each frame.

Fixes: https://issues.oss-fuzz.com/issues/464471792
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Fixes: out of array read
Fixes: 464471792/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DPX_DEC_fuzzer-5275522210004992
2025-12-07 19:41:02 +00:00
Marton Balint 07e3d760bf fate/filter-audio: add amerge layout_mode test
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-12-07 19:36:49 +00:00
Marton Balint 315446da2f avfilter/af_amerge: fix indentation
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-12-07 19:36:49 +00:00
Marton Balint 3d667b147a avfilter/af_amerge: add layout_mode option to control output channel layout
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-12-07 19:36:49 +00:00
Marton Balint 4e0a8b745a avfilter/af_amerge: rework routing calculation
No change in functionality.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-12-07 19:36:49 +00:00
Marton Balint e8b10a9b09 avfilter/af_amerge: fix possible crash with custom layouts
The check if a native layout can be created from the sources was incomplete and
casued a crash with custom layouts if the layout contained a native channel
multiple times, as in this example command line:

ffmpeg -lavfi "sine[a0];sine,pan=FL+FL[a1];[a0][a1]amerge[aout]" -map "[aout]" -t 1 -f framecrc -

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-12-07 19:36:49 +00:00
caifan3 40d7f7774a avformat/unix: add pkt_size option
Add a "pkt_size" AVOption to the Unix domain socket protocol. This option
allows the user to specify the maximum packet size for packet-oriented
sockets (SOCK_DGRAM and SOCK_SEQPACKET).

Signed-off-by: caifan3 <caifan3@xiaomi.com>
2025-12-07 19:36:03 +00:00
Rémi Denis-Courmont 10ea5f8b99 lavc/h264idct: R-V V 9-bit h264_luma_dc_dequant_idct
Note that, like the C reference, the same function can be used for
larger bit depths.
2025-12-07 20:27:35 +02:00
Rémi Denis-Courmont d69a36a8d1 lavc/h264idct: R-V V 8-bit h264_luma_dc_dequant_idct
This does not improve performance with current hardware due to the poor
performance of segmented accesses. Performance should be slightly better
with expensive or near-future hardware that I don't have, however it is
still limited by two other factors:
- There are only 4 elements.
- The final stores are necessarily indexed and hit multiple cache lines,
  thus as slow as scalar.
2025-12-07 20:27:35 +02:00
Rémi Denis-Courmont f222eb2b08 lavc/mpv_unquantize: R-V V H.263 DCT unquantize
SpacemiT X60:
dct_unquantize_h263_inter_c:                           417.8 ( 1.00x)
dct_unquantize_h263_inter_rvv_i32:                      66.0 ( 6.33x)
dct_unquantize_h263_intra_c:                           140.2 ( 1.00x)
dct_unquantize_h263_intra_rvv_i32:                      67.7 ( 2.07x)

Note that the C benchmarks are not stable, depending heavily on the
number of coefficients picked by the RNG. The R-V V benchmarks are
however very stable and generally better than C's.
2025-12-07 20:20:38 +02:00
averne c384b1e803 vulkan/prores: use vkCmdClearColorImage
The VK spec forbids using clear commands on YUV images,
so we need to allocate separate per-plane images.
This removes the need for a separate reset shader.
2025-12-07 18:17:36 +00:00
Marvin Scholz facc32b0d8 .forgejo/labeler: consistently quote strings 2025-12-07 16:24:10 +00:00
James Almer 00caeba050 avcodec: rename avcodec_receive_frame2 to avcodec_receive_frame_flags
It's a name that communicates its functionality in a better way.
Since the function was introduced very recently, we can safely rename it.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-07 12:47:46 -03:00
Michael Niedermayer 88f26718a0 avcodec/decode: Fix build due to ff_thread_receive_frame()
Regression since: 5e56937b74

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-07 11:58:01 +01:00
Kacper Michajłow 6a14a93af5 checkasm/sw_xyz2rgb: fix function type
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-05 21:55:03 +00:00
Niklas Haas 929a2ced9b fftools/ffmpeg_dec: decode the first frame synchronously
In an ideal world, a filtergraph like `-i A -i B ... -filter_complex concat`
would only keep resources in memory related to the file currently being output
by the concat filter. So ideally, we'd open and fully decode A, then open and
fully decode B, and so on.

Practically, however, fftools wants to get one frame from each input file in
order to initialize the filter graph (buffersrc parameters). So what happens
currently is that fftools will request a single frame from each input A, B, etc
that is plugged into the filtergraph.

When using frame threading, the design of the decoder (ff_thread_receive_frame)
is that it will not output any frames until we have received enough packets to
saturate all threads. This, however, forces the decoder to buffer at least as
many frames for each input file as we have threads, before outputting anything.

By decoding the first frame synchronously, we avoid this issue and allow
configuring the filter graph more quickly and without wasting excess resources
on frames that will not (yet) be used.
2025-12-05 19:42:45 +01:00
Niklas Haas 5e56937b74 avcodec: allow bypassing frame threading with an optional flag
Normally, this function tries to make sure all threads are saturated with
work to do before returning any frames; and will continue requesting packets
until that is the case.

However, this significantly slows down initial decoding latency when only
requesting a single frame (to e.g. configure the filter graph), and also
wastes a lot of unnecessary memory in the event that the user does not intend
to decode more frames until later.

By introducing a new `flags` paramater and a new flag
`AV_CODEC_RECEIVE_FRAME_FLAG_SYNCHRONOUS` to go along with it, we can allow
users to temporarily bypass this logic.
2025-12-05 19:42:41 +01:00
Araz Iusubov 077864dfd6 avcodec/amf: fix hw_device_ctx handling 2025-12-05 15:53:19 +00:00
Zhao Zhili d3953237d1 avcodec/h264_slice: don't force ff_get_format unconditionally after flush
h->context_initialized is zero after flush, which triggers call to
ff_get_format unconditionally. ff_get_format can be heavy with
ff_hwaccel_uninit and hwaccel_init. For example, it takes 20 ms on
macOS with videotoolbox. ff_get_format should not be called if
nothing changed. ff_get_format is guarantee to be called at the
first time and when video information changed with
(must_reinit || needs_reinit).

Fix #20760.
2025-12-05 13:54:08 +00:00
Andreas Rheinhardt 1d47ae65bf avcodec/tableprint_vlc: Unbreak hardcoded tables
Forgotten in d8ffec5bf9.
Fixes issue #21102.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-05 11:31:23 +01:00
Arpad Panyik 1f30ff30fb swscale: Add AArch64 Neon path for xyz12Torgb48 LE
Add optimized Neon code path for the little endian case of the
xyz12Torgb48 function. The innermost loop processes the data in 4x2
pixel blocks using software gathers with the matrix multiplication
and clipping done by Neon.

Relative runtime of micro benchmarks after this patch on some
Cortex and Neoverse CPU cores:

 xyz12le_rgb48le    X1      X3      X4    X925      V2
 16x4_neon:       2.55x   4.34x   3.84x   3.31x   3.22x
 32x4_neon:       2.39x   3.63x   3.22x   3.35x   3.29x
 64x4_neon:       2.37x   3.31x   2.91x   3.33x   3.27x
 128x4_neon:      2.34x   3.28x   2.91x   3.35x   3.24x
 256x4_neon:      2.30x   3.17x   2.91x   3.32x   3.10x
 512x4_neon:      2.26x   3.10x   2.91x   3.30x   3.07x
 1024x4_neon:     2.26x   3.07x   2.96x   3.30x   3.05x
 1920x4_neon:     2.26x   3.06x   2.93x   3.28x   3.04x

 xyz12le_rgb48le   A76     A78    A715    A720    A725
 16x4_neon:       2.33x   2.28x   2.53x   3.33x   3.19x
 32x4_neon:       2.35x   2.18x   2.45x   3.23x   3.24x
 64x4_neon:       2.35x   2.16x   2.42x   3.15x   3.21x
 128x4_neon:      2.35x   2.13x   2.39x   3.00x   3.09x
 256x4_neon:      2.36x   2.12x   2.35x   2.85x   2.99x
 512x4_neon:      2.35x   2.14x   2.35x   2.78x   2.95x
 1024x4_neon:     2.31x   2.09x   2.33x   2.80x   2.91x
 1920x4_neon:     2.30x   2.07x   2.32x   2.81x   2.94x

 xyz12le_rgb48le   A55    A510    A520
 16x4_neon:       2.09x   1.92x   2.36x
 32x4_neon:       2.05x   1.89x   2.38x
 64x4_neon:       2.02x   1.77x   2.35x
 128x4_neon:      1.96x   1.74x   2.25x
 256x4_neon:      1.90x   1.72x   2.19x
 512x4_neon:      1.83x   1.75x   2.16x
 1024x4_neon:     1.83x   1.62x   2.15x
 1920x4_neon:     1.82x   1.60x   2.15x

Signed-off-by: Arpad Panyik <Arpad.Panyik@arm.com>
2025-12-05 10:28:18 +00:00
Arpad Panyik a13871ae19 checkasm: Add xyz12Torgb48le test
Add checkasm coverage for the XYZ12LE to RGB48LE path via the
ctx->xyz12Torgb48 hook. Integrate the test into the build and runner,
exercise a variety of widths/heights, compare against the C reference,
and benchmark when width is multiple of 4.

This improves test coverage for the new function pointer in preparation
for architecture-specific implementations in subsequent commits.

Signed-off-by: Arpad Panyik <Arpad.Panyik@arm.com>
2025-12-05 10:28:18 +00:00
Arpad Panyik ef651b84ce swscale: Refactor XYZ+RGB state and add function hooks
Prepare for xyz12Torgb48 architecture-specific optimizations in
subsequent patches by:
 - Grouping XYZ+RGB gamma LUTs and 3x3 matrices into SwsColorXform
   (ctx->xyz2rgb and ctx->rgb2xyz), replacing scattered fields.
 - Dropping the unused last matrix column giving the same or smaller
   SwsInternal size.
 - Renaming ff_xyz12Torgb48 and ff_rgb48Toxyz12 and routing calls via
   the new per-context function pointer (ctx->xyz12Torgb48 and
   ctx->rgb48Toxyz12) in graph.c and swscale.c.
 - Adding ff_sws_init_xyzdsp and invoking it in swscale init paths
   (normal and unscaled).
 - Making fill_xyztables public to ease its setup later in checkasm.

These modifications do not introduce any functional changes.

Signed-off-by: Arpad Panyik <Arpad.Panyik@arm.com>
2025-12-05 10:28:18 +00:00
Andreas Rheinhardt 9e038fd959 swscale/tests/swscale: Fix typo
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-05 10:42:01 +01:00
James Almer 52c84b06d5 avfilter/f_sidedata: also handle global side data in filter links
Should fix issue #21071

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-04 13:50:45 -03:00
Andreas Rheinhardt e0845ec2cf avformat/movenc: Fix leak of IAMFContext on error
Forgotten in 5b87869c09.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 16:15:09 +00:00
Lynne f80addbb07 ffv1enc_vulkan: fix encoding with large contexts
When RGB_LINECACHE == 2, then top2 is not the current line.
2025-12-04 16:53:58 +01:00
Andreas Rheinhardt 4b6e40a298 avcodec/vp8dsp: Don't compile unused functions
The width 16 epel functions never use four taps in any direction*,
so don't build said functions. Saves 4352B of .text and 89B of
.text.unlikely here.

*: mx and my in vp8_mc_luma() are always even.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 9cff236e2f avcodec/riscv/vp8dsp_rvv: Remove unused functions
Only the sixtap functions are used for size 16.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 050c80a526 avcodec/x86/vp8dsp: Don't use saturated addition when unnecessary
For the epel functions, there can be no overflow as long as the sum
contains only one of the two large central coefficients; for bilinear
functions, there can be no overflow whatsoever.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 575e9e9c08 avcodec/x86/vp8dsp: Reduce number of coefficient tables
By changing the permutations used in the epel8_h{4,6} case
we can simply reuse the coefficient tables from the vertical epel
filters.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 99fb257f58 avcodec/x86/vp8dsp: Don't use MMX registers in ff_put_vp8_epel4_h6_ssse3
Doubling the register width allowed to avoid a pshufb and a pmaddubsw.

Old benchmarks:
vp8_put_epel4_h6_c:                                    115.9 ( 1.00x)
vp8_put_epel4_h6_ssse3:                                 20.2 ( 5.74x)
vp8_put_epel4_h6v4_c:                                  276.3 ( 1.00x)
vp8_put_epel4_h6v4_ssse3:                               58.6 ( 4.71x)
vp8_put_epel4_h6v6_c:                                  363.6 ( 1.00x)
vp8_put_epel4_h6v6_ssse3:                               62.5 ( 5.82x)

New benchmarks:
vp8_put_epel4_h6_c:                                    116.4 ( 1.00x)
vp8_put_epel4_h6_ssse3:                                 16.0 ( 7.29x)
vp8_put_epel4_h6v4_c:                                  280.9 ( 1.00x)
vp8_put_epel4_h6v4_ssse3:                               44.3 ( 6.33x)
vp8_put_epel4_h6v6_c:                                  365.6 ( 1.00x)
vp8_put_epel4_h6v6_ssse3:                               53.1 ( 6.89x)

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 3135bc0d3a avcodec/x86/vp8dsp: Don't use MMX registers in ff_put_vp8_epel4_h4_ssse3
Doubling the register width allows to use only one pshufb and pmaddubsw.

Old benchmarks:
vp8_put_epel4_h4_c:                                     82.8 ( 1.00x)
vp8_put_epel4_h4_ssse3:                                 13.9 ( 5.96x)

New benchmarks:
vp8_put_epel4_h4_c:                                     82.7 ( 1.00x)
vp8_put_epel4_h4_ssse3:                                 11.7 ( 7.08x)

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 714cbf1c70 avcodec/x86/vp8dsp: Don't use MMX registers in ff_put_vp8_epel4_v4_ssse3
Switching to xmm registers allows to process two rows in parallel,
leading to speedups. It is also ABI compliant (no more missing emms).

Old benchmarks:
vp8_put_epel4_v4_c:                                     96.8 ( 1.00x)
vp8_put_epel4_v4_ssse3:                                 28.2 ( 3.43x)

New benchmarks:
vp8_put_epel4_v4_c:                                     95.1 ( 1.00x)
vp8_put_epel4_v4_ssse3:                                 22.8 ( 4.17x)

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt f017806829 avcodec/x86/vp8dsp: Don't use MMX registers in ff_put_vp8_epel4_v6_ssse3
Switching to xmm registers allows to process two rows in parallel,
leading to speedups. It is also ABI compliant (no more missing emms).

Old benchmarks:
vp8_put_epel4_v6_c:                                    132.8 ( 1.00x)
vp8_put_epel4_v6_ssse3:                                 34.3 ( 3.87x)

New benchmarks:
vp8_put_epel4_v6_c:                                    131.5 ( 1.00x)
vp8_put_epel4_v6_ssse3:                                 27.1 ( 4.86x)

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 7411998757 avcodec/x86/vp8dsp: Avoid unpacking multiple times
Always pair row i with row i+2 for the vertical four-tap filter
and row i+3 for the vertical six-tap filter (instead of pairing
the first with the sixth, the second with the third and the fourth
and the fifth). This allows to unpack each row only once instead
of (at most) three times.

Old benchmarks:
vp8_put_epel4_v4_c:                                     98.4 ( 1.00x)
vp8_put_epel4_v4_ssse3:                                 28.6 ( 3.44x)
vp8_put_epel4_v6_c:                                    131.6 ( 1.00x)
vp8_put_epel4_v6_ssse3:                                 38.5 ( 3.42x)
vp8_put_epel8_v4_c:                                    362.5 ( 1.00x)
vp8_put_epel8_v4_sse2:                                  63.8 ( 5.68x)
vp8_put_epel8_v4_ssse3:                                 44.4 ( 8.16x)
vp8_put_epel8_v6_c:                                    538.3 ( 1.00x)
vp8_put_epel8_v6_sse2:                                  86.5 ( 6.22x)
vp8_put_epel8_v6_ssse3:                                 57.0 ( 9.44x)
vp8_put_epel16_v6_c:                                  1044.6 ( 1.00x)
vp8_put_epel16_v6_sse2:                                158.0 ( 6.61x)
vp8_put_epel16_v6_ssse3:                               106.7 ( 9.79x)

New benchmarks:
vp8_put_epel4_v4_c:                                    100.0 ( 1.00x)
vp8_put_epel4_v4_ssse3:                                 28.4 ( 3.52x)
vp8_put_epel4_v6_c:                                    131.7 ( 1.00x)
vp8_put_epel4_v6_ssse3:                                 34.3 ( 3.84x)
vp8_put_epel8_v4_c:                                    364.4 ( 1.00x)
vp8_put_epel8_v4_sse2:                                  63.7 ( 5.72x)
vp8_put_epel8_v4_ssse3:                                 43.3 ( 8.42x)
vp8_put_epel8_v6_c:                                    550.2 ( 1.00x)
vp8_put_epel8_v6_sse2:                                  86.4 ( 6.37x)
vp8_put_epel8_v6_ssse3:                                 52.9 (10.40x)
vp8_put_epel16_v6_c:                                  1052.5 ( 1.00x)
vp8_put_epel16_v6_sse2:                                158.3 ( 6.65x)
vp8_put_epel16_v6_ssse3:                                98.9 (10.64x)

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 24cdd4100d avcodec/x86/vp8dsp_init: Remove unused macro
Forgotten in 6a551f1405.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 76900089fb avcodec/x86/vp8dsp: Avoid reload
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 86aa1b81ec avcodec/x86/vp8dsp: Increment src pointer earlier
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt e59ed3470d avcodec/x86/vp8dsp: Directly use negated stride
There is a register available. No change in benchmarks here.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 8fb6b0c733 avcodec/x86/vp8dsp: Don't use MMX registers in put_vp8_pixels8
Use GPRs on x64 and xmm registers else (using GPRs reduces codesize).
This avoids clobbering the floating point state and therefore no longer
breaks the ABI.
No change in benchmarks here.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:36 +01:00
Andreas Rheinhardt ed5e0f9c68 avcodec/x86/vp8dsp: Remove MMXEXT functions overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMX(EXT) functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:36 +01:00
Lynne 9b14ea0aa1 vulkan_dpx: fix alignment issue
12-bit images apparently require mod-32 alignment for each line.
Go figure.
2025-12-04 15:08:46 +01:00
Oliver Chang d6458f6a8b avcodec/aacdec: Fix heap-use-after-free in USAC decoding
A heap-use-after-free vulnerability was identified in
`libavcodec/aac/aacdec.c`.  When `che_configure` frees a
`ChannelElement` (`ac->che[type][id]`), it failed to clear all
references to it in `ac->tag_che_map`.  `ac->tag_che_map` caches
pointers to `ChannelElement`s and can contain cross-type mappings (e.g.,
a `TYPE_SCE` tag mapping to a `TYPE_LFE` element).

In a USAC stream reconfiguration scenario, an LFE element was freed, but
a stale pointer remained in `ac->tag_che_map`. Subsequent calls to
`ff_aac_get_che` returned this dangling pointer, leading to a crash in
`decode_usac_core_coder`.

This commit fixes the issue by iterating over the entire
`ac->tag_che_map` in `che_configure` and clearing any entries that point
to the `ChannelElement` about to be freed, ensuring no dangling pointers
remain.

Fixes: https://issues.oss-fuzz.com/issues/440220467
2025-12-04 09:34:32 +00:00
Xia Tao 7922d4ca7d avcodec/wasm/hevc: fix typo in butterfly macro
Signed-off-by: Xia Tao <xiatao@gmail.com>
2025-12-04 08:40:43 +00:00
stevxiao 7b2ae2ccf7 avcodec/d3d12va_encode: add intra refresh support for d3d12va encode
Intra refresh is a technique that gradually refreshes the video by encoding rows or regions as intra macroblocks/CTUs spread over multiple frames, rather than using periodic I-frames.
This provides better error resilience for video streaming while maintaining more consistent bitrate.

Disable Intra Refresh (This is the default)
ffmpeg -init_hw_device d3d12va -hwaccel d3d12va -hwaccel_output_format d3d12 \
-i input.mp4 \
-c:v h264_d3d12va \
-intra_refresh_mode none \
-intra_refresh_duration 30 \
-g 60 \
output.h264

Enable Intra Refresh
ffmpeg -init_hw_device d3d12va -hwaccel d3d12va -hwaccel_output_format d3d12 \
-i input.mp4 \
-c:v h264_d3d12va \
-intra_refresh_mode row_based \
-intra_refresh_duration 30 \
-g 60 \
output.h264

Parameters
- `-intra_refresh_mode`: Set to `row_based` to enable row-based intra refresh, or `NONE` to disable
- `-intra_refresh_duration`: Number of frames over which to spread the intra refresh (default: 0 = use GOP size)
- `-g`: GOP size (should typically be larger than intra refresh duration)
2025-12-04 08:26:26 +00:00
Michael Niedermayer 12e7d095b1 Revert "avformat/rawdec: set framerate in codec parameters"
Fixes single image videos
this works and creates our single image video
./ffmpeg -i lena.pnm /tmp/file.m2v

this fails after 3d96d83a0a:
./ffmpeg -i /tmp/file.m2v /tmp/file.jpg -y

This reverts commit 3d96d83a0a.
2025-12-04 01:59:04 +00:00
Kacper Michajłow 9ed71a837b avutil/vulkan: fix device memory size truncation
size_t cannot fit VK_WHOLE_SIZE on 32-bit builds.

Fixes: warning: conversion from 'long long unsigned int' to 'size_t' {aka 'unsigned int'} changes value from '18446744073709551615' to '4294967295'

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-03 23:45:44 +00:00
Kacper Michajłow 3cc10b5ff6 fftools/cmdutils: use strcpy directly, the length is computed already
There is no need to scan for NULL, if we inject it ourselves.

Fixes: warning: 'strncat' specified bound 10 equals source length [-Wstringop-overflow=]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-03 23:45:44 +00:00
Kacper Michajłow f7b7972f78 avdevice/gdigrab: suppress int to pointer cast warning
Fixes: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-03 23:45:44 +00:00
wutno f4312ea138 avformat/xmv: Handle zero sized packet at end of file
Some XMVs introduce a blank packet at the end of the stream. Previously, we
didn't account for this and returned AVERROR_INVALIDDATA, indicating an issue
with the file. Instead, let's check for this and close out with AVERROR_EOF.
2025-12-03 22:09:20 +00:00
Lynne a8e8daa276 hwcontext_vulkan: fix final error to let old header files work
........
2025-12-03 22:34:32 +01:00
Jack Lau c4b050fd67 tests/fate/filter-video: add two feedback tests
- Add fate-filter-feedback-yadif

- add fate-filter-feedback-hflip

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2025-12-03 21:23:51 +00:00
Jack Lau 3f0842294f avfilter/vf_feedback: fix feedback block
Fix #20940

The feedback and its sub-filter both request frame
from each other, casuing block since 4440e499ba

The feedback should only request inputs[1] once
rather than continuously request frame cause blocking.

This patch add check whether feedback already request
inputs[1] via ff_outlink_frame_wanted(ctx->outputs[1]),
if true, then exit and waiting inputs[0] because it means
we need more frames input to proceed.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2025-12-03 21:23:51 +00:00
Lynne bce14bb160 hwcontext_vulkan: fix compilation with older header versions 2025-12-03 21:22:54 +01:00
Oliver Chang 041d4f010e libavcodec/prores_raw: Fix heap-buffer-overflow in decode_frame
Fixes a heap-buffer-overflow in `decode_frame` where `header_len` read
from the bitstream was not validated against the remaining bytes in the
input buffer (`gb`). This allowed `gb_hdr` to be initialized with a size
exceeding the actual packet data, leading to an out-of-bounds read.

The fix adds a check to ensure `bytestream2_get_bytes_left(&gb)` is
greater than or equal to `header_len - 2` before initializing `gb_hdr`.

Fixes: https://issues.oss-fuzz.com/issues/439711053
2025-12-03 16:40:02 +00:00
Andreas Rheinhardt e3e3265034 tests/checkasm/mpegvideo_unquantize: Add missing const
Fixes this test under UBSan:
runtime error: call to function dct_unquantize_mpeg1_intra_c through pointer to incorrect function type 'void (*)(struct MpegEncContext *, short *, int, int)'
I don't know how I could forget this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 14:17:58 +01:00
Martin Storsjö b98179cec6 avcodec/{arm,neon}/mpegvideo: Readd a missed initialization
This was accidentally removed in
357fc5243c.

This fixes test failures when built with Clang and MSVC;
surprisingly, the checkasm test did seem to pass when built with
GCC. Clang and MSVC also warn about the use of the uninitialized
variable, while GCC didn't.
2025-12-03 13:53:54 +02:00
Andreas Rheinhardt 5d9270df7f libavutil/internal: Remove {SIZE,PTRDIFF}_SPECIFIER
Possible since 222127418b.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 11:52:54 +01:00
Andreas Rheinhardt c22c2c5e03 avcodec/mpegvideo: Port dct_unquantize_mpeg2_intra_mmx to SSE2
Benefits from wider registers.

Benchmarks:
dct_unquantize_mpeg2_intra_c:                          228.2 ( 1.00x)
dct_unquantize_mpeg2_intra_mmx:                         28.2 ( 8.10x)
dct_unquantize_mpeg2_intra_sse2:                        18.4 (12.37x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 6e2153111d avcodec/x86/mpegvideo: Port dct_unquantize_mpeg2_inter_mmx to SSSE3
Benefits from wider registers, pabsw and psignw.

Benchmarks:
dct_unquantize_mpeg2_inter_c:                          131.2 ( 1.00x)
dct_unquantize_mpeg2_inter_mmx:                         50.2 ( 2.62x)
dct_unquantize_mpeg2_inter_ssse3:                       20.5 ( 6.38x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 60084b1369 avcodec/x86/mpegvideo: Port MPEG-1 unquantize functions to SSSE3
Benefits from wider registers and pabsw, psignw.

Benchmarks:
dct_unquantize_mpeg1_inter_c:                          343.0 ( 1.00x)
dct_unquantize_mpeg1_inter_mmx:                         50.6 ( 6.78x)
dct_unquantize_mpeg1_inter_ssse3:                       17.2 (19.94x)
dct_unquantize_mpeg1_intra_c:                          352.1 ( 1.00x)
dct_unquantize_mpeg1_intra_mmx:                         48.8 ( 7.22x)
dct_unquantize_mpeg1_intra_ssse3:                       19.5 (18.03x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 1cb987d25b avcodec/x86/mpegvideo: Port dct_unquantize_h263_{intra,inter}_mmx to SSSE3
It benefits from wider registers and psignw.

Benchmarks:
dct_unquantize_h263_inter_c:                            88.3 ( 1.00x)
dct_unquantize_h263_inter_mmx:                          24.7 ( 3.58x)
dct_unquantize_h263_inter_ssse3:                         9.3 ( 9.47x)
dct_unquantize_h263_intra_c:                            93.7 ( 1.00x)
dct_unquantize_h263_intra_mmx:                          30.6 ( 3.06x)
dct_unquantize_h263_intra_ssse3:                        16.5 ( 5.69x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt a9a23925df avcodec/x86/mpegvideo: Don't duplicate register
Currently several inline ASM blocks used a value as
an input and rax as clobber register. The input value
was just moved into the register which then served as loop
counter. This is wasteful, as one can just use the value's
register directly as loop counter.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 1fa8ffc1db avcodec/x86/mpegvideo: Improve unquantizing MPEG-2 intra blocks
Unquantizing involves calculating
    (block[j] * qscale * quant_matrix[j]) / 16
where / rounds towards zero. Arithmetic right shifts
naturally round towards -inf, so the earlier code
calculated the absolute value first, then used a right-shift
and then negated the result if necessary.

This commit uses a different procedure: It biases the product
for negative values of block[j] by 0xf. The combination of
this and the arithmetic right shift is the same as rounding
towards zero.

Furthermore, a write-only store to mm7 has been removed.

Benchmarks:
dct_unquantize_mpeg2_intra_c:                          214.3 ( 1.00x)
dct_unquantize_mpeg2_intra_mmx (old):                   43.0 ( 4.98x)
dct_unquantize_mpeg2_intra_mmx (new):                   28.4 ( 7.56x)

(The bitexact flag and the test for correctness have beem removed
from checkasm for the benchmarks.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 6d56807a06 avcodec/x86/mpegvideo: Use correct inline assembly constraints
The H.263 unquantize functions modified an input parameter.
(And they did so since this code was added in
7f3f5ec87b. I am surprised
that this didn't cause issues, particularly with the intra function.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 0f7cc6aeea avcodec/mpegvideo: Move ff_init_scantable() to mpegvideo_unquantize.c
This is necessary so that the mpegvideo_unquantize checkasm test
does not pull mpegvideo.o and then all of libavcodec into checkasm.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 357fc5243c avcodec/{arm,neon}/mpegvideo: Fix h263 unquantize functions
These functions currently operate on the assumption that the number
of coefficients to process is always of the form 16k+m with m<=4 or >8.
Yet this is not true when the IDCT permutation is of type FF_IDCT_PERM_LIBMPEG2
(i.e. when FF_IDCT_INT is in use).

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:39 +01:00
Andreas Rheinhardt 581050a175 tests/checkasm: Add mpegvideo unquantize test
This adds a test for the mpegvideo unquantize functions.

It has been written in order to be able to easily bench
these functions. It should be noted that the random input
fed to the tested functions is not necessarily representative
of the stuff actually occuring in the wild. So benchmarks should
be taken with a grain of salt; but comparisons between two functions
that do not depend on branch predictions are valid (the usecase
for this is to port the x86 mmx functions to use xmm registers).

During testing I have found a bug in the arm/aarch64 neon optimizations
when using the LIBMPEG2 permutation (used by FF_IDCT_INT): The code
seems to be based on the presumption that the remainder of the number
of coefficients to process is always <= 4 mod 16. The test therefore
sometimes fails for these arches.

Hint: I am not certain that 16 bits are enough for the intermediate
values of all the computations involved; e.g. both FLV and MPEG-4
escape values can go beyond that after the corresponding
multiplications. The input in this test is nevertheless designed
to fit into 16 bits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:39 +01:00
Andreas Rheinhardt e7a629049f avcodec/{arm,neon}/mpegvideo: Use intra scantable to unquant H263 intra
Forgotten in 70a7df049c.

Using the wrong scantable matters for codecs for which both scantables
can differ, namely the MPEG-4 decoder and the WMV1/2 codecs.

For WMV1 it can lead to wrong output in case the IDCT permutation
is FF_IDCT_PERM_PARTTRANS, because in this case the entries of
of the intra scantable's raster end are not always <= the corresponding
entries of the inter scantable's raster end when the former is
initialized via ff_wmv1_scantable[1] and the latter via ff_wmv1_scantable[0].
FF_IDCT_PERM_PARTTRANS is used iff the Neon IDCT is used (for both arm
and aarch64).* Said IDCT is not used during FATE, so that this issue
went unnoticed.

WMV2 uses the same scantables, but uses a custom IDCT
which always uses FF_IDCT_PERM_NONE for which the inter_scantable,
so that the output is always correct for it.

The scantable for MPEG-4 can change mid-stream (for the decoder),
but since c41818dc5d only the intra
scantable is updated, so that both scantables can get out of sync.
In such a case the unquantize intra functions could unquantize
an incorrect number of coefficients.

Using raster_end of the wrong scantable can also lead to an
unnecessarily large amount of coefficients unquantized.

*: FF_IDCT_PERM_SIMPLE and FF_IDCT_PERM_TRANSPOSE would also not work,
but they are not used at all by arm and aarch64.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:20:42 +01:00
Andreas Rheinhardt 5d41d3e21d avcodec/ppc/mpegvideo_altivec: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:20:42 +01:00
Andreas Rheinhardt 011ef7fc65 avcodec/ppc/mpegvideo_altivec: Split intra/inter unquantizing
Don't use a single function that checks mb_intra. Forgotten
in d50635cd24.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:20:42 +01:00
Andreas Rheinhardt 358c569b05 avcodec/mpegvideo_unquantize: Constify MPVContext pointee
Also use MPVContext instead of MpegEncContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:20:41 +01:00
yuanhecai f7551e7505 avcodec: fix checkasm-hpeldsp failed on LA 2025-12-03 01:36:01 +00:00
Zhao Zhili 413346bd06 tests/fate/ffmpeg: add test for -force_key_frames scd_metadata 2025-12-02 03:03:55 +00:00
Zhao Zhili 540aacf759 fftools/ffmpeg: add force key frame by scdet metadata support
For example:

./ffmpeg -hwaccel videotoolbox \
	-i input.mp4 -c:a copy \
	-vf scdet=threshold=10 \
	-c:v h264_videotoolbox \
	-force_key_frames scd_metadata \
	-g 1000 -t 30 output.mp4
2025-12-02 03:03:55 +00:00
Thomas Gritzan 27e94281d1 libavdevice/decklink: add support for DeckLink SDK 14.3
This patch adds support for DeckLink SDK 14.3 and newer by using
the legacy interfaces in the header <DeckLinkAPI_v14_2_1.h>.

The missing QueryInterface implementations are also provided.
2025-12-01 21:37:12 +00:00
averne 1e90047fe6 vulkan: fix host copy stride
memoryRowLength is is texels, not bytes
2025-12-01 15:40:40 +01:00
llyyr 7043522fe0 avutil/hwcontext_d3d12va: use hwdev context for logging
This fixes warning about av_log being called with NULL AVClass. This is
also an API violation

Fixes: https://trac.ffmpeg.org/ticket/11335
2025-12-01 03:15:25 +00:00
Lynne 932a872dbc hwcontext_vulkan: fix VkImageToMemoryCopyEXT.sType
It was copy pasted from the upload path.
Somehow, it was missed, despite god knows how many validation layer runs.
2025-11-30 23:11:46 +01:00
Kacper Michajłow 17456c553e tests/checkasm: fix check for 32-bit Windows build
With --disable-asm, ARCH_X86_32 is set to 0, but we still build the
checkasm binary. Update the check so it is config.h agnostic.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-30 22:07:39 +00:00
Russell Greene 3beaa2d70f hwcontext_vulkan: remove VK_HOST_IMAGE_COPY_MEMCPY flag
Reading the spec for what this flag means, it copies the data verbatim, including any swizzling/tiling, this has two issues

1. the format may not be what ffmpeg expects elsewhere, as it is expecing normal pitch linear host memeory in `swf`
2. the size of the copied data may not match the size of buffer provided, causing heap buffer overflow

It seems like addition of this flag is an oversight as it seems to be for caching/backups of image data, just to be used with copying back to the GPU with the MEMCPY flag, which is *not* how its used in ffmpeg.

Additionally, set memoryRowLength as if it isn't set, it assumes pitch = width_in_bytes, which I don't think is necessarily the case
2025-11-30 21:47:12 +00:00
Andreas Rheinhardt 59d75bf9e4 avutil/x86/Makefile: Only compile ASM init files when X86ASM is enabled
To do so, simply add these init files to X86ASM-OBJS instead of OBJS
in the Makefile. The former is already used for the actual assembly
files, but using them for the C init files just works, because the build
system uses file extensions to derive whether it is a C or a NASM file.

This avoids compiling unused function stubs and also reduces our
reliance on DCE: We don't add %if checks to the asm files except
for AVX, AVX2, FMA3, FMA4, XOP and AVX512, so all the MMX-SSE4
functions will be available. It also allows to remove HAVE_X86ASM checks
in these init files.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 22:20:13 +01:00
Andreas Rheinhardt d5a47bf2b3 swresample/x86/Makefile: Only compile ASM init files when X86ASM is enabled
To do so, simply add these init files to X86ASM-OBJS instead of OBJS
in the Makefile. The former is already used for the actual assembly
files, but using them for the C init files just works, because the build
system uses file extensions to derive whether it is a C or a NASM file.

This avoids compiling unused function stubs and also reduces our
reliance on DCE: We don't add %if checks to the asm files except
for AVX, AVX2, FMA3, FMA4, XOP and AVX512, so all the MMX-SSE4
functions will be available. It also allows to remove HAVE_X86ASM checks
in these init files.

(x86/ops.c has already been put in X86ASM-OBJS.)

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 22:20:13 +01:00
Andreas Rheinhardt 7356981bec avfilter/x86/Makefile: Only compile ASM init files when X86ASM is enabled
To do so, simply add these init files to X86ASM-OBJS instead of OBJS
in the Makefile. The former is already used for the actual assembly
files, but using them for the C init files just works, because the build
system uses file extensions to derive whether it is a C or a NASM file.

This avoids compiling unused function stubs and also reduces our
reliance on DCE: We don't add %if checks to the asm files except
for AVX, AVX2, FMA3, FMA4, XOP and AVX512, so all the MMX-SSE4
functions will be available. It also allows to remove HAVE_X86ASM checks
in these init files.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 22:20:13 +01:00
Andreas Rheinhardt eccf130fdb {lib{avcodec,swscale}/x86/,}Makefile: Kill MMX-OBJS
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 22:20:13 +01:00
Andreas Rheinhardt ba94177242 avcodec/x86/Makefile: Only compile ASM init files when X86ASM is enabled
To do so, simply add these init files to X86ASM-OBJS instead of OBJS
in the Makefile. The former is already used for the actual assembly
files, but using them for the C init files just works, because the build
system uses file extensions to derive whether it is a C or a NASM file.

This avoids compiling unused function stubs and also reduces our
reliance on DCE: We don't add %if checks to the asm files except
for AVX, AVX2, FMA3, FMA4, XOP and AVX512, so all the MMX-SSE4
functions will be available. It also allows to remove HAVE_X86ASM checks
in these init files.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 22:20:13 +01:00
Andreas Rheinhardt 65b4feb782 avcodec/x86/Makefile: Remove redundant WebP decoder->vp8dsp dependencies
Redundant since 35b02732b9.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 22:20:13 +01:00
averne 1d1643b42a vulkan/prores: use cached bitstream reader
Speedup is around 75% on NVIDIA 3050, 20% on AMD 6700XT, 5% on Intel TigerLake.
2025-11-30 22:01:17 +01:00
averne fd2fd3828c libavcodec/vulkan: remove unnessary member in GetBitContext
The number of remaining bits can be calculated using existing state.
This simplifies calculations and frees up one register.
2025-11-30 19:21:08 +01:00
averne ef7354d471 libavcodec/vulkan: introduce cached bitstream reader
This stores a small buffer in shared memory per decode thread (16 bytes),
which helps reduce the number of memory accesses.
The bitstream buffer is first aligned to a 4 byte boundary, so that the
buffer can be filled with a single memory request.
2025-11-30 19:21:04 +01:00
Kacper Michajłow 2456a39581 avfilter/avfiltergraph: fix constant string comparision
It's not guaranteed that the conversion filter name string will be
deduplicated to the same memory location. While this is common
optimization to do, we cannot rely on it always happening.

Fixes regression since 8b375b2ffd.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-30 03:02:41 +01:00
Andreas Rheinhardt 89f984e3d1 avcodec/x86/h264_idct: Fix ff_h264_luma_dc_dequant_idct_sse2 checkasm failures
ff_h264_luma_dc_dequant_idct_sse2() does not pass checkasm for certain
seeds, because the input to packssdw no longer fits into an int16_t,
leading to saturation, where the C code just truncates. I don't know
whether the spec contains provisions that ensure that valid input
must not exceed 16 bit or whether the such inputs (even if invalid)
can be triggered by the actual code and not only the test.

This commit adapts the behavior of the function to the C reference code
to fix the test. packssdw is avoided, instead the lower words are
directly transfered to GPRs to be written out. This has unfortunately
led to a slight performance regression here (14.5 vs 15.1 cycles).

Fixes issue #20835.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt e6ae2802a3 avcodec/x86/h264_idct: Deduplicate generating constant
pw_1 is currently loaded in both codepaths. Generate it earlier instead.
Gives tiny speedups (15 vs 14.5 cycles) and reduces codesize.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt ada0a81577 avcodec/x86/h264_idct: Don't use MMX registers in ff_h264_luma_dc_dequant_idct_sse2
It is ABI compliant and gives a tiny speedup here (and is 16B smaller).

Old benchmarks:
h264_luma_dc_dequant_idct_8_c:                          33.2 ( 1.00x)
h264_luma_dc_dequant_idct_8_sse2:                       16.0 ( 2.07x)

New benchmarks:
h264_luma_dc_dequant_idct_8_c:                          33.0 ( 1.00x)
h264_luma_dc_dequant_idct_8_sse2:                       15.0 ( 2.20x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt 012c25bac4 avcodec/x86/h264_idct: Zero with full-width stores
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt b9cbbd9074 avcodec/x86/h264_idct: Use tail call where advantageous
It is possible on UNIX64.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt 0ec9c1b68d avutil/x86/x86inc: Use parentheses in has_epilogue
Prevents surprises.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt 01ff05e4bc avcodec/x86/h264_idct: Avoid call where possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt b51cbd4116 avcodec/x86/h264_idct: Remove redundant movsxdifnidn
Only exported (i.e. cglobal) functions need it; stride is already
sign-extended when it reaches any of the internal functions used here,
so don't sign-extend again.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt 18019f177e avcodec/x86/h264idct: Remove dead MMX macros
Forgotten in 4618f36a24.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Kacper Michajłow 9cd4be6d7c tools/sofa2wavs: fix build on Windows
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-29 21:43:12 +00:00
averne 1c5bb1b12d vulkan/prores: normalize coefficients during IDCT
This allows increased internal precision.
In addition, we can introduce an offset to the DC coefficient
during the second IDCT step, to remove a per-element addition
in the output codepath.
Finally, by processing columns first we can remove the barrier
after loading coefficients.

Signed-off-by: averne <averne381@gmail.com>
2025-11-29 17:56:28 +01:00
averne 1982add485 vulkan/prores: fix dequantization for 4:2:2 subsampling
Bug introduced in d00f41f due to an oversight.
2025-11-29 17:27:21 +01:00
Niklas Haas 04eeaeed11 avfilter/vf_libplacebo: also rotate SAR when fitting 2025-11-29 08:45:24 +00:00
Niklas Haas f83fdad550 avfilter/vf_libplacebo: fix math when AVRationals are undefined 2025-11-29 08:45:24 +00:00
Niklas Haas 6e0034ab7e avfilter/vf_libplacebo: un-rotate image crop after fitting
When combining rotation with a FIT_ mode other than FIT_FILL, the fitting
logic was operating on the un-rotated rects, when it should have been
operating on the rotated (output) rects.
2025-11-29 08:45:24 +00:00
Piotr Pawlowski 372dab2a4d All: Removed reliance on compiler performing dead code elimination, changed various macro constant checks from if() to #if 2025-11-28 19:52:51 +01:00
Hao Chen a6206a31ea swscale: Fix out-of-bounds write errors in yuv2rgb_lasx.c file.
The patch adds support for dstw values ending in 2, 4, 6, 8, 10, 12, and 14,
which fixes the out-of-bounds write problem.
2025-11-28 03:40:47 +00:00
Ayose c1b86a009e tests/fate-filter-drawvg-video: copy drawvg.lines file to tests/data.
If the SRC_PATH variable contains certain characters (like a `:`, which may
happen when FATE is executed on Windows), the value for the `file` option is
broken, so `make fate-filter-drawvg-video` always fails.

The solution in this commit is to copy the `drawvg.lines` to the `tests/data`
directory (which already has temp files), so the value for `file` is a fixed
string with no problematic characters.

Signed-off-by: Ayose <ayosec@gmail.com>
2025-11-28 02:38:09 +00:00
Gavin Li 3d96d83a0a avformat/rawdec: set framerate in codec parameters
Commit ba4b73c977 caused a regression in
the usage of avg_frame_rate to detect the frame rate of raw h264/hevc
bitstreams: after the commit, avg_frame_rate is always the value of the
-framerate option (which is set to 25 by default) instead of the actual
frame rate derived from the bitstream SPS/VPS NALUs.

This commit fixes the regression by setting the framerate codec
parameter to the value of the framerate option instead. After this
change, bitstreams without timing information will derive avg_frame_rate
from the -framerate option, while bitstreams with timing information
will derive avg_frame_rate from the bitstream itself.

The h264-bsf-dts2pts test now returns the correct frame durations for a
bitstream with a mix of single-field and double-field frames.

Signed-off-by: Gavin Li <git@thegavinli.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-27 20:01:54 -03:00
James Almer 69534d4e7e avcodec/cavs_parser: parse sequence headers for stream parameters
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-27 20:01:54 -03:00
Diego de Souza 75b8567591 avfilter/scale_cuda: Add support for 4:2:2 chroma subsampling
The supported YUV pixel formats were separated between planar
and semiplanar. This approach reduces the number of CUDA kernels
for all pixel formats.

This patch:
1. Adds support for YUV 4:2:2 planar and semi-planar formats:
        yuv422p, yuv422p10, nv16, p210, p216
2. Implements new conversion structures and kernel definitions
        for planar and semi-planar formats

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2025-11-27 22:11:57 +01:00
Diego de Souza 04b5e25d35 avfilter/hwupload_cuda: Expands pixel formats support
Add support for uploading additional pixel formats to NVIDIA GPUs:
- Planar formats (yuv420p10, yuv422p, yuv422p10, yuv444p10)
- Semiplanar formats (nv16, p210, p216)

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2025-11-27 22:11:57 +01:00
Diego de Souza 9c76d7db86 avutil/hwcontext_cuda: Expands pixel formats support
Add support for additional pixel formats in CUDA hardware context:
- Planar formats (yuv420p10, yuv422p, yuv422p10, yuv444p10)
- Semiplanar formats (nv16, p210, p216)

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2025-11-27 22:11:57 +01:00
Thomas Gritzan 0cd75dbfa0 libavdevice/decklink: Implement QueryInterface to support newer driver
Playback to a decklink device with a newer version of the
DeckLink SDK (14.3) stalls because the driver code calls
IDeckLinkVideoFrame::QueryInterface, which is not
implemented by ffmpeg.
This patch implements decklink_frame::QueryInterface,
so that playback works with both older (12.x) and
newer (>= 14.3) drivers.

Note: The patch still does not allow the code to compile
with DeckLink SDK 14.3 or newer, as the API has changed.
2025-11-27 20:12:03 +00:00
Frank Plowman 5169b0c3dc lavc/vvc: Ensure seq_decode is always updated with SPS
seq_decode is used to ensure that a picture and all of its reference
pictures use the same SPS. Any time the SPS changes, seq_decode should
be incremented. Prior to this patch, seq_decode was incremented in
frame_context_setup, which is called after the SPS is potentially
changed in decode_sps. Should the decoder encounter an error between
changing the SPS and incrementing seq_decode, the SPS could be modified
while seq_decode was not incremented, which could lead to invalid
reference pictures and various downstream issues. By instead updating
seq_decode within the picture set manager, we ensure seq_decode and the
SPS are always updated in tandem.
2025-11-27 14:51:52 +00:00
Anthony Bajoua 93ccca22bb libavformat/mov: Fixes individual track duration on fragmented files 2025-11-27 14:05:33 +00:00
mux47 618fc15e65 libavcodec/opus/parser: Fix spurious 'Error parsing Opus packet header'
When PARSER_FLAG_COMPLETE_FRAMES is set, opus_parse() calls
set_frame_duration even on flush (buf_size==0), which triggers
a spurious "Error parsing Opus packet header" at EOF.

Match streaming-path behavior by skipping duration parsing on empty buffers.
Fixes #20954
2025-11-27 14:04:20 +00:00
Zhao Zhili cac5018eb9 avformat/mov: fix crash when stsz_sample_size is zero and sample_sizes is null
Co-Authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-27 14:03:06 +00:00
Andreas Rheinhardt f0f7834726 avcodec/cbs_apv: Use ff_cbs_{read,write}_simple_unsigned()
Avoids checks and makes the calls cheaper.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 14:00:45 +00:00
Andreas Rheinhardt 7018ce14df avcodec/x86/vp6dsp: Avoid packing+unpacking
Store the intermediate values as words, clipped to the 0..255 range
instead.

Old benchmarks:
filter_diag4_c:                                        353.4 ( 1.00x)
filter_diag4_sse2:                                      57.5 ( 6.15x)

New benchmarks:
filter_diag4_c:                                        350.6 ( 1.00x)
filter_diag4_sse2:                                      55.1 ( 6.36x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:49 +01:00
Andreas Rheinhardt 300cd2c2f2 avcodec/x86/vp6dsp: Avoid saturated addition
Only the two middle coefficients are so huge that overflow can happen.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:46 +01:00
Andreas Rheinhardt dcc101167c avcodec/x86/vp6dsp: Simplify splatting
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:43 +01:00
Andreas Rheinhardt 111fabf5b4 avcodec/x86/vp6dsp: Don't align the stack manually
For most systems (particularly all x64), the stack is already
guaranteed to be sufficiently aligned. So just use x86inc's
stack feature which does the right thing.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:40 +01:00
Andreas Rheinhardt 363a34a7cb avcodec/x86/vp6dsp: Fix outdated comment
Forgotten in 6cb3ee80b3.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:37 +01:00
Andreas Rheinhardt aabaab10d2 tests/checkasm: Test VP6DSP
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:34 +01:00
Andreas Rheinhardt 962858169a avcodec/vp6dsp: Constify source in vp6_filter_diag4
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:32 +01:00
Andreas Rheinhardt f397fe86c3 avcodec/vp56dsp: Separate VP5DSP and VP6DSP
They don't have anything in common since
160ebe0a8d.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:29 +01:00
Andreas Rheinhardt 5dadae9feb avcodec/vp56: Fix indentation
Forgotten in 160ebe0a8d.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:26 +01:00
Andreas Rheinhardt 8443940002 avcodec/arm/vp6dsp: Remove VP6 edge filter functions
Forgotten in 160ebe0a8d.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:08:45 +01:00
Andreas Rheinhardt 0ea961c070 avcodec/vp3: Redo updating frames
VP3's frame managment is actually simple: It has three frame slots:
current, last and golden. After having decoded the current frame,
the old last frame will be freed and replaced by the current frame.
If the current frame is a keyframe, it also takes over the golden slot.

The VP3 decoder handled this like this: In single-threaded mode,
the above procedure was carried out (on success). Doing so with
frame-threading is impossible, as it would lead to data races.
Instead vp3_update_thread_context() created new references
to these frames and then carried out said procedure.

This means that vp3_update_thread_context() is not just a "dumb"
function that only copies certain fields from src to dst; instead
it actually processes them. E.g. trying to copy the decoding state
from A to B and then from B to C (with no decode_frame call in between)
will not be equivalent to copying from A to C, as both current and last
frames will be blank in the first case.

This commit changes this: Because last_frame won't be needed after
decoding, no reference to it will be created to it in
vp3_update_thread_context(); instead it is now always unreferenced
after decoding it (even on error). Replacing last_frame with the new
frame is now always performed when the new frame is allocated.
Replacing the golden frame is now done earlier, namely in decode_frame()
before ff_thread_finish_setup(), so that update_thread_context only
has to reference current frame and golden frame. Being dumb means
that update_thread_context also no longer checks whether the current
frame is valid, so that it can no longer error out.

This unifies the single- and multi-threaded codepaths; it can lead
to changes in output in single threaded mode: When erroring out,
the current frame would be discarded and not be put into one
of the reference slots at all in single-threaded mode. The new
code meanwhile does everything as the frame-threaded code already did
in order to reduce discrepancies between the two. It would be possible
to keep the old single-threaded behavior (one would need to postpone
replacing the golden frame to the end of vp3_decode_frame and would
need to swap the current frame and the last frame on error,
unreferencing the former).

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 11:34:25 +01:00
Andreas Rheinhardt 2ca072e168 avcodec/vp3: Remove always-false checks
The dimensions are only set at two places: theora_decode_header()
and vp3_decode_init(). These functions are called during init
and during dimension changes, but the latter is only supported
(and attempted) when frame threading is not active. This implies that
the dimensions of the various worker threads in
vp3_update_thread_context() always coincide, so that these checks
are dead and can be removed.

(These checks would of course need to be removed when support
for dimension changes during frame threading is implemented;
and in any case, a dimension change is not an error.)

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 11:33:00 +01:00
Andreas Rheinhardt d52bca36ef avcodec/vp3: Move last_qps from context to stack
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 11:32:54 +01:00
Andreas Rheinhardt 90551b7d80 avcodec/vp3: Sync VLCs once during init, fix crash
6c7a344b65 made the VLCs shared between
threads and did so in a way that was designed to support stream
reconfigurations, so that the structure containing the VLCs was
synced in update_thread_context. The idea was that the currently
active VLCs would just be passed along between threads.

Yet this was broken by 5acbdd2264:
Before this commit, submit_packet() was a no-op during flushing
for VP3, as it is a no-delay decoder, so it won't produce any output
during flushing. This meant that prev_thread in pthread_frame.c
contained the last dst thread that update_thread_context()
was called for (so that these VLCs could be passed along between
threads). Yet after said commit, submit_packet was no longer
a no-op during flushing and changed prev_thread in such a way
that it did not need to contain any VLCs at all*. When flushing,
prev_thread is used to pass the current state to the first worker
thread which is the one that is used to restart decoding.
It could therefore happen that the decoding thread did not contain
the VLCs at all any more after decoding restarts after flushing
leading to a crash (this scenario was never anticipated and
must not happen at all).

There is a simple, easily backportable fix given that we do not
support stream reconfigurations (yet) when using frame threading:
Don't sync the VLCs in update_thread_context(), instead do it once
during init.

This fixes forgejo issue #20346 and trac issue #11592.

(I don't know why 5acbdd2264
changed submit_packet() to no longer be a no-op when draining
no-delay decoders.)

*: The exact condition for the crash is nb_threads > 2*nb_frames.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 11:30:55 +01:00
Zhao Zhili 61b034a47c avcodec/rkmppenc: add h264/hevc rkmpp encoder
Bump rockchip_mpp to 1.3.8.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-27 15:54:49 +08:00
Zhao Zhili d8e095b56d configure: cleanup rkmpp check
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-27 15:54:42 +08:00
Lynne 7d0483e6a7 vulkan_dpx: fix compilation with older headers
Fixes #21028
2025-11-27 03:12:30 +01:00
Timo Rothenpieler f7aaa8ecb5 forgejo/workflows: make test shared/static mode more human readable 2025-11-26 23:21:11 +00:00
Lynne 231f735d55 vulkan_dpx: use host visible allocation for host image copy buffer
Fixes black screen on Nvidia.
2025-11-26 18:33:10 +01:00
Lynne 162e07da61 vulkan_dpx: fix "upoad" typo 2025-11-26 18:32:25 +01:00
James Almer faa382e5b1 avformat/iamf_parse: ensure the stream count in a scalable channel representation is equal to the audio element's stream count
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-26 12:01:17 -03:00
James Almer 554ae5ada9 avformat/iamf_parse: ensure each layout in an scalable channel representation has an increasing number of channels
Fixes issue #21013

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-26 12:01:17 -03:00
Lynne 3bcf2be06c Changelog: bump lavc minor and add entry for the DPX Vulkan hwaccel 2025-11-26 15:16:43 +01:00
Lynne 531ce713a0 dpxdec: add a Vulkan hwaccel 2025-11-26 15:16:43 +01:00
Lynne a9acae202a dpxdec: add hardware decoding hooks 2025-11-26 15:16:42 +01:00
Lynne 61ae1ec85f dpxdec: move data parsing into a separate function 2025-11-26 15:16:42 +01:00
Lynne bc07d03d06 dpx: add a context
This simply adds a context with 4 fields to enable hardware unpacking.
2025-11-26 15:16:42 +01:00
Lynne 7af5b5cec3 vulkan_prores_raw: use the native image representation
It allows us to easily synchronize the software and hardware
decoders, by removing the abstraction the Vulkan layer added by changing
the values written.
2025-11-26 15:16:42 +01:00
Lynne a811a6885a vulkan_prores_raw: read the header length rather than assuming its 8
In all known samples, it is equal to 8.
2025-11-26 15:16:42 +01:00
Lynne 0db891366d vulkan_prores_raw: fix dynamically non-uniform accesses to pushconsts
The Vulkan spec requires that all accesses to push data are uniform for
all invocations (e.g. can't be based on gl_WorkGroupID or gl_LocalInvocationID).
2025-11-26 15:16:41 +01:00
Lynne edb844510e vulkan_prores_raw: use regular descriptors for tile data instead of BDA
Regular descriptors are faster.
2025-11-26 15:16:41 +01:00
Lynne bb30a0d0d8 vulkan_prores_raw: split up decoding and DCT
This commit optimizes the Vulkan decoder by splitting up decoding
from iDCT, and merging the few tables needed directly into the shader.

The speedup on Intel is 10x.
2025-11-26 15:16:41 +01:00
Lynne 0c20edaa7a vulkan_prores: initialize only the necessary shaders on init 2025-11-26 15:16:41 +01:00
Lynne a160e4a9e2 prores_raw: call ff_get_format if the version changes 2025-11-26 15:16:41 +01:00
Lynne 3934089de2 vulkan_prores: initialize only the necessary shaders on init 2025-11-26 15:16:41 +01:00
Lynne 8c0314d44a proresdec: call ff_get_format if the interlacing changes
Decoders need to track all state that hwaccels may be intersted in,
and trigger a reconfiguration if it changes.
2025-11-26 15:16:41 +01:00
Lynne 56dea1a9e8 vulkan_ffv1: initialize only the necessary shaders on init
The decoder will reinit the hwaccel upon pixfmt/dimension changes,
so we can remove the f->use32bit and is_rgb variants of all shaders.

This speeds up init time.
2025-11-26 15:16:40 +01:00
Lynne a1154b74a4 ffv1dec: call ff_get_format if the EC coding changes
Decoders need to track all state that hwaccels may be intersted in,
and trigger a reconfiguration if it changes.
2025-11-26 15:16:40 +01:00
Lynne be9998674a vulkan_ffv1/prores: remove unnecessary slice buffer unref
The slice buffer is already unref'd by ff_vk_decode_free_frame().
2025-11-26 15:16:40 +01:00
Lynne 615b26f1b1 vulkan_ffv1: fix swapped colors for x2bgr10 2025-11-26 15:16:40 +01:00
Lynne 3ddcf042b2 ffv1enc_vulkan: add support for x2bgr10/x2rgb10 2025-11-26 15:16:40 +01:00
Lynne 23cfcf93d2 vulkan: change ff_vk_frame_barrier access and stage type to sync2
Cleans up a compiler warning.
2025-11-26 15:16:40 +01:00
Lynne d36d88dcbb vulkan/common: add reverse2 endian reversal macro 2025-11-26 15:16:39 +01:00
Lynne 6c3984db7f vulkan/common: add a function to flush/invalidate a buffer and use it
Just for convenience.
2025-11-26 15:16:39 +01:00
Lynne d288d4a24e hwcontext_vulkan: use vkTransitionImageLayoutEXT to switch layouts
Falls back to regular submit-based layout switching if unsupported.
2025-11-26 15:16:39 +01:00
Lynne 5c89528342 hwcontext_vulkan: disable host image transfers for Nvidia devices
Nvidia's binary drivers have a very buggy implementation that is
yet to be fixed.
2025-11-26 15:16:39 +01:00
Lynne 686951849b hwcontext_vulkan: re-enable host image copy extension
We'll slowly start to use it in the code in safe places
rather than globally.
2025-11-26 15:16:39 +01:00
Lynne fc2dd6c751 hwcontext_vulkan: enable runtime descriptor sizing
We were already using this in places, but it seems validation
layers finally got support to detect it.
2025-11-26 15:16:39 +01:00
Lynne 58d26c2055 Changelog: add ProRes Vulkan hwaccel to the list
Forgotten when it got merged.
2025-11-26 15:16:34 +01:00
Niklas Haas 38a5fcc02c fftools/ffmpeg_filter: close all no-longer needed inputs
Currently, the thread loop of ffmpeg_filter essentially works like this:

while (1) {
    frame, idx = get_from_decoder();
    err = send_to_filter_graph(frame);
    if (err) { // i.e. EOF
        close_input(idx);
        continue;
    }

    while (filtered_frame = get_filtered_frame())
        send_to_encoder(filtered_frame);
}

The exact details are not 100% correct since the actual control flow is a bit
more complicated as a result of the scheduler, but this is the general flow.

Notably, this leaves the possibility of leaving a no-longer-needed input
permanently open if the filter graph starts producing infinite frames (during
the second loop) *after* it finishes reading from an input, e.g. in a filter
graph like -af atrim,apad.

This patch avoids this issue by always querying the status of all filter graph
inputs and explicitly closing any that were closed downstream; after each round
of reading output frames. As a result, information about the filtergraph being
closed can now propagate back upstream, even if the filter is no longer
requesting any input frames (i.e. input_idx == fg->nb_inputs).

Fixes: https://trac.ffmpeg.org/ticket/11061
See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20457#issuecomment-6208
2025-11-26 13:15:16 +00:00
Niklas Haas 623669a02c avfilter/buffersrc: add av_buffersrc_get_status()
There is currently no way for API users to know that a buffersrc is no longer
accepting input, except by trying to feed it a frame and seeing what happens.

Of course, this is not possible if the user does not *have* a frame to feed,
but may still wish to know if the filter is still accepting input or not.

Since passing `frame == NULL` to `av_buffersrc_add_frame()` is already treated
as closing the input, we are left with no choice but to introduce a new
function for this.

We don't explicitly return the result of `ff_outlink_get_status()` to avoid
leaking internal status codes, and instead translate them all to AVERROR(EOF).
2025-11-26 13:15:16 +00:00
Araz Iusubov 92f2f9ea5c avcodec/d3d12va_encode: D3D12 AV1 encoding support
Implement AV1 hardware encoding
using Direct3D 12 Video API (D3D12VA).
2025-11-26 09:58:44 +00:00
Andreas Rheinhardt 81362b319e avcodec/x86/me_cmp: Avoid call on UNIX64
The internal functions for calculating the hadamard difference
of two 8x8 blocks have no epilogue on UNIX64, so one can avoid
the call altogether by placing the 8x8 function so that it directly
falls into the internal function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-26 00:01:09 +00:00
Andreas Rheinhardt 23720df371 avcodec/me_cmp: Remove MMXEXT hadamard diff functions
The SSE2 and SSSE3 functions are now available everywhere,
making the MMXEXT functions irrelevant.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-26 00:01:09 +00:00
Andreas Rheinhardt 6588bf3686 avcodec/x86/me_cmp: Avoid manual stack handling
Use x86inc's stack alignment feature instead of allocating the stack
manually*; this means that this code now also automatically supports
unaligned stacks, so that the SSE2 and SSSE3 functions will now be
available everywhere.

*: The code for this was also buggy: It resulted in the stack pointer
to be 4 mod 8 for x64 for the mmxext version before it was disabled
in 542765ce3e, because it hardcode 4
instead of using gprsize.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-26 00:01:09 +00:00
Niklas Haas f3346ca6f7 avfilter/x86/f_ebur128: only use filter_channels_avx for >= 2 channels
The approach of this ASM routine is to process two channels at a time using
AVX instructions. Obviously, there is no point in doing this if there is only
a single channel; in which case the scalar loop would be better.

Fixes a performance regression when filtering mono audio on certain CPUs,
notably e.g. the Intel N100.
2025-11-25 22:13:57 +00:00
Kacper Michajłow a75b15a4ab avfilter/vf_drawvg: round color values to avoid differences on some platforms
This ensures consistent color conversion between double and u8 and
guarantees that values remain consistent across different platforms,
especially when x87 math is used.

Note that libcairo also performs rounding internally when converting
doubles to integers, see _cairo_color_double_to_short().

Fixes: fate-filter-drawvg-interpreter
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-25 22:32:50 +01:00
averne 1d84ab331c vulkan/prores: Adopt the same IDCT routine as the prores-raw hwaccel
The added rounding at the final output conforms
to the SMPTE document and reduces the deviation
against the software decoder.
2025-11-25 17:54:56 +00:00
Gyan Doshi 2b221fdb4a avfilter/zscale: add support for resize filter spline64
Fixes #20928
2025-11-25 12:42:41 +05:30
Jack Lau 0486ad61ce configure: replace openssl header check with 1.1.1 API
Fix #20571

Avoid build errors with openssl forks (like libressl)
that lack some APIs.

This patch replace header check for OPENSSL_init_ssl
(was added in 1.1.0) with the OpenSSL 1.1.1 new API
DTLS_get_data_mtu.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2025-11-24 21:29:45 +00:00
Georgii Zagoruiko f790de2a87 aarch64/vvc: Optimisations of put_luma_h() functions for 10/12-bit
RPi4 (auto-vectorisation is turned on)
put_luma_h_10_4x4_c:                                   282.8 ( 1.00x)
put_luma_h_10_8x8_c:                                  1069.5 ( 1.00x)
put_luma_h_10_8x8_neon:                                207.5 ( 5.15x)
put_luma_h_10_16x16_c:                                1999.6 ( 1.00x)
put_luma_h_10_16x16_neon:                              777.5 ( 2.57x)
put_luma_h_10_32x32_c:                                6612.9 ( 1.00x)
put_luma_h_10_32x32_neon:                             3201.6 ( 2.07x)
put_luma_h_10_64x64_c:                               25059.0 ( 1.00x)
put_luma_h_10_64x64_neon:                            13623.5 ( 1.84x)
put_luma_h_10_128x128_c:                             91310.1 ( 1.00x)
put_luma_h_10_128x128_neon:                          50358.3 ( 1.81x)
put_luma_h_12_4x4_c:                                   282.1 ( 1.00x)
put_luma_h_12_8x8_c:                                  1068.4 ( 1.00x)
put_luma_h_12_8x8_neon:                                207.7 ( 5.14x)
put_luma_h_12_16x16_c:                                1998.0 ( 1.00x)
put_luma_h_12_16x16_neon:                              777.5 ( 2.57x)
put_luma_h_12_32x32_c:                                6612.0 ( 1.00x)
put_luma_h_12_32x32_neon:                             3201.6 ( 2.07x)
put_luma_h_12_64x64_c:                               25036.8 ( 1.00x)
put_luma_h_12_64x64_neon:                            13595.1 ( 1.84x)
put_luma_h_12_128x128_c:                             91305.8 ( 1.00x)
put_luma_h_12_128x128_neon:                          50359.7 ( 1.81x)

Apple M2 Air (auto-vectorisation is turned on)
put_luma_h_10_4x4_c:                                     0.3 ( 1.00x)
put_luma_h_10_8x8_c:                                     1.0 ( 1.00x)
put_luma_h_10_8x8_neon:                                  0.4 ( 2.59x)
put_luma_h_10_16x16_c:                                   2.9 ( 1.00x)
put_luma_h_10_16x16_neon:                                1.4 ( 2.01x)
put_luma_h_10_32x32_c:                                   9.4 ( 1.00x)
put_luma_h_10_32x32_neon:                                5.8 ( 1.62x)
put_luma_h_10_64x64_c:                                  35.6 ( 1.00x)
put_luma_h_10_64x64_neon:                               23.6 ( 1.51x)
put_luma_h_10_128x128_c:                               131.1 ( 1.00x)
put_luma_h_10_128x128_neon:                             92.6 ( 1.42x)
put_luma_h_12_4x4_c:                                     0.3 ( 1.00x)
put_luma_h_12_8x8_c:                                     1.0 ( 1.00x)
put_luma_h_12_8x8_neon:                                  0.4 ( 2.58x)
put_luma_h_12_16x16_c:                                   2.9 ( 1.00x)
put_luma_h_12_16x16_neon:                                1.4 ( 2.00x)
put_luma_h_12_32x32_c:                                   9.4 ( 1.00x)
put_luma_h_12_32x32_neon:                                5.8 ( 1.61x)
put_luma_h_12_64x64_c:                                  35.3 ( 1.00x)
put_luma_h_12_64x64_neon:                               23.3 ( 1.52x)
put_luma_h_12_128x128_c:                               131.2 ( 1.00x)
put_luma_h_12_128x128_neon:                             92.4 ( 1.42x)
2025-11-24 21:22:55 +00:00
Martin Storsjö 8b71eeb72e tools: Make indent_arm_assembly.pl able to reformat a file in place
This allows using the tool for one-off reindentations without needing
the check_arm_indent.sh script (e.g. for use outside of ffmpeg),
without having to pipe the file through stdin/stdout.
2025-11-24 23:02:05 +02:00
Dmitrii Ovchinnikov 140b4f28c3 avutil/hwcontext_amf: move AVMutex to internal context 2025-11-24 20:06:24 +00:00
Ayose efd6e85abb fftools/tf_mermaid: close subgraph header when there are no inputs.
Ensure that the fragment to close the header (`</div>\"]`) is written when the
function `mermaid_print_section_header` is called only once, which happens when
the filtergraph has no inputs.
2025-11-24 20:01:40 +00:00
Ayose 5717c5c1e1 fftools/tf_mermaid: logic to complete subgraphs in a reusable function.
`subgraph` blocks can be closed in different places. The logic to complete the
header is moved to a function, so it can be reused later.
2025-11-24 20:01:40 +00:00
Andreas Rheinhardt 04a9e2a809 avutil/error: Avoid relocations and unused information
Use a string table instead to avoid relocations and don't add
the tag string to libavutil/error.c: It is only used
during the test program, so move it there.

Reviewed-by: Rémi Denis-Courmont <remi@remlab.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-24 16:48:31 +01:00
Andreas Rheinhardt 0eb423866f avcodec/j2kenc: Remove dead, disabled debug code
Seems to have never worked, even when this was added in
83654c7b1b.

Reviewed-by: Rémi Denis-Courmont <remi@remlab.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-24 16:48:31 +01:00
Andreas Rheinhardt 2a90e7d725 av{codec,util}/tests: Remove pointless undefs
Before commit e96d90eed6 lavu/internal.h
contained redefined various discouraged/forbidden functions to induce
compilation failures upon use, like e.g.
 #define malloc please_use_av_malloc
In order to use these functions, some files had to undefine these
macros. This commit removes the remaining pointless undefs.

Reviewed-by: Rémi Denis-Courmont <remi@remlab.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-24 16:48:31 +01:00
James Almer ee623a43e3 avformat: don't return EIO on demuxer errors
Demuxers should not generate this error code when they encounter truncated
or otherwise invalid files. It's a code the underlying protocol should generate
when there are legitimate reading errors.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-24 12:07:15 -03:00
Zhao Zhili c732564d2e avutil/hwcontext_vaapi: fix use fourcc not supported by devices
1. A AVPixelFormat can map to multiple VA_FOURCCs, while
vaapi_format_from_pix_fmt() only returns the first item matched
before this patch.
2. vaapi_frames_init() use vaapi_format_from_pix_fmt() to get the
first item. Fourcc in this item may not be supported by the device.

This patch makes vaapi_format_from_pix_fmt return all matched items
iteratively, then use strict check in vaapi_frames_init to get the
right fourcc.
2025-11-24 08:51:17 +00:00
Frank Plowman 76827a6f3b lavc/hevc: Fix usage of slice segment in invalid state
Previously, we set s->slice_initialized to 0 to prevent other slice
segments from depending on this slice segment only if hls_slice_header
failed.  If decode_slice fails for some other reason, however, before
decode_slice_data is called to bring the context back into a consistent
state, then slices could depend on this slice segment while it is in an
invalid state.  This can cause segmentation faults and other sorts of
nastiness.  Patch fixes this by always setting s->slice_initialized to 0
while the state is inconsistent.

Resolves #11652.
2025-11-24 05:08:58 +00:00
Neal Gompa 069d465895 configure: Lower libdvdnav and libdvdread minimum versions for EL9
Red Hat Enterprise Linux 9 is one patch version lower than what
FFmpeg currently requests. The slightly older versions still result
in a working build of FFmpeg with DVD support, so allow those
versions to be consumed to build FFmpeg.

Signed-off-by: Neal Gompa <neal@gompa.dev>
2025-11-24 03:08:20 +00:00
James Almer 6f4a3be9dc avformat/movenc: add support for writing srat box
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-24 02:59:02 +00:00
Kacper Michajłow 148cf61585 fate: add missing options in config template
Fixes: f01c771577
Fixes: 523d688c2b
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-24 02:47:08 +00:00
Kacper Michajłow 6cb002610b fate: add skip_clean option
This is useful if one wants to inspect build artifacts after running
fate.sh script.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-24 02:47:08 +00:00
James Almer fd4e86be9e avformat/mov: reindent after the previous change
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-23 17:01:39 -03:00
Dmitrii Okunev eccbbd528e fftools: Fix MediaCodec on Android15+
On Android15+ MediaCodec HAL backend was switched from HIDL to AIDL.
As a result, MediaCodec operations started to hang, see:

    https://trac.ffmpeg.org/ticket/11363
    https://github.com/termux/termux-packages/issues/21264
    https://issuetracker.google.com/issues/382831999

To fix that it is necessary to initialize binder thread pool.

Signed-off-by: Dmitrii Okunev <xaionaro@dx.center>
2025-11-23 12:53:43 +00:00
Zhao Zhili d3e80837e7 avformat/mov: fix incorrect sample rate by parse srat box 2025-11-23 12:13:07 +00:00
James Almer c0044ec9c4 avformat/mov: don't parse reserved ISOBMFF fields as if they were QT
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-23 11:51:26 +00:00
James Almer 9e09be513d configure: move libtls out of non-free libraries list
LibreSSL uses a permisive license, and the OpenSSL code has the same license as
OpenSSL < 3.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-22 23:19:01 -03:00
Romain Beauxis c75ada5040 ffplay: print new metadata 2025-11-22 18:38:40 +00:00
Anders Rein 32f73138f5 fate/filter-audio: Added test for aselect 2025-11-22 18:36:41 +00:00
Anders Rein 7411e902da avfilter/f_select: Added activate for aselect
During migration to the activation filter API the aselect filter was
accidentally turned into a no-op filter.
2025-11-22 18:36:41 +00:00
Martin Storsjö 3cc1dc3358 swscale: Remove the unused ff_sws_pixel_type_to_uint
This function uses ff_sws_pixel_type_size to switch on the
size of the provided type. However, ff_sws_pixel_type_size returns
a size in bytes (from sizeof()), not a size in bits. Therefore,
this would previously never return the right thing but always
hit the av_unreachable() below.

As the function is entirely unused, just remove it.

This fixes compilation with MSVC 2026 18.0 when targeting ARM64,
which previously hit an internal compiler error [1].

[1] https://developercommunity.visualstudio.com/t/Internal-Compiler-Error-targeting-ARM64-/10962922
2025-11-21 21:07:34 +00:00
Andreas Rheinhardt 775b102182 avformat/oggenc: Schedule pagesize option for removal
Deprecated in 59220d559b.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-21 18:41:15 +00:00
James Almer 191f7e4869 tests/checkasm/sw_ops: fix signed integer related UB when shifting values
Fixes:
src/tests/checkasm/sw_ops.c:441:34: runtime error: shift exponent 32 is too large for 32-bit type 'int'
src/tests/checkasm/sw_ops.c:591:37: runtime error: shift exponent 32 is too large for 32-bit type 'int'

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-21 18:40:58 +00:00
James Almer 06b3a20761 swscale/ops_tmpl_int: fix signed integer related UB when shifting values
Fixes:
src/libswscale/ops_tmpl_int.c:292:23: runtime error: left shift of 188 by 24 places cannot be represented in type 'int'
src/libswscale/ops_tmpl_int.c:290:23: runtime error: left shift of 158 by 24 places cannot be represented in type 'int'
src/libswscale/ops_tmpl_int.c:293:23: runtime error: left shift of 136 by 24 places cannot be represented in type 'int'
src/libswscale/ops_tmpl_int.c:291:23: runtime error: left shift of 160 by 24 places cannot be represented in type 'int'

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-21 18:40:58 +00:00
James Almer 30d66be21a swscale/x86/ops: fix signed integer related UB in normalize_clear()
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-21 18:40:58 +00:00
Andreas Rheinhardt 43abd1ced9 avcodec/mpegvideo: Move last_dc to {H263Dec,Mpeg12Slice,MPVEnc}Context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-21 11:55:09 +01:00
Andreas Rheinhardt b497de698c avcodec/Makefile: Remove mpegvideo_parser->mpeg12.o dependency
Forgotten in 3ceffe7839.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-21 11:55:09 +01:00
Andreas Rheinhardt 2586763376 avcodec/mpeg12: Inline ff_mpeg1_clean_buffers() into its callers
This function is extremely small, so inlining it is appropriate (and
actually beneficial size-wise here). It furthermore allows to remove
the mpeg12codecs.h header and the mpeg12-encoders->mpeg12.o dependency.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-21 11:55:09 +01:00
Kacper Michajłow fc3893f5e7 Makefile: remove config_components.asm on distclean
Forgotten in c607aae2b9.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-20 21:20:24 +00:00
James Zern 32cefd3789 avcodec/libaomenc: Fix use of uninitialized value
codecctl_intp() is used to populate values via aom_codec_control(), not
set them. This change moves the output of the return pointer's value
after the aom_codec_control() to avoid a memory sanitizer warning (use
of uninitialized value).

Signed-off-by: James Zern <jzern@google.com>
2025-11-19 12:43:12 -08:00
Zhao Zhili 0ae8df5f2c avutil/common: cast GET_BYTE/GET_16BIT returned value
In case of GET_BYTE/GET_16BIT return signed value.
2025-11-19 17:46:06 +00:00
Zhao Zhili a5cc0e5c9e avfilter/vf_drawtext: fix call GET_UTF8 with invalid argument
For GET_UTF8(val, GET_BYTE, ERROR), val has type of uint32_t,
GET_BYTE must return an unsigned integer, otherwise signed
extension happened due to val= (GET_BYTE), and GET_UTF8 went to
the error path.

This bug incidentally cancelled the bug where hb_buffer_add_utf8
was being called with incorrect argument, allowing drawtext to
function correctly on x86 and macOS ARM, which defined char as
signed. However, on Linux and Android ARM environments, because
char is unsigned by default, GET_UTF8 now returns the correct
return, which unexpectedly revealed issue #20906.
2025-11-19 17:46:06 +00:00
Zhao Zhili 9bc3c572ea avfilter/vf_drawtext: fix incorrect text length
From the doc of HarfBuzz, what hb_buffer_add_utf8 needs is the
number of bytes, not Unicode character:
hb_buffer_add_utf8(buf, text, strlen(text), 0, strlen(text));

Fix issue #20906.
2025-11-19 17:46:06 +00:00
Zhao Zhili 551e964e8a avcodec/videotoolboxenc: remove redundant "Error: " in error message 2025-11-20 00:56:12 +08:00
Zhao Zhili d4031984db avcodec/videotoolboxenc: reorder and cleanup headers 2025-11-20 00:56:12 +08:00
Zhao Zhili 7049df14c8 avcodec/videotoolboxenc: fix crash with negative linesize 2025-11-20 00:56:05 +08:00
Zhao Zhili 0da15c93c8 avcodec/videotoolboxenc: improve Lock/Unlock BaseAddress error handling
1. Fix continue after CVPixelBufferLockBaseAddress.
2. Remove redundant "Error: " in error message.
2025-11-20 00:55:32 +08:00
GyanD f283750ba8 doc/encoders: minor mediafoundation encoders updates 2025-11-19 04:48:11 +00:00
Harshitha 4e556b0c0c doc/encoders: Document MediaFoundation encoders 2025-11-19 04:48:11 +00:00
Hendi b399896046 avformat/dashdec: Fix urls with special characters in manifest
This was especially a problem with ampersands, which occur
frequently as part of query parameters.
2025-11-18 22:10:34 +00:00
Stefan Breunig 4c4ab2ec6f fate/filter-video: add frei0r test where input is realigned
An installation of frei0r-plugins is required to run the tests,
which is usually seperate from the build headers. Some systems
have it packaged (e.g. apt install frei0r-plugins). An upstream
release extracted to FREI0R_PATH also works.

The distort0r filter requires dimensions to be divisible by 8.
2025-11-18 21:26:36 +00:00
Stefan Breunig f8bfc20281 avfilter/vf_frei0r: fix time when input is realigned
av_frame_copy doesn't copy the input's PTS property, which resulted
in the frei0r filter always receiving the same static time.

Example that has a static distortion without patch:

ffmpeg -filter_complex "testsrc2=s=328x240:d=5,frei0r=distort0r" out.mp4
2025-11-18 21:26:36 +00:00
Andreas Rheinhardt 5bf57a925c avutil/x86/asm: Remove wrong comment, rename FF_REG_sp
Before FFmpeg commit 531b0a316b,
FFmpeg used REG_SP as macro for the stack pointer, yet this
clashed with a REG_SP define in Solaris system headers, so it
was changed to REG_sp and a comment was added for this.

Libav fixed it by adding an FF_ prefix to the macros in
1e9c5bf4c1. FFmpeg switched
to using these prefixes in 9eb3da2f99,
using FF_REG_sp instead of Libav's FF_REG_SP. In said commit
the comment was changed to claim that Solaris system headers
define FF_REG_SP, but this is (most likely) wrong.

This commit removes the wrong comment and renames the (actually unused)
macro to FF_REG_SP to make it consistent with FF_REG_BP.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:13 +01:00
Andreas Rheinhardt 99209c2876 avcodec/x86/mpegvideoenc_template: Reduce number of registers used
qmat and bias always have a constant offset, so one can use one register
to address both of them. This allows to remove the check for HAVE_6REGS
(untested on a system where HAVE_6REGS is false).
Also avoid FF_REG_a while at it.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:13 +01:00
Andreas Rheinhardt b890cd0f73 avcodec/x86/mpegvideoenc_template: Avoid touching nonvolatile register
xmm7 is nonvolatile on x64 Windows.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:13 +01:00
Andreas Rheinhardt aeb138679a avcodec/x86/mpegvideoencdsp: Port add_8x8basis_ssse3() to ASM
Both GCC and Clang completely unroll the unlikely loop at -O3,
leading to codesize bloat; their code is also suboptimal, as they
don't make use of pmulhrsw (even with -mssse3). This commit
therefore ports the whole function to external assembly. The new
function occupies 176B here vs 1406B for GCC.

Benchmarks for a testcase with huge qscale (notice that the C version
is unrolled just like the unlikely loop in the SSSE3 version):
add_8x8basis_c:                                         43.4 ( 1.00x)
add_8x8basis_ssse3 (old):                               43.6 ( 1.00x)
add_8x8basis_ssse3 (new):                               11.9 ( 3.63x)

Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:12 +01:00
Andreas Rheinhardt 0d3a88e55f tests/checkasm/mpegvideoencdsp: Test denoise_dct
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:12 +01:00
Andreas Rheinhardt 1c00e09427 avcodec/mpegvideo_enc: Port denoise_dct to MpegvideoEncDSPContext
It is very simple to remove the MPVEncContext from it.
Notice that this also fixes a bug in x86/mpegvideoenc.c: It only
used the SSE2 version of denoise_dct when dct_algo was auto or mmx
(and it was therefore unused during FATE).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:12 +01:00
Andreas Rheinhardt d633fa0433 avcodec/x86/mpegvideoenc: Port denoise_dct_sse2 to external assembly
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:12 +01:00
Andreas Rheinhardt 2cfef7031c avcodec/x86/mpegvideoenc: Reduce number of registers used
Avoids a push+pop on x64 Windows.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:12 +01:00
Andreas Rheinhardt 503afa40f7 avcodec/x86/mpegvideoenc: Remove check for MMX
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:12 +01:00
Marvin Scholz 00ef656a85 .forgejo/CODEOWNERS: add myself to VideoToolbox and Icecast 2025-11-18 15:17:05 +01:00
Carl Hetherington via ffmpeg-devel 1eb2cbd865 avfilter/f_ebur128: Fix incorrect ebur128 peak calculation.
Since 3b26b782ee it would only look at the
first channel.

Signed-off-by: Carl Hetherington <cth@carlh.net>
Reviewed-by: Niklas Haas <ffmpeg@haasn.xyz>
2025-11-18 08:40:08 +01:00
Gyan Doshi f60db2e566 doc/fate: document setting of session-wide env variables 2025-11-18 04:19:06 +00:00
Kacper Michajłow 9b2162275b configure: filter out -guard:signret from armasm flags
While cl.exe supports -guard:signret, armasm64 complains about
unknown flag. Note that -guard:ehcont is accepted by armasm64.

Fixes:
error A2029: unknown command-line argument or argument value -guard:signret

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-17 20:41:34 +00:00
Kacper Michajłow 523d688c2b fate: add more configure flags to fate config
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-17 20:25:24 +00:00
Andreas Rheinhardt ddf443f1e9 avfilter/vf_fsppdsp: Fix left shifts of negative numbers
They are undefined behavior and UBSan warns about them
(in the checkasm test). Put the shifts in the constants
instead. This even gives a tiny speedup here:

Old benchmarks:
column_fidct_c:                                       3369.9 ( 1.00x)
column_fidct_sse2:                                     829.1 ( 4.06x)
New benchmarks:
column_fidct_c:                                       3304.2 ( 1.00x)
column_fidct_sse2:                                     827.9 ( 3.99x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt f8bcea4946 avfilter/vf_fsppdsp: Remove pointless cast
Also don't cast const away and use a smaller scope.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt 0c556a6b09 avfilter/vf_fspp: Pre-reorder threshold table
Avoids reordering at runtime.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt 778ff97efa avfilter/vf_fspp: Make output endian-independent
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt f442145729 avfilter/vf_fspp: Avoid casts, effective-type violations
Maybe uint64_t has been used as a poor man's alignment specifier?
Anyway, reading an uint64_t via an lvalue of type int16_t (as happens
in the C versions of the dsp functions) is undefined behavior.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt c0648b2004 avfilter/x86/vf_spp: Fix comment
Forgotten in dcb28ed860.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt 06b0dae51b avfilter/vf_fsppdsp: Constify
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt cc97f1e276 avfilter/vf_fspp: Fix effective type violation
Also don't use unnecessarily large alignment; it avoids having to align
the stack.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt 3cd452cbf1 avfilter/x86/vf_fspp: Avoid stack on x64
Possible due to the amount of registers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt ddd74276f8 avfilter/x86/vf_fspp: Port ff_column_fidct_mmx() to SSE2
It gains a lot because it has to operate on eight words;
it also saves 608B of .text here.

Old benchmarks:
column_fidct_c:                                       3365.7 ( 1.00x)
column_fidct_mmx:                                     1784.6 ( 1.89x)

New benchmarks:
column_fidct_c:                                       3361.5 ( 1.00x)
column_fidct_sse2:                                     801.1 ( 4.20x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:11 +01:00
Andreas Rheinhardt 68b11cde82 tests/checkasm/vf_fspp: Add test for column_fidct
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:11 +01:00
Andreas Rheinhardt 63493bf0e0 avfilter/x86/vf_fspp: Put shifts into constants
This avoids some shift instructions and also gives us more headroom
in the registers. In fact, I have proven to myself that everything
that is supposed to fit into 16bits now actually does so.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:11 +01:00
Andreas Rheinhardt 66af18d06a avfilter/x86/vf_fspp: Make ff_column_fidct_mmx() bitexact
It currently is not, because the shortcut mode uses different rounding
than the C code (as well as the non-shortcut code).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:11 +01:00
Andreas Rheinhardt 1049a5fba8 avfilter/vf_fsppdsp: Reduce discrepancies between C code and x86 asm
The x86 assembly uses the following pattern to zero all
the values with abs<threshold:
    x -= threshold;
    x satu+= threshold (unsigned saturated addition)
    x += threshold
    x satu-= threshold (unsigned saturated subtraction)
The reference C code meanwhile zeroed everything
with abs <= threshold. This commit makes the C code behave
like the x86 assembly to reduce discrepancies between the two.

An alternative would be to require SSSE3, so that
one can use pabsw, pcmpgtw for abs>threshold, followed by
a pand with the original data. Or one could modify the thresholds
to make both equal.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt d19050a1ae avfilter/vf_fsppdsp: Use restrict
It is possible because the requirements are fulfilled;
it is also beneficial performance and code-size wise.
For GCC 14 (with -O3), this reduced codesize by 26750B
here; for Clang 20, it was 432B.

Old benchmarks:
mul_thrmat_c:                                            4.3 ( 1.00x)
mul_thrmat_sse2:                                         4.3 ( 1.00x)
store_slice_c:                                        2810.8 ( 1.00x)
store_slice_sse2:                                      542.5 ( 5.18x)
store_slice2_c:                                       3817.0 ( 1.00x)
store_slice2_sse2:                                     410.4 ( 9.30x)

New benchmarks:
mul_thrmat_c:                                            4.3 ( 1.00x)
mul_thrmat_sse2:                                         4.3 ( 1.00x)
store_slice_c:                                        1510.1 ( 1.00x)
store_slice_sse2:                                      545.2 ( 2.77x)
store_slice2_c:                                       1763.5 ( 1.00x)
store_slice2_sse2:                                     408.3 ( 4.32x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt ff85a20b7d avfilter/x86/vf_fspp: Port store_slice to SSE2
Old benchmarks:
store_slice_c:                                        2798.3 ( 1.00x)
store_slice_mmx:                                       950.2 ( 2.94x)
store_slice2_c:                                       3811.7 ( 1.00x)
store_slice2_mmx:                                      682.3 ( 5.59x)

New benchmarks:
store_slice_c:                                        2797.2 ( 1.00x)
store_slice_sse2:                                      543.5 ( 5.15x)
store_slice2_c:                                       3817.0 ( 1.00x)
store_slice2_sse2:                                     408.2 ( 9.35x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 570f8fc6c9 tests/checkasm/vf_fspp: Test store_slice
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt e042f17e99 avfilter/vf_fsppdsp: Use standard clamping
This is obviously what is intended and what the MMX code does;
yet I cannot rule out that it changes the output for some inputs:
I have observed individual src values which would lead to temp
values just above 512 if they came in pairs (i.e. if both inputs
were simultaneously huge).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 52ba2ac7bd avfilter/x86/vf_fspp: Port mul_thrmat to SSE2
This fixes an ABI violation, as mul_thrmat did not issue emms.
It seems that this ABI violation could reach the user, namely
if ff_get_video_buffer() fails. Notice that ff_get_video_buffer()
itself could fail because of this, namely if the allocator uses
floating point registers.

On x64 (where GCC already used SSE2 in the C version)
mul_thrmat_c:                                            4.4 ( 1.00x)
mul_thrmat_mmx:                                          8.6 ( 0.52x)
mul_thrmat_sse2:                                         4.4 ( 1.00x)

On 32bit (where SSE2 is not known to be available):
mul_thrmat_c:                                           56.0 ( 1.00x)
mul_thrmat_sse2:                                         6.0 ( 9.40x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 70eb8a76a9 tests/checkasm: Add vf_fspp mul_thrmat test
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 9f4d5d818d avfilter/x86/vf_fspp: Don't duplicate dither table
Reuse the one from vf_fsppdsp.c; also don't overalign said table too
much.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 1699de0955 avfilter/vf_fsppdsp: Use enum for constants
It means that the compiler does not have to optimize the static const
object away.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 9b34088c4d avfilter/vf_fspp: Add DSPCtx, move DSP functions to file of their own
This is in preparation for adding checkasm tests; without it,
checkasm would pull all of libavfilter in.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 57d6898730 configure: Only test for SSE2 intrinsics on x86
Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 10:36:54 +01:00
Artem Smorodin e94439e49b avformat/tee: fix the default onfail setting of the tee salves
I found that the default value is not set for onfail option. I see that there is an attempt to set this value by default inside parse_slave_failure_policy_option. But look at the CONSUME_OPTION macro. If av_dict_get cannot find this option, then this function is not even called.
2025-11-17 00:01:42 +00:00
Michael Niedermayer 88b676105d avcodec/prores_raw: Check bits in get_value()
The code loads 32bit so we can at maximum use 32bit

the return type is also changed to uint16_t (was requested in review),

no path is known where a return value above 32767 is produced, but that was not exhaustively checked

Fixes: runtime error: shift exponent -9 is negative
Fixes: 439483046/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PRORES_RAW_DEC_fuzzer-6649466540326912

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-16 21:43:17 +01:00
Michael Niedermayer 9ccc33d84d avcodec/prores_raw: Prettify ff_prores_raw_*_cb
the values contain 3 4 bit values, thus using hex is more natural
and shows more information

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-16 21:34:38 +01:00
Michael Niedermayer ad956ff076 avfilter/vf_drawtext: Account for bbox text seperator
Fixes: out of array access
no test case

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-16 20:32:11 +01:00
Andreas Rheinhardt 643e2e10f9 avutil/cpu: Deprecate AV_CPU_FLAG_FORCE
This flag does nothing since the deactivation of
the dsp_mask field of AVCodecContext in
commits 9ae6ba2883 and
9ae6ba2883 (it has
been superseded with better ways to override the CPU flags).
So deprecate it.

Reviewed-by: Lynne <dev@lynne.ee>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-16 11:24:00 +01:00
Zhao Zhili 925282fafc doc/filters: add section for VideoToolbox filter
Move scale_vt and transpose_vt to this section.
2025-11-16 10:22:19 +00:00
Martin Storsjö e096a592cb doc: Fix building with makeinfo 4.8
This fixes building after commit
1ce88d29d0.

That commit caused the following errors:

    src/doc/fate.texi:234: @anchor expected braces.
    src/doc/fate.texi:245: @item found outside of an insertion block.
    src/doc/fate.texi:249: @item found outside of an insertion block.
    src/doc/fate.texi:261: @item found outside of an insertion block.
    src/doc/fate.texi:265: @item found outside of an insertion block.
    src/doc/fate.texi:268: @item found outside of an insertion block.
    src/doc/fate.texi:274: @item found outside of an insertion block.
    src/doc/fate.texi:277: @item found outside of an insertion block.
    src/doc/fate.texi:281: @item found outside of an insertion block.
    src/doc/fate.texi:287: Unmatched `@end'.
    ./src/doc/fate.texi:65: Cross reference to nonexistent node `makefile variables' (perhaps incorrect sectioning?).
2025-11-15 19:29:08 +02:00
Gyan Doshi 1ce88d29d0 doc/fate: improve section on running FATE
With thanks to Adam Koszek.
2025-11-15 08:28:51 +00:00
Cameron Gutman d3dea2b142 avcodec/v4l2_buffers: map additional V4L2 TRCs
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-11-15 00:39:43 +00:00
Andreas Rheinhardt e293091d98 avcodec/prores_raw: Reuse permutation
The ProresDSPContext already contains the idct_permutation.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-14 14:27:53 +01:00
Michael Niedermayer 41a9c6ec5f avcodec/mediacodecdec_common: Check that the input to mediacodec_wrap_sw_audio_buffer() contains channel * sample_size
Fixes: out of array access
no testcase

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-14 12:16:48 +00:00
James Almer b478037423 avdevice/lavfi: stop setting deprecated buffersink options
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-13 21:02:10 -03:00
Dmitrii Ovchinnikov 62184be548 avutil/hwcontext_amf: Simplified blocking before frame submission
Instead of blocking the entire context, which can cause issues in more
complex pipelines, now only frame sending is blocked via AVMutex
2025-11-13 15:49:42 +01:00
James Almer 6cdd2cbe32 avformat/riffenc: add support for HEAACWAVEFORMAT
This is an extension to WAVEFORMATEX used for some AAC streams, defined in the
Windows SDK.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-12 21:30:02 -03:00
James Almer 362d673ad6 avformat/riffdec: add support for HEAACWAVEFORMAT
This is an extension to WAVEFORMATEX used for some AAC streams, defined in the
Windows SDK.

Fixes issue #20887.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-12 21:29:49 -03:00
Sean McGovern 35464ad9eb libavcodec/ppc: remove broken AltiVec acceleration for lossless audio
It fails sporadically on big- or little-endian POWER/PPC, as well as
triggers the undefined-behaviour & address scanners in GCC.
2025-11-12 14:40:14 -05:00
Niklas Haas 203c6a93d7 avutil/hwcontext_vulkan: actually limit number of queues
This option is parsed after it is used.
2025-11-12 15:25:07 +00:00
Andreas Rheinhardt 2452b81769 avcodec/h264idct_template: Deduplicate h264_{luma,chroma}_dc_dequant_idct
All the high bit depth functions of these types are identical.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-12 14:50:46 +01:00
Andreas Rheinhardt 1fafb13cd4 avcodec/bit_depth_template: Add PIXELSIZE
Sometimes functions for bit depth 9..16 are the same (because they
actually only depend on the underlying pixel type). The macros added
here allow to support this usecase.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-12 14:50:21 +01:00
Lynne f39884b3fd vulkan: fix driver warning for unrecognized structure
VkQueueFamilyQueryResultStatusPropertiesKHR was added with the
VK_KHR_video_queue extension, which NVK does not support yet.
Correctly classify it as part of the video extensions.
2025-11-12 10:36:48 +01:00
Lynne 418235e98a vulkan_prores: fix buffer leaks on error 2025-11-12 00:37:25 +01:00
Lynne d12bb4a2a5 vulkan_prores: fix pushconst updating
ff_vk_shader_update_push_const executes a command that
updates push data for the currently bound shader.
2025-11-12 00:37:25 +01:00
Lynne dd32bb8855 vulkan: allow arrays of buffers
Could be useful.
2025-11-12 00:37:25 +01:00
Lynne a0d0b5cf73 ffv1enc_vulkan: only use native image representation
This was done for an unknown reason, and for whatever reason,
non-rgb 8+ bit formats were broken by this.
2025-11-12 00:37:24 +01:00
Lynne 9860017495 vulkan/ffv1: use u32vec2 for slice offsets
Simplifies calculations slightly.
2025-11-12 00:37:24 +01:00
Lynne 6080db7d23 ffv1dec: call ff_get_format if width and height change 2025-11-12 00:37:24 +01:00
Lynne 18d7ded29e prores_raw: call ff_get_format if width and height change 2025-11-12 00:37:24 +01:00
Lynne e93e2a5be1 prores: call ff_get_format if width and height change
The issue is that hardware decoders may have some state they depend on,
which would get broken if the dimensions change.
2025-11-12 00:37:19 +01:00
Zhao Zhili cbc6134a4a avcodec/nvenc: fix -Wenum-conversion on colorspace/pri/trc
SDK 12.0 defined enum types for colorspace/pri/trc, while lower
versions use uint32_t.
2025-11-11 20:08:36 +00:00
Rémi Denis-Courmont 9b348aa60b riscv/cpu: add V subset feature detection
This adds support for detecting Zve32x, Zve32f, Zve64x and Zve64d on
a system that does not support (or declare) the full V feature set.

Because the code assumes that vector detected at runtime are at least
128-bit long, we have to manually check that too (in theory, vectors
can be 32-bit or 64-bit, though that makes little sense in 2025).
2025-11-11 18:40:47 +00:00
Lynne be99d2c0b2 vf_colorspace: allow for extended primaries and colorspace 2025-11-10 21:50:58 +00:00
Lynne d916803290 swscale: allow extended primaries 2025-11-10 21:50:58 +00:00
Martin Storsjö 032bdf8ebd Revert "Re-initialize stream on new metadata."
This reverts commit 7b18eafabd.

That commit added tests that don't work on Windows, and which
also fail in setups with cross/remote testing (with --target-exec
and --target-path).

See https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20876 for more
discussions about issues with that commit.
2025-11-10 14:03:43 +02:00
Niklas Haas 133a0bcb13 fftools/ffmpeg_sched: prevent demuxers from getting stuck
When the furthest-behind stream is being fed by a demuxer that is also
feeding packets to a choked filter graph, we need to unchoke that filter
graph to prevent the demuxer from getting stuck trying to write packets to
the choked filter graph.

This situation can also apply recursively - if the demuxer is also writing
to a filtergraph that is also reading from a choked demuxer, there is a
similar deadlock.

Solve all such deadlocks by just brute-force recursively unchoking all
nodes that can somehow prevent this demuxer from writing packets. This
should normally not result in any change in behavior, unless audio/video
streams are badly desynchronized, in which case it may result in extra
memory usage from the too-far-ahead stream buffering packets inside the
muxer. (But this is, of course, preferable to a deadlock)

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/20611
2025-11-10 09:55:40 +00:00
Zhao Zhili 071db4b81c tests/fate/hevc: add a mv-hevc sample using long term ref 2025-11-10 12:22:05 +08:00
Zhao Zhili 141f5c9071 avcodec/hevc: reset long_term_rps.nb_refs for IDR
For mv-hevc, the second layer of IDR frame can be a P slice.
long_term_rps wasn't been reset before the patch, which leading to
ff_hevc_frame_nb_refs return incorrect result.

This fix decoding failure for samples from Pico VR.
2025-11-10 12:22:05 +08:00
Zhao Zhili 6bdea3ae23 avcodec/hevc: remove an always true condition
long_rps is &sh->long_term_rps.
2025-11-10 12:22:05 +08:00
Zhao Zhili c4ce51ee62 avfilter/vf_libopencv: bump to opencv4 2025-11-10 04:12:50 +00:00
Michael Niedermayer 729d0379ab avcodec/rv60dec: Clear blk_info
Fixes: use of uninitialized memory
Fixes: 418335931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-5103986067963904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-10 01:46:52 +00:00
Michael Niedermayer c199b3d48f avformat/whip: Fix rtp_ctx->streams access
Fixes: out of array access
No testcase

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-10 00:24:44 +00:00
Romain Beauxis 7b18eafabd Re-initialize stream on new metadata. 2025-11-09 11:45:37 -06:00
Andreas Rheinhardt dd05022def avformat/mp3enc: Avoid av_unused
Possible now that -Wdeclaration-after-statement is no more.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-09 13:44:18 +01:00
Andreas Rheinhardt 08b74d5d5c swresample/swresample: Avoid av_unused
Possible now that -Wdeclaration-after-statement is no longer used.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-09 13:42:27 +01:00
Romain Beauxis f2b9b1923d Don't reset last{pts,dts} on new sequentialized ogg streams.
This fixes PTS/DTS discontinuity on sequentialized ogg streams.
2025-11-09 10:46:08 +00:00
Michael Niedermayer 59db32b433 avcodec/utvideodec: Set B for the width= 1 case in restore_median_planar_il()
Fixes: use of uninitialized memory
Fixes: 439878388/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_DEC_fuzzer-5635866203848704

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-09 10:44:09 +00:00
Michael Niedermayer 08816b9376 avcodec/osq: Fix 32bit sample overflow
Fixes: signed integer overflow: 2147483565 + 128 cannot be represented in type 'int'
Fixes: 428055715/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6358069900804096

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-09 02:42:17 +01:00
averne d00f41f213 vulkan/prores: forward quantization parameter to the IDCT shader
The qScale syntax element has a maximum value of 512, which would overflow the 16-bit store from the VLD shader in extreme cases.
This fixes that edge case by forwarding the element in a storage buffer, and applying the inverse quantization fully in the IDCT shader.
2025-11-08 22:31:21 +00:00
Tim Blechmann 28461f2c43 libavutil: fix memory leak of drmVersion
address sanitizer showed some leaks of drmVersion structs.
`vaapi_device_create` did not call drmFreeVersion in all possible code
paths.
2025-11-08 21:48:00 +00:00
Martin Storsjö 586898dc1f avformat: Make ff_make_codec_str output to an AVBPrint object 2025-11-08 21:19:31 +00:00
Martin Storsjö 900b77b1b7 hlsenc, dashenc: Share the routine for generating a codec string
The one in dashenc was added in
fe5e6e34c0, while the one in hlsenc
was added later in 0afa171f25. Both
have had various additions on top; merge both implementations
into one shared. (Notable additions in
060e74e2a9,
1cf2f040e3,
a2b1dd0ce3 and
797f0b27c175022d896e46db4ac2873e3e0a70af.)

For H264/avc1, use the implementation from hlsenc (which doesn't
use temporary allocations). For most other codecs, use the
only implementation from whichever had one.

The original dashenc implementation tried to be generic based
on RFC 6381, looking up codec tags in ff_codec_movvideo_tags
or ff_codec_movaudio_tags, and doing specific extra additions
for "mp4a" and "mp4v". In practice, only AV_CODEC_ID_AAC
and AV_CODEC_ID_MPEG4 ever mapped to these; simplify this to
a more straightforward codec id based handling, and merge
with the AAC profile based code from hlsenc.

There's a slight behaviour difference from the old one in
dashenc; if there's no code for a specific codec ID, we previously
just output what we matched from the mov tag tables, but now
we won't output anything. But most commonly used codecs in
DASH should be covered here.
2025-11-08 21:19:31 +00:00
Martin Storsjö ee22107c67 avformat/vpcc: Make input pointers const 2025-11-08 21:19:31 +00:00
Martin Storsjö d015382f4a avformat/vpcc: Generalize the AVFormatContext parameter to void*
This parameter is only used as a logging context; don't require
a full AVFormatContext here.
2025-11-08 21:19:31 +00:00
Stefan Breunig 549b45459e avfilter/vf_frei0r: fix time not being passed in seconds
The frei0r API expects the time in seconds, but was given it in
milliseconds. The bug might exist since 41f1d3a (~14 years ago),
but plugins depending on the time are unwatchable without this
patch. For example:

ffmpeg -filter_complex "testsrc2=d=5,frei0r=distort0r" out.mp4

Signed-off-by: Stefan Breunig <stefan-ffmpeg-devel@breunig.xyz>
2025-11-08 20:55:03 +00:00
Andreas Rheinhardt cb7b962a4a avutil/timecode: Fix -Wformat-truncation warning
Using unsigned for fps is more natural since the corresponding
AVTimecode field is unsigned. It also fixes a -Wformat-truncation
warning from GCC 16: in case fps were negative, hours, minutes
and seconds would be negative, leading to additional '-' characters
which are not accounted for in AV_TIMECODE_STR_SIZE.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 19:33:11 +01:00
Andreas Rheinhardt 32f32537b6 avcodec/dvdec,mjpegdec: Remove emms_c
It is no longer necessary now that the IDCTDSP is always ABI-compliant
(and free of MMX).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt ade54335b2 avcodec/x86/simple_idct: Port to SSE2
Before this commit, the (32-bit only) simple idct came in three
versions: A pure MMX IDCT and idct-put and idct-add versions
which use SSE2 at the put and add stage, but still use pure MMX
for the actual IDCT.

This commit ports said IDCT to SSE2; this was entirely trivial
for the IDCT1-5 and IDCT7 parts (where one can directly use
the full register width) and was easy for IDCT6 and IDCT8
(involving a few movhps and pshufds). Unfortunately, DC_COND_INIT
and Z_COND_INIT still use only the lower half of the registers.

This saved 4658B here; the benchmarking option of the dct test tool
showed a 15% speedup.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt 625f5c993c avcodec/tests/dct: Remove unnecessary emms_c
Unnecessary since the Xvid IDCT no longer uses MMX registers at all.
(Notice that the simple MMX IDCT issues emms and is therefore ABI
compliant.)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt a26b99f793 avcodec/x86/xvididct: Remove remnants of MMX
The non-MMX code only uses the first six rounders.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt b03b09aeda avcodec/x86/xvididct: Don't use MMX registers in SSE2 function
It is higly surprising and would necessitate emms in order to be ABI
compliant; but it is better just not to use them in the first place.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt a7013f813c avcodec/tests/x86/dct: Test 32bit simple idct
The test has been removed in bfb28b5ce8
when MMX idctdsp functions overridden by SSE2 were removed;
ff_simple_idct_mmx() has been completely disabled in this patch
for x64 and so the test should have been disabled on x64 instead
of removing it.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt 86f8adc58e avcodec/x86/idctdsp_init: Fix IDCT permutation for 32bit without SSE2
bfb28b5ce8 removed the MMX idct_put
and idct_add functions, because they were overridden by SSE2 versions
(which use SSE2 only for the put/add part, not the actual IDCT).
This meant that for MMX, the idct functions are not set in unison,
so that the permutation which is meant to apply to all three
is incorrect on 32bit systems if SSE2 is unavailable/disabled.

Fix this by setting the MMX version only if SSE2 is enabled.

(No one complained, so apparently no one uses a new FFmpeg
with non-SSE2 capable systems.)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Michael Niedermayer d4e0d5ed48 avformat/rtpdec_rfc4175: Check dimensions
Fixes: out of array access
Fixes: zeropath/int_overflow_in_rtpdec_rfc4175

Found-by: Joshua Rogers <joshua@joshua.hu>
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 18:41:24 +01:00
Michael Niedermayer c03e49dd1d avformat/rtpdec_rfc4175: Only change PayloadContext on success
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 18:41:24 +01:00
Michael Niedermayer af3dee3132 avformat/rtpdec_rfc4175: Fix memleak of sampling
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 18:41:17 +01:00
Andreas Rheinhardt a8dd83b4b1 avcodec/get_bits: Avoid unused variable
Fixes lots of warnings from MSVC (which does not support av_unused).

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 14:48:12 +01:00
Zhao Zhili 36e5576a44 avutil/hwcontext_d3d12va: fix buf size when call av_buffer_create 2025-11-08 08:15:17 +00:00
Michael Niedermayer b518c027a0 avformat/http: Fix off by 1 error
Fixes: out of array access
Fixes: zeropath/off-by-one-one-byte

Found-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 02:26:36 +01:00
Michael Niedermayer d80f8f3651 avcodec/exr: spelling
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 01:17:46 +01:00
oblivionsage 8abeb879df avcodec/rv60dec: add upper bound check for qp
The quantization parameter (qp) can exceed 63 when the base value
from frame header (0-63) is combined with the offset from slice data
(up to +2), resulting in qp=65. This causes out-of-bounds access to
the rv60_qp_to_idx[64] array in decode_cbp8(), decode_cbp16(), and
get_c4x4_set().

Fixes: Out-of-bounds read
Signed-off-by: oblivionsage <cookieandcream560@gmail.com>

No testsample is available

This is related to 61cbcaf93f and clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-5160167345291264
which fixed rv60_qp_to_idx[qp + 32] out of array access
These 2 checks are not redundant and neither covers the cases of the other

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 01:16:39 +01:00
veygax 162f75b5e6 avcodec/exr: use tile dimensions in pxr24 UINT case
update the switch statement for EXR_UINT in pxr24_uncompress to
correctly use the tile width td->xsize instead of using the full window
width s->xdelta. s->delta is larger than td->xsize which lead to two
buffer overflows when interacting with the ptr variable in the same
switch statement.

Fixes: out of bounds read and write
Found-by: veygax's insomnia network (INSOMNIA-1)
Signed-off-by: veygax <veyga@veygax.dev>
2025-11-07 23:27:34 +01:00
Michael Niedermayer 6e8cf0377f avcodec/exr: Simple check for available channels
The existing is_luma check is fragile as depending on the order
of channels it can be set or reset

No testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-07 23:12:42 +01:00
Andreas Rheinhardt dd092f7fd9 avcodec/avcodec: Simplify sentinel checks
There is no need to check the whole AVChannelLayout; checking
its nb_channels is enough.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt 946a1dbd94 avcodec/tests/avcodec: Check codec {pix,sample}_fmt etc. arrays
E.g. check that the ordinary entries are valid (e.g. no negative sample
rates, must have pix fmt descriptor) and also that the sentinels
are valid where they contain redundant information.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt e9be8b831d avcodec/tests/avcodec: Test that decoders don't set encoder-only fields
For decoders, the pixel format is negotiated via the get_format callback
(if there is a choice at all), so decoders should not set pix_fmts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt 2523235a31 avcodec/amfdec: Don't set AVCodec.pix_fmts
It is not supposed to be set by decoders (where format negotiation
happens via the get_format callback).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt ef3e337079 avcodec/tests/avcodec: Test color_ranges and alpha_modes
Test that they are only set by video codecs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt ab70751c8a avcodec/codec_internal: Use bitfield for alpha_modes
Right now, FFCodec contains a dedicated pointer for
alpha_mode; this is wasteful, as there is only a very limited
range of options for this value, namely four.
So store it as a two-bit bitfield like color_ranges.
This reduces sizeof(FFCodec) by 16 here (the placement
of alpha_mode entailed unnecessary padding) and
saves 11328B of .data.rel.ro here (on a standard build with
no external libraries).

(If it were not for effective-type violations, one could
share the code and the table with AV_CODEC_CONFIG_COLOR_RANGE.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt df1b6f9cfd avcodec/avcodec: Avoid relocations for color ranges
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt 1d68ae7389 avcodec/avcodec: Remove always-true branches
avcodec_get_supported_config() always sets a dummy for
the pointer to the number of entries in case it is not set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt a2210902ff avcodec/encode: Use enum AVPictureType in ff_encode_add_stats_side_data
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Andreas Rheinhardt 08e75b8211 avcodec/packet: Move ff_side_data_set_encoder_stats() to encode.c
And rename it to ff_encode_add_stats_side_data() and move its
declaration to encode.h. Also constify the error pointee.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Andreas Rheinhardt ec239259a7 avcodec/libx265: Remove stray FF_ENABLE_DEPRECATION_WARNINGS
Forgotten in 7d07723db5.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Andreas Rheinhardt 8a46fe1a7d avcodec/libaomenc: Avoid av_unused
pict_type is always used since 5e0eac3d4566839598f6d6fe5d77770023d6713a;
ctx in set_pix_fmt() seems to have been always unused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Rémi Denis-Courmont 7435a3180d riscv/cpu: add av_const for VLEN helpers
This is read from a read-only constant system register.
2025-11-07 08:43:23 +00:00
Rémi Denis-Courmont 39abb1ac94 pixblockdsp: avoid segments on R-V V diff_pixels_unaligned
On SpacemiT X86, before:
diff_pixels_unaligned_rvv_i32:                         250.2 ( 0.59x)
...after:
diff_pixels_unaligned_rvv_i32:                          56.9 ( 2.60x)
2025-11-07 08:43:23 +00:00
Rémi Denis-Courmont c17d304e1f pixblockdsp: avoid segments on R-V V get_pixels_unaligned
On SpacemiT X86, before:
get_pixels_unaligned_rvv_i32:                          172.4 ( 0.37x)
...after:
get_pixels_unaligned_rvv_i32:                           34.4 ( 1.84x)
2025-11-07 08:43:23 +00:00
Rémi Denis-Courmont e3b0d58394 Revert "lavc/pixblockdsp: rework R-V V get_pixels_unaligned"
The optimised version does not work if the stride is not a multiple 8,
which can occur as reproduce by vsynth3-asv1 and vsynth3-asv2 tests.

This reverts commit 02594c8c01.

Conflicts:
	libavcodec/riscv/pixblockdsp_init.c
	libavcodec/riscv/pixblockdsp_rvv.S
2025-11-07 08:43:23 +00:00
Michael Yang df1fd43db4 libavcodec/vulkan_encode_av1: fix non-monotonic DTS
Combine P-frame with following B-frame into a single packet with the
latter's order. Emit a tail packet with a show_existing_frame header
to show it at the correct PTS.
2025-11-06 22:06:42 +00:00
Lynne dd80ecb666 doc/APIchanges: bump lavu minor and remove reverted pixfmts 2025-11-06 21:47:08 +01:00
Lynne 6720f71247 Revert "vulkan/prores: output LSB-padded data"
This reverts commit 909d71322a.

The issue was elsewhere, not in our code.
2025-11-06 21:46:43 +01:00
Lynne 9a7174bc9a Revert "lavu/pixfmt: add grayscale 10 and 12-bit MSB padded variants"
This reverts commit ed5b694ebe.
2025-11-06 21:46:43 +01:00
Lynne 26236a47b2 Revert "lavu/pixfmt: add 420 and 422, 10 and 12-bit MSB padded variants"
This reverts commit e42c7698f5.
2025-11-06 21:46:43 +01:00
Lynne b982b2a2a3 Revert "swscale: add support for 10/12-bit grayscale MSB pixfmts"
This reverts commit a5be0ecbfd.
2025-11-06 21:46:41 +01:00
Lynne 72a19a1c4a Revert "swscale: add support for 10/12-bit 422 and 444 MSB pixfmts"
This reverts commit bc0ee8b7cc.
2025-11-06 21:44:13 +01:00
Lynne 22cc958c58 Revert "hwcontext_vulkan: fix grayscale 10 and 12-bit formats using the new MSB formats"
This reverts commit 471acedec2.
2025-11-06 21:44:13 +01:00
Lynne 2c7732a676 Revert "hwcontext_vulkan: fix 3-plane 444 10 and 12-bit formats using the new MSB formats"
This reverts commit 41ecb203c5.
2025-11-06 21:44:13 +01:00
Lynne 38df9ba71b Revert "hwcontext_vulkan: fix planar 10 and 12-bit RGB formats using the new MSB formats"
This reverts commit 98ee3f6718.
2025-11-06 21:44:13 +01:00
Lynne 15e82dc452 Revert "hwcontext_vulkan: remove unsupported/broken pixel formats"
This reverts commit 5b388f2838.
2025-11-06 21:44:13 +01:00
Lynne deaece6e56 Revert "swscale/format: add missing fmt_shift for gray12/12 msb formats"
This reverts commit c9710dae3c.
2025-11-06 21:44:13 +01:00
Ramiro Polla 4bee010844 swscale/range_convert: fix truncation bias in range conversion
384fe39623 introduced a regression in the
range conversion offset calculation, resulting in a slight green tint
in full-range RGB to YUV conversions of grayscale values.

The offset being calculated was not taking into consideration a bias
needed for correctly rounding the result from the multiplication stage,
leading to a truncated value.

Fixes issue #11646.
2025-11-06 20:36:08 +00:00
Niklas Haas 01b105bb06 tests/fate/swscale: add swscale self-test
This one takes about 2.93s on my machine, but ensures that every pixel
format conversion roundtrips correctly. Note that due to existing bugs in
libswscale, this one only passes when using the new format conversion code.

Restrict the test to -v 16 (AV_LOG_ERROR) to avoid excess amounts of output.
2025-11-06 20:34:51 +00:00
Niklas Haas 9a386078cc tests/swscale: use av_log() where appropriate
We can't use ANSI color codes inside av_log(), so fall back to printf()
for these; but match the INFO verbosity level.

Also change the format slightly to drop SSIM numbers down to just below
VERBOSE level, since VERBOSE tends to generate a lot of swscale related
spam.
2025-11-06 20:34:51 +00:00
Niklas Haas 84b365d522 avfilter/avfiltergraph: print both failing links on conversion error
This is more informative than the current behavior, because when the first
MERGE() succeeds but the second fails, the original link already has
merged formats and thus the error message is confusing.
2025-11-06 18:16:10 +01:00
Niklas Haas 6c3a63112b avfilter/avfiltergraph: only print format lists for failing mergers
Instead of printing all format lists on a link negotiation error, just print
the relevant/failing format lists.
2025-11-06 18:09:36 +01:00
Niklas Haas 7b564e2efc avfilter/avfiltergraph: print all format lists on config failure
Instead of just printing the pixel/sample formats.
2025-11-06 18:01:37 +01:00
Niklas Haas ad5b151f88 avfilter/formats: add name field to AVFilterFormatMerger
Needed to properly print format lists on format configuration failure.
2025-11-06 18:01:33 +01:00
Niklas Haas f5bc9704ed avfilter/formats: constify ff_filter_get_negotiation 2025-11-06 17:48:50 +01:00
Niklas Haas c1717cb666 avfilter/format: add print_list() to AVFilterFormatsMerger
So that the generic code can correctly print format lists for failing mergers.
2025-11-06 17:34:43 +01:00
Niklas Haas c9710dae3c swscale/format: add missing fmt_shift for gray12/12 msb formats
The MSB YUV formats were added, but the gray formats were not. Seems to have
been an oversight.

Fixes: a5be0ecbfd
2025-11-06 15:56:24 +01:00
Zhao Zhili 222127418b avutil/internal: remove some compats for msvc
They are supported by MSVC with C11.
2025-11-06 02:16:27 +00:00
Andreas Rheinhardt 79080a547a avcodec/x86/h264_chromamc: Use xmm regs in chroma_mc4 SSSE3 functions
Doubling the register size allowed to avoid two pmaddubsw.
It is also ABI compliant (the old version lacked an emms)
and the average versions no longer rely on padding (the old versions
used pavgb with a memory operand reading eight bytes,
although only four are needed).

Old benchmarks (the latter four refer to RV40):
avg_h264_chroma_mc4_8_c:                               145.7 ( 1.00x)
avg_h264_chroma_mc4_8_ssse3:                            32.3 ( 4.51x)
put_h264_chroma_mc4_8_c:                               136.1 ( 1.00x)
put_h264_chroma_mc4_8_ssse3:                            29.0 ( 4.70x)
avg_chroma_mc4_c:                                      162.1 ( 1.00x)
avg_chroma_mc4_ssse3:                                   31.1 ( 5.22x)
put_chroma_mc4_c:                                      137.5 ( 1.00x)
put_chroma_mc4_ssse3:                                   28.6 ( 4.81x)

New benchmarks:
avg_h264_chroma_mc4_8_c:                               146.7 ( 1.00x)
avg_h264_chroma_mc4_8_ssse3:                            26.5 ( 5.53x)
put_h264_chroma_mc4_8_c:                               136.8 ( 1.00x)
put_h264_chroma_mc4_8_ssse3:                            22.5 ( 6.09x)
avg_chroma_mc4_c:                                      165.5 ( 1.00x)
avg_chroma_mc4_ssse3:                                   27.2 ( 6.08x)
put_chroma_mc4_c:                                      138.1 ( 1.00x)
put_chroma_mc4_ssse3:                                   23.2 ( 5.96x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-06 02:16:28 +01:00
Kacper Michajłow 3eb0cb3b0b avutil/hwcontext_vulkan: use correct bitmask types
Vulkan headers define *FlagBits enum with individual bit values, and
coresponding *Flags typedef to be used to store the bitmask of
coresponding bits.

In practice those two types map to the same type, but for consistency
*Flags should be used.

Fixes MSVC warnings about type mismatch.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-05 19:04:09 +01:00
Kacper Michajłow f478964226 avcodec/vulkan_encode_av1: fix unit_elems check
Wrong enum value was used to check unit_elems. While
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA (11) would trigger when
UNIT_MASTERING_DISPLAY (2) was set, it also would match
UNIT_CONTENT_LIGHT_LEVEL (1) which is not expected.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-05 19:04:01 +01:00
Kacper Michajłow c3ff7d23f5 avcodec/dxva2: move variable declaration to for loop to avoid warning
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-05 19:04:01 +01:00
Kacper Michajłow 08d327e92c fftools/ffmpeg: suppress unused variable warning, but using it
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-05 19:04:00 +01:00
Lynne 873a173328 aacpsy: fix whitespace and code style
The last merged patch contained garbage.
2025-11-05 16:31:59 +00:00
Zhao Zhili 632958d2bf avformat/mov: log unknown tag via av_fourcc2str
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-05 23:45:31 +08:00
Zhao Zhili 07581d6736 avformat/mov: check prji box version and flags
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-05 23:45:31 +08:00
Zhao Zhili 0734d1c55a avformat/mov: relax check on proj box size
Pico VR adds a '\0' after projection_type (a real C string than
a fourcc). It's not strictly correct, but doesn't affect parsing.

[prji: Projection Information Box]
    position = 149574743
    size = 17
    version = 0
    flags = 0x000000
    projection_type = rect

Co-Authored-by: Keven Ma
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-05 23:45:31 +08:00
Zhao Zhili 84fcbce16c fate/hevc: add tests for the dts2pts bsf 2025-11-05 15:13:54 +00:00
Zhao Zhili 2d241202ff avcodec/bsf/dts2pts: add hevc support 2025-11-05 15:13:54 +00:00
Zhao Zhili 6c83bcadbb avcodec/hevc: add ff_hevc_compute_poc2 which don't depend on HEVCSPS directly
So it can be used in other places like bsf.
2025-11-05 15:13:54 +00:00
Zhao Zhili 5f15734d92 avcodec/bsf/dts2pts: fix return 0 on error path 2025-11-05 15:13:54 +00:00
Zhao Zhili 91b2fe71cc avcodec/bsf/dts2pts: remove always true check 2025-11-05 15:13:54 +00:00
Kacper Michajłow 671e54d715 configure: add -static suffix to internal static libs for test programs
In MSVC builds, object files built for shared or static libraries are
technically not compatible with each other. That's why building both
shared and static libraries simultaneously is not allowed in configure.
This may change in the future once dllimport/dllexport attributes are no
longer used. Which will be possible on next major bump. The only
remaining use of dllexport was changed in c6c8063186.

However, for test programs, we still build internal static libraries
that allow the test programs to access internal symbols.

In commit 8eca3fa619, I assumed that when
CONFIG_STATIC=0, we would never build a static library. We actually do
build one for internal purposes, for the test executables. In that case,
we only link the tested library statically (using the same object files
as built for the shared library), the rest of the libraries are still
linked dynamically.

Such libraries are never installed and are used only for test programs.
This change adds a -static suffix to these internal libraries to avoid
name conflicts. In the MSVC world, static libraries and import libraries
are generally the same thing and share the same naming conventions.

Fixes: 8eca3fa619
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-05 13:00:09 +00:00
Niklas Haas 08eda05967 avfilter/vf_libplacebo: make rotation check more robust
This currently does not make any difference, but it makes the check
more robust against possible future changes to the rotation parameter.
2025-11-04 12:38:55 +00:00
Niklas Haas 49452967e7 avfilter/vf_libplacebo: don't override existing rotation attribute
This is a regression introduced by the addition of the rotation option,
which overrode the existing rotation attribute that may have been set to
the image.

To fix it, add the rotation istead of setting it - however we have to do this
directly when mapping, so as to not add it multiple times.

Fixes: 4f623b4c59
2025-11-04 12:38:55 +00:00
Andreas Rheinhardt 6c1acbbffb avcodec/x86/fdct: Remove obsolete comment
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:41:32 +01:00
Andreas Rheinhardt 18e08101eb avcodec/x86/Makefile: Don't use MMX-OBJS for fdct.o
MMX has been removed in d402ec6be9.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:41:29 +01:00
Andreas Rheinhardt 8157aa1a3f avcodec/x86/me_cmp: Remove MMX sse functions
They are overridden by SSE2 and no longer needed by the no longer
existing nsse MMX functions. Saves 240B here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:41:11 +01:00
Andreas Rheinhardt 3f596ec478 avcodec/x86/me_cmp: Port nsse{8,16} to SSSE3
Even nsse8 has to operate on eight words and therefore gains
a lot from xmm registers (and pabsw).

Old benchmarks:
nsse_0_c:                                              359.2 ( 1.00x)
nsse_0_mmx:                                            151.8 ( 2.37x)
nsse_1_c:                                              151.2 ( 1.00x)
nsse_1_mmx:                                             77.5 ( 1.95x)

New benchmarks:
nsse_0_c:                                              358.8 ( 1.00x)
nsse_0_ssse3:                                           62.2 ( 5.77x)
nsse_1_c:                                              151.2 ( 1.00x)
nsse_1_ssse3:                                           33.6 ( 4.50x)

The MMX nsse functions have been removed.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:40:39 +01:00
Andreas Rheinhardt 86062cfa03 avcodec/x86/me_cmp: Add ff_sse8_sse2()
Benchmarks:
sse_1_c:                                                51.9 ( 1.00x)
sse_1_mmx:                                              16.5 ( 3.15x)
sse_1_sse2:                                              9.7 ( 5.36x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:40:32 +01:00
Andreas Rheinhardt 232e72d00e avcodec/x86/me_cmp: Rename registers
This will avoid using xmm registers that are volatile for Win64
in the next commit.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:40:19 +01:00
Andreas Rheinhardt 87cfbcb74a avcodec/x86/me_cmp: Avoid unnecessary instruction
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:39:25 +01:00
Manuel Lauss d058d5db10 avcodec/sanm: implement codec45
This is a post-processing codec: given delta-x/y coordinates and a run length,
the r/g/b components of the 4 surrounding pixels are summed up, and the resulting
15bit value is used as index into a color quantization table to derive the
resulting pixel at the center.

It is only used in 10-20 frames of the Rebel Assault 2 LxxRETRY.SAN files
to slightly blur the outline of the "opening aperture" effect.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-11-04 10:28:57 +00:00
Martin Storsjö 8313dc1120 movenc: Make hybrid_fragmented retain the fragmented form headers
This makes the final file truly hybrid: Externally the file
is a regular, non-fragmented file, but internally, the fragmented
form also exists un-overwritten.

To make any use of that, first, the fragments need to be muxed in
a position independent form, i.e. with empty_moov+default_base_moof
(or the dash or cmaf meta-flags).

Making use of the fragmented form when the file is finalized is
not entirely obvious though. One can dump the contents of the
single mdat box, and get the fragmented form. (This is a neat
trick, but not something that anybody really is expected to
want to do.)

The main expected use case is accessing fragments in the form of
byte range segments, for e.g. HLS.

Previously, the start of the file would look like this:

- ftyp
- free
- moov
 - (moov contents)

After finalizing the file, it would look like this:

- ftyp
- free
- mdat (previously moov)
 - (moov contents)

In this form, the size and type of the original moov box were
overwritten, and the original moov contents is just leftover
as unused data in the mdat box.

To avoid this issue, the start of the file now looks like this:

- ftyp
- free
- free
 - ftyp
- moov
 - (moov contents)

The second, hidden ftyp box inside mdat, would normally never be
seen.

After finalizing, the difference is that the mdat box now is
extended to cover the ftyp and the whole moov including its header
(and all the following fragments).

I.e., the start of the file looks like this:

- ftyp
- free
- mdat
 - ftyp
 - moov
  - (moov contents)

This allows accessing the "ftyp+moov" pair sequentially as such,
with a byte range - this range is untouched when finalizing,
producing the same ftyp+moov pair both while writing, when the
file is fragmented, and after finalizing, when the file is
transformed to non-fragmented externally.

Note; the sequential two "free+free" boxes may look slightly
silly; it could be tempting to make the second one an mdat
from the get-go. However, some players of fragmented mp4 (in
particular, Apple's HLS player) bail out if the initialization
segment contains an mdat box - therefore, use a free box.

It could also be possible to use just one single free box with
8 bytes of padding at the start - but that would require more
changes to the finalization logic.

For a segmenting user of the muxer, the only unclarity is how
to determine the right byte range for the internal ftyp+moov
pair. Currently, this requires parsing the muxer output and skip
past anything up to the start of the non-empty free box.
2025-11-04 10:23:31 +00:00
Agent45 a06aee359b revert 458a942481151ede27478e6ac6d9d2866d438b84
revert avcodec/aacenc: add bitrate threshold for PNS
2025-11-04 09:55:51 +00:00
Agent45 e11dfb3f09 trim trailing whitespace in aacpsy.c 2025-11-04 09:55:51 +00:00
Agent45 d907f7d555 avcodec/aacpsy: fix attack detection logic and subblock indexing
Fix several indexing errors in attack detection logic and refine transient handling in the AAC psychoacoustic model.

- Change PSY_LAME_NUM_SUBBLOCKS from 3 to 2 to ensure full coverage of all 1024 MDCT samples, with each subblock containing exactly 1024 / (8 * 2) = 64 samples—matching LAME’s empirical design.
- Introduce next_attack0_zero state flag to stabilize attack[0] prediction across frames.
- Adjust attack threshold presets.

These changes improve the handling of periodic signals such as trumpet, especially under low bitrate conditions.
2025-11-04 09:55:51 +00:00
Agent45 9bded2145f avcodec/aacenc: add bitrate threshold for PNS 2025-11-04 09:55:51 +00:00
Timo Rothenpieler d479a4926a forgejo/workflows: make one of the builds shared 2025-11-03 19:03:16 +00:00
James Almer 4bdc932ec9 avcodec/pthread_frame: sync alpha_mode across worker threads and the user context
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-03 00:16:03 -03:00
James Almer f5eb11a71d avcodec/decode: add missing syncing of side_data_pref_mask to worker threads
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-02 18:14:17 -03:00
Andreas Rheinhardt 8e90f150eb avcodec/decode: Optimize lcevc away if disabled
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 16:50:36 +01:00
Andreas Rheinhardt 63685709b9 avcodec/decode: Mark init,close functions as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 16:49:26 +01:00
Andreas Rheinhardt 2786e5a9ad avcodec/decode: Put lcevc fields into structure of their own
Makes it easier to see that width and height in DecodeContext is
actually a lcevc field.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 16:00:06 +01:00
Andreas Rheinhardt 182b9c7a4a avcodec/decode: Don't allocate LCEVC context for non-video
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 15:29:59 +01:00
Andreas Rheinhardt abf819cff6 avcodec/pthread_frame: Call ff_decode_internal_sync() only during init
It is not necessary to do it more than once, as none of the fields
set change after init.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 15:09:43 +01:00
Andreas Rheinhardt 1e0cd4b650 .gitignore: Add config_components.asm
Forgotten in c607aae2b9.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 13:10:58 +00:00
Andreas Rheinhardt a2914a1ec3 avcodec/x86/hpeldsp: Don't use PAVGB macro
It was only needed for MMX and there are no MMX functions here any more.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 12:05:52 +01:00
Andreas Rheinhardt c5e94a564c avcodec/x86/hpeldsp: Don't use saturated addition when unnecessary
The numbers here are small (sums of values unpacked from bytes).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 12:05:52 +01:00
Andreas Rheinhardt 2be1b2ea96 avcodec/x86/hpeldsp: Actually use constants in registers
Forgotten in 36f92206bb.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 12:05:52 +01:00
Andreas Rheinhardt a677b38298 avcodec/x86/vp3dsp: Remove remnants of MMX
Forgotten in eefec06634.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 12:01:52 +01:00
Andreas Rheinhardt d355749ca6 avcodec/x86/hevc/add_res: Avoid unnecessary modification
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 09:46:15 +01:00
Andreas Rheinhardt f4d9fb0bd0 avcodec/x86/hevc/add_res: Reduce number of registers used
This makes these functions use only volatile registers (even on Win64).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 09:46:15 +01:00
Andreas Rheinhardt 23efbb5e2e avcodec/x86/hevc/add_res: Remove AVX add_residual functions
The AVX and SSE2 functions are identical except for the VEX encodings
used since e9abef437f and
8b8492452d.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 09:46:15 +01:00
James Almer 7770c0bf0d avcodec/exr: don't remove Float2HalfTables tables alongside the deprecated gamma code
It's used by other parts of the module that will fail to build otherwise after
the aforementioned removal.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-02 00:21:18 -03:00
Michael Niedermayer 5b98cea4bf avformat/sctp: Check size in sctp_write()
Fixes: out of array access
No testcase

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-01 23:22:32 +01:00
Michael Niedermayer 83e0298de2 avformat/rtmpproto: consider command line argument lengths
Fixes: out of array access
Fixes: zeropath/rtmp-2025-10

Found-by: Joshua Rogers <joshua@joshua.hu>
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-01 19:54:07 +01:00
Michael Niedermayer a64e037429 avformat/rtmpproto_ Check tcurl and flashver length
Fixes: out of array accesses

Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-01 19:53:46 +01:00
Andreas Rheinhardt fa959bb135 avcodec/parsers: Silence deprecation warnings
Slipped through because Clang (in contrast to GCC) does not warn about
this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 18:48:17 +01:00
Andreas Rheinhardt 25968dbb05 avcodec/parser_internal: Rename PASSTHROUGH macro to avoid name conflict
wingdi.h defines its own PASSTHROUGH and it is included implicitly
by the VC-1 parser (which is mpegvideo-based and therefore includes
a lot of stuff).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 18:41:27 +01:00
Andreas Rheinhardt 8a322c956f avcodec/avcodec: Schedule parser API to use enum AVCodecID for codec ids
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 16:57:03 +01:00
Andreas Rheinhardt 7c43cc4cb7 avcodec/parser_internal: Remove prefix from parser_{init,parse,close}
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 16:57:03 +01:00
Andreas Rheinhardt e0b0ca8111 avcodec/avcodec: Schedule moving private fields of AVCodecParser out of avcodec.h
AVCodecParser has several fields which are not really meant
to be accessed by users, but it has no public-private
demarkation line, so these fields are technically public
and can therefore not simply be made private like
20f9727018 did for AVCodec.*

This commit therefore deprecates these fields and
schedules them to become private. All parsers have already
been switched to FFCodecParser, which (for now) is a union
of AVCodecParser and an unnamed clone of AVCodecParser
(new fields can be added at the end of this clone).

*: This is also the reason why split has never been removed despite
not being set for several years now.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 16:57:02 +01:00
Andreas Rheinhardt e9fe30ccd1 avcodec/parsers: Add macro to set list of codec ids
The current code relies on AV_CODEC_ID_NONE being zero, so that
unused codec ids are set to their proper value. This commit adds
a macro to set unset ids to AV_CODEC_ID_NONE.

(The actual rationale for this macro is to simplify
the transition to making the private fields that are
currently public in avcodec.h really private.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 16:57:02 +01:00
Andreas Rheinhardt 12f7a7724d avcodec: Remove unnecessary parser.h inclusions
It only contains declarations for some auxiliary functions for parsing
that parsers that only work with complete packets don't need.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 16:57:02 +01:00
James Almer 633d424b1b avutil/csp: don't dereference NULL pointer in av_csp_primaries_desc_from_id()
Fixes CID 1668265.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-01 12:41:23 -03:00
James Almer 492310ec6e fftools/ffmpeg_demux: fix memory leak when creating tile grid filtergraphs
If av_packet_side_data_to_frame() fails, graph_str will leak.

Fixes CID 1668266.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-01 12:41:23 -03:00
James Almer acd2cfe2eb fftools/ffmpeg: make fg_create{_simple,} clear the input string pointer
The graph string is either freed or attached to the filtergraph, so it's best to
not leave a dangling pointer with the caller.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-01 12:41:23 -03:00
James Almer 9c266084fe avcodec/vc1_parser: stop splitting ENDOFSEQ markers into separate packets
The decode API can handle outputting delayed frames without relying on the
parser splitting off the ENDOFSEQ marker.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-01 12:23:19 -03:00
James Almer 9ab6a94195 avcodec/vc1dec: look for ENDOFSEQ markers at the end of a packet's payload
This is in preparation for the parser no longer splitting them into their own
packets.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-01 12:22:49 -03:00
Andreas Rheinhardt fc2c030fb2 avcodec/vc1dec: Deduplicate cleanup code
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 15:47:45 +01:00
Andreas Rheinhardt a44f7b6c4f avcodec/vc1dec: Don't initialize write-only intra_scantable
VC-1 does not use it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 15:47:45 +01:00
Andreas Rheinhardt b91081274f avcodec/x86/h264_qpel: Add and use ff_{avg,put}_pixels16x16_l2_sse2()
This avoids mmx (the size 16 h264qpel dsp now no longer uses any mmx)
and improves performance, particularly for the avg case:

Old benchmarks:
avg_h264_qpel_16_mc01_8_c:                             780.0 ( 1.00x)
avg_h264_qpel_16_mc01_8_sse2:                           91.2 ( 8.55x)
avg_h264_qpel_16_mc03_8_c:                             804.0 ( 1.00x)
avg_h264_qpel_16_mc03_8_sse2:                           91.2 ( 8.82x)
put_h264_qpel_16_mc01_8_c:                             779.5 ( 1.00x)
put_h264_qpel_16_mc01_8_sse2:                           82.8 ( 9.41x)
put_h264_qpel_16_mc03_8_c:                             770.1 ( 1.00x)
put_h264_qpel_16_mc03_8_sse2:                           82.5 ( 9.33x)

New benchmarks:
avg_h264_qpel_16_mc01_8_c:                             783.9 ( 1.00x)
avg_h264_qpel_16_mc01_8_sse2:                           84.1 ( 9.32x)
avg_h264_qpel_16_mc03_8_c:                             797.4 ( 1.00x)
avg_h264_qpel_16_mc03_8_sse2:                           83.9 ( 9.51x)
put_h264_qpel_16_mc01_8_c:                             767.4 ( 1.00x)
put_h264_qpel_16_mc01_8_sse2:                           80.5 ( 9.53x)
put_h264_qpel_16_mc03_8_c:                             779.9 ( 1.00x)
put_h264_qpel_16_mc03_8_sse2:                           80.3 ( 9.71x)

(qpeldsp will use these functions when it gets ported to SSE2;
then the mmxext functions will be removed as well.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 15:17:05 +01:00
Andreas Rheinhardt 529a048c31 avcodec/x86/qpel: Add specializations for put_l2 functions
These functions are currently always called with height either
being equal to the block size or block size+1. height is
a compile-time constant at every callsite. This makes it possible
to split this function into two to avoid the check inside
the function for whether height is odd or even.

The corresponding avg function is only used with height == block size,
so that it does not have a height parameter at all. Removing the
parameter from the put_l2 functions as well therefore simplifies
the C code.

The new functions increase the size of .text from qpel{dsp}.o
by 32B here, yet they save 464B of C code here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 15:17:05 +01:00
Andreas Rheinhardt 5715eb1274 avcodec/x86/{h264_qpel,qpeldsp_init}: Move shared decls into header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 15:17:05 +01:00
Andreas Rheinhardt b03b45cf22 avcodec/x86/h264_chromamc: Remove MMX(EXT) funcs overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMX(EXT) functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 13:34:23 +01:00
Andreas Rheinhardt cb054ee89b avcodec/x86/h264_chromamc: Add SSSE3 RV40 chroma motion compensation functions
The only difference between it and the H.264/VC-1 versions is the
bias constant which depends on the shift parameters for RV40.
This value ends up in a register and therefore one can reuse
the H.264 code by setting the registers for RV40 and then jumping
into the relevant H.264 function, making the four new functions
cheap (just 256 bytes in total). This approach uses one jump more
for the no-filter case and one jump less in the one-dimensional
case than an approach using separate functions.

avg_chroma_mc4_c:                                      167.5 ( 1.00x)
avg_chroma_mc4_mmxext:                                  48.1 ( 3.48x)
avg_chroma_mc4_ssse3:                                   31.1 ( 5.39x)
avg_chroma_mc8_c:                                      325.5 ( 1.00x)
avg_chroma_mc8_mmxext:                                 103.2 ( 3.15x)
avg_chroma_mc8_ssse3:                                   33.5 ( 9.71x)
put_chroma_mc4_c:                                      137.4 ( 1.00x)
put_chroma_mc4_mmx:                                     44.5 ( 3.09x)
put_chroma_mc4_ssse3:                                   28.4 ( 4.83x)
put_chroma_mc8_c:                                      271.4 ( 1.00x)
put_chroma_mc8_mmx:                                     99.9 ( 2.72x)
put_chroma_mc8_ssse3:                                   30.6 ( 8.86x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 13:34:00 +01:00
Andreas Rheinhardt c607aae2b9 configure: Add config_components.asm
This is in preparation for the next commit.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 13:33:56 +01:00
Andreas Rheinhardt c6efe1abda avcodec/h264chroma: Move mc1 function to mpegvideo_dec.c
It is only used by mpegvideo decoders (for lowres). It is also only used
for bitdepth == 8, so don't build the bitdepth == 16 function at all any
more.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 13:31:57 +01:00
lholliger e59d964a3c libavformat/mov: add support for name udta
In the QTFF documentation for udta/"user data atoms", "name" is a
valid entry for "name of object" however it is currently skipped
leading to some missing metadata when copying for some files. This
isn't classified the same as "(C)nam" which is "Title of content"
so they aren't necessarily the same.
2025-10-31 14:28:23 +00:00
Desmond Liu 4348bde2d2 libavformat/udp: Fix call to recvfrom(2)
Last parameter to recvfrom() is not initialized, causing
recvfrom() to randomly return EINVAL. Issue was introduced in
af04a27893.
2025-10-30 17:22:12 -07:00
James Almer 746650dfe5 Changelog: add entry about tiled HEIF support with the CLI
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 13:46:36 -03:00
James Almer a979c9b935 tests/ffmpeg: add test for HEIF automatic tile merging
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 5ff8395e78 fftools/ffmpeg_demux: create a filtegraph to merge HEIF tiles automatically
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 433d18a1d9 fftools/ffmpeg_filter: handle metadata from stream group in relevant the filtergraphs
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer dec3cc0138 fftools/ffmpeg_filter: allow binding unlabeled filtergraphs
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer e7cf188bb6 fftools/ffmpeg_filter: reindent after the previous commit
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 9dcd25b7cd fftools/ffmpeg_filter: allow removing filtergraphs that contain unbound outputs
Actual practical implementation of the previous commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer cce85642c9 fftools/ffmpeg_sched: add a function to remove a filtergraph from the scheduler
For the purpose of merging streams in a stream group, a filtergraph can't be
created once we know it will be used. Therefore, allow filtergraphs to be
removed from the scheduler after being added.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer c751ad2c36 fftools/ffmpeg_mux_init: allow creating streams from filtergraphs created out of stream groups
Several formats are being designed where more than one independent video or
audio stream within a container are part of what should be a single combined
output. This is the case for HEIF (Defining a grid where the decoded output
of several separate video streams are to be placed to generate a single output
image) and IAMF (Defining audio streams where channels are present in separate
coded stream).

AVStreamGroup was designed and implemented in libavformat to convey this
information, but the actual merging is left to the caller.
This change allows the FFmpeg CLI to take said information, parse it, and
create filtergraphs to merge the streams, making the combined output be usable
automatically further in the process.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 99ec0752d7 fftools/ffmpeg_demux: add InputStreamGroup to store stream groups
Preparatory work for upcoming changes. Make ffmpeg keep track of stream groups
internally.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer ba0dc3d49e fftools/ffmpeg_opt: add helpers to match stream groups
Will be used to check for specifiers that match a given stream group and not
a stream within one.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 7b18beb477 fftools: pass global side data through using a separate array
This keeps global and per frame side data clearly separated, and actually
propagates the former as it comes out from the buffersink filter.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 7ac1b410e1 fftools/ffmpeg_filter: fix passing certain parameters to inputs bound to a filtergraph output
Certain parameters, like calculated framerate, are unavailable when connecting
the output of a filtergraph to the input of another.

This fixes command lines like

ffmpeg -lavfi "testsrc=rate=1:duration=1[out0]" -filter_complex "[out0]null[out1]" -map [out1] -y out.png

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 6879c8ee5d avcodec/avcodec: add helpers to convert between packet and frame side data
They will be used in following commits.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 10:54:01 -03:00
Andreas Rheinhardt 0242cb36a5 avcodec/rv34dsp: Reduce size of qpel functions arrays
Only size 16 and 8 are used (and set).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-30 12:17:25 +01:00
Gyan Doshi 00c23bafb0 doc/filters: add link to rendered doc of drawvg 2025-10-30 15:35:14 +05:30
Zhao Zhili 82c495fd15 avcodec/hevc: fix false alarm when build with enable-small
profile_name is always NULL with --enable-small, which leading to
a warning message "Unknown profile bitstream".
2025-10-30 09:26:17 +00:00
Andreas Rheinhardt 0f105b96a3 avcodec/x86/hevc/idct: Port ff_hevc_idct_4x4_dc_{8,10,12}_mmxext to SSE2
Practically no change in benchmarks (and in codesize).

hevc_idct_4x4_dc_8_c:                                    7.8 ( 1.00x)
hevc_idct_4x4_dc_8_mmxext:                               6.9 ( 1.14x)
hevc_idct_4x4_dc_8_sse2:                                 6.8 ( 1.15x)
hevc_idct_4x4_dc_10_c:                                   7.9 ( 1.00x)
hevc_idct_4x4_dc_10_mmxext:                              6.9 ( 1.16x)
hevc_idct_4x4_dc_10_sse2:                                6.8 ( 1.16x)
hevc_idct_4x4_dc_12_c:                                   7.8 ( 1.00x)
hevc_idct_4x4_dc_12_mmxext:                              7.0 ( 1.13x)
hevc_idct_4x4_dc_12_sse2:                                6.8 ( 1.15x)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-30 08:56:45 +01:00
Michael Niedermayer 909af3a571 avcodec/g723_1enc: Make min_err 64bit
This is intending to fix the case described in https://lists.ffmpeg.org/archives/list/ffmpeg-devel@ffmpeg.org/thread/AAZ7GJPPUJI5SCVTDGJ6QL7UUEP56WOM/
Where FCBParam optim is used uninitialized

a min_err of 1<<30, allows the struct to be never initilialized as all
err (which is int32_t) can be larger than min_err. By increasing min_err
above the int32_t range this is no longer possible

Untested, as i do not have the testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>i
2025-10-30 03:41:24 +01:00
Michael Niedermayer d8ffec5bf9 avcodec/vlc: Clear val8/16 in vlc_multi_gen() by av_mallocz()
Fixes: use of uninitialized memory
Fixes: 427814450/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_DEC_fuzzer-646512196065689
Fixes: 445961558/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_DEC_fuzzer-5515158672965632

the multi vlc code will otherwise return uninitialized data. Now one can argue that this data should
not be used, but on errors this data can remain ...

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-30 02:08:14 +01:00
Michael Niedermayer d03483bd26 avformat/rtpenc_h264_hevc: Check space for nal_length_size in ff_rtp_send_h264_hevc()
Fixes: memcpy with negative size
Fixes: momo_trip-poc/input

Reported-by: Momoko Shiraishi <shiraishi@os.is.s.u-tokyo.ac.jp>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-30 01:24:23 +01:00
Lynne afd927e0ca prores_raw: skip frames if the discard flag is set
All other decoders do this.
2025-10-28 23:10:15 +01:00
Lynne 0d11c5c2f9 libplacebo: extend allowed range of color primaries and transfer functions
This was left out of the earlier commits.
2025-10-28 22:19:34 +01:00
Lynne 3d12d5682b doc/APIchanges: add AVCOL_PRI_EXT_BASE and AVCOL_PRI_V_GAMUT
They were left out.
2025-10-28 22:19:34 +01:00
Araz Iusubov d31983dc8e MAINTAINERS: Update the entries for AMF 2025-10-28 21:06:37 +00:00
Andreas Rheinhardt 0941646182 avcodec/fflcms2: Don't access inexistent array elements
This would happen if one of the extended transfer characteristics is in
use (currently only AVCOL_TRC_V_LOG).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-28 21:40:50 +01:00
Lynne e85947576c ffv1enc_vulkan: limit probability caching to RADV only
Nvidia's drivers recently broke this.
2025-10-28 20:46:25 +01:00
Lynne bcfb4b2e3e prores_raw_parser: set color params based on vendor
Panasonic cameras record ProRes RAW in V-Log/V-Gamut internally.

Atomos is a brand of recorders which can record uncompressed
non-debayered RAW over HDMI.
All known cameras output linear RAW over HDMI, so mark the transfer function
as linear in that case.
2025-10-28 20:46:21 +01:00
Lynne 71c7b9156b lavu: bump minor and add APIchanges entry for V-Log/V-Gamut 2025-10-28 20:46:21 +01:00
Lynne 92a688cabd lavu: add support for Panasonic V-Gamut 2025-10-28 20:46:21 +01:00
Lynne aeb9b19ebc lavu: add support for Panasonic V-Log 2025-10-28 20:46:21 +01:00
James Almer 08c94518c9 avfilter/vsrc_testsrc: add support for YUV444P1{0,2}MSB to yuvtestsrc
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-28 19:16:58 +00:00
Baptiste Coudurier 1025beeef1 lavf/id3v2: allow empty strings without bom, fixes #20597 2025-10-28 10:59:25 -07:00
James Almer c7a2b31f84 avformat/demux: pass new extradata to the parser
The parser API doesn't work with packets, only raw data, so in order for it to
be made aware of new extradata propagated through packet side data we need to
pass it in some other form, namely, replacing the main extradata and ensuring
it will be parsed by restarting the parser.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-28 10:10:22 -03:00
James Almer 530ca627a3 avcodec/mlpdec: don't depend on context channel layout when setting substream masks
If avctx->ch_layout is unset (as it's allowed and even expeced by the
AV_CODEC_CAP_CHANNEL_CONF flag), the code setting substream masks will fail for
stereo and mono layouts unless a downmix channel was requested.
Fix this by deriving the mask with coded values only.

Fixes issue #20764.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-28 13:08:02 +00:00
xin.guo 0a4bd6cc23 avcodec/h264_vulkan: Fix param error in set_sps
Signed-off-by: xin.guo <xin.guo@sophgo.com>
2025-10-28 06:12:36 +00:00
averne 909d71322a vulkan/prores: output LSB-padded data
For consistency with existing Vulkan-based hwaccels
2025-10-28 06:12:14 +00:00
Lynne 70be2e2ae2 lavc/hwaccels: properly order list 2025-10-28 07:11:26 +01:00
Lynne 51843adfe5 vulkan/rangecoder: ifdef out encode and decode chunks
There's little code sharing between them.
2025-10-28 07:11:26 +01:00
Lynne 3cd678506c vulkan_decode: align images to the subsampling
Normally, the Vulkan drivers handle this. But Vulkan decided "nah".

This requires API users to crop out odd-numbered images with subsampling.
2025-10-28 07:11:26 +01:00
Lynne 964e9cc63b hwcontext_vulkan: add support for VK_EXT_zero_initialize_device_memory 2025-10-28 07:11:21 +01:00
caifan3 91512f0856 fftools/cmdutils: Rename file_read to read_file_to_string to avoid symbol collision with NuttX
The function name 'file_read' is too generic and conflicts with a function
of the same name in the NuttX kernel. Since NuttX links kernel and userspace
into a single binary, this causes a symbol collision when building FFmpeg tools.

Signed-off-by: caifan3 <caifan3@xiaomi.com>
2025-10-28 02:48:05 +00:00
Lynne 5b388f2838 hwcontext_vulkan: remove unsupported/broken pixel formats
We have no use for 14-bit pixel formats for now, so remove support for gray14,
which was broken due to the LSB padding issue.

Similarly YUVA at 10/12 bit was broken for the same reason.
2025-10-27 22:59:41 -03:00
Lynne 98ee3f6718 hwcontext_vulkan: fix planar 10 and 12-bit RGB formats using the new MSB formats 2025-10-27 22:59:41 -03:00
Lynne 41ecb203c5 hwcontext_vulkan: fix 3-plane 444 10 and 12-bit formats using the new MSB formats
We previously tried to fudge this somehow, but the pixel formats
are simply broken and we cannot use them without declaring them as MSB.
2025-10-27 22:59:41 -03:00
Lynne 471acedec2 hwcontext_vulkan: fix grayscale 10 and 12-bit formats using the new MSB formats 2025-10-27 22:59:41 -03:00
Lynne dc34d0764f lavu: bump minor and add APIchanges entry for the new pixfmts 2025-10-27 22:59:41 -03:00
Lynne bc0ee8b7cc swscale: add support for 10/12-bit 422 and 444 MSB pixfmts 2025-10-27 22:59:41 -03:00
Lynne a5be0ecbfd swscale: add support for 10/12-bit grayscale MSB pixfmts 2025-10-27 22:59:40 -03:00
Lynne e42c7698f5 lavu/pixfmt: add 420 and 422, 10 and 12-bit MSB padded variants
Vulkan has defined all its 3-plane formats as MSB padded.
2025-10-27 22:59:39 -03:00
Lynne ed5b694ebe lavu/pixfmt: add grayscale 10 and 12-bit MSB padded variants 2025-10-27 22:58:21 -03:00
Chris Hodges d12791ef7f libavformat: fix rtpdec_av1 regarding OBU size
Fix the AV1 RTP depacketizer for instances where the OBU elements
did not have their OBU size fields removed according to the
recommendation (SHOULD) of the AV1 RTP specification.

Roger Hardiman courteously reported that the depacketizer doesn't
work correctly for fragmented OBU elements with their OBU size
fields still present and will incorrectly state that the
continuation of such a fragment was unexpected, because the
frag_obu_size field was used as a state and only incremented
when the size field needed to be updated on OBU size field
restoration. This patch solves the slip.

Change-Id: I95af8cc89862e8ecf79aabcf029dd95a20dfd7ad
2025-10-27 22:11:58 +00:00
James Almer e10473f13e avformat/matroskadec: relax the check for cropped dimensions
There seem to be samples with no Video element on video tracks in the wild,
which even if not spec compliant, can be demuxed fine after lavf probes the
stream with a decoder/parser.
Relax the check to allow tracks with no dimensions to work, and also add a
check for strict spec compliance to maintain the current behavior if desired.

Fixes issue #20649.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-27 15:54:22 -03:00
Kacper Michajłow ccb1865a82 avfilter/buffersink: move ret declaration to suppress unused warning
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 15:39:39 +01:00
Kacper Michajłow a6ccaa2eea avcodec/d3d12va_encode_h264: remove unused variables
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 15:39:39 +01:00
Kacper Michajłow d57de83352 avcodec/d3d12va_encode: fix format specifier for HRESULT
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 15:39:39 +01:00
David Rosca a0a16f2ea4 cbs_vp9: Always update loop filter and segmentation from current frame
Fixes decoding vp90-2-09-aq2, vp90-2-15-segkey_adpq, vp90-2-15-segkey
and vp90-2-22-svc_1280x720_1 with Vulkan hwaccel.

Fixes: 26a2a76346 ("cbs_vp9: Fix VP9 passthrough")
2025-10-27 13:44:03 +00:00
Kacper Michajłow 4deb8b3a7a avutil/vulkan_glslang: use AVMutex instead of pthread_mutex_t
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 11:54:53 +01:00
Anthony Bajoua 68152978b5 libavformat/movenc: Output ftyp atom with hybrid_fragmented+delay_moov 2025-10-27 09:06:06 +00:00
Kacper Michajłow 8c633f45b0 configure: fix glslang linking on platforms without pthreads
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 02:59:09 +01:00
Andreas Rheinhardt d01608e022 avcodec/proresdec: Remove unused hwaccel_last_picture_private
ProRes is an intra-only codec.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-25 22:34:30 +02:00
averne 23df9d4172 avcodec/prores: add parser
Introduce a basic parser for ProRes frame headers.
This avoid having to decode an entire frame to
extract codec information.
2025-10-25 19:56:44 +00:00
averne 98412edfed lavc: add a ProRes Vulkan hwaccel
Add a shader-based Apple ProRes decoder.
It supports all codec features for profiles up to
the 4444 XQ profile, ie.:
- 4:2:2 and 4:4:4 chroma subsampling
- 10- and 12-bit component depth
- Interlacing
- Alpha

The implementation consists in two shaders: the
VLD kernel does entropy decoding for color/alpha,
and the IDCT kernel performs the inverse transform
on color components.

Benchmarks for a 4k yuv422p10 sample:
- AMD Radeon 6700XT:   178 fps
- Intel i7 Tiger Lake: 37 fps
- NVidia Orin Nano:    70 fps
2025-10-25 19:54:13 +00:00
averne 3fd55d952e avcodec/proresdec: save slice width parameter in codec context
Save the log2_desired_slice_size_in_mb syntax
element in the codec context.
Required by the Vulkan hwaccel to compute slice
widths and positions.
2025-10-25 19:54:13 +00:00
averne 987368ef25 avcodec/prores: adapt hwaccel code for slice-based accelerators
In preparation for the Vulkan hwaccel.
The existing hwaccel code was designed around
videotoolbox, which ingests the whole frame
bitstream including picture headers.
This adapts the code to accomodate lower-level,
slice-based hwaccels.
2025-10-25 19:54:13 +00:00
averne 9195af77eb proresdec: allocate private memory for hwaccel pictures
In preparation for the Vulkan hwaccel, which
stores per-frame acceleration structures.
2025-10-25 19:54:13 +00:00
Anders Rein f5f72b4f8a Fix incorrect extraction of Origin
The code that attempted to extract origin (4B.02) was put in the wrong
metadata handler and was also read as the wrong integer type. According
ST 377-1 Origin is of type "Position" (Int64) in the Timeline Track, not
a 8 bit unsigned integer in the Sequence.
2025-10-25 19:22:48 +00:00
James Almer defd5f3f64 Changelog: fix ordering for drawvg entry
Entries should be sorted chronologically from oldest to youngest.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-25 10:59:42 -03:00
James Almer d9853e66d3 avfilter/Makefile: fix dependency for drawvg test
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-25 10:57:56 -03:00
Ayose 016d767c8e lavfi: add drawvg video filter.
The drawvg filter can draw vector graphics on top of a video, using libcairo. It
is enabled if FFmpeg is configured with `--enable-cairo`.

The language for drawvg scripts is documented in `doc/drawvg-reference.texi`.

There are two new tests:

- `fate-filter-drawvg-interpreter` launch a script with most commands, and
  verify which libcairo functions are executed.
- `fate-filter-drawvg-video` render a very simple image, just to verify that
  libcairo is working as expected.

Signed-off-by: Ayose <ayosec@gmail.com>
2025-10-25 13:21:50 +00:00
Kacper Michajłow d77f917621 ffbuild/common: silence DEPCXX output
Fixes: 0ce413af9c

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:15:06 +02:00
Kacper Michajłow 25fe4105c8 tests/fate/api: fix fate-lavf-flv test
fate-lavf-flv is dependency of fate-api-seek, but the fate-api-seek is
setting CMP = null, which affects fate-lavf-flv. Reset CMP value to
expected by the flv test and use default diff compare.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow c5edd125f4 tests/ref/fate: remove leftover mapchan ref files
Those tests were removed in e48055fdce.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow 51762c956c tests/ref/fate/iirfilter: remove leftover ref file
Test doesn't exist anymore.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow df7b6b23ff tests/fate/filter-atempo: remove leftover ref file
Test was onverted to oneoff in 6cde03739e.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow dd4c524dbc api-h264-test: indent output
This matches tests/ref files.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow 63bb6201c7 avutil/tests/hash: don't print trailing spaces
This matches the tests/ref files, which were manually stripped.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow c819e59721 avutil/tests/dict: don't print trailing spaces
This matches the tests/ref files, which were manually stripped.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow 8d16f85764 avutil/tests/fifo: don't print trailing spaces
This matches the tests/ref files, which were manually stripped.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow 3e69541ff3 avutil/tests/audio_fifo: don't print trailing spaces
This matches the tests/ref files, which were manually stripped.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:34 +02:00
Andreas Rheinhardt 7b5b29910a avutil/x86/cpu: Remove 3dnow flags, macros
Unused since 5ef613bcb0.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-25 07:27:11 +02:00
Andreas Rheinhardt 9a9edd8024 configure: Remove 3dnow
The last 3dnow functions have been removed in commit
5ef613bcb0. So remove 3dnow
from configure; the only thing kept is that --disable-amd3dnow
is still accepted, but no longer advertised by --help.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-25 07:04:39 +02:00
Kacper Michajłow ddeec523a2 avcodec/x86/idctdsp: add restrict to match function pointer types
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow 49cfafefd4 avcodec/rectangle: use uintptr_t for integer pointer type
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow 0cd999266f avcodec/put_bits: add explicit cast to suppress MSVC warning
Supresses:
warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)

Also drop L, as shift will never exceed 31.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow fe425d97d1 avcodec/cbs*: remove redundant const, it's already in typedef
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow 9ad20839fb avcodec/pixblockdsp: be consistent about restrict use in ff_{get,diff}_pixels
Suppresses warnings about function pointer mismatch.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow c597d8cac1 avcodec/aacpsdsp: add restrict to function pointers to match declarations
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:14 +02:00
Kacper Michajłow 20f59bfc6b fftools/ffmpeg: use enum VideoSyncMethod instead of int
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:14 +02:00
Kacper Michajłow a2b47ccfbf avcodec/{png,mov}enc: use EOTF gamma approximation for gAMA chunk
This is how images encoded with specific transfer function should be
viewed. Image viewers that doesn't support named trc metadata, will
fallback to simple gAMA value and both of those cases should produce the
same image apperance for the viewer.

Fixes: https://github.com/mpv-player/mpv/issues/13438

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-24 22:24:54 +00:00
Kacper Michajłow 00e43619cd avutil/csp: add av_csp_approximate_eotf_gamma()
2.2 gamma was used for bt.1886 aproximation as the most common target in
real world.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-24 22:24:54 +00:00
Bin Peng 3115c0c0e6 lavc/aarch64: Fix addp overflow in ff_pred16x16_plane_neon_10
The mismatch between neon and C functions can be reproduced
using the following bitstream and command line on aarch64 devices.

wget https://streams.videolan.org/ffmpeg/incoming/replay_intra_pred_16x16.h264
 ./ffmpeg -cpuflags 0  -threads 1 -i replay_intra_pred_16x16.h264  -f framemd5 -y md5_ref
 ./ffmpeg              -threads 1 -i replay_intra_pred_16x16.h264 -f framemd5 -y md5_neon

Signed-off-by: Bin Peng <pengbin@visionular.com>
2025-10-24 15:32:35 +00:00
Andreas Rheinhardt 7e8ef2ded2 configure: Add mxpeg->hpeldsp dependency
Forgotten in 124c856d38.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-24 12:56:24 +02:00
Baptiste Coudurier 7f7335ec43 lavf/mxfenc: fix muxing for DNxHD/DNxHR 444 2025-10-24 00:16:21 +00:00
Baptiste Coudurier 548bdee8db lavf/mxfenc: factorize cdci descriptor functions 2025-10-24 00:16:21 +00:00
Baptiste Coudurier 48c6b8a907 lavf/mxfenc: fix return value to int64_t 2025-10-24 00:16:21 +00:00
Baptiste Coudurier 1cd3f61ad8 lavf/mxfenc: correctly add jpeg2000 subdescriptor reference in cdci, factorize 2025-10-24 00:16:21 +00:00
Baptiste Coudurier cfcd996575 lavf/mxfenc: remove cdci pixel format specific values from stream context 2025-10-24 00:16:21 +00:00
Baptiste Coudurier 06b04da4dc lavf/mxfenc: require pixel format to be set for video streams 2025-10-24 00:16:21 +00:00
Baptiste Coudurier 0b0cb7cd6c lavf/movenc: improve AVdh atom generation for DNxHD/DNxHR 2025-10-24 00:16:21 +00:00
cenzhanquan1 1120b3db30 avcodec/liblc3enc: support packed float (AV_SAMPLE_FMT_FLT) input.
Previously, the LC3 encoder only accepted planar float (AV_SAMPLE_FMT_FLTP).
This change extends support to packed float (AV_SAMPLE_FMT_FLT) by properly
handling channel layout and sample stride.

The pcm data pointer and stride are now calculated based on the sample
format: for planar, use frame->data[ch]; for packed, use frame->data[0]
with channel offset. The stride is set to 1 for planar and number of
channels for packed layout.

This enables encoding from common packed audio sources without requiring
a prior planar conversion, improving usability and efficiency.

Signed-off-by: cenzhanquan1 <cenzhanquan1@xiaomi.com>
2025-10-23 14:42:50 +00:00
cenzhanquan1 0eb572f080 avcodec/liblc3dec: support sample format negotiation and planar layout.
1. Adds support for respecting the requested sample format. Previously,
   the decoder always used AV_SAMPLE_FMT_FLTP. Now it checks if the
   caller requested a specific format via avctx->request_sample_fmt and
   honors that request when supported.

2. Improves planar/interleaved audio buffer handling. The decoding
   logic now properly handles both planar and interleaved sample
   formats by calculating the correct stride and buffer pointers based
   on the actual sample format.

The changes include:
- Added format mapping between AVSampleFormat and lc3_pcm_format
- Implemented format selection logic in initialization.
- Updated buffer pointer calculation for planar/interleaved data.
- Maintained backward compatibility with existing behavior.

Signed-off-by: cenzhanquan1 <cenzhanquan1@xiaomi.com>
2025-10-23 22:06:04 +08:00
Jack Lau cb5e201f5c avformat/whip: cleanup the redundant variable
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-23 10:58:45 +00:00
Jack Lau 0e8cff52bc avformat/whip: add DTLS active role support
Add dtls_active flag to specify the dtls role.

Properly set the send key and recv key depends on DTLS role:

As DTLS server, the recv key is client master key plus salt,
the send key is server master key plus salt.
As DTLS client, the recv key is server master key plus salt,
the send key is client master key plus salt.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-23 10:58:45 +00:00
Gyan Doshi 535d4047d3 ffmpeg: unbreak max_error_rate application
The calculation of decode error rate neglected to cast
its operands to float, thus always leading to a value of 0.
2025-10-21 13:22:08 +00:00
Zhao Zhili edf5b777c9 avcodec/vvc: fix false alarm of missing ref on RASL 2025-10-21 13:21:52 +00:00
Andreas Rheinhardt 05b8608c76 avcodec/x86/mpegvideoencdsp_init: Fix left shift of negative number
Uncovered by UBSan when running the mpegvideoencdsp checkasm
test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-21 12:11:55 +02:00
Martin Storsjö e442128944 movenc: Make sure to flush the delayed moov atom for hybrid fragmented
If using the delay_moov flag in combination with hybrid_fragment
(which is a potentially problematic combination otherwise - the
ftyp box does end up hidden in the end), then we need to flush
twice to get both the moov box and the first fragment, if the
file is finished before the first fragment is completed.
2025-10-21 08:38:32 +00:00
Martin Storsjö 27f5561885 movenc: Fix sample clustering for hybrid_fragmented+delay_moov
If samples were available when the moov was written, chunking
for those samples has been done already, which has to be reset
here.

This is the case when not using empty_moov, when the moov box
describes the first fragment - this case was accounted for already.
But if using the delay_moov flag, then those samples also were
available when writing the moov, so chunking for them has already
been done in this case as well.

Therefore, always reset chunking here (it should be harmless to
always do it), and update the comment to clarify the cases
involved here.
2025-10-21 08:38:32 +00:00
Leo Izen dc39a576ad avcodec/pngenc: include EXIF buffer in max_packet_size
When calculating the max size of an output PNG packet, we should
include the size of a possible eXIf chunk that we may write.

This fixes a regression since d3190a64c3
as well as a bug that existed prior in the apng encoder since commit
4a580975d4.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-10-19 09:17:38 -04:00
Michael Niedermayer 51d3c4b4b6 tools/target_dec_fuzzer: Adjust threshold for PIXLET
Fixes: Timeout
Fixes: 425754611/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PIXLET_fuzzer-4778526102585344

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 02:07:03 +02:00
Michael Niedermayer 388e6fb3be avcodec/ffv1enc: Consider variation in slice sizes
When splitting a 5 lines image in 2 slices one will be 3 lines and thus need more space

Fixes: Assertion sc->slice_coding_mode == 0 failed at libavcodec/ffv1enc.c:1668
Fixes: 422811239/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-4933405139861504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:26 +02:00
Michael Niedermayer 56ef66d350 tools/target_dec_fuzzer: Adjust threshold for CRI
Fixes: Timeout
Fixes: 421997576/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-5335057265131520

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:17 +02:00
Michael Niedermayer b132c1755a tools/target_dec_fuzzer: Adjust threshold for qdraw
Fixes: Timeout
Fixes: 421954735/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QDRAW_fuzzer-4515776981172224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:14 +02:00
Michael Niedermayer 8988734d09 tools/target_dec_fuzzer: Adjust threshold for CAVS
Fixes: Timeout
Fixes: 421951267/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CAVS_fuzzer-4766360421072896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpe
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:10 +02:00
Michael Niedermayer 51f0f2d2cf tools/target_dec_fuzzer: Adjust threshold for interplay video
Fixes: Timeout
Fixes: 421945523/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INTERPLAY_VIDEO_fuzzer-4776910965506048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:06 +02:00
Michael Niedermayer d43f19064e MAINTAINERS: libtheoraenc seems unmaintained
See: [FFmpeg-devel] libtheora maintainer ?

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:00 +02:00
Michael Niedermayer 4666c1eed3 libavcodec/cbs_apv_syntax_template: limit tile to 2gb
We do not support larger tiles as we use signed int
Alternatively we can check this in apv_decode_tile_component() or init_get_bits*()
or support bitstreams above 2gb length

Fixes: init_get_bits() failure later
Fixes: 421817631/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APV_fuzzer-4957386534354944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:32:42 +02:00
Araz Iusubov d19b7c283c avcodec/d3d12va_encode: D3D12 H264 encoding support
This patch introduces hardware-accelerated H.264 encoding
using Direct3D 12 Video API (D3D12VA).
2025-10-18 12:20:11 +00:00
Andreas Rheinhardt ed007ad427 avcodec/x86/fpel: Port ff_put_pixels8_mmx() to SSE2
This has the advantage of not violating the ABI by using
MMX registers without issuing emms; it e.g. allows
to remove an emms_c from bink.c.

This commit uses GP registers on Unix64 (there are not
enough volatile registers to do likewise on Win64) which
reduces codesize and is faster on some CPUs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-17 13:27:56 +02:00
Andreas Rheinhardt d91b1559e0 avcodec/x86/me_cmp: Replace MMXEXT size 16 funcs by unaligned SSE2 funcs
Snow calls some of the me_cmp_funcs with insufficient alignment
for the first pointer (see get_block_rd() in snowenc.c);
therefore SSE2 functions which really need this alignment
don't get set for Snow and 542765ce3e
consequently didn't remove MMXEXT functions which are overridden
by these SSE2 functions for normal codecs.

For reference, here is a command line which would segfault
if one simply used the ordinary SSE2 functions for Snow:

./ffmpeg -i mm-short.mpg -an -vcodec snow -t 0.2 -pix_fmt yuv444p \
-vstrict -2 -qscale 2 -flags +qpel -motion_est iter 444iter.avi

This commit adds unaligned SSE2 versions of these functions
and removes the MMXEXT ones. This in particular implies that
sad 16x16 now never uses MMX which allows to remove an emms_c
from ac3enc.c.

Benchmarks (u means unaligned version):
sad_0_c:                                                 8.2 ( 1.00x)
sad_0_mmxext:                                           10.8 ( 0.76x)
sad_0_sse2:                                              6.2 ( 1.33x)
sad_0_sse2u:                                             6.7 ( 1.23x)

vsad_0_c:                                               44.7 ( 1.00x)
vsad_0_mmxext (approx):                                 12.2 ( 3.68x)
vsad_0_sse2 (approx):                                    7.8 ( 5.75x)

vsad_4_c:                                               88.4 ( 1.00x)
vsad_4_mmxext:                                           7.1 (12.46x)
vsad_4_sse2:                                             4.2 (21.15x)
vsad_4_sse2u:                                            5.5 (15.96x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-17 13:05:07 +02:00
Andreas Rheinhardt 69a700043d avcodec/x86/me_cmp: Remove MMXEXT functions overridden by SSE2
The SSE2 function overriding them are currently only set
if the SSE2SLOW flag is not set and if the codec is not Snow.
The former affects only outdated processors (AMDs from
before Barcelona (i.e. before 2007)) and is therefore irrelevant.
Snow does not use the pix_abs function pointers at all,
so this is also no obstacle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-17 13:05:07 +02:00
Andreas Rheinhardt 20c4608af8 avcodec/x86/me_cmp: Add SSE2 sad 8,16 xy2 functions
The new functions are faster than the existing exact
functions, yet get beaten by the nonexact functions
(they can avoid unpacking to words and back).
The exact (slow) MMX functions have therefore been
removed, which was actually beneficial size-wise
(416B of new functions, 619B of functions removed).

pix_abs_0_3_c:                                         216.8 ( 1.00x)
pix_abs_0_3_mmx:                                        71.8 ( 3.02x)
pix_abs_0_3_mmxext (approximative):                     17.6 (12.34x)
pix_abs_0_3_sse2:                                       23.5 ( 9.23x)
pix_abs_0_3_sse2 (approximative):                        9.9 (21.94x)

pix_abs_1_3_c:                                          98.4 ( 1.00x)
pix_abs_1_3_mmx:                                        36.9 ( 2.66x)
pix_abs_1_3_mmxext (approximative):                      9.2 (10.73x)
pix_abs_1_3_sse2:                                       14.8 ( 6.63x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-17 13:05:07 +02:00
Michael Yang 20051ed3af avcodec/vulkan_encode_av1: fix level index 2025-10-16 21:59:24 +00:00
Michael Yang 62d43ba2e3 libavfilter/vf_nlmeans_vulkan: fix str defaults
Revert back to NAN as -1.0 was erroneously to 0.0 to fit in the options
range.

Add special handling of str per requested.
2025-10-16 21:32:43 +00:00
Michael Yang e8213f766f libavfilter/vf_nlmeans_vulkan: amend doc 2025-10-16 21:32:43 +00:00
Michael Yang 7d65ce7763 libavfilter/vf_nlmeans_vulkan: clean up defaults
Change per-plane strength defaults to -1.0.
2025-10-16 21:32:43 +00:00
Michael Yang 26dee5b43e libavfilter/vf_nlmeans_vulkan: reverse img_bar 2025-10-16 21:32:43 +00:00
Michael Yang 71ff349cc1 libavfilter/vf_nlmeans_vulkan: lower strength min
Lower (per-component) strength minimum from 1.0 to 0.0, with 0.0 skipping
integral and weights calculations.
2025-10-16 21:32:43 +00:00
Michael Yang 2e12b3251d libavfilter/vf_nlmeans_vulkan: clean up naming
Add `nb_components` to push data.

Rename `ws_total_*`` to `ws_*`.
2025-10-16 21:32:43 +00:00
Michael Yang 3fac2d8593 avfilter/vf_nlmeans_vulkan: rewrite filter
This is a major rewrite of the exising nlmeans vulkan code, with bug
fixes and major performance improvement.

Fix visual artifacts found in ticket #10661, #10733. Add OOB checks for
image loading and patch sized area around the border. Correct chroma
plane height, strength and buffer barrier index.

Improve parallelism with component workgroup axis and more but smaller
workgroups. Split weights pass into vertical/horizontal (integral) and
weights passes. Remove h/v order logic to always calculate sum on
vertical pass. Remove atomic float requirement, which causes high memory
locking contentions, at the cost of higher memory usage of w/s buffer.
Use cache blocking in h pass to reduce memory bandwidth usage.
2025-10-16 21:32:43 +00:00
Martin Storsjö 36896af64a movenc: Make the hybrid_fragmented mode more robust
Write the moov tag at the end first, before overwriting the mdat size
at the start of the file.

In case writing the final moov box fails (e.g. due to being out
of disk), we haven't broken the initial moov box yet.

Thus if writing stops between these steps, we could end up with
a file with two moov boxes - which arguably is more feasible to
recover from, than from a file with no moov boxes at all.
2025-10-16 18:58:54 +00:00
Niklas Haas a45d30a675 avutil/hwcontext_vulkan: always enable baseline usage flags
The documentation states that this field is for enabling "extra" usage
flags. This conflicts with the implementation, and the rest of the comment,
though.

In resolving this ambiguity, I think it's better to lean towards the first
sentence and treat this field purely as specifying *extra* usage flags to
enable. Otherwise, this may break vulkan encoding or subsequent hwdownload
if the upstream filter did not specifically advertise this.

Change the default behavior and update the documentation slightly to more
clearly document the semantics.
2025-10-16 17:40:25 +00:00
Andreas Rheinhardt b1f2eea1cd avfilter/vf_noise: Deduplicate option flags
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 19:10:51 +02:00
Andreas Rheinhardt 3ba570de8b avfilter/x86/vf_noise: Port line_noise funcs to SSE2
This avoids having to fix up ABI violations via emms_c and
also leads to a 73% speedup for the line noise average version
here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 19:09:45 +02:00
Andreas Rheinhardt adfec0f52e avfilter/x86/vf_noise: Make line_noise_avg_mmx() match C function
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 18:41:19 +02:00
Andreas Rheinhardt 214b52df43 avfilter/vf_noise: Avoid cast
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 18:41:19 +02:00
Andreas Rheinhardt ece623b1b3 avfilter/vf_noise: Fix race with very tall images
When using averaged noise with height > MAX_RES (i.e. 4096),
multiple threads would access the same prev_shift slot,
leading to races. Fix this by disabling slice threading
in such scenarios.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 18:41:19 +02:00
Andreas Rheinhardt 6a53a4e341 avfilter/vf_noise: Don't write beyond end-of-array
This is not only UB, but also leads to races and nondeterministic
output, because the write one last the end of the buffer actually
conflicts with accesses by the thread that actually owns it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 18:41:18 +02:00
Andreas Rheinhardt 94948bd6b9 avfilter/vf_noise: Make private context smaller
"all" only exists to set options; it does not need the big arrays
contained in FilterParams.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 18:41:18 +02:00
Zhao Zhili cd4b01707d Revert "avformat/movenc: sidx earliest_presentation_time is applied after editlist"
This reverts commit 301141b576.

cluster[0].dts, pts and frag_info[0].time are already in presentation
timeline, so they shouldn't be shift by start_pts.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-10-16 11:22:37 +08:00
Zhao Zhili 0de3b1f358 avformat/mov: don't shift sidx_pts
sidx_pts is already in presentation time, so it shouldn't be shift
by sc->time_offset again.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-10-16 11:22:37 +08:00
James Almer 2e1d702cfc avformat/dump: fix log level passed to av_log when printing stream group side data
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-15 17:49:11 -03:00
Andreas Rheinhardt 74a3c1ddb6 avfilter/x86/vf_pullup: Port pullup functions to SSE2, SSSE3
The diff and var functions benefit from psadbw, comb from wider
registers which allows to avoid reloading values, reducing the number
of loads from 48 to 10. Performance increased by 117% (the loop
in compute_metric() has been timed); codesize decreased by 144B.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-15 19:43:37 +02:00
Andreas Rheinhardt dcb28ed860 avfilter/x86/vf_spp: Port store_slice to SSE2
This allows to remove an emms_c from the filter. It also gives
25% speedup here (when timing the calls to store_slice using
START/STOP_TIMER).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-15 19:43:37 +02:00
Andreas Rheinhardt f4a87d8ca4 avcodec/x86/mpegvideoencdsp_init: Use xmm registers in SSSE3 functions
Improves performance and no longer breaks the ABI (by forgetting
to call emms).

Old benchmarks:
add_8x8basis_c:                                         43.6 ( 1.00x)
add_8x8basis_ssse3:                                     12.3 ( 3.55x)

New benchmarks:
add_8x8basis_c:                                         43.0 ( 1.00x)
add_8x8basis_ssse3:                                      6.3 ( 6.79x)

Notice that the output of try_8x8basis_ssse3 changes a bit:
Before this commit, it computes certain values and adds the values
for i,i+1,i+4 and i+5 before right shifting them; now it adds
the values for i,i+1,i+8,i+9. The second pair in these lists
could be avoided (by shifting xmm0 and xmm1 before adding both together
instead of only shifting xmm0 after adding them), but the former
i,i+1 is inherent in using pmaddwd. This is the reason that this
function is not bitexact.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-15 08:55:13 +02:00
Andreas Rheinhardt cffd029e98 avcodec/x86/mpegvideoencdsp_init: Don't use slow path unnecessarily
The only requirement of this code (and essentially the pmulhrsw
instruction) is that the scaled scale fits into an int16_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-15 08:55:13 +02:00
Andreas Rheinhardt ce499ebf96 tests/checkasm/mpegvideoencdsp: Add test for add_8x8basis
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-15 08:55:13 +02:00
Michael Niedermayer 566e9032b1 swscale/output: Fix unsigned cast position in yuv2*
Fixes: signed overflow

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-14 20:55:54 +02:00
Michael Niedermayer 0c6b7f9483 swscale/output: Fix integer overflow in yuv2ya16_X_c_template()
Found-by: colod colod <colodcolod7@gmail.com>

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-14 20:55:53 +02:00
Zhao Zhili 6b961f5963 avformat/mov: fix missing video size when some decoders are disabled
Fix #20667

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-10-14 20:05:55 +08:00
Andreas Rheinhardt a24e0f536d avcodec/x86/hpeldsp_init: Remove check for inline mmx
Forgotten in 4c55724da8.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-14 12:31:15 +02:00
Frank Plowman b0c77e5a12 lavc/vvc: Store RefStruct references to referenced PSs/headers in slice
This loosens the coupling between CBS and the decoder by no longer using
CodedBitstreamH266Context (containing the most recently parsed PSs & PH)
to retrieve the PSs & PH in the decoder. Doing so is beneficial in two
ways:
1. It improves robustness to the case in which an AVPacket doesn't
   contain precisely one PU.
2. It allows the decoder parameter set manager to properly handle the
   case in which a single PU (erroneously) contains conflicting
   parameter sets.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2025-10-13 19:05:36 +01:00
Andreas Rheinhardt 31f0749cd4 avcodec/vp3: Optimize alignment check away when possible
Check only on arches that need said check.

(Btw: I do not see how h_loop_filter benefits from alignment
at all and why h_loop_filter_unaligned exists.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-13 18:59:49 +02:00
Andreas Rheinhardt 5823ab347a avcodec/vp3dsp: Remove unused flags parameter from ff_vp3dsp_init()
No longer necessary now that the x86 loop filter functions are
bitexact.

Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-13 18:59:24 +02:00
Andreas Rheinhardt e3ca57ae8f avcodec/x86/vp3dsp: Port loop filters to SSE2
The old code operated on bytes and did lots of tricks
due to their limited range; it did not completely succeed,
which is why the old versions were not used when bitexact
output was requested.

In contrast, the new version is much simpler: It operates
on signed 16 bit words whose range is more than sufficient.
This means that these functions don't need a check for bitexactness
(and can be used in FATE).

Old benchmarks (for this, the AV_CODEC_FLAG_BITEXACT check has been
removed from checkasm):
h_loop_filter_c:                                        29.8 ( 1.00x)
h_loop_filter_mmxext:                                   32.2 ( 0.93x)
h_loop_filter_unaligned_c:                              29.9 ( 1.00x)
h_loop_filter_unaligned_mmxext:                         31.4 ( 0.95x)
v_loop_filter_c:                                        39.3 ( 1.00x)
v_loop_filter_mmxext:                                   14.2 ( 2.78x)
v_loop_filter_unaligned_c:                              38.9 ( 1.00x)
v_loop_filter_unaligned_mmxext:                         14.3 ( 2.72x)

New benchmarks:
h_loop_filter_c:                                        29.2 ( 1.00x)
h_loop_filter_sse2:                                     28.6 ( 1.02x)
h_loop_filter_unaligned_c:                              29.0 ( 1.00x)
h_loop_filter_unaligned_sse2:                           26.9 ( 1.08x)
v_loop_filter_c:                                        38.3 ( 1.00x)
v_loop_filter_sse2:                                     11.0 ( 3.47x)
v_loop_filter_unaligned_c:                              35.5 ( 1.00x)
v_loop_filter_unaligned_sse2:                           11.2 ( 3.18x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-13 18:58:50 +02:00
Andreas Rheinhardt 5d9a392bce tests/checkasm: Add VP3 loop filter test
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-13 18:58:50 +02:00
zhanghongyuan 0bc54cddb1 fftools/opt_common: add long-form license option
Add "license" as a long-form command line option alongside the existing
"L" short option for showing license information. This maintains
consistent option naming patterns with other commands that provide both
short and long forms (help/?/help, etc.) and improves command line
usability by providing more descriptive option names.
2025-10-12 03:26:21 +00:00
Tong Wu 10e9672a8c avcodec/d3d12va_encode: use macros to set QP range and max frame size
Signed-off-by: Tong Wu <wutong1208@outlook.com>
2025-10-12 01:50:57 +00:00
Andreas Rheinhardt 36f92206bb avcodec/x86/hpeldsp: Improve ff_{avg,put}_pixels8_xy2_ssse3()
This SSSE3 function uses MMX registers (of course without emms
at the end) and processes eight bytes of input by unpacking
it into two MMX registers. This is very suboptimal given
that one can just use XMM registers to process eight words.
This commit switches them to using XMM registers.

Old benchmarks:
avg_pixels_tab[1][3]_c:                                114.5 ( 1.00x)
avg_pixels_tab[1][3]_ssse3:                             43.6 ( 2.62x)
put_pixels_tab[1][3]_c:                                 83.6 ( 1.00x)
put_pixels_tab[1][3]_ssse3:                             34.0 ( 2.46x)

New benchmarks:
avg_pixels_tab[1][3]_c:                                115.3 ( 1.00x)
avg_pixels_tab[1][3]_ssse3:                             24.6 ( 4.69x)
put_pixels_tab[1][3]_c:                                 83.8 ( 1.00x)
put_pixels_tab[1][3]_ssse3:                             19.7 ( 4.24x)

Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-12 02:45:37 +02:00
Andreas Rheinhardt 4c55724da8 avcodec/x86/hpeldsp: Add ff_put_no_rnd_pixels8_xy2_ssse3()
Given that one has to deal with 16 byte intermediates it is
unsurprising that SSE2 wins against MMX; the MMX version has
therefore been removed (as well as the now unused inline_asm.h).
The new function is even 32B smaller than the old MMX one.

Old benchmarks:
put_no_rnd_pixels_tab[1][3]_c:                          84.1 ( 1.00x)
put_no_rnd_pixels_tab[1][3]_mmx:                        41.1 ( 2.05x)

New benchmarks:
put_no_rnd_pixels_tab[1][3]_c:                          84.0 ( 1.00x)
put_no_rnd_pixels_tab[1][3]_ssse3:                      22.1 ( 3.80x)

Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-12 02:45:25 +02:00
Andreas Rheinhardt f84e06026a avcodec/x86/hpeldsp: Add SSE2 of {avg,put} no_rnd xy2 with blocksize 16
Also remove the now superseded MMX versions (the new functions have the
exact same codesize as the removed ones).

Old benchmarks:
avg_no_rnd_pixels_tab[0][3]_c:                         233.7 ( 1.00x)
avg_no_rnd_pixels_tab[0][3]_mmx:                       121.5 ( 1.92x)
put_no_rnd_pixels_tab[0][3]_c:                         171.4 ( 1.00x)
put_no_rnd_pixels_tab[0][3]_mmx:                        82.6 ( 2.08x)

New benchmarks:
avg_no_rnd_pixels_tab[0][3]_c:                         233.3 ( 1.00x)
avg_no_rnd_pixels_tab[0][3]_sse2:                       45.0 ( 5.18x)
put_no_rnd_pixels_tab[0][3]_c:                         172.1 ( 1.00x)
put_no_rnd_pixels_tab[0][3]_sse2:                       40.9 ( 4.21x)

Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-12 02:43:29 +02:00
Andreas Rheinhardt ce9d181444 avcodec/mjpegdec: Remove unnecessary reloads
Hint: The parts of this patch in decode_block_progressive()
and decode_block_refinement() rely on the fact that GET_VLC
returns -1 on error, so that it enters the codepaths for
actually coded block coefficients.

Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-11 08:20:42 +02:00
Andreas Rheinhardt dad06a445f avcodec/Makefile: Remove h263 decoder->mpeg4videodec.o dependency
Also prefer using #if CONFIG_MPEG4_DECODER checks in order not
to rely on DCE.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-11 07:51:01 +02:00
Andreas Rheinhardt 10d3479da0 avcodec/h263dec: Avoid redundant branch
Only the MPEG-4 decoder can have partitioned frames here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-11 07:51:01 +02:00
Andreas Rheinhardt d96f8d32ad avcodec/x86/h264_qpel: Don't instantiate unused functions
The v_lowpass wrappers (which are instantiated by this macro)
are only used in the put (and not the avg) form for SSSE3
(the avg form is only used for mc02, which doesn't exist
for SSSE3). Clang warns about the unused functions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-10 16:27:57 +02:00
Niklas Haas 6f1ab828d3 libavfilter/vf_libplacebo: add temperature option 2025-10-09 20:45:09 +00:00
Leo Izen eab3b68237 avcodec/exif: avoid printing errors for makernote non-IFD parsing
When we parse a MakerNote, we first try to parse it as an IFD and if
that fails, we try to re-parse it as a binary blob. This is because
MakerNote is not well-documented in its nature.

However, if we fail to parse it the first time, we should not av_log
error messages about the parse failure, so instead we log these as
AV_LOG_DEBUG.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reported-by: Ramiro Polla <ramiro.polla@gmail.com>
2025-10-09 12:40:41 -04:00
James Almer 41c168444e avcodec/hevc/sei: don't attempt to use stale values in HEVCSEITimeCode
Invalidate the whole struct on SEI reset.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-09 12:09:35 -03:00
James Almer 8e01bff774 avcodec/hevc/sei: don't attempt to use stale values in HEVCSEITDRDI
Invalidate the whole struct on SEI reset.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-09 12:09:35 -03:00
James Almer d448d6d1a0 avcodec/hevc/sei: prevent storing a potentially bogus num_ref_displays value in HEVCSEITDRDI
Fixes: 439711052/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4956250308935680
Fixes: out of array access

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-09 12:09:35 -03:00
Jack Lau a934d48440 doc/muxers: correct default pkt_size value of whip
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 14:33:02 +00:00
Jack Lau b43f8dec18 avformat/whip: add macros to replace magic number
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 14:32:03 +00:00
Jack Lau bc6164eb6f avformat/whip: remove WHIP_STATE_DTLS_CONNECTING
This value is only useful when dtls handshake is NONBLOCK mode,
dtls handshake just need to call ffurl_handshake once since it
force block mode.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 14:32:03 +00:00
Jack Lau 76b13ca0a6 avformat/whip: check the peer whether is ice lite
See RFC 5245 Section 4.3
If an agent is a lite implementation, it MUST include an "a=ice-lite"
session-level attribute in its SDP.  If an agent is a full
implementation, it MUST NOT include this attribute.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 14:32:03 +00:00
Jack Lau ec0a04de0d avformat/whip: remind user increase -buffer_size
The udp buffer size might be too small to easily
be full temporarily and return WSAEWOULDBLOCK.
The udp code will handle the windows error code
and convert it to AVERROR(EAGAIN).

This issue just can be reproduced on windows.

If sleep a interval and retry to send pkt when hit
EAGAIN, it will increase latency, and appropriate
interval is hard to define.

So this patch just remind user increase the buffer
size via -buffer_size to avoid this issue.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 09:55:18 +00:00
Jack Lau b3793d9941 avformat/whip: pass through buffer_size option to udp
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 09:55:18 +00:00
Jack Lau 469aad3897 avformat/whip: add ICE consent freshness support
Refer to RFC 9725 4.2,
"Once a session is set up, consent freshness as per
[RFC7675] SHALL be used to detect non-graceful
disconnection by full ICE implementations and DTLS
teardown for session termination by either side"

Refer to RFC 7675,
send STUN Binding request every 5s,
expire consent after 30s without response,
terminate session when the consent expired.

TODO:
Random consent check interval (4-6s) will be
added later.

Co-authored-by: Sergio Garcia Murillo <sergio.garcia.murillo@gmail.com>
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 09:29:25 +00:00
Jack Lau aba84db96f avformat/whip: add WHIP_US_PER_MS macro to replace 1000
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 09:29:25 +00:00
Manuel Lauss aa91ae25b8 avcodec/sanm: minor comment and size detection changes
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:02 +02:00
Manuel Lauss c46c1cb0db avcodec/sanm: remove rotate_code context member
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:02 +02:00
Manuel Lauss 72df8f271d avcodec/sanm: implement 3 blits for codec37/47/48
The various game engines implement the following blit types, from the decoded
result to the main canvas:
- normal (opaque) blit (c37/c47/c48)
- masked blit (c37/c48)
- interpolated-frame blit (c48)
  Here an artificial frame is generated by looking up the pixels
  from both buffers and picking a color from the interpolation table
  for the artificial frame.
  This is only supported in the decoder of "Making Magic".

Implement and hook up these 3 schemes for each of the 3 compresstion types,
and switch codec20 to a call to the opaque blit function.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:02 +02:00
Manuel Lauss d7d97ea32c avcodec/sanm: partially fix codec48 for Making Magic
Making Magic makes use of codec48 flag bit 0, which, when set,
means NOT to swap both buffers on even sequence numbers.

This fixes most of the artifacts in the Making Magic videos.
It's not complete though, bits 1 and 4 still need to be handled.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:02 +02:00
Manuel Lauss 9e72b2f2d0 avcodec/sanm: codec37/47/48 updates
- align the incoming widths to 4(c37) / 8(c47/78) pixels. LucasArts
   game videos have these aligned.
- since these codecs use their 2/3 buffers for themselves, adjust the
  stride to the aligned width, keeping it even, which gets rid of
  an unaligned store in c48_4to8() found by the fuzzer with an
  odd stride.
- clear the whole diff buffer, not just the area described by w/h.
- adjust the RLE "decoded_size" to the product of the aligned width
   and reported height.

These changes are the result of various fuzzer-found issues; all my
test videos still work fine.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:02 +02:00
Manuel Lauss 0eb58e40cb avcodec/sanm: codec20 left/top offset support
Add left/top offsets and clipping to codec20 (raw images),
use it for the copying of codec37/47/48 images to main buffer.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss a108be2ba3 avcodec/sanm: for ANIM codecs with own buffers, really check dimensions
Codec37/47/48 have their own buffers; left/top are applied after
the decoding is done when copying to the main buffer.  Don't add left/top
to their width/height when doing checks against the established buffer sizes.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss b6a9c4671a avcodec/sanm: reimplement XPAL algorithm identical to DOS smush engine
This implements XPAL the same way the DOS/Windows players do, with an
additional 768-entry table holding the palette left-shifted by 7 bits,
and adding the deltapal values to this.

This results in a perfectly smooth day-to-night transition in the last
30 seconds of the Outlaws RAE.SAN (ending) video, while before there
were visible brightness "pulses" when a new palette was loaded.
It also fixes color banding in the The Dig Intro (sq1.san), in the
scene showing the shuttle launch pad and the night sky.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss 4316914b39 avcodec/sanm: codec37: comp1: guard against invalid mv index
the c37 mvtable has only 255 pairs, change index 255 to zero to
avoid reading outside the table boundaries.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss 5f1f5dd2d4 avcodec/sanm: guard against image area growing larger than buffer
When checking for oversized frames, check not only for the width
and height being larger, but also the area not outgrowing the
allocated buffer.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss 556cef27d9 avcodec/sanm: enforce SANM min and max sizes at decode_init()
Enforce at least 8x8 and at max 800x600 for SANM/BL16.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss 70b04717d0 avcodec/sanm: distrust dimensions for ANIM in decode_init
When decode_init() is called for ANIM content, zero the dimensions
set in avctx width/height. Only SANM files have image dimensions in
their header, while ANIM do not.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss 0802044d81 avcodec/sanm: codec48: reimplement block scaling
Reimplement opcodes 0xFF and 0xFD the same way the c48 decoder
in the "Mysteries of the Sith" game engine does it:
The source pixel(s) and various pixels from inside the same and above
block of the second to last image rendered to the destination buffer
are used together with the interpolation table to generate a 4x4 pattern,
which is then expanded by doubling each pixel horizontally and vertically
to produce the final 8x8 block.

This fixes visible artifacts in frames 25-50 of the S1L1OCS.SAN
video of Mysteries of the Sith.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss b99b7a6f90 avcodec/sanm: change codec37 opcode FE to 4 2x2 blocks
It was initially implemented as 4 4x1 blocks, reimplement it as 4 2x2 blocks.
Fixes a few The Dig videos, esp. black dots on the asteroid in the
intro scene.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss d618577747 avcodec/sanm: check codec48 subblock mv index
Codec48 opcodes F9 and FC take per-subblock indices into the motion vector
table from the source stream, however the table has only 255 entries.
Luckily, index 255 is index 0 of the following table, which means no
motion vector, the same as index 0 of the current table.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss dd875f56b7 avcodec/sanm: invalidate STOR data when subversion changes
since the STOR data is a different format.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss b7e55ef8a1 avcodec/sanm: per-fobj GetByteContext
Create a separate GetByteContext from the general one, to be able
to limit the size of the FOBJ to the size described in the tag size.
Otherwise each fobj could theoretically use all the remaining data
in the FRME (which also contains audio, subtitles, ...).

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss a0c4dfc63b avcodec/sanm: handle FTCH on video start
some videos have a FTCH at the start of the video, to restore the
last image produced by the previous game file.  This leads to
ugly messages like these:

[sanm @ 0x7f18cc001980] [IMGUTILS @ 0x7f18d7ffe8e0] Picture size 0x0 is invalid
[sanm @ 0x7f18cc001980] video_get_buffer: image parameters invalid
[sanm @ 0x7f18cc001980] get_buffer() failed

Fix this by not setting the got_frame_ptr when there is nothing to
restore/fetch.  Seen with a lot of RA1 and the RA2 Level 11/12 videos.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss 7c205b5397 avcodec/sanm: rename motion_vectors[] table to c47_mv[]
Rename the generic motion_vectors to c47_mv, as this vector table
was initially introduced with codec47 which predates bl16 by 1-2 years,
and bl16 is a development of codec47 (with a bit of c48 thrown in).

No functional change.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 3945d100ef avcodec/sanm: remove unused SANMFrameHeader
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 2ef26c30eb avcodec/sanm: implement BL16 subcodecs 1 and 7
Both of these encode a quarter-sized keyframe, with missing pixels
interpolated from the immediate neighbours.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss b1a7f8b7cf avcodec/sanm: factor out the ANIM decoding into separate function
Mainly for readability. No functional changes.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 49c552d066 avcodec/sanm: restructure SANM like the other block codecs
Restructe the SANM (or BL16 as LucasArts calls it) decoder to make it
look like the others, as it is basically a development of old_codec47
for rgb565 values.

No functional changes.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 4d5e87eaa4 Revert "avcodec/sanm: Check w,h,left,top"
This reverts commit 134fbfd1dc.

As it breaks valid uses of this in Rebel Assault 1 videos.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 75b6937527 avcodec/sanm: reset rotate_code every iteration
and eliminate the explicit reset in the other decoders that
don't need it.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss de7db62acc avcodec/sanm: rename process_block to codec47_block
the new name better indicates where it belongs to.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 043dafc4c2 avcodec/sanm: codec37/47/48 size checks
Add more size checks to old_codec37/47/48, esp. the headers.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss f98cd66b4b avcodec/sanm: codec47: read the small codebook
codec47 carries a 4-byte small codebook in its header. Read those
4 bytes into context member instead of awkwardly redirecting the
bytestream pointer every time it needs to be accessed.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 72e6206c88 avcodec/sanm: partially fix codec48
The mv check introduced with d5bdb0b705 broke MotS videos:
- their height (300 lines) is 37,5 blocks; unfortunately the videos try to
  access up to 1 block more.
  Extend the mv check to the aligned_height, which fixes most artifacts.
- don't return an error when an mv is invalid; rather skip the (subblock).
  Gets rid of almost all artifacts.

Some artifacts still remain, esp in space scenes where the original
encoder apparently fetched black pixels from outside of the aligned
height.  An increase of the buffer size by 8 lines will fix that later.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 24ce42b406 avcodec/sanm: codec4 improvements
- don't draw outside the buffers
- don't wrap around when coordinates go over the edge

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss dfe4a0626f avcodec/sanm: codec31 improvements
- don't draw outside the buffers
- don't wrap around when coordinates go over the edge
  this is especially noticeable in the e.g. O1OPEN.ANM, C1C3PO.ANM
  RA1 files with planets wrapping around.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss da4b88494c avcodec/sanm: codec1 improvements
- don't draw outside the buffers
- don't wrap around when coordinates go over the edge
  this is especially noticeable in the e.g. O1OPEN.ANM, C1C3PO.ANM
  RA1 files with planets wrapping around.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:28:59 +02:00
Manuel Lauss d18c25f1a9 avcodec/sanm: codec21 improvements
- don't draw outside the buffers
- don't wrap around when coordinates go over the edge

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:28:59 +02:00
Manuel Lauss 67b28acba3 avcodec/sanm: codec23 improvements
- don't draw outside the buffers
- don't wrap around when coordinates go over the edge

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:28:59 +02:00
Kacper Michajłow 3a8ea78b88 avutil/attributes: add AV_HAS_ATTRIBUTE
Maybe useful and to fix MSVC preprocessor warnings.

Fixes: afad332d77
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-09 06:25:06 +02:00
Zhao Zhili 9034ca30ef avformat/flacdec: fix self assign warning 2025-10-09 03:41:29 +00:00
Kacper Michajłow afad332d77 avutil/attributes: use __has_attribute to test for format attribute
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-09 03:35:16 +00:00
Kacper Michajłow 086597adae avutil/attributes: don't force format checking to __gnu_printf__ on mingw build
Use __MINGW_{PRINTF,SCANF}_FORMAT which matches the format check for
implementation that is actually used.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-09 03:35:16 +00:00
James Almer 4377affc28 avcodec/hevc/refs: don't unconditionally discard non-IRAP frames if no IRAP frame was seen before
Should fix issue #20661

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-09 02:52:46 +00:00
Andreas Rheinhardt 378d5bb08a avcodec/x86/fpel: Add blocksize x blocksize avg/put functions
This commit deduplicates the wrappers around the fpel functions
for copying whole blocks (i.e. height equaling width). It does
this in a manner which avoids having push/pop function arguments
when the calling convention forces one to pass them on the stack
(as in 32bit systems).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:53 +02:00
Andreas Rheinhardt ad498f9759 avcodec/x86/cavsdsp: Remove MMXEXT Qpeldsp
Superseded by SSE2. Saves about 11630B here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:08 +02:00
Andreas Rheinhardt 650098955e avcodec/x86/cavs_qpel: Add SSE2 vertical motion compensation
This is not based on the MMXEXT one, because the latter is quite
suboptimal: Motion vector types mc01 and mc03 (vertical motion vectors
with remainder of one quarter or three quarter) use different neighboring
lines for interpolation: mc01 uses two lines above and two lines below,
mc03 one line above and three lines below. The MMXEXT code uses
a common macro for all of them and therefore reads six lines
before it processes them (even reading lines which are not used
at all), leading to severe register pressure.

Another difference to the old code is that the positive and negative
parts of the sum to calculate are accumulated separately and
the subtraction is performed with unsigned saturation, so
that one can avoid biasing the sum.

The fact that the mc01 and mc03 filter coefficients are mirrors
of each other has been exploited to reduce mc01 to mc03.

But of course the most important different difference between
this code and the MMXEXT one is that XMM registers allow to
process eight words at a time, ideal for 8x8 subblocks,
whereas the MMXEXT code processes them in 4x8 or 4x16 blocks.

Benchmarks:
avg_cavs_qpel_pixels_tab[0][4]_c:                      917.0 ( 1.00x)
avg_cavs_qpel_pixels_tab[0][4]_mmxext:                 222.0 ( 4.13x)
avg_cavs_qpel_pixels_tab[0][4]_sse2:                    89.0 (10.31x)
avg_cavs_qpel_pixels_tab[0][12]_c:                     885.7 ( 1.00x)
avg_cavs_qpel_pixels_tab[0][12]_mmxext:                223.2 ( 3.97x)
avg_cavs_qpel_pixels_tab[0][12]_sse2:                   88.5 (10.01x)
avg_cavs_qpel_pixels_tab[1][4]_c:                      222.4 ( 1.00x)
avg_cavs_qpel_pixels_tab[1][4]_mmxext:                  57.2 ( 3.89x)
avg_cavs_qpel_pixels_tab[1][4]_sse2:                    23.3 ( 9.55x)
avg_cavs_qpel_pixels_tab[1][12]_c:                     216.0 ( 1.00x)
avg_cavs_qpel_pixels_tab[1][12]_mmxext:                 57.4 ( 3.76x)
avg_cavs_qpel_pixels_tab[1][12]_sse2:                   22.6 ( 9.56x)
put_cavs_qpel_pixels_tab[0][4]_c:                      750.9 ( 1.00x)
put_cavs_qpel_pixels_tab[0][4]_mmxext:                 210.4 ( 3.57x)
put_cavs_qpel_pixels_tab[0][4]_sse2:                    84.2 ( 8.92x)
put_cavs_qpel_pixels_tab[0][12]_c:                     731.6 ( 1.00x)
put_cavs_qpel_pixels_tab[0][12]_mmxext:                210.7 ( 3.47x)
put_cavs_qpel_pixels_tab[0][12]_sse2:                   84.1 ( 8.70x)
put_cavs_qpel_pixels_tab[1][4]_c:                      191.7 ( 1.00x)
put_cavs_qpel_pixels_tab[1][4]_mmxext:                  53.8 ( 3.56x)
put_cavs_qpel_pixels_tab[1][4]_sse2:                    24.5 ( 7.83x)
put_cavs_qpel_pixels_tab[1][12]_c:                     179.1 ( 1.00x)
put_cavs_qpel_pixels_tab[1][12]_mmxext:                 53.9 ( 3.32x)
put_cavs_qpel_pixels_tab[1][12]_sse2:                   24.0 ( 7.47x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:08 +02:00
Andreas Rheinhardt 74a88c0c11 avcodec/x86/cavsdsp: Add SSE2 mc20 horizontal motion compensation
Basically a direct port of the MMXEXT one. The main difference
is of course that one can process eight pixels (unpacked to words)
at a time, leading to speedups.

avg_cavs_qpel_pixels_tab[0][2]_c:                      700.1 ( 1.00x)
avg_cavs_qpel_pixels_tab[0][2]_mmxext:                 158.1 ( 4.43x)
avg_cavs_qpel_pixels_tab[0][2]_sse2:                    86.0 ( 8.14x)
avg_cavs_qpel_pixels_tab[1][2]_c:                      171.9 ( 1.00x)
avg_cavs_qpel_pixels_tab[1][2]_mmxext:                  39.4 ( 4.36x)
avg_cavs_qpel_pixels_tab[1][2]_sse2:                    21.7 ( 7.92x)
put_cavs_qpel_pixels_tab[0][2]_c:                      525.7 ( 1.00x)
put_cavs_qpel_pixels_tab[0][2]_mmxext:                 148.5 ( 3.54x)
put_cavs_qpel_pixels_tab[0][2]_sse2:                    75.2 ( 6.99x)
put_cavs_qpel_pixels_tab[1][2]_c:                      129.5 ( 1.00x)
put_cavs_qpel_pixels_tab[1][2]_mmxext:                  36.7 ( 3.53x)
put_cavs_qpel_pixels_tab[1][2]_sse2:                    19.0 ( 6.81x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:08 +02:00
Andreas Rheinhardt 54598238e4 tests/checkasm: Add CAVS qpel test
This test already uncovered a bug in the vertical qpel motion
compensation code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:08 +02:00
Andreas Rheinhardt cc2e2f12ca avcodec/x86/cavsdsp: Fix vertical qpel motion compensation
The prediction involves terms of the form
(-1 * s0 - 2 * s1 + 96 * s2 + 42 * s3 - 7 * s4 + 64) >> 7,
where the s values are in the range of 0..255.
The sum can have values in the range -2550..35190, which
does not fit into a signed 16bit integer. The code uses
an arithmetic right shift, which does not yield the correct
result for values >= 2^15; such values should be clipped
to 255, yet are clipped to 0 instead.

Fix this by shifting the values by 4096, so that the range
is positive, use a logical right shift and subtract 32.

bunny.mp4 from the FATE suite can be used to reproduce the problem.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:08 +02:00
Andreas Rheinhardt ec2fe94b3f avcodec/cavs: Remove unused parameter
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:08 +02:00
Michael Niedermayer 7896cc67c1 avcodec/exr: Check that DWA has 3 channels
The implementation hardcodes access to 3 channels, so we need to check that
Fixes: out of array access
Fixes: BIGSLEEP-445394503-crash.exr

Found-by: Google Big Sleep
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-08 00:27:49 +00:00
Michael Niedermayer c911e00011 avcodec/exr: Round dc_w/h up
Without rounding them up there are too few dc coeffs for the blocks.
We do not know if this way of handling odd dimensions is correct, as we have
no such DWA sample.
thus we ask the user for a sample if she encounters such a file

Fixes: out of array access
Fixes: BIGSLEEP-445392027-crash.exr

Found-by: Google Big Sleep
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-08 00:27:49 +00:00
Michael Niedermayer 8e078826da avcodec/exr: check ac_size
Fixes: out of array read
Fixes: dwa_uncompress.py.crash.exr

The code will read from the ac data even if ac_size is 0, thus that case
is not implemented and we ask for a sample and error out cleanly

Found-by: Google Big Sleep

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-08 00:27:49 +00:00
Baptiste Coudurier ef60d5ac32 general: fix warning 'av_malloc_array' sizes specified with 'sizeof'
in the earlier argument and not in the later argument [-Wcalloc-transposed-args]

Fixes trac ticket #11620
2025-10-07 14:51:46 -07:00
Andreas Rheinhardt 00225e9ebc avcodec/x86/h264_qpel: Simplify macros
1. Remove the OP parameter from the QPEL_H264* macros. These are
a remnant of inline assembly and were forgotten in
610e00b359.
2. Pass the instruction set extension for the shift5 function
explicitly in the macro instead of using magic #defines.
3. Likewise, avoid magic #defines for (8|16)_v_lowpass_ssse3.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 3049694e9f avcodec/x86/h264_qpel: Split hv2_lowpass_sse2 into size 8,16 funcs
This is beneficial size-wise: 384B of new asm functions are more
than outweighted by 416B savings from simpler calls here (for size 16,
the size 8 function had been called twice).
It also makes the code more readable, as it allowed to remove
several wrappers in h264_qpel.c.

It is also beneficial performance-wise. Old benchmarks:
avg_h264_qpel_16_mc12_8_c:                            1757.7 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2:                          197.7 ( 8.89x)
avg_h264_qpel_16_mc12_8_ssse3:                         204.6 ( 8.59x)
avg_h264_qpel_16_mc21_8_c:                            1631.6 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          276.4 ( 5.90x)
avg_h264_qpel_16_mc21_8_ssse3:                         290.7 ( 5.61x)
avg_h264_qpel_16_mc22_8_c:                            1122.7 ( 1.00x)
avg_h264_qpel_16_mc22_8_sse2:                          179.5 ( 6.25x)
avg_h264_qpel_16_mc22_8_ssse3:                         181.8 ( 6.17x)
avg_h264_qpel_16_mc23_8_c:                            1626.7 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          276.8 ( 5.88x)
avg_h264_qpel_16_mc23_8_ssse3:                         290.9 ( 5.59x)
avg_h264_qpel_16_mc32_8_c:                            1754.1 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2:                          193.8 ( 9.05x)
avg_h264_qpel_16_mc32_8_ssse3:                         203.6 ( 8.62x)
put_h264_qpel_16_mc12_8_c:                            1733.6 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2:                          189.6 ( 9.14x)
put_h264_qpel_16_mc12_8_ssse3:                         199.6 ( 8.69x)
put_h264_qpel_16_mc21_8_c:                            1616.0 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          284.3 ( 5.69x)
put_h264_qpel_16_mc21_8_ssse3:                         296.5 ( 5.45x)
put_h264_qpel_16_mc22_8_c:                             963.7 ( 1.00x)
put_h264_qpel_16_mc22_8_sse2:                          169.9 ( 5.67x)
put_h264_qpel_16_mc22_8_ssse3:                         186.1 ( 5.18x)
put_h264_qpel_16_mc23_8_c:                            1607.2 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          275.0 ( 5.84x)
put_h264_qpel_16_mc23_8_ssse3:                         297.8 ( 5.40x)
put_h264_qpel_16_mc32_8_c:                            1734.7 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2:                          189.4 ( 9.16x)
put_h264_qpel_16_mc32_8_ssse3:                         199.4 ( 8.70x)

New benchmarks:
avg_h264_qpel_16_mc12_8_c:                            1743.7 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2:                          189.7 ( 9.19x)
avg_h264_qpel_16_mc12_8_ssse3:                         204.4 ( 8.53x)
avg_h264_qpel_16_mc21_8_c:                            1637.7 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          267.7 ( 6.12x)
avg_h264_qpel_16_mc21_8_ssse3:                         291.5 ( 5.62x)
avg_h264_qpel_16_mc22_8_c:                            1150.3 ( 1.00x)
avg_h264_qpel_16_mc22_8_sse2:                          164.6 ( 6.99x)
avg_h264_qpel_16_mc22_8_ssse3:                         182.1 ( 6.32x)
avg_h264_qpel_16_mc23_8_c:                            1635.3 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          268.5 ( 6.09x)
avg_h264_qpel_16_mc23_8_ssse3:                         298.5 ( 5.48x)
avg_h264_qpel_16_mc32_8_c:                            1740.6 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2:                          182.6 ( 9.53x)
avg_h264_qpel_16_mc32_8_ssse3:                         201.9 ( 8.62x)
put_h264_qpel_16_mc12_8_c:                            1727.4 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2:                          188.1 ( 9.18x)
put_h264_qpel_16_mc12_8_ssse3:                         199.6 ( 8.65x)
put_h264_qpel_16_mc21_8_c:                            1623.5 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          265.9 ( 6.11x)
put_h264_qpel_16_mc21_8_ssse3:                         299.4 ( 5.42x)
put_h264_qpel_16_mc22_8_c:                             954.0 ( 1.00x)
put_h264_qpel_16_mc22_8_sse2:                          161.8 ( 5.89x)
put_h264_qpel_16_mc22_8_ssse3:                         180.4 ( 5.29x)
put_h264_qpel_16_mc23_8_c:                            1611.2 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          265.8 ( 6.06x)
put_h264_qpel_16_mc23_8_ssse3:                         300.3 ( 5.37x)
put_h264_qpel_16_mc32_8_c:                            1734.5 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2:                          180.0 ( 9.63x)
put_h264_qpel_16_mc32_8_ssse3:                         199.7 ( 8.69x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 3ed590c7b9 avcodec/x86/h264_qpel: Port qpel8or16_hv2_lowpass_op_mmxext to SSE2
This means that only blocksize 4 still uses mmx(ext).

Old benchmarks:
avg_h264_qpel_8_mc12_8_c:                              428.4 ( 1.00x)
avg_h264_qpel_8_mc12_8_sse2:                            74.3 ( 5.77x)
avg_h264_qpel_8_mc12_8_ssse3:                           69.3 ( 6.18x)
avg_h264_qpel_8_mc21_8_c:                              401.4 ( 1.00x)
avg_h264_qpel_8_mc21_8_sse2:                            97.8 ( 4.10x)
avg_h264_qpel_8_mc21_8_ssse3:                           93.7 ( 4.28x)
avg_h264_qpel_8_mc22_8_c:                              281.8 ( 1.00x)
avg_h264_qpel_8_mc22_8_sse2:                            66.7 ( 4.23x)
avg_h264_qpel_8_mc22_8_ssse3:                           62.6 ( 4.50x)
avg_h264_qpel_8_mc23_8_c:                              397.2 ( 1.00x)
avg_h264_qpel_8_mc23_8_sse2:                            97.9 ( 4.06x)
avg_h264_qpel_8_mc23_8_ssse3:                           93.7 ( 4.24x)
avg_h264_qpel_8_mc32_8_c:                              432.4 ( 1.00x)
avg_h264_qpel_8_mc32_8_sse2:                            73.9 ( 5.85x)
avg_h264_qpel_8_mc32_8_ssse3:                           69.5 ( 6.22x)
avg_h264_qpel_16_mc12_8_c:                            1756.4 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2:                          240.0 ( 7.32x)
avg_h264_qpel_16_mc12_8_ssse3:                         204.5 ( 8.59x)
avg_h264_qpel_16_mc21_8_c:                            1635.3 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          321.2 ( 5.09x)
avg_h264_qpel_16_mc21_8_ssse3:                         288.5 ( 5.67x)
avg_h264_qpel_16_mc22_8_c:                            1130.8 ( 1.00x)
avg_h264_qpel_16_mc22_8_sse2:                          219.4 ( 5.15x)
avg_h264_qpel_16_mc22_8_ssse3:                         182.2 ( 6.21x)
avg_h264_qpel_16_mc23_8_c:                            1622.5 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          321.3 ( 5.05x)
avg_h264_qpel_16_mc23_8_ssse3:                         289.5 ( 5.60x)
avg_h264_qpel_16_mc32_8_c:                            1762.5 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2:                          236.1 ( 7.46x)
avg_h264_qpel_16_mc32_8_ssse3:                         205.2 ( 8.59x)
put_h264_qpel_8_mc12_8_c:                              427.2 ( 1.00x)
put_h264_qpel_8_mc12_8_sse2:                            72.1 ( 5.93x)
put_h264_qpel_8_mc12_8_ssse3:                           67.0 ( 6.38x)
put_h264_qpel_8_mc21_8_c:                              402.9 ( 1.00x)
put_h264_qpel_8_mc21_8_sse2:                            95.9 ( 4.20x)
put_h264_qpel_8_mc21_8_ssse3:                           91.9 ( 4.38x)
put_h264_qpel_8_mc22_8_c:                              235.0 ( 1.00x)
put_h264_qpel_8_mc22_8_sse2:                            64.6 ( 3.64x)
put_h264_qpel_8_mc22_8_ssse3:                           60.0 ( 3.92x)
put_h264_qpel_8_mc23_8_c:                              403.6 ( 1.00x)
put_h264_qpel_8_mc23_8_sse2:                            95.9 ( 4.21x)
put_h264_qpel_8_mc23_8_ssse3:                           91.7 ( 4.40x)
put_h264_qpel_8_mc32_8_c:                              430.7 ( 1.00x)
put_h264_qpel_8_mc32_8_sse2:                            72.1 ( 5.97x)
put_h264_qpel_8_mc32_8_ssse3:                           67.0 ( 6.43x)
put_h264_qpel_16_mc12_8_c:                            1724.2 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2:                          230.7 ( 7.47x)
put_h264_qpel_16_mc12_8_ssse3:                         199.8 ( 8.63x)
put_h264_qpel_16_mc21_8_c:                            1613.3 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          327.5 ( 4.93x)
put_h264_qpel_16_mc21_8_ssse3:                         297.2 ( 5.43x)
put_h264_qpel_16_mc22_8_c:                             959.2 ( 1.00x)
put_h264_qpel_16_mc22_8_sse2:                          211.9 ( 4.53x)
put_h264_qpel_16_mc22_8_ssse3:                         186.1 ( 5.15x)
put_h264_qpel_16_mc23_8_c:                            1619.0 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          319.7 ( 5.06x)
put_h264_qpel_16_mc23_8_ssse3:                         299.2 ( 5.41x)
put_h264_qpel_16_mc32_8_c:                            1741.7 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2:                          230.9 ( 7.54x)
put_h264_qpel_16_mc32_8_ssse3:                         199.4 ( 8.74x)

New benchmarks:
avg_h264_qpel_8_mc12_8_c:                              427.2 ( 1.00x)
avg_h264_qpel_8_mc12_8_sse2:                            63.9 ( 6.69x)
avg_h264_qpel_8_mc12_8_ssse3:                           69.2 ( 6.18x)
avg_h264_qpel_8_mc21_8_c:                              399.2 ( 1.00x)
avg_h264_qpel_8_mc21_8_sse2:                            87.7 ( 4.55x)
avg_h264_qpel_8_mc21_8_ssse3:                           93.9 ( 4.25x)
avg_h264_qpel_8_mc22_8_c:                              285.7 ( 1.00x)
avg_h264_qpel_8_mc22_8_sse2:                            56.4 ( 5.07x)
avg_h264_qpel_8_mc22_8_ssse3:                           62.6 ( 4.56x)
avg_h264_qpel_8_mc23_8_c:                              398.6 ( 1.00x)
avg_h264_qpel_8_mc23_8_sse2:                            87.6 ( 4.55x)
avg_h264_qpel_8_mc23_8_ssse3:                           93.8 ( 4.25x)
avg_h264_qpel_8_mc32_8_c:                              425.8 ( 1.00x)
avg_h264_qpel_8_mc32_8_sse2:                            63.8 ( 6.67x)
avg_h264_qpel_8_mc32_8_ssse3:                           69.0 ( 6.17x)
avg_h264_qpel_16_mc12_8_c:                            1748.2 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2:                          198.5 ( 8.81x)
avg_h264_qpel_16_mc12_8_ssse3:                         203.2 ( 8.60x)
avg_h264_qpel_16_mc21_8_c:                            1638.1 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          277.4 ( 5.91x)
avg_h264_qpel_16_mc21_8_ssse3:                         291.1 ( 5.63x)
avg_h264_qpel_16_mc22_8_c:                            1140.7 ( 1.00x)
avg_h264_qpel_16_mc22_8_sse2:                          180.3 ( 6.33x)
avg_h264_qpel_16_mc22_8_ssse3:                         181.9 ( 6.27x)
avg_h264_qpel_16_mc23_8_c:                            1629.9 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          278.0 ( 5.86x)
avg_h264_qpel_16_mc23_8_ssse3:                         291.0 ( 5.60x)
avg_h264_qpel_16_mc32_8_c:                            1752.1 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2:                          193.7 ( 9.05x)
avg_h264_qpel_16_mc32_8_ssse3:                         203.4 ( 8.61x)
put_h264_qpel_8_mc12_8_c:                              421.8 ( 1.00x)
put_h264_qpel_8_mc12_8_sse2:                            61.7 ( 6.83x)
put_h264_qpel_8_mc12_8_ssse3:                           67.2 ( 6.28x)
put_h264_qpel_8_mc21_8_c:                              396.8 ( 1.00x)
put_h264_qpel_8_mc21_8_sse2:                            85.4 ( 4.65x)
put_h264_qpel_8_mc21_8_ssse3:                           91.6 ( 4.33x)
put_h264_qpel_8_mc22_8_c:                              234.1 ( 1.00x)
put_h264_qpel_8_mc22_8_sse2:                            54.4 ( 4.30x)
put_h264_qpel_8_mc22_8_ssse3:                           60.2 ( 3.89x)
put_h264_qpel_8_mc23_8_c:                              399.2 ( 1.00x)
put_h264_qpel_8_mc23_8_sse2:                            85.5 ( 4.67x)
put_h264_qpel_8_mc23_8_ssse3:                           91.8 ( 4.35x)
put_h264_qpel_8_mc32_8_c:                              422.2 ( 1.00x)
put_h264_qpel_8_mc32_8_sse2:                            61.8 ( 6.83x)
put_h264_qpel_8_mc32_8_ssse3:                           67.0 ( 6.30x)
put_h264_qpel_16_mc12_8_c:                            1720.3 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2:                          189.9 ( 9.06x)
put_h264_qpel_16_mc12_8_ssse3:                         199.9 ( 8.61x)
put_h264_qpel_16_mc21_8_c:                            1624.5 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          285.4 ( 5.69x)
put_h264_qpel_16_mc21_8_ssse3:                         296.4 ( 5.48x)
put_h264_qpel_16_mc22_8_c:                             963.9 ( 1.00x)
put_h264_qpel_16_mc22_8_sse2:                          170.1 ( 5.67x)
put_h264_qpel_16_mc22_8_ssse3:                         186.4 ( 5.17x)
put_h264_qpel_16_mc23_8_c:                            1613.5 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          274.6 ( 5.88x)
put_h264_qpel_16_mc23_8_ssse3:                         300.4 ( 5.37x)
put_h264_qpel_16_mc32_8_c:                            1735.9 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2:                          189.6 ( 9.15x)
put_h264_qpel_16_mc32_8_ssse3:                         199.5 ( 8.70x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 617c042093 avcodec/x86/h264_qpel_8bit: Avoid doing unnecessary work
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 29f439077a avcodec/h264_qpel: Move loop into qpel4_hv_lowpass_v_mmxext()
Every caller calls it three times in a loop, with slightly
modified arguments. So it makes sense to move the loop
into the callee.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 4539f7e4d4 avcodec/x86/h264_qpel_8bit: Don't duplicate qpel4_hv_lowpass_v_mmxext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 3e2d9b73c1 avcodec/h264qpel: Move Snow-only code to snow.c
Blocksize 2 is Snow-only, so move all the code pertaining
to it to snow.c. Also make the put array in H264QpelContext
smaller -- it only needs three sets of 16 function pointers.
This continues 6eb8bc4217
and b0c91c2fba.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 15a4289b79 avcodec/x86/h264_qpel_8bit: Improve register allocation
None of the other registers need to be preserved at this time,
so six XMM registers are always enough. Forgotten in
fa9ea5113b.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Zhao Zhili c7815a4b70 avfilter/vf_chromakey: specify alphamode of chromakey filter
Fix assert failure with:
ffmpeg -i input.mp4 \
	-vf chromakey=similarity=0.1,format=yuva420p,alphaextract \
	-f null -

Assertion frame->alpha_mode == link->alpha_mode failed at src/libavfilter/avfilter.c:1085
2025-10-07 16:00:27 +00:00
Zhao Zhili ba9c635784 avfilter/vf_chromakey_cuda: specify alpha_mode of output
Fix assert failure with:

ffmpeg -init_hw_device cuda=gpu -filter_hw_device gpu \
	-i input.mp4 -an \
	-vf hwupload,format=cuda,chromakey_cuda=color=black,hwdownload,format=yuva420p,alphaextract \
	-f null -

Assertion frame->alpha_mode == link->alpha_mode failed at src/libavfilter/avfilter.c:1085
2025-10-07 16:00:27 +00:00
Zhao Zhili 027497891b avfilter/vf_chromakey_cuda: simplify frame management 2025-10-07 16:00:27 +00:00
Zhao Zhili bb3a4de5a7 avfilter/vf_bilateral_cuda: remove a goto which has no effect 2025-10-07 16:00:27 +00:00
Zhao Zhili 4e27a4ba03 avfilter/vf_bilateral_cuda: remove some variables and redundant operations
Since output format is equal to input format, there is no point to
save two groups of fmt and desc.
2025-10-07 16:00:27 +00:00
Zhao Zhili d5f0c55f3f avfilter/vf_bilateral_cuda: don't create a new hwframe_ctx
There is no change on properties, so just reference the input
link's hwframe ctx.
2025-10-07 16:00:27 +00:00
Zhao Zhili adf51312ee avfilter/vf_bilateral_cuda: simplify frame management 2025-10-07 16:00:27 +00:00
Zhao Zhili a91cf4f38f avfilter/vf_bilateral_cuda: simplify the checking of window_size 2025-10-07 16:00:27 +00:00
Zhao Zhili 2749f5f91e avfilter/vf_bilateral_cuda: remove write only variable 2025-10-07 16:00:27 +00:00
Andreas Rheinhardt dcfef80bd9 avcodec/pngenc: Mark unreachable default switch cases as such
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 17:36:25 +02:00
James Almer 660983b7f3 avformat/mccenc: use Lavf version string instead of FFmpeg
The muxed subtitle is created by libavformat, and as such that's what should be
reported. This is in line with the string we write for every other muxer.
After this change, the muxer will no longer be recompiled every time a commit
is made.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-06 11:51:50 -03:00
James Almer 6231fa7fb7 avcodec/av1dec: don't emit a warning when parsing isobmff style extradata
No OBUs may be present and it's a valid scenario, so only warn when parsing raw
extradata.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-05 22:23:51 -03:00
James Almer 78a16e42bd avcodec/av1dec: don't overwrite container level color information if none is coded in the bitstream
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-05 13:22:23 -03:00
James Almer 009e4a1c20 avcodec/libdav1d: also consider user defined color information when selectiog pix_fmt
Fixes issue #20624.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-05 13:22:23 -03:00
James Almer 9b709532d5 avformat/demux: don't overwrite container level color information if set
If the information is coded at the container level, then that's what should be
exported. The user will still have access to values coded at the bitstream
level by firing a decoder.

Fixes issue #20121

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-05 13:22:17 -03:00
James Almer 95850f339e tests/checkasm: add a test for dcadsp
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-05 10:09:04 -03:00
James Almer 99034b581f avcodec/dcadsp: constify lfe_samples parameter
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-04 14:18:30 -03:00
Andreas Rheinhardt e05f8acabf avfilter/blend_modes: Don't build duplicate functions
Some of the blend mode functions only depend on the underlying type
and therefore need only one version for 9, 10, 12, 14, 16 bits.
This saved 35104B with GCC and 26880B with Clang.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 17:49:08 +02:00
Andreas Rheinhardt ea346a23de avfilter/blend_modes: Use stride in bytes
The blend functions currently convert strides from bytes to elements
of the type by using the stride /= sizeof(pixel) idiom. Yet this has
several drawbacks:
1. It invokes undefined behavior that happens to work when stride is
negative: size_t is typically the unsigned type of ptrdiff_t and
therefore the division will be performed as size_t, i.e. use logical
right shifts, making stride very big when sizeof(pixel) is > 1. This
works, because pointer to pixel for accesses entails an implicit
factor of sizeof(pixel) so that everything is correct modulo SIZE_MAX.
Yet this is UB and UBSan complains about it.
2. It makes the compiler emit actual shifts/ands to discard the low bits
shifted away.
3. There may be systems where alignof(uint16_t) or alignof(float) is
strictly smaller than their sizeof, so that the stride (in bytes) is
not guaranteed to be multiple of these sizeofs. In this case, dividing
by sizeof(pixel) is simply wrong.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 17:49:08 +02:00
Andreas Rheinhardt 8fad52bd57 avcodec/x86/h264_qpel: Use ptrdiff_t for strides
Avoids having to sign-extend the strides in the assembly
(it also is more correct given that the qpel_mc_func
already uses ptrdiff_t).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 495c3d03ae avcodec/x86/h264_qpel_10bit: Remove SSE2 "cache64" duplicates
The horizontal 10bit MC SSE2 functions are currently duplicated:
They exist both in ordinary form as well as with a "sse2_cache64"
suffix. A comment in ff_h264qpel_init_x86() indicates that this
is due to older processors not liking accesses that cross cache
lines, yet these functions are identical to the non-cache64
functions (apart from the unavoidable changes in the rip-offset).

The only difference between these functions and the ordinary ones
are that the cache64 ones are created via a special form of the
INIT_XMM macro: "INIT_XMM sse2, cache64". This affects the name
and apparently defines cpuflags_cache64, yet nothing checks for
this, so both versions are identical. So remove the cache64 ones
and treat the remaining ones like ordinary SSE2 functions.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 697da64c8e avcodec/x86/h264_qpel: Port pixel8_l2_shift5 from MMXEXT to SSE2
This abides by the ABI (no missing emms) and yields a tiny
performance improvement here.

Old benchmarks:
avg_h264_qpel_8_mc12_8_c:                              419.9 ( 1.00x)
avg_h264_qpel_8_mc12_8_sse2:                            78.9 ( 5.32x)
avg_h264_qpel_8_mc12_8_ssse3:                           71.7 ( 5.86x)
avg_h264_qpel_8_mc32_8_c:                              429.1 ( 1.00x)
avg_h264_qpel_8_mc32_8_sse2:                            76.9 ( 5.58x)
avg_h264_qpel_8_mc32_8_ssse3:                           73.4 ( 5.84x)
put_h264_qpel_8_mc12_8_c:                              424.0 ( 1.00x)
put_h264_qpel_8_mc12_8_sse2:                            78.6 ( 5.40x)
put_h264_qpel_8_mc12_8_ssse3:                           70.6 ( 6.00x)
put_h264_qpel_8_mc32_8_c:                              425.7 ( 1.00x)
put_h264_qpel_8_mc32_8_sse2:                            75.2 ( 5.66x)
put_h264_qpel_8_mc32_8_ssse3:                           70.4 ( 6.05x)

New benchmarks:
avg_h264_qpel_8_mc12_8_c:                              425.7 ( 1.00x)
avg_h264_qpel_8_mc12_8_sse2:                            77.5 ( 5.49x)
avg_h264_qpel_8_mc12_8_ssse3:                           69.8 ( 6.10x)
avg_h264_qpel_8_mc32_8_c:                              423.7 ( 1.00x)
avg_h264_qpel_8_mc32_8_sse2:                            74.6 ( 5.68x)
avg_h264_qpel_8_mc32_8_ssse3:                           71.9 ( 5.89x)
put_h264_qpel_8_mc12_8_c:                              422.2 ( 1.00x)
put_h264_qpel_8_mc12_8_sse2:                            75.8 ( 5.57x)
put_h264_qpel_8_mc12_8_ssse3:                           67.9 ( 6.22x)
put_h264_qpel_8_mc32_8_c:                              421.8 ( 1.00x)
put_h264_qpel_8_mc32_8_sse2:                            72.6 ( 5.81x)
put_h264_qpel_8_mc32_8_ssse3:                           67.7 ( 6.23x)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 4ac9162beb avcodec/x86/h264_qpel: Don't use ff_ prefix for static functions
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt cd077e88d1 avcodec/x86/h264_qpel: Add ff_{avg,put}_h264_qpel16_h_lowpass_l2_sse2()
These functions are currently emulated via four calls to the versions
for 8x8 blocks. In fact, the size savings from the simplified calls
in h264_qpel.c (GCC 1344B, Clang 1280B) more than outweigh the size
of the added functions (512B) here.

It is also beneficial performance-wise. Old benchmarks:
avg_h264_qpel_16_mc11_8_c:                            1414.1 ( 1.00x)
avg_h264_qpel_16_mc11_8_sse2:                          206.2 ( 6.86x)
avg_h264_qpel_16_mc11_8_ssse3:                         177.7 ( 7.96x)
avg_h264_qpel_16_mc13_8_c:                            1417.0 ( 1.00x)
avg_h264_qpel_16_mc13_8_sse2:                          207.4 ( 6.83x)
avg_h264_qpel_16_mc13_8_ssse3:                         178.2 ( 7.95x)
avg_h264_qpel_16_mc21_8_c:                            1632.8 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          349.3 ( 4.67x)
avg_h264_qpel_16_mc21_8_ssse3:                         291.3 ( 5.60x)
avg_h264_qpel_16_mc23_8_c:                            1640.2 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          351.3 ( 4.67x)
avg_h264_qpel_16_mc23_8_ssse3:                         290.8 ( 5.64x)
avg_h264_qpel_16_mc31_8_c:                            1411.7 ( 1.00x)
avg_h264_qpel_16_mc31_8_sse2:                          203.4 ( 6.94x)
avg_h264_qpel_16_mc31_8_ssse3:                         178.9 ( 7.89x)
avg_h264_qpel_16_mc33_8_c:                            1409.7 ( 1.00x)
avg_h264_qpel_16_mc33_8_sse2:                          204.6 ( 6.89x)
avg_h264_qpel_16_mc33_8_ssse3:                         178.1 ( 7.92x)
put_h264_qpel_16_mc11_8_c:                            1391.0 ( 1.00x)
put_h264_qpel_16_mc11_8_sse2:                          197.4 ( 7.05x)
put_h264_qpel_16_mc11_8_ssse3:                         176.1 ( 7.90x)
put_h264_qpel_16_mc13_8_c:                            1395.9 ( 1.00x)
put_h264_qpel_16_mc13_8_sse2:                          196.7 ( 7.10x)
put_h264_qpel_16_mc13_8_ssse3:                         177.7 ( 7.85x)
put_h264_qpel_16_mc21_8_c:                            1609.5 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          341.1 ( 4.72x)
put_h264_qpel_16_mc21_8_ssse3:                         289.2 ( 5.57x)
put_h264_qpel_16_mc23_8_c:                            1604.0 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          340.9 ( 4.71x)
put_h264_qpel_16_mc23_8_ssse3:                         289.6 ( 5.54x)
put_h264_qpel_16_mc31_8_c:                            1390.2 ( 1.00x)
put_h264_qpel_16_mc31_8_sse2:                          194.6 ( 7.14x)
put_h264_qpel_16_mc31_8_ssse3:                         176.4 ( 7.88x)
put_h264_qpel_16_mc33_8_c:                            1400.4 ( 1.00x)
put_h264_qpel_16_mc33_8_sse2:                          198.5 ( 7.06x)
put_h264_qpel_16_mc33_8_ssse3:                         176.2 ( 7.95x)

New benchmarks:
avg_h264_qpel_16_mc11_8_c:                            1413.3 ( 1.00x)
avg_h264_qpel_16_mc11_8_sse2:                          171.8 ( 8.23x)
avg_h264_qpel_16_mc11_8_ssse3:                         173.0 ( 8.17x)
avg_h264_qpel_16_mc13_8_c:                            1423.2 ( 1.00x)
avg_h264_qpel_16_mc13_8_sse2:                          172.0 ( 8.27x)
avg_h264_qpel_16_mc13_8_ssse3:                         173.4 ( 8.21x)
avg_h264_qpel_16_mc21_8_c:                            1641.3 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          322.1 ( 5.10x)
avg_h264_qpel_16_mc21_8_ssse3:                         291.3 ( 5.63x)
avg_h264_qpel_16_mc23_8_c:                            1629.1 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          323.0 ( 5.04x)
avg_h264_qpel_16_mc23_8_ssse3:                         293.3 ( 5.55x)
avg_h264_qpel_16_mc31_8_c:                            1409.2 ( 1.00x)
avg_h264_qpel_16_mc31_8_sse2:                          172.0 ( 8.19x)
avg_h264_qpel_16_mc31_8_ssse3:                         173.7 ( 8.11x)
avg_h264_qpel_16_mc33_8_c:                            1402.5 ( 1.00x)
avg_h264_qpel_16_mc33_8_sse2:                          172.5 ( 8.13x)
avg_h264_qpel_16_mc33_8_ssse3:                         173.6 ( 8.08x)
put_h264_qpel_16_mc11_8_c:                            1393.7 ( 1.00x)
put_h264_qpel_16_mc11_8_sse2:                          170.4 ( 8.18x)
put_h264_qpel_16_mc11_8_ssse3:                         178.2 ( 7.82x)
put_h264_qpel_16_mc13_8_c:                            1398.0 ( 1.00x)
put_h264_qpel_16_mc13_8_sse2:                          170.2 ( 8.21x)
put_h264_qpel_16_mc13_8_ssse3:                         178.6 ( 7.83x)
put_h264_qpel_16_mc21_8_c:                            1619.6 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          320.6 ( 5.05x)
put_h264_qpel_16_mc21_8_ssse3:                         297.2 ( 5.45x)
put_h264_qpel_16_mc23_8_c:                            1617.4 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          320.0 ( 5.05x)
put_h264_qpel_16_mc23_8_ssse3:                         297.4 ( 5.44x)
put_h264_qpel_16_mc31_8_c:                            1389.7 ( 1.00x)
put_h264_qpel_16_mc31_8_sse2:                          169.9 ( 8.18x)
put_h264_qpel_16_mc31_8_ssse3:                         178.1 ( 7.80x)
put_h264_qpel_16_mc33_8_c:                            1394.0 ( 1.00x)
put_h264_qpel_16_mc33_8_sse2:                          170.9 ( 8.16x)
put_h264_qpel_16_mc33_8_ssse3:                         176.9 ( 7.88x)

Notice that the SSSE3 versions of mc21 and mc23 benefit from
an optimized version of hv2_lowpass.

Also notice that there is no SSE2 version of the purely horizontal
motion compensation. This means that src2 is currently always aligned
when calling the SSE2 functions (and that srcStride is always equal
to the block width). Yet this has not been exploited (yet).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 4880fa4dca avcodec/x86/h264_qpel_8bit: Remove dead macro
Forgotten in 4011a76494.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 35aaf697e9 avcodec/x86/h264_qpel_8bit: Replace qpel8_h_lowpass_l2 MMXEXT by SSE2
Using xmm registers here is very natural, as it allows to
operate on eight words at a time. It also saves 48B here
and does not clobber the MMX state.

Old benchmarks (only tests affected by the modified function are shown):
avg_h264_qpel_8_mc11_8_c:                              352.2 ( 1.00x)
avg_h264_qpel_8_mc11_8_sse2:                            70.4 ( 5.00x)
avg_h264_qpel_8_mc11_8_ssse3:                           53.9 ( 6.53x)
avg_h264_qpel_8_mc13_8_c:                              353.3 ( 1.00x)
avg_h264_qpel_8_mc13_8_sse2:                            72.8 ( 4.86x)
avg_h264_qpel_8_mc13_8_ssse3:                           53.8 ( 6.57x)
avg_h264_qpel_8_mc21_8_c:                              404.0 ( 1.00x)
avg_h264_qpel_8_mc21_8_sse2:                           116.1 ( 3.48x)
avg_h264_qpel_8_mc21_8_ssse3:                           94.3 ( 4.28x)
avg_h264_qpel_8_mc23_8_c:                              398.9 ( 1.00x)
avg_h264_qpel_8_mc23_8_sse2:                           118.6 ( 3.36x)
avg_h264_qpel_8_mc23_8_ssse3:                           94.8 ( 4.21x)
avg_h264_qpel_8_mc31_8_c:                              352.7 ( 1.00x)
avg_h264_qpel_8_mc31_8_sse2:                            71.4 ( 4.94x)
avg_h264_qpel_8_mc31_8_ssse3:                           53.8 ( 6.56x)
avg_h264_qpel_8_mc33_8_c:                              354.0 ( 1.00x)
avg_h264_qpel_8_mc33_8_sse2:                            70.6 ( 5.01x)
avg_h264_qpel_8_mc33_8_ssse3:                           53.7 ( 6.59x)
avg_h264_qpel_16_mc11_8_c:                            1417.0 ( 1.00x)
avg_h264_qpel_16_mc11_8_sse2:                          276.9 ( 5.12x)
avg_h264_qpel_16_mc11_8_ssse3:                         178.8 ( 7.92x)
avg_h264_qpel_16_mc13_8_c:                            1427.3 ( 1.00x)
avg_h264_qpel_16_mc13_8_sse2:                          277.4 ( 5.14x)
avg_h264_qpel_16_mc13_8_ssse3:                         179.7 ( 7.94x)
avg_h264_qpel_16_mc21_8_c:                            1634.1 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          421.3 ( 3.88x)
avg_h264_qpel_16_mc21_8_ssse3:                         291.2 ( 5.61x)
avg_h264_qpel_16_mc23_8_c:                            1627.0 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          420.8 ( 3.87x)
avg_h264_qpel_16_mc23_8_ssse3:                         291.0 ( 5.59x)
avg_h264_qpel_16_mc31_8_c:                            1418.4 ( 1.00x)
avg_h264_qpel_16_mc31_8_sse2:                          278.5 ( 5.09x)
avg_h264_qpel_16_mc31_8_ssse3:                         178.6 ( 7.94x)
avg_h264_qpel_16_mc33_8_c:                            1407.3 ( 1.00x)
avg_h264_qpel_16_mc33_8_sse2:                          277.6 ( 5.07x)
avg_h264_qpel_16_mc33_8_ssse3:                         179.9 ( 7.82x)
put_h264_qpel_8_mc11_8_c:                              348.1 ( 1.00x)
put_h264_qpel_8_mc11_8_sse2:                            69.1 ( 5.04x)
put_h264_qpel_8_mc11_8_ssse3:                           53.8 ( 6.47x)
put_h264_qpel_8_mc13_8_c:                              349.3 ( 1.00x)
put_h264_qpel_8_mc13_8_sse2:                            69.7 ( 5.01x)
put_h264_qpel_8_mc13_8_ssse3:                           53.7 ( 6.51x)
put_h264_qpel_8_mc21_8_c:                              398.5 ( 1.00x)
put_h264_qpel_8_mc21_8_sse2:                           115.0 ( 3.46x)
put_h264_qpel_8_mc21_8_ssse3:                           95.3 ( 4.18x)
put_h264_qpel_8_mc23_8_c:                              399.9 ( 1.00x)
put_h264_qpel_8_mc23_8_sse2:                           120.8 ( 3.31x)
put_h264_qpel_8_mc23_8_ssse3:                           95.4 ( 4.19x)
put_h264_qpel_8_mc31_8_c:                              350.4 ( 1.00x)
put_h264_qpel_8_mc31_8_sse2:                            69.6 ( 5.03x)
put_h264_qpel_8_mc31_8_ssse3:                           54.2 ( 6.47x)
put_h264_qpel_8_mc33_8_c:                              353.1 ( 1.00x)
put_h264_qpel_8_mc33_8_sse2:                            71.0 ( 4.97x)
put_h264_qpel_8_mc33_8_ssse3:                           54.2 ( 6.51x)
put_h264_qpel_16_mc11_8_c:                            1384.2 ( 1.00x)
put_h264_qpel_16_mc11_8_sse2:                          272.9 ( 5.07x)
put_h264_qpel_16_mc11_8_ssse3:                         178.3 ( 7.76x)
put_h264_qpel_16_mc13_8_c:                            1393.6 ( 1.00x)
put_h264_qpel_16_mc13_8_sse2:                          271.1 ( 5.14x)
put_h264_qpel_16_mc13_8_ssse3:                         178.3 ( 7.82x)
put_h264_qpel_16_mc21_8_c:                            1612.6 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          416.5 ( 3.87x)
put_h264_qpel_16_mc21_8_ssse3:                         289.1 ( 5.58x)
put_h264_qpel_16_mc23_8_c:                            1621.3 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          416.9 ( 3.89x)
put_h264_qpel_16_mc23_8_ssse3:                         289.4 ( 5.60x)
put_h264_qpel_16_mc31_8_c:                            1408.4 ( 1.00x)
put_h264_qpel_16_mc31_8_sse2:                          273.5 ( 5.15x)
put_h264_qpel_16_mc31_8_ssse3:                         176.9 ( 7.96x)
put_h264_qpel_16_mc33_8_c:                            1396.4 ( 1.00x)
put_h264_qpel_16_mc33_8_sse2:                          276.3 ( 5.05x)
put_h264_qpel_16_mc33_8_ssse3:                         176.4 ( 7.92x)

New benchmarks:
avg_h264_qpel_8_mc11_8_c:                              352.1 ( 1.00x)
avg_h264_qpel_8_mc11_8_sse2:                            52.5 ( 6.71x)
avg_h264_qpel_8_mc11_8_ssse3:                           53.9 ( 6.54x)
avg_h264_qpel_8_mc13_8_c:                              350.8 ( 1.00x)
avg_h264_qpel_8_mc13_8_sse2:                            54.7 ( 6.42x)
avg_h264_qpel_8_mc13_8_ssse3:                           54.3 ( 6.46x)
avg_h264_qpel_8_mc21_8_c:                              400.1 ( 1.00x)
avg_h264_qpel_8_mc21_8_sse2:                            98.6 ( 4.06x)
avg_h264_qpel_8_mc21_8_ssse3:                           95.5 ( 4.19x)
avg_h264_qpel_8_mc23_8_c:                              400.4 ( 1.00x)
avg_h264_qpel_8_mc23_8_sse2:                           101.4 ( 3.95x)
avg_h264_qpel_8_mc23_8_ssse3:                           95.9 ( 4.18x)
avg_h264_qpel_8_mc31_8_c:                              352.4 ( 1.00x)
avg_h264_qpel_8_mc31_8_sse2:                            52.9 ( 6.67x)
avg_h264_qpel_8_mc31_8_ssse3:                           54.4 ( 6.48x)
avg_h264_qpel_8_mc33_8_c:                              354.5 ( 1.00x)
avg_h264_qpel_8_mc33_8_sse2:                            52.9 ( 6.70x)
avg_h264_qpel_8_mc33_8_ssse3:                           54.4 ( 6.52x)
avg_h264_qpel_16_mc11_8_c:                            1420.4 ( 1.00x)
avg_h264_qpel_16_mc11_8_sse2:                          204.8 ( 6.93x)
avg_h264_qpel_16_mc11_8_ssse3:                         177.9 ( 7.98x)
avg_h264_qpel_16_mc13_8_c:                            1409.8 ( 1.00x)
avg_h264_qpel_16_mc13_8_sse2:                          206.4 ( 6.83x)
avg_h264_qpel_16_mc13_8_ssse3:                         178.0 ( 7.92x)
avg_h264_qpel_16_mc21_8_c:                            1634.1 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          349.6 ( 4.67x)
avg_h264_qpel_16_mc21_8_ssse3:                         290.0 ( 5.63x)
avg_h264_qpel_16_mc23_8_c:                            1624.1 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          350.0 ( 4.64x)
avg_h264_qpel_16_mc23_8_ssse3:                         291.9 ( 5.56x)
avg_h264_qpel_16_mc31_8_c:                            1407.2 ( 1.00x)
avg_h264_qpel_16_mc31_8_sse2:                          205.8 ( 6.84x)
avg_h264_qpel_16_mc31_8_ssse3:                         178.2 ( 7.90x)
avg_h264_qpel_16_mc33_8_c:                            1400.5 ( 1.00x)
avg_h264_qpel_16_mc33_8_sse2:                          206.3 ( 6.79x)
avg_h264_qpel_16_mc33_8_ssse3:                         179.4 ( 7.81x)
put_h264_qpel_8_mc11_8_c:                              349.7 ( 1.00x)
put_h264_qpel_8_mc11_8_sse2:                            50.2 ( 6.96x)
put_h264_qpel_8_mc11_8_ssse3:                           51.3 ( 6.82x)
put_h264_qpel_8_mc13_8_c:                              349.8 ( 1.00x)
put_h264_qpel_8_mc13_8_sse2:                            50.7 ( 6.90x)
put_h264_qpel_8_mc13_8_ssse3:                           51.7 ( 6.76x)
put_h264_qpel_8_mc21_8_c:                              398.0 ( 1.00x)
put_h264_qpel_8_mc21_8_sse2:                            96.5 ( 4.13x)
put_h264_qpel_8_mc21_8_ssse3:                           92.3 ( 4.31x)
put_h264_qpel_8_mc23_8_c:                              401.4 ( 1.00x)
put_h264_qpel_8_mc23_8_sse2:                           102.3 ( 3.92x)
put_h264_qpel_8_mc23_8_ssse3:                           92.8 ( 4.32x)
put_h264_qpel_8_mc31_8_c:                              349.4 ( 1.00x)
put_h264_qpel_8_mc31_8_sse2:                            50.8 ( 6.88x)
put_h264_qpel_8_mc31_8_ssse3:                           51.8 ( 6.75x)
put_h264_qpel_8_mc33_8_c:                              351.1 ( 1.00x)
put_h264_qpel_8_mc33_8_sse2:                            52.2 ( 6.73x)
put_h264_qpel_8_mc33_8_ssse3:                           51.7 ( 6.79x)
put_h264_qpel_16_mc11_8_c:                            1391.1 ( 1.00x)
put_h264_qpel_16_mc11_8_sse2:                          196.6 ( 7.07x)
put_h264_qpel_16_mc11_8_ssse3:                         178.2 ( 7.81x)
put_h264_qpel_16_mc13_8_c:                            1385.2 ( 1.00x)
put_h264_qpel_16_mc13_8_sse2:                          195.6 ( 7.08x)
put_h264_qpel_16_mc13_8_ssse3:                         176.6 ( 7.84x)
put_h264_qpel_16_mc21_8_c:                            1607.5 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          341.0 ( 4.71x)
put_h264_qpel_16_mc21_8_ssse3:                         289.1 ( 5.56x)
put_h264_qpel_16_mc23_8_c:                            1616.7 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          340.8 ( 4.74x)
put_h264_qpel_16_mc23_8_ssse3:                         288.6 ( 5.60x)
put_h264_qpel_16_mc31_8_c:                            1397.6 ( 1.00x)
put_h264_qpel_16_mc31_8_sse2:                          197.3 ( 7.08x)
put_h264_qpel_16_mc31_8_ssse3:                         175.4 ( 7.97x)
put_h264_qpel_16_mc33_8_c:                            1394.3 ( 1.00x)
put_h264_qpel_16_mc33_8_sse2:                          197.7 ( 7.05x)
put_h264_qpel_16_mc33_8_ssse3:                         175.2 ( 7.96x)

As can be seen, the SSE2 version is often neck-to-neck with the SSSE3
version (which also benefits from a better hv2_lowpass SSSE3
implementation for mc21 and mc23) for eight byte block sizes.
Unsurprisingly, SSSE3 beats SSE2 for 16x16 blocks: For SSE2,
these blocks are processed by calling the 8x8 function four times
whereas SSSE3 has a dedicated function (on x64).
This implementation should also be extendable to an AVX version
for 16x16 blocks.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt fa9ea5113b avcodec/x86/h264_qpel_8bit: Optimize branch away
ff_{avg,put}_h264_qpel8or16_hv2_lowpass_ssse3()
currently is almost the disjoint union of the codepaths
for sizes 8 and 16. This size is a compile-time constant
at every callsite. So split the function and avoid
the runtime branch.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 400203c00c avcodec/x86/h264_qpel: Remove unused parameter from hv2_lowpass funcs
tmpstride is unused. This also allows to remove said parameter
from lots of functions in h264_qpel.c.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt b84c818c83 avcodec/x86/h264_qpel: Remove constant parameters from shift5 funcs
They are constant since the size 16 version is no longer emulated
via the size 8 version.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 810bd3e62a avcodec/x86/h264_qpel: Add ff_{avg,put}_pixels16_l2_shift5_sse2
Up until now this function was emulated via two calls
to ff_{avg,pull}_pixels8_l2_shift5_mmxext(). Adding a dedicated
function proved beneficial both size wise and performance wise:
The new functions take 192B, yet the simplified calls save
256B with GCC and 320B with Clang here.

This change will also allow further optimizations.

Old benchmarks:
avg_h264_qpel_16_mc12_8_c:                            1735.8 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2:                          300.8 ( 5.77x)
avg_h264_qpel_16_mc12_8_ssse3:                         233.3 ( 7.44x)
avg_h264_qpel_16_mc32_8_c:                            1777.9 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2:                          275.6 ( 6.45x)
avg_h264_qpel_16_mc32_8_ssse3:                         235.7 ( 7.54x)
put_h264_qpel_16_mc12_8_c:                            1808.2 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2:                          267.2 ( 6.77x)
put_h264_qpel_16_mc12_8_ssse3:                         231.9 ( 7.80x)
put_h264_qpel_16_mc32_8_c:                            1766.9 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2:                          272.9 ( 6.47x)
put_h264_qpel_16_mc32_8_ssse3:                         229.5 ( 7.70x)

New benchmarks:
avg_h264_qpel_16_mc12_8_c:                            1742.3 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2:                          240.3 ( 7.25x)
avg_h264_qpel_16_mc12_8_ssse3:                         214.8 ( 8.11x)
avg_h264_qpel_16_mc32_8_c:                            1748.0 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2:                          238.0 ( 7.35x)
avg_h264_qpel_16_mc32_8_ssse3:                         209.2 ( 8.35x)
put_h264_qpel_16_mc12_8_c:                            2014.4 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2:                          243.7 ( 8.27x)
put_h264_qpel_16_mc12_8_ssse3:                         211.5 ( 9.52x)
put_h264_qpel_16_mc32_8_c:                            1800.0 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2:                          238.8 ( 7.54x)
put_h264_qpel_16_mc32_8_ssse3:                         206.7 ( 8.71x)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 279b6f3cf5 avcodec/fpel: Avoid loop in ff_avg_pixels4_mmxext()
It is only used by h264_qpel.c and only with height four
(which is unrolled) and uses a loop in order to handle
multiples of four as height. Remove the loop and the height
parameter and move the function to h264_qpel_8bit.asm.
This leads to a bit of code duplication, but this is simpler
than all the %if checks necessary to achieve the same outcome
in fpel.asm.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt e340f31b89 avcodec/x86/fpel: Remove redundant repetition
The repetition count is always one since
2cf9e733c6.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt b0c91c2fba avcodec/h264qpel: Make avg_h264_qpel_pixels_tab smaller
avg_h264_qpel only supports 16x16,8x8 and 4x4 blocksizes,
so it is currently unnecessarily large.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 6eb8bc4217 avcodec/h264qpel: Don't build unused 2x2 size funcs for bitdepths > 8
The 2x2 put functions are only used by Snow and Snow uses
only the eight bit versions. The rest is dead code. Disabling
it saved 41277B here.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 92ae9d1ffc configure: Remove vc1dsp->qpeldsp dependency
It only needs it for some x86 fpel functions; instead
add a direct dependency for that.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 16d5e074dc avcodec/mips/Makefile: Fix VC1DSP build rules
Affected standalone builds of the VC-1 parser.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt d09f4f3c78 configure: Remove h263_decoder->h263_parser,qpeldsp dependency
The former is unnecessary since
3ceffe7839. The latter is since
ff_mpeg4_workaround_bugs() (and thereby setting the "old" qpeldsp
functions) has been moved inside #if CONFIG_MPEG4_DECODER.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 0035d99c61 configure: Avoid mpeg4video_parser->{h263,qpel}dsp dependency
This can be easily achieved by moving code only used by the MPEG-4
decoder behind #if CONFIG_MPEG4_DECODER.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 770f78b24a configure: Remove mss2->qpeldsp dependency
Forgotten in 9cc38cc636.
(mss2 still has an implicit dependency on qpeldsp
via the VC-1 decoder.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt c4c616db53 avcodec/x86/qpel: Move ff_{put,avg}_pixels4_l2_mmxext to h264_qpel
Only used there.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 1e11fdff52 avcodec/x86/qpel{,dsp_init}: Remove constant function parameters
ff_avg_pixels{4,8,16}_l2_mmxext() are always called with height
equal to their blocksize. And ff_{put,avg}_pixels4_l2_mmxext()
are furthermore always called with both strides being equal.
So remove these redundant function parameters.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 52a77128fd avcodec/x86/qpel{dsp,dsp_init}: Use ptrdiff_t for stride
This is more correct given that qpel_mc_func already uses ptrdiff_t;
it also allows to avoid movsxdifnidn.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt cacf854fe7 avcodec/x86/qpel: Remove always-false branches
The ff_avg_pixels{4,8,16}_l2_mmxext() functions are only ever
used in the last step (the one that actually writes to the dst buffer)
where the number of lines to process is always equal to the
dimensions of the block, whereas ff_put_pixels{8,16}_mmxext()
are also used in intermediate calculations where the number of
lines can be 9 or 17.

The code in qpel.asm uses common macros for both and processes
more than one line per loop iteration; it therefore checks
for whether the number of lines is odd and treats this line separately;
yet this special handling is only needed for the put functions,
not the avg functions. It has therefore been %if'ed away for these.

The check is also not needed for ff_put_pixels4_l2_mmxext() which
is only used by H.264 which always processes four lines. Because
ff_{avg,put}_pixels4_l2_mmxext() processes four lines in a single loop
iteration, not only the odd-height handling, but the whole loop
could be removed.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 8820e2205c tests/checkasm/hpeldsp: Use instruction-set independent height
Otherwise the benchmark numbers are incomparable.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 9a0581fca0 tests/checkasm: Add qpeldsp checkasm
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 15a9c8dea3 avcodec/liblc3enc: Avoid allocating buffer to send a zero frame
liblc3 supports arbitrary strides, so one can simply use a stride
of zero to make it read the same zero value again and again.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 06:07:37 +02:00
Andreas Rheinhardt ab7d1c64c9 avcodec/x86/h263_loopfilter: Port loop filter to SSE2
Old benchmarks:
h263dsp.h_loop_filter_c:                                41.2 ( 1.00x)
h263dsp.h_loop_filter_mmx:                              39.5 ( 1.04x)
h263dsp.v_loop_filter_c:                                43.5 ( 1.00x)
h263dsp.v_loop_filter_mmx:                              16.9 ( 2.57x)

New benchmarks:
h263dsp.h_loop_filter_c:                                41.6 ( 1.00x)
h263dsp.h_loop_filter_sse2:                             28.2 ( 1.48x)
h263dsp.v_loop_filter_c:                                42.4 ( 1.00x)
h263dsp.v_loop_filter_sse2:                             15.1 ( 2.81x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-03 17:05:46 +00:00
Andreas Rheinhardt a8a16c15c8 tests/checkasm/llviddsp: Use the same width for each cpuflag
Otherwise the benchmark numbers would be incomparable nonsense.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-03 17:05:46 +00:00
Cameron Gutman df4587789f avcodec/amfenc: avoid unnecessary output delay in low delay mode
The code optimizes throughput by letting the encoder work on frame N
until frame N+1 is ready for submission, but this hurts low-delay uses
by delaying output by one frame. Don't delay output beyond what is
necessary when AV_CODEC_FLAG_LOW_DELAY is used.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-10-03 11:05:03 +00:00
Marton Balint f1d5114103 avformat/tls_openssl: do not cleanup tls after a successful dtls_start()
Regression since 8e11e2cdb8.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-02 18:41:47 +02:00
Michael Niedermayer 61b6877637 avcodec/mjpegdec: Explain buf_size/width/height check
Suggested-by: Ramiro

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-02 12:52:43 +00:00
Zhao Zhili 1a02412170 avformat/movenc_ttml: fix memleaks
Memory leaks can happen on normal case when break from while loop
early, and it can happen on error path with goto cleanup.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-10-01 22:31:03 +08:00
Romain Beauxis cb4052beae libavformat/oggparseopus.c: Parse comments from secondary chained streams header packet. 2025-10-01 14:20:55 +00:00
Romain Beauxis 45d7d5d3e2 libavformat/oggparseflac.c: Parse ogg/flac comments in new ogg packets, add them to ogg stream
new_metadata.
2025-10-01 14:20:55 +00:00
Romain Beauxis 7dbf7d2a45 libavformat/oggdec.c: Use AV_PKT_DATA_STRINGS_METADATA to pass metadata updates. 2025-10-01 14:20:55 +00:00
Romain Beauxis cebbb6ae8a libavformat/oggdec.h, libavformat/oggparsevorbis.c: Factor out vorbis metadata update mechanism. 2025-10-01 14:20:55 +00:00
Romain Beauxis de8d57e4c5 ogg/vorbis: implement header packet skip in chained ogg bitstreams. 2025-10-01 14:20:55 +00:00
James Almer 5511641365 avcodec/atrac9dec: use av_zero_extend()
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-01 01:26:19 +00:00
James Almer 7ce3a14496 avcodec/apv_entropy: use av_zero_extend()
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-01 01:26:19 +00:00
James Almer 776ee07990 avcodec/aom_film_grain: use av_zero_extend()
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-01 01:26:19 +00:00
Marton Balint 8e11e2cdb8 avformat/tls_openssl: initialize underlying protocol early for dtls_start()
The same way we do with TLS, so all tls URL options will be properly supported.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint 2762ae74c5 avformat/tls: use ff_parse_opts_from_query_string() to set URL parameters
Note that this changes the code to work the same way as other protocols where
an URL parameter can override an AVOption.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint 3166e3b539 avformat/rtpproto: use ff_parse_opts_from_query_string() to set URL parameters
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint f231439ee7 avformat/sctp: use ff_parse_opts_from_query_string() to set URL parameters
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint 49c6e6cc44 avformat/tcp: use ff_parse_opts_from_query_string() to set URL parameters
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint 7e58fff9d0 avformat/udp: use ff_parse_opts_from_query_string() to set URL parameters
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint 2d06ed9308 avformat/libsrt: use ff_parse_opts_from_query_string() to set URL parameters
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint 70e0e3e257 avformat/utils: add helper function to set opts from query string
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:18 +02:00
Marton Balint c5be4b7075 avformat: compile urldecode unconditionally
It will be used by the generic helper function to set options from URLs.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-30 23:48:14 +02:00
Marton Balint 6f17053e6c avformat/urldecode: add ff_urldecode_len function
This will be used later to decode partial strings.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-30 23:48:14 +02:00
Michael Niedermayer 8cb1ff78ac avformat/dhav: Factorize some code in get_duration()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-30 21:13:56 +00:00
Niklas Haas b80f28fcbc avfilter/vf_libplacebo: introduce fit_sense option
This allows choosing whether the `fit_mode` merely controls the placement
of the image within the output resolution, or whether the output resolution
is also adjusted according to the given `fit_mode`.
2025-09-30 15:39:39 +00:00
Niklas Haas 12d696cff4 avfilter/vf_libplacebo: introduce fit_mode option
The semantics of these keywords are well-defined by the CSS 'object-fit'
property. This is arguably more user-friendly and less obtuse than the
existing `normalize_sar` and `pad_crop_ratio` options. Additionally, this
comes with two new (useful) behaviors, `none` and `scale_down`, neither of
which map elegantly to the existing options.

One additional benefit of this option is that, unlike `normalize_sar`, it
does *not* also imply `reset_sar`; meaning that users can now choose to
have an anamorphic base layer and still have the overlay images scaled to fit
on top of it according to the chosen strategy.

See-Also: https://drafts.csswg.org/css-images/#the-object-fit
2025-09-30 15:39:39 +00:00
Niklas Haas 6ad839ff2e avfilter/vf_scale_*: add enum names for force_oar magic values 2025-09-30 15:39:39 +00:00
Gyan Doshi 74115b017c doc: indicate libmpeghdec is non-free 2025-09-30 11:55:02 +00:00
Niklas Haas fd1fd5850d fftools/ffmpeg_sched: unchoke upstream nodes on recv-closed filter inputs
This allows upstream filters to observe EOF on their corresponding outputs
and terminate early, which is particularly useful for decoders and demuxers
that may then gracefully release their resources.

Prevents "leaking" memory for previously used, but now unused, filter inputs.
2025-09-30 13:16:59 +02:00
Niklas Haas d43fd5b332 fftools/ffmpeg_sched: close stream when sch_filter_send receives EOF
THis is currently done by sch_demux_send() (via demux_stream_send_to_dst()),
sch_enc_send() (via enc_send_to_dst()), and sch_dec_send() (via
dec_send_to_dst()), but not by sch_filter_send().

Implement the same queue-closing logic for them. The main benefit here is that
this will allow them to mark downstream inputs as send-done (in addition
to received-done), which is useful for a following commit.
2025-09-30 13:16:59 +02:00
Niklas Haas 56d9ca69d7 fftools/ffmpeg_dec: free decoder ctx after EOF
The codec context is no longer used after the decoder thread exits, but
still idly sticks around until program exit, wasting memory.
2025-09-30 13:16:59 +02:00
Niklas Haas 9d0b88feb1 fftools/ffmpeg_sched: forward demuxer choke status to dst queues
Cut off a choked demuxer's output codec/filter queues, effectively preventing
them from processing packets while the demuxer is choked. Avoids downstream
nodes from piling up extra input that a demuxer shouldn't currently be
sending.

The main benefit of this is to avoid queuing up excess packets that don't want
to be decoded yet, reducing memory consumption for idle inputs by preventing
them from being read earlier than needed.
2025-09-30 13:16:59 +02:00
Niklas Haas 59a847a237 fftools/thread_queue: allow choking thread queues directly
Currently, when a demuxer thread is choked, it will avoid queuing more
packets, but any packets already present on the thread queue will still be
processed.

This can be quite wasteful if the choke is due to e.g. decoder not being
needed yet, such as in a filter graph involving concatenation-style filters.
Adding the ability to propagate the choke status to the thread queue directly
allows downstream decoders and filter graphs to avoid unnecessary work and
buffering.

Reduces the effective latency between scheduler updates and changes in the
thread workfload.
2025-09-30 13:16:59 +02:00
Niklas Haas 5f4cbb5617 fftools/ffmpeg_sched: choke inputs during filtergraph configuration
Currently, while the filter graph is being initially created, the scheduler
continues demuxing frames on the last input that happened to be active before
the filter graph was complete.

This can lead to an excess number of decoded frames "piling" up on this input,
regardless of whether or not it will actually be requested by the configured
filter graph. Suspending the filter graph during this initialization phase
reduces the amount of wasted memory.
2025-09-30 13:16:59 +02:00
Niklas Haas 23f1f094f8 fftools/ffmpeg_sched: get rid of src_sched
This field is just saving (typically) a single pointer indirection; and IMO
makes the logic and graph relations unnecessarily complicated. I am also
considering adding choking logic to decoders and encoders as well, which this
field would get in the way of.

Apart from the unchoking logic in unchoke_for_input(), the only other place
that uses this field is the (cold) function check_acyclic(), which can be
served just as well with a simple function to do the graph traversal there.
2025-09-30 13:16:59 +02:00
Niklas Haas fd4b5b24ce fftools/ffmpeg_sched: lower default frame queue size
I tested this extensively under different conditions and could not come up
with any scenario where using a larger queue size was actually beneficial.
Moreover, having such a large default queue is very wasteful especially
for larger frame sizes; and can in the worst case lead to an extra ~50% memory
footprint per input (with the default 16 threads), regardless of whether that
input is currently in use or not.

My methodology was to add logging in the event of a queue underrun/overrun,
and then observe and then observe the frequency of such events in practice,
as well as the impact on performance. I came up with an example filter graph
involving decoding, filtering and encoding with several input files and
various changes to move the bottleneck around.

I found that, in all configurations I tested, with all thread counts and
bottlenecks, using a queue size of 2 frames yielded practically identical
performance to a queue size of 8 frames. I was only able to consistently
measure a slowdown when restricting the queue to a single frame, where the
underruns ended up making up almost 1.1% of frame events in the worst case.

A summary of my test log follows:

= Bottleneck in decoder =

ffmpeg -i A -i B -i C -filter_complex "concat=n=3" -f null -

== 16 threads ==

=== Queue statistics (dec -> filtergraph) ===
- 8 frames = 91355 underruns, 1 overrun
- 4 frames = 91381 underruns, 2 overruns
- 2 frames = 91326 underruns, 21 overruns
- 1 frame  = 91284 underruns, 102 overruns

=== Time elapsed ===
- 8 frames = 14.37s
- 4 frames = 14.28s
- 2 frames = 14.27s
- 1 frame  = 14.35s

== 1 thread ==

=== Queue statistics (dec -> filtergraph) ===
- 8 frames = 91801 underruns, 0 overruns
- 4 frames = 91929 underruns, 1 overrun
- 2 frames = 91854 underruns, 7 overruns
- 1 frame  = 91745 underrons, 83 overruns

=== Time elapsed ===
- 8 frames = 39.51s
- 4 frames = 39.94s
- 2 frames = 39.91s
- 1 frame  = 41.69s

= Bottleneck in filter graph: =

ffmpeg -i A -i B -i C -filter_complex "concat=n=3,scale=3840x2160" -f null -

== 16 threads ==

=== Queue statistics (dec -> filtergraph) ===
- 8 frames =  277 underruns, 84673 overruns
- 4 frames =  640 underruns, 86523 overruns
- 2 frames =  850 underruns, 88751 overruns
- 1 frame  = 1028 underruns, 89957 overruns

=== Time elapsed ===
- 8 frames = 26.35s
- 4 frames = 26.31s
- 2 frames = 26.38s
- 1 frame  = 26.55s

== 1 thread ==

=== Queue statistics (dec -> filtergraph) ===
- 8 frames = 29746 underruns, 57033 overruns
- 4 frames = 29940 underruns, 58948 overruns
- 2 frames = 30160 underruns, 60185 overruns
- 1 frame  = 30259 underruns, 61126 overruns

=== Time elapsed ===
- 8 frames = 52.08s
- 4 frames = 52.49s
- 2 frames = 52.25s
- 1 frame  = 52.69s

= Bottleneck in encoder: =

ffmpeg -i A -i B -i C -filter_complex "concat=n=3" -c:v libx264 -preset veryfast -f null -

== 1 thread ==

== Queue statistics (filtergraph -> enc) ==
- 8 frames = 26763 underruns, 63535 overruns
- 4 frames = 26863 underruns, 63810 overruns
- 2 frames = 27243 underruns, 63839 overruns
- 1 frame  = 27670 underruns, 63953 overruns

== Time elapsed ==
- 8 frames = 89.45s
- 4 frames = 89.04s
- 2 frames = 89.24s
- 1 frame  = 90.26s
2025-09-30 13:16:59 +02:00
Niklas Haas 15407cf90b fftools/ffmpeg_sched: relax queue size assertion
The code in the decoder just cares about allocating enough extra hw frames
to cover the size of the queue; but there's no reason we actually *have* to
use this many. We can safely relax the assertion to a <= check.
2025-09-30 13:16:59 +02:00
Nikolay Aleksandrov 1608aa38a2 doc/infra: More details about hosting and security
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

I have redacted the exact location of the FFmpeg server as writing
that in public seems just a bad idea
2025-09-30 13:14:03 +02:00
Koushik Dutta via ffmpeg-devel fd136a4d82 ffv1enc_vulkan: fix empty struct build error on msvc
Signed-off-by: Koushik Dutta <koushd@gmail.com>
2025-09-30 19:36:56 +09:00
Jack Lau bc561013c9 avformat/whip: add RTX initial support
Refer to RFC 4588.

Add and set the basic param of RTX like
ssrc, payload_type, srtp.

Modify the SDP to add RTX info so that
the peer be able to parse the RTX packet.

There are more pateches to make RTX really
work.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-30 05:42:40 +00:00
Gyan Doshi f1e9032a20 configure: unbreak glslang build
Don't unconditionally link to libSPVRemapper which was removed in 16.0 in 3a7f787
2025-09-30 04:26:18 +00:00
James Almer d975dbd7b7 avcodec/libdav1d: bump minimum supported version to 1.0.0
This allows us to remove old deprecated options.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-28 23:53:27 -03:00
Kaarle Ritvanen 0fdb5829e3 avformat/rtsp: set AVFMTCTX_UNSEEKABLE flag
for live RTP streams. Some external applications, such as Qt Multimedia,
depend on this flag being set correctly.

Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
2025-09-28 13:37:43 +00:00
Rémi Denis-Courmont dd977adcfe Add myself to CODEOWNERS 2025-09-28 12:35:14 +00:00
Andreas Rheinhardt 635cb4543f avcodec/bsf/ahx_to_mp2: Don't output uninitialized data
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-27 17:57:15 +02:00
Andreas Rheinhardt 8a34faa250 swscale/ppc/swscale_ppc_template: Fix av_unused placement
Forgotten in d6cb0d2c2b.

Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 22:38:13 +02:00
Andreas Rheinhardt 0f1f345c37 avcodec/x86/qpeldsp_init: Fix compilation without external assembly
Broken in 2cf9e733c6.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 18:30:53 +02:00
Kacper Michajłow 941eae01b1 avutil/attributes: prefer clang attributes even in non-gnu builds
In MSVC mode Clang doesn't define __GNUC__, but we can still attributes.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-26 16:15:46 +00:00
Kacper Michajłow b7ab357db4 avutil/attributes: use standard attributes when they are available
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-26 16:15:46 +00:00
Kacper Michajłow a7f0377a3d avutil/attributes: add AV_HAS_STD_ATTRIBUTE
For testing language standard attributes, for both C++ and C.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-26 16:15:46 +00:00
Kacper Michajłow d6cb0d2c2b ALL: move av_unused to conform with standard requirement
This is required placement by standard [[maybe_unused]] attribute, works
the same for __attribute__((unused)).

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-26 16:15:46 +00:00
James Almer b9cc8e3210 avfilter/vf_scale: don't attempt to rescale AV_NOPTS_VALUE
Finishes fixing issue #20589.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-26 12:24:04 -03:00
James Almer 5614672d1b avfilter/framesync: don't attempt to rescale AV_NOPTS_VALUE
Part of a fix for issue #20589.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-26 12:24:04 -03:00
Sean McGovern c605d2a7ae MAINTAINERS: add me for Linux / PowerPC architecture 2025-09-26 13:16:53 +00:00
Sean McGovern 9ed6503b62 MAINTAINERS: add my OpenPGP key
My key is available at:

https://keys.openpgp.org/vks/v1/by-fingerprint/6D03BC603A33E6156E2E06AD8C0681756F598684

and

https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x6d03bc603a33e6156e2e06ad8c0681756f598684
2025-09-26 13:16:53 +00:00
Timo Rothenpieler 994a368451 configure: deprecate support for libnpp 2025-09-26 12:31:39 +00:00
Andreas Rheinhardt a54d6b1d91 avcodec/x86/rnd_template: Merge into hpeldsp_init.c
It is now only included exactly once.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:58 +02:00
Andreas Rheinhardt 43fe9554cc avcodec/x86/hpeldsp_init: Avoid complicating macro
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:55 +02:00
Andreas Rheinhardt 00e046df13 avcodec/x86/hpeldsp_init: Remove MMX(EXT) funcs overridden by SSE2
This affects the {avg,put}_no_rnd_pixels16_{x,y}2 MMX and
(put-only) MMXEXT versions. Removing these functions saved
1184B here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:53 +02:00
Andreas Rheinhardt 30c4007c65 avcodec/x86/hpeldsp: Add SSE2 avg_no_rnd size 16 versions
These currently only exist as MMX versions.
The added functions occupy 320B here. So far, they are only for
the x2 and y2 (i.e. right and down, not down-right) directions.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:49 +02:00
Andreas Rheinhardt 1e677e6964 avcodec/x86/hpeldsp: Add SSE2 put_no_rnd size 16 versions
These currently only exist as MMX and (not bitexact) MMXEXT versions.
The added functions occupy 288B here. So far, they are only for
the x2 and y2 (i.e. right and down, not down-right) directions.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:46 +02:00
Andreas Rheinhardt 262791b8d8 avcodec/hpeldsp: Make put_no_rnd_pixels_tab smaller
Only the blocksizes 16 and 8 are implemented, yet the motion estimation
code touches the blocksize 4 entries. But really nothing touches
the blocksize 2 entries, so that we can reduce the put_no_rnd_pixels_tab
array size to [3][4].

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:43 +02:00
Andreas Rheinhardt c7161befb4 avcodec/x86/h264_qpel: Remove MMX(EXT) funcs overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMX(EXT) functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:39 +02:00
Andreas Rheinhardt 4fc05c28f4 avfilter/x86/vf_gradfun: Remove MMXEXT func overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 version
of filter_line.
This commit therefore removes the overridden MMXEXT version
(which didn't abide by the ABI) which allows us to remove
an emms_c() from vf_gradfun.c, so that users with SSSE3 no longer
pay a price for the mere existence of an MMXEXT version.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:35 +02:00
Andreas Rheinhardt 5ef613bcb0 avcodec/x86/mpegvideoencdsp_init: Remove MMX, 3DNOw funcs overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMX and 3DNOW functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Also merge the mpegvideoenc_qns_template.c file into the main file.

The 3DNOW functions removed in this commit were the last in the
codebase.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:31 +02:00
Andreas Rheinhardt 6a47ea5f9f avcodec/x86/vvc/sao_10bit: Remove unused functions
Saves 65280B here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:26 +02:00
Andreas Rheinhardt 918d37d9d1 avcodec/x86/rv40dsp_init: Remove MMX(EXT) funcs overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMX(EXT) functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:23 +02:00
Andreas Rheinhardt e86f137514 avcodec/x86/hpeldsp_init: Remove MMX(EXT) funcs overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMX(EXT) functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:19 +02:00
Andreas Rheinhardt 2cf9e733c6 avcodec/x86/qpeldsp_init: Use SSE2 versions where possible
The mc00 versions (i.e. the qdsp functions with no subpixel
interpolation) are just wrappers around their fpel versions.
There are SSE2 versions of these, yet the qpel code only
uses the MMX(EXT) versions. This commit changes this and
also removes the MMX(EXT) versions.

This also allowed to remove ff_avg_pixels16_mmxext,
ff_put_pixels16_mmx.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:16 +02:00
Andreas Rheinhardt 1f9ef6a8dc avcodec/x86/h264_qpel: Remove MMX(EXT) functions overridden by SSE2FAST
CPUs which support SSE2, but not in a fast way (so that
they get the additional AV_CPU_FLAG_SSE2SLOW) are ancient
nowadays (2007 and older), so ignore the distinction between
the two and remove MMX and MMXEXT functions that are now
overridden by SSE2 functions.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:12 +02:00
Andreas Rheinhardt 8a7858dacf avcodec/x86/hpeldsp_init: Remove MMX(EXT) functions overridden by SSE2FAST
CPUs which support SSE2, but not in a fast way (so that
they get the additional AV_CPU_FLAG_SSE2SLOW) are ancient
nowadays (2007 and older), so ignore the distinction between
the two and remove MMX and MMXEXT functions that are now
overridden by SSE2 functions.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:08 +02:00
Andreas Rheinhardt 4d691da5ed avcodec/x86/hpeldsp_init: Remove MMX functions overridden by MMXEXT
Forgotten in a51279bbde because
I only looked for MMX(EXT) functions overridden by SSE2.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:04 +02:00
Andreas Rheinhardt 4e2ef29cba tests/checkasm: Add hpeldsp checkasm
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:02 +02:00
Andreas Rheinhardt fcb9e0b5f0 avcodec/hpel{dsp,_template}: Use ptrdiff_t for strides
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:20:56 +02:00
Andreas Rheinhardt 89f2016ece avcodec/hpel_template: Fix unintentional usage of unsigned offsets
The value of sizeof() is of type size_t which means that
an expression like
src1[i * src_stride1 + 4 * (int)sizeof(pixel)]
will use a very large offset if src_stride1 is sufficiently negative.
It works in practice (because it is correct modulo SIZE_MAX),
but UBSan treats it as error:
libavcodec/hpel_template.c:104:1: runtime error: addition of unsigned offset to 0x7ffdfa0391d8 overflowed to 0x7ffdfa0391cc
Fix this by casting sizeof(pixel) to int.

(This has been uncovered by a checkasm test for the hpeldsp
which will be added in a later commit.)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:20:52 +02:00
Andreas Rheinhardt b316a1bdd1 avcodec/hpeldsp: Fix documentation
This commit fixes two issues in the documentation:
a) The documentation for {put,avg}_pixels_tab only mentions
widths 16 and 8, although it explicitly mentions that there
are four horizontal blocksizes. This part of the patch
basically reverts e5771f4f37.
b) The restrictions on height don't match the reality. While
most users abide by it, some do not:
i) vp56.c copies a 16x12 block.
ii) indeo3 can copy an arbitrary multiple of four lines
for block widths 4, 8 and 16.
iii) SVQ3 can use block sizes luma block sizes 16x16, 8x16,
16x8, 8x8, 4x8, 8x4 and 4x4 and the corresponding
8x8, 4x8, 8x4, 4x4, 2x4, 4x2 and 2x2 chroma block sizes.

This implies that for widths 2 and 4 height can be two
and is guaranteed to be at least even. For all other widths,
height can be a multiple of four.

Furthermore, a comment for the SVQ3 blocksizes has been added.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:20:30 +02:00
Andreas Rheinhardt baace56169 avfilter/vf_tonemap_opencl: Make array smaller
Also makes the code more independent of AVCOL_TRC_NB.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:00:43 +02:00
Andreas Rheinhardt f0586ffa95 avfilter/vf_colorspace: Make array smaller
Also makes it more independent of AVCOL_TRC_NB.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:00:14 +02:00
Andreas Rheinhardt 188440929d avcodec/libmpeghdec: Check channel layouts generically
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:38:46 +02:00
Andreas Rheinhardt ca7679c82f avcodec/libmpeghdec: Don't set AVCodecContext.frame_size
It indicates a constant frame size (in samples); yet the documentation
of the MPEGH_DECODER_OUTPUT_INFO structure says that it
"gives information about the currently decoded audio data"
and makes no guarantees about it being constant.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:38:41 +02:00
Andreas Rheinhardt 7cd0641a99 avcodec/libmpeghdec: Align FFCodec initializers
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:38:37 +02:00
Andreas Rheinhardt 0ec21ea8d0 avcodec/libmpeghdec: Remove always-false check
The pointer to the decoder is always set after init has been
called successfully.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:38:32 +02:00
Andreas Rheinhardt f46bd4add2 avcodec/libmpeghdec: Don't use too big buffer
The channel count is fixed, so we don't need to allocate
space to hold samples for nonexisting channels. This also
means that the maximum channel count is no longer hardcoded
in the macro.
Also switch to decoder_buffer_size to be samples-based.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:37:55 +02:00
Andreas Rheinhardt 60b88e75e4 avcodec/libmpeghdec: Inline constant
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:37:51 +02:00
Andreas Rheinhardt a98f75d22c avcodec/libmpeghdec: Don't set AVCodec.sample_fmts
It is mostly pointless for decoders (only useful for those
codecs for which a floating-point and a fixed-point decoder
exist).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:37:30 +02:00
Andreas Rheinhardt 839042b0c0 avcodec/libmpeghdec: Remove private class
This decoder doesn't have any options.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:37:24 +02:00
Andreas Rheinhardt b8f341ff05 avcodec/libmpeghdec: Remove redundant manual close calls
This decoder has the INIT_CLEANUP flag set.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:36:42 +02:00
James Almer 6d8732f397 avformat/movenc: clear subsample information on fragment flush
Don't keep around information from a previous traf atom.

Fixes issue #20492.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-25 23:18:08 -03:00
Kacper Michajłow fa72f9a292 forgejo/workflows: include size and mtime in cache hash
In case some file has been updated. Generally fate samples shouldn't be
replaced to preserve compatibility with older revisions, but before
merge it may happen that files is replaced.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-25 21:51:03 +02:00
Kacper Michajłow f40766da45 configure: suppress C4267 warnings from MSVC
Suppresses implicit integer conversion narrowing warnings:
warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data

Those implicit conversions are abundant in ffmpeg's code base.
Additionally equivalent warnings are not enabled for GCC/Clang by
default, so they are mostly left unfixed.

Suppress reports about them to reduce noise in MSVC build log.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-25 18:02:44 +00:00
Leo Izen 2c8835dd72 avcodec/libjxldec: submit frame after file is complete
This commit causes the libjxl decoder wrapper to hold onto the decoded
frame until the trailing metadata after the frame is possibly complete
before it submits the frame. This allows EXIF and other metadata boxes
that occur after the frame is fully rendered to be attached to it as
side data.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-09-25 12:40:57 -04:00
Vittorio Palmisano 9970dc32bf avfilter/af_whisper: fix srt index
The srt index should be incremented for each segment.
2025-09-25 11:34:10 +00:00
Niklas Haas 96065d1261 avcodec/aom_film_grain: fix AVCOL_*_NB range check
These should also exclude the _NB values themselves.
2025-09-25 11:08:37 +00:00
Lynne 0599d508c9 prores_raw: use MKBETAG for the frame header tag
Equivalent, but more explicit. All values in the header are big endian.
2025-09-25 19:14:12 +09:00
Lynne bc4d03c530 prores_raw: set profile based on the codec tag
This is the same as what the parser does.
2025-09-25 19:14:08 +09:00
Andreas Rheinhardt cb5dbb30ca avcodec/tiff_common: Remove unused ff_tadd_*_metadata() funcs
Unused since ad77345a5d.

Reviewed-by: Leo Izen <leo.izen@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-25 06:47:30 +02:00
Andreas Rheinhardt 371931250a avcodec/ohdec: Check mutex/conditions initialization
Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-25 05:29:58 +02:00
Andreas Rheinhardt 748fa0a9bb avcodec/ohdec: Switch to RefStruct API for internal refcounting
It avoids allocations and corresponding error conditions.

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-25 05:29:26 +02:00
Andreas Rheinhardt 320133aafc avcodec/ohdec: Release decoder on allocation failure
Normally, the OH_AVCodec is wrapped inside an AVBuffer
to be freed in its free callback; yet when creating
the AVBuffer fails, the decoder is never destroyed.

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-25 05:28:16 +02:00
Marvin Scholz 5cb6d2221a avformat/http: Handle IPv6 Zone ID in hostname
When using a literal IPv6 address as hostname, it can contain a Zone ID
especially in the case of link-local addresses. Sending this to the
server in the Host header is not useful to the server and in some cases
servers refuse such requests.

To prevent any such issues, strip the Zone ID from the address if it's
an IPv6 address. This also removes it for the Cookies lookup.

Based on a patch by: Daniel N Pettersson <danielnp@axis.com>
2025-09-24 12:03:13 +00:00
Stadelmann, Daniel 56c14f2311 avcodec/libmpeghdec: add MPEG-H 3DA Fraunhofer IIS mpeghdec decoder
Adds a wrapper around the Fraunhofer IIS MPEG-H 3D Audio mpeghdec [1]
decoder shared library.

[1] https://github.com/Fraunhofer-IIS/mpeghdec

Signed-off-by: Stadelmann, Daniel <daniel.stadelmann@iis.fraunhofer.de>
2025-09-24 08:25:42 +02:00
rcombs e5f82ab868 Revert "lavc/libsvtav1: set packet durations"
This reverts commit 5c9b2027bc.

This doesn't actually work the way it'd appeared to in testing;
the output was based on frame *encode latency*.
2025-09-23 20:22:33 -07:00
Andreas Rheinhardt 17d5759bd9 avcodec/x86/apv_dsp: Don't export arrays unnecessarily
The const here is unnecessary, because everything inside
SECTION_RODATA is automatically const and using it exports
these objects from the object file because const is a macro
in x86inc.asm.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-24 01:21:32 +00:00
Vittorio Palmisano f18b1e2389 avfilter/af_whisper: fix int64 printf format
Use PRId64 for printing int64_t values in the SRT output.
2025-09-23 23:35:58 +00:00
Andreas Rheinhardt 7c78a63476 avcodec/mpegaudiodec_float: Don't set AVCodec.sample_fmts directly
It is deprecated and doing so gives warnings from Clang.
Use CODEC_SAMPLEFMTS instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-23 22:16:02 +00:00
Andreas Rheinhardt cf30a3757f configure: Add missing dependencies for AHX decoder
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-23 22:16:02 +00:00
Marvin Scholz e63e040f0c avformat/rtsp: fix leading space in RTSP reason
When parsing the RTSP message reason, the whole remainder
after parsing the status code was used, which would lead to
a leading space in the parsed reason string.
2025-09-23 21:33:37 +00:00
Marvin Scholz 2ed47ab725 avformat/rtsp: do not log invalid values
When reading fails the first time, ch would be uninitialized and
printed in the log message. Instead check for an error early and
log it properly.
2025-09-23 21:33:37 +00:00
Niklas Haas 899e497122 avfilter/vf_libplacebo: force premultiplied blending for linear texture
Blending onto independent alpha framebuffers is not possible under the
constraints of the supported blend operators. While we could handle
blending premul-onto-premul, this would break if the base layer is YUV,
since premultiplied alpha does not survive the (nonlinear) YUV conversion.

Fortunately, blending independent-onto-premul is just as easy, and works in
all cases. So just force this mode when using a linear intermediate blend
texture, which is always RGBA.
2025-09-23 18:50:03 +00:00
Niklas Haas 6f08ab6c4c avfilter/vf_libplacebo: use temporary params struct for per-pass params
Instead of directly mutating `opts->params`. Avoids any possible leak of
overriden params between invocations of this function, as well as the later
`pl_render_image` during the linear output pass.
2025-09-23 18:50:03 +00:00
rcombs 5c9b2027bc lavc/libsvtav1: set packet durations 2025-09-23 14:32:47 +00:00
Derek Buitenhuis ae03b629db avformat/mov: Merge tts after building index for old-style uncompressed PCM
This was a regression introduced in 292c1df7c1.

Since we don't know the length of the stts data until after building the
index, since we're generating it, we need to merge any ctts data after,
since otherwise tts_count is set to 0, and no packets will be output.

We can't remove the merge entirely, because uncompressed PCM with
a ctts atom is technically valid (e.g. a constant CTS offset).

This fixes old-style uncompressed PCM demuxing.

Fixes #11490.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2025-09-23 14:39:13 +01:00
Krzysztof Pyrkosz 03c054d43c avcodec/aarch64/vvc: Implement dmvr_v_8
A72
dmvr_v_8_12x20_neon:                                   207.0 ( 4.15x)
dmvr_v_8_20x12_neon:                                   170.4 ( 4.37x)
dmvr_v_8_20x20_neon:                                   273.4 ( 4.58x)

A53
dmvr_v_8_12x20_neon:                                   450.6 ( 4.21x)
dmvr_v_8_20x12_neon:                                   342.8 ( 3.70x)
dmvr_v_8_20x20_neon:                                   550.9 ( 3.79x)
2025-09-23 11:20:20 +00:00
Krzysztof Pyrkosz 56a638d836 avcodec/aarch64/vvc: Unroll vvc_bdof_grad_filter_8x_neon
Before and after:
A53:
apply_bdof_8_16x8_neon:                               2733.1 ( 4.88x)
apply_bdof_8_16x16_neon:                              5458.6 ( 4.86x)
apply_bdof_10_16x8_neon:                              2789.8 ( 4.64x)
apply_bdof_10_16x16_neon:                             5523.8 ( 4.68x)
apply_bdof_12_16x8_neon:                              2792.8 ( 4.58x)
apply_bdof_12_16x16_neon:                             5519.5 ( 4.63x)

apply_bdof_8_16x8_neon:                               2571.8 ( 5.12x)
apply_bdof_8_16x16_neon:                              5173.3 ( 5.12x)
apply_bdof_10_16x8_neon:                              2635.1 ( 4.87x)
apply_bdof_10_16x16_neon:                             5243.0 ( 4.89x)
apply_bdof_12_16x8_neon:                              2613.0 ( 4.89x)
apply_bdof_12_16x16_neon:                             5231.7 ( 4.90x)

A78:
apply_bdof_8_16x8_neon:                                565.3 ( 8.43x)
apply_bdof_8_16x16_neon:                              1109.5 ( 8.60x)
apply_bdof_10_16x8_neon:                               568.2 ( 7.92x)
apply_bdof_10_16x16_neon:                             1114.1 ( 8.08x)
apply_bdof_12_16x8_neon:                               570.2 ( 7.87x)
apply_bdof_12_16x16_neon:                             1116.3 ( 8.03x)

apply_bdof_8_16x8_neon:                                541.4 ( 8.81x)
apply_bdof_8_16x16_neon:                              1065.9 ( 8.97x)
apply_bdof_10_16x8_neon:                               543.2 ( 8.32x)
apply_bdof_10_16x16_neon:                             1071.5 ( 8.39x)
apply_bdof_12_16x8_neon:                               544.2 ( 8.25x)
apply_bdof_12_16x16_neon:                             1074.1 ( 8.37x)
2025-09-23 11:20:11 +00:00
Paul B Mahol e5ac70042e avformat/aiff: add support for ADPCM N64 decoder
(cherry picked from commit 0fdf549a890f276243ba62f194e0ec08b10df60f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-22 23:46:29 +00:00
Paul B Mahol 00eef74336 avformat/adxdec: add AHX support
(cherry picked from commit b40bb6ad1e5739dd7927f3be5c2a06fb8aeef0cb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-22 23:46:29 +00:00
Michael Niedermayer 745cb6f8c7 configure: Put modules added from almpeg under --enable-gpl as suggested by several members of the GA
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-22 23:46:29 +00:00
asivery 97bfb606e3 avformat/aeadec, avcodec/atrac1: Fix 8 and 4-channel ATRAC1 support
Signed-off-by: asivery <asivery@protonmail.com>
(cherry picked from commit 81cdf42222961c2959f1ede2d86fea0d1dcbbfcb)
2025-09-22 23:46:29 +00:00
Paul B Mahol e0638cee0a avcodec/adpcm: improve decooding output for 4-bit ADPCM IMA WAV
(cherry picked from commit f11422f1a6251e2b3c42b4044efbc722b863778d)
2025-09-22 23:46:29 +00:00
Paul B Mahol 066432ebcf avcodec: add ADPCM IMA Escape audio decoder
(cherry picked from commit 4a663e78c4421da226e7d480d6767de803ee2122)
2025-09-22 23:46:29 +00:00
Paul B Mahol 5d6c9a15eb avcodec: add ADPCM Circus decoder
(cherry picked from commit cdd3d794c7e01e4d6f485e7b975a4b9107d3f2fd)
2025-09-22 23:46:29 +00:00
Paul B Mahol f6dfb20302 avcodec: add ADPCM PSXC audio decoder
(cherry picked from commit a4055b5cc6d77c26867948e24de6bdfd5c0e6a3b)
2025-09-22 23:46:29 +00:00
Paul B Mahol a4f778890b avcodec/adpcm: fix non-4bit adpcm ima wav decoding
(cherry picked from commit f4e05abeded46515bd7b4248fc7d65df82d9af2a)
2025-09-22 23:46:29 +00:00
Paul B Mahol 30fc5b1baa avcodec: add ADPCM IMA Magix decoder
(cherry picked from commit 2ec3ad2122484ce2c84f6ba055c5ebc1661c5b14)
2025-09-22 23:46:29 +00:00
Paul B Mahol 58c0711fca avcodec: add ADPCM IMA HVQM2 decoder
(cherry picked from commit 480e36592d5fc27a47e378d62570824613f26b7b)
2025-09-22 23:46:29 +00:00
Paul B Mahol 1943b31cdd avcodec/adpcm: fix overflow in mono ADPCM IMA HVQM4
(cherry picked from commit 6a9b0f7272a0725abbe6f887f766fb5f1f119a66)
2025-09-22 23:46:29 +00:00
Paul B Mahol 5fc9c79f53 avcodec: add ADPCM Silicon Graphics N64 decoder
(cherry picked from commit 13484237fdf19c9d927b8a64b81d00100a4178c3)
2025-09-22 23:46:29 +00:00
Paul B Mahol 648b5d017d avcodec: add ADPCM IMA PDA decoder
(cherry picked from commit ab9f7513d55cfd87d1a1ce22d02abffbfb9bb296)
2025-09-22 23:46:29 +00:00
Paul B Mahol 424dbb03ae avcodec: add ADPCM IMA HVQM4 decoder
Signed-off-by: Paul B Mahol <onemda@gmail.com>
(cherry picked from commit bae3cecfa6f1fbc765d95d84ef4a377aedbca8bb)
2025-09-22 23:46:29 +00:00
Paul B Mahol e95171fbff avcodec: add AHX parser
(cherry picked from commit ddcb47c4c512bf49b22cc6b2d07fade0f96377e3)
2025-09-22 23:46:29 +00:00
Paul B Mahol b2e821310b avcodec: add AHX decoder
(cherry picked from commit 039dc23d185214b8b0ef2bbccae197ceb5ad42a2)
2025-09-22 23:46:29 +00:00
Michael Niedermayer b1cbc7c8ff configure: strip non numeric trailer from gcc version
Fixes: ../configure: 7820: [: Illegal number: 13-win32

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-22 21:41:42 +00:00
Andreas Rheinhardt b815431126 Revert "avformat/tls_openssl: add av_assert0() for tls_shared"
This reverts commits fd55c4b5f7
(for tls_openssl.c) and c74181a04b
(for tls_gnutls.c).

It is impossible for a pointer to a member of a structure
to be NULL: If the containing structure exists, the member
exists and can't have a NULL address; if the containing
structure does not exist, then getting a pointer to the
substructure via &c->tls_shared would already be undefined
behavior.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-22 22:02:03 +02:00
Andreas Rheinhardt db6cd6c6bf avformat/tls_openssl: Don't call functions inside FFMIN
It may call the function multiple times.

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-22 21:58:00 +02:00
Brad Smith ced4a6ebc9 libavutil/arm: Rename the HWCAP defines
Rename the HWCAP defines to use the same naming scheme as AArch64 and PPC.

Signed-off-by: Brad Smith <brad@comstyle.com>
2025-09-22 07:28:21 -04:00
Brad Smith cdae5c3639 libavutil/arm: Make use of elf_aux_info() on FreeBSD/OpenBSD
- FreBSD/OpenBSD have elf_aux_info() on arm
- Wrap AT_HWCAP as the value is different for BSD vs Linux (16 vs 25)

Signed-off-by: Brad Smith <brad@comstyle.com>
2025-09-22 07:16:24 -04:00
Andreas Rheinhardt c9168717bf avcodec/h274: Make H274FilmGrainDatabase a shared object
Right now, the private contexts of every decoder supporting
H.274 film grain synthesis (namely H.264, HEVC and VVC)
contain a H274FilmGrainDatabase; said structure is very large
700442B before this commit) and takes up the overwhelming
majority of said contexts: Removing it reduces sizeof(H264Context)
by 92.88%, sizeof(HEVCContext) by 97.78% and sizeof(VVCContext)
by 99.86%. This is especially important for H.264 and HEVC
when using frame-threading.

The content of said film grain database does not depend on
any input parameter; it is shareable between all its users and
could be hardcoded in the binary (but isn't, because it is so huge).

This commit adds a database with static storage duration to h274.c
and uses it instead of the elements in the private contexts above.
It is still lazily initialized as-needed; a mutex is used
for the necessary synchronization. An alternative would be to use
an AV_ONCE to initialize the whole database either in the decoders'
init function (which would be wasteful given that most videos
don't use film grain synthesis) or in ff_h274_apply_film_grain().

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-22 04:54:22 +02:00
zhanghongyuan b5e0d9f648 fftools/opt_common: add separator line to show_filters output
Add a separator line to show_filters() function output to maintain
consistent formatting with other show functions like show_codecs,
show_formats_devices, etc. This provides uniform formatting across
all command-line output functions for better readability and
parsing by external tools.
2025-09-22 02:47:40 +00:00
Krzysztof Pyrkosz f1a155d975 avcodec/aarch64/vvc: Optimize dmvr_hv_10
Before and after on A53:
dmvr_hv_10_12x20_neon:                                1838.2 ( 3.02x)
dmvr_hv_10_20x12_neon:                                1330.2 ( 1.83x)
dmvr_hv_10_20x20_neon:                                2148.2 ( 1.85x)
dmvr_hv_12_12x20_neon:                                1839.2 ( 3.02x)
dmvr_hv_12_20x12_neon:                                1330.6 ( 1.83x)
dmvr_hv_12_20x20_neon:                                2147.2 ( 1.85x)

dmvr_hv_10_12x20_neon:                                1755.0 ( 3.17x)
dmvr_hv_10_20x12_neon:                                1165.8 ( 2.09x)
dmvr_hv_10_20x20_neon:                                1876.1 ( 2.12x)
dmvr_hv_12_12x20_neon:                                1754.4 ( 3.17x)
dmvr_hv_12_20x12_neon:                                1167.8 ( 2.09x)
dmvr_hv_12_20x20_neon:                                1878.8 ( 2.12x)
2025-09-21 19:39:27 +00:00
Niklas Haas 0bd5a7d371 avfilter/vf_colordetect: only report detected properties on EOF
Instead of reporting them also when the filtergraph is suddenly destroyed
mid-stream, e.g. during the `ffmpeg` tool's early init.
2025-09-21 13:28:58 +02:00
Niklas Haas 843920d5d6 avfilter/x86/vf_idetdsp: add AVX2 and AVX512 implementations
The only thing that changes slightly is the horizontal sum at the end.
2025-09-21 11:02:41 +00:00
Niklas Haas 4c067d0778 avfilter/x86/vf_idetdsp: generalize 8-bit macro
This is mostly compatible with AVX as well, so turn it into a macro.
2025-09-21 11:02:41 +00:00
Niklas Haas 00e05bcd68 tests/checkasm: add vf_idet checkasm 2025-09-21 11:02:41 +00:00
Niklas Haas 326abf359f avfilter/vf_idetdsp: use consistent uint8_t pointer type
Even for 16-bit DSP functions. Instead, cast the pointer inside the
function.
2025-09-21 11:02:41 +00:00
Niklas Haas 60dbcc5321 avfilter/vf_idetdsp: pass actual bit depth
More informative and IMO cleaner; some implementations may want to
differentiate by exact bit depth or support 32 bit down the line.
2025-09-21 11:02:41 +00:00
Niklas Haas 56bb187ca9 avfilter/vf_idet: correctly update dsp function on format change
Currently, this never updates on change from high bit depth to low bit depth.
2025-09-21 11:02:41 +00:00
Niklas Haas 2b67137daa avfilter/vf_idet: correctly reset pixdesc on format change 2025-09-21 11:02:41 +00:00
Niklas Haas 5830743363 avfilter/vf_idet: separate DSP parts
To avoid pulling in the entire libavfilter when using the DSP functions
from checkasm.

The rest of the struct is not needed outside vf_idet.c and was moved there.
2025-09-21 11:02:41 +00:00
Niklas Haas 367febc491 avfilter/vf_idet: expose DSP init function internally
For checkasm.
2025-09-21 11:02:41 +00:00
Zhao Zhili e02e6d54b0 tests/fate/demux: add hxvs test case 2025-09-21 17:42:19 +08:00
Zhao Zhili dcddb2bf08 avformat: add hxvs demuxer 2025-09-21 17:42:19 +08:00
Brad Smith db0b86a4ad avformat/udp: fix warning about unused varible
libavformat/udp.c:283:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Brad Smith <brad@comstyle.com>
2025-09-20 22:59:50 -04:00
Michael Niedermayer 55e71768cf avformat/dhav: Fix off by length of read element error
Fixes: out of array read
Fixes: BIGSLEEP-445383648
Fixes: crash_input_1/2/3.dhav

Found-by: Google Big Sleep
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-21 00:49:44 +00:00
Lynne 8d65da767b lavf: fix demuxing of FLAC files with id3v2 tags
Due to the recent id3v2 refactor, FLAC was left out due to
earlier code not checking for id3v2 presence on FLAC.
Without the id3v2 data parsed, detection of FLAC and therefore
demuxing fails.

Fixes 9d037c54f2
2025-09-20 22:46:39 +09:00
Lynne 99285cba21 lavf/id3v2: report incorrect BOM value on error 2025-09-20 22:46:35 +09:00
Henrik Gramner 82b5a0faba vp9: Remove 8bpc AVX asm for inverse transforms
There's very little performance difference vs SSE2/SSSE3 and most
systems will use the AVX2 implementations anyway.

This reduces code size and compilation time by a significant amount.
2025-09-19 23:12:59 +00:00
Henrik Gramner 0b5d46ee1c vp9: Add 8bpc AVX2 asm for inverse transforms 2025-09-19 23:12:59 +00:00
Andreas Rheinhardt 49b5c17e09 avformat/mccdec: Constify data
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:31:10 +02:00
Andreas Rheinhardt cce1af5413 avformat/mccenc: Hardcode codec names
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:31:05 +02:00
Andreas Rheinhardt f65875c082 avformat/mccdec: Avoid relocations
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:31:02 +02:00
Andreas Rheinhardt e965fe9057 avformat/mccenc: Avoid relocations
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:59 +02:00
Andreas Rheinhardt 28f0b7a237 avformat/mccenc: Add newlines to logmessages
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:53 +02:00
Andreas Rheinhardt 3c79219e93 avformat/mccenc: Check version-timecode compatibility earlier
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:33 +02:00
Andreas Rheinhardt 159330016c avformat/mccenc: Deduplicate strings
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:28 +02:00
Andreas Rheinhardt d81a971b35 avformat/mccenc: Constify read-only data
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:24 +02:00
Andreas Rheinhardt 62dd3e1e7d avformat/mccenc: Remove redundant setting of time base
It has already been done in init.

Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:20 +02:00
Andreas Rheinhardt 0cd78bddc4 avformat/mccenc: Fix assert check
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:17 +02:00
Andreas Rheinhardt a34a85ed54 avformat/mccenc: Remove redundant check
This has already been checked in init.

Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:29:41 +02:00
Marton Balint 82a09aef05 avformat/urldecode: factorize core url decoding from ff_urldecode
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint 23cf2c5f01 avformat/urldecode: fix decoding last char if it was percent encoded
The length check was too strict and if the end of the string was a percent
encoded sequence it did not decode correctly.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint b0314dc76e avformat/rtpproto: use proper return error codes in rtp_open
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint 3a29702cb6 avformat/rtpproto: add some URL options as AVOption aliases
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint f2be0e68ef avformat/tls: move AVClass to TLSShared
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint b2184a9741 avformat/tls: use AV_OPT_TYPE_BOOL for some AVOptions
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint 7d1e22b7ea avformat/tls: add some URL options as AVOption aliases
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint ca8cba4eac avformat/udp: factorize warning unsupported options for builds without PTHREAD_CANCEL
Also fix 'circular_buffer_size' parameter name in the message and the
'fifo_size' option description.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint 3e7314fe30 avformat/udp: add DSCP as a normal AVOption
Previously this was an URL-only option.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Kacper Michajłow 1ce3f9fdab forgejo/workflows: run fate-build
It's not included in make fate target.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-18 16:53:05 +00:00
Jack Lau c74181a04b avformat/tls_gnutls: add av_assert0() for tls_shared
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-18 12:34:15 +00:00
Jack Lau df7532b21d avformat/tls_gnutls: add initial dtls support
Set GNUTLS_DATAGRAM flag when is_dtls is true.
Set mtu when it's specified.
Modify the read/write function could use udp socket.

There are more patches to make dtls really work.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-18 12:34:15 +00:00
Michael Niedermayer 647138334a avcodec/exif: check count in exif_decode_tag()
Fixes: out of array access
Fixes: integer overflow
Fixes: poc_heap_bof

Found-by: *2ourc3 (Salim LARGO)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-18 11:06:16 +00:00
Michael Niedermayer 88e04205b3 avcodec/exif: Do not leave uninitialized pointers on errors in exif_clone_entry()
No testcase, but this looks like it could free garbage pointers

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-18 11:06:16 +00:00
Michael Niedermayer 742b0d4675 avcodec/exif: Use av_fast_mallocz() in av_exif_clone_ifd()
using fast realloc leaves the entries uninitialized and frees garbage pointers on
errors

Fixes: bug_triggering_file

Found-by: *2ourc3, 5pider
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-18 11:06:16 +00:00
Kacper Michajłow c373636f55 avfilter/vsrc_gfxcapture: fix string format specifier
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-18 03:55:54 +02:00
Timo Rothenpieler 61835e1d8b avfilter/vsrc_gfxcapture: keep cbdata object alive
Depending on the threading backend the stdlib uses, creating a
mutex/condvar can be quite expensive.
So keep this object alive in the ctx, on which we synchronize via the
uninit mutex anyway.
2025-09-18 01:04:59 +00:00
Timo Rothenpieler c4e537793b avfilter/vsrc_gfxcapture: fix leaking all callback handlers
Fixes #20537
2025-09-18 01:04:59 +00:00
Timo Rothenpieler 1849068c65 avfilter/vsrc_gfxcapture: use free threaded capture frame pool
Apparently, using a normal frame pool in a multithreaded environment
leads to strange resource leaks on shutdown, which vanish when using a
free threaded pool.
2025-09-18 01:04:59 +00:00
Timo Rothenpieler 4879c9f4e2 avfilter/vsrc_gfxcapture: stop capture session before initializing capture thread shutdown
It might have things going on in the background that still need cleaned
up, and this gives it a chance to enqueue them on the dispatch queue.
2025-09-18 01:04:59 +00:00
Timo Rothenpieler 23d9412ff9 avfilter/vsrc_gfxcapture: fix re-using ret variable from outside of lambda scope 2025-09-18 01:04:59 +00:00
Timo Rothenpieler 983fed34f8 avfilter/vsrc_gfxcapture: don't pass pointer to ComPtr
While it does appear to work fine, with all the operator overloads, it
at least has potential for surprises, so pass it by reference instead.
2025-09-18 01:04:59 +00:00
Andreas Rheinhardt 8accbbdf9a avcodec/vvc/data: Mark tables as hidden
This allows compilers to optimize accesses like
ff_vvc_diag_scan_x[2][2][x] by baking the offset derived
from [2][2] into the relocation (so that it is performed
at link-time).

Reviewed-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-17 22:48:39 +02:00
Timo Rothenpieler efd484cb2d avutil/hwcontext_d3d11va: remove D3D11_BIND_RENDER_TARGET restriction for array textures
This was added in 4f78711f9c, with the
commit message claiming that it's a Microsoft restriction that array
textures with ArraySize > 2 cannot be created with
D3D11_BIND_RENDER_TARGET.

I was unable to find any documentation or other references on that, and
a quick test also found it to not be the case. So this patch removes
that restriction.

This enables frame sources, like the d3d11 capture filters, to output
frames in an array texture, which is neccesary to pass those frames as
input to some hardware encoders.
2025-09-17 14:50:41 +00:00
Timo Rothenpieler 00ddb408c5 avfilter/vsrc_ddagrab: support rendering mouse cursor onto array textures 2025-09-17 14:50:41 +00:00
Cameron Gutman a0936b9769 avcodec/vaapi_encode: skip AVBR if HRD parameters are set
AVBR does not use VAEncMiscParameterTypeHRD, so attempting to set
rc_buffer_size and bit_rate together will cause the rc_buffer_size
to be ignored if the VAAPI driver supports AVBR. We should prefer
regular VBR for that case.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-09-17 06:40:16 +00:00
James Almer c6297b689f tests/fate/image: add Exif rotation metadata tests
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-17 02:17:09 +00:00
James Almer ca72b2d712 avcodec/tiffenc: support writing Orientation tag
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-17 02:17:09 +00:00
James Almer 796b3ba63b tests/fate/prores: add a probe test
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-16 15:42:03 -03:00
James Almer e0ddb4ac82 tests/fate-run: pass threads argument to ffprobe
Ensures it honors the THREADS variable if set to anything other than 1, which will be
useful to detect bugs.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-16 15:42:03 -03:00
James Almer fdb5f709b7 avcodec/h2645_sei: add missing ambient_viewing_environment copy in ff_h2645_sei_ctx_replace()
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-16 15:42:03 -03:00
James Almer 26f4230082 avcodec/decode: sync initial_pict_type and intra_only_flag with thread worker's avctx
Regression since 5acbdd2264, which removed
setting both values from PerThreadContext.
Given the pthread code calls ff_decode_receive_frame_internal() on the frame,
any value set before it will be overwritten, so instead sync each thread's
DecodeContext and let ff_decode_receive_frame_internal() handle these values.

Fixes issue #20534.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-16 15:41:50 -03:00
Andreas Rheinhardt f47b270b41 avfilter/vf_colordetect: Move ff_color_detect_dsp_init() out of .c file
Otherwise checkasm pulls in vf_colordetect.o and then all of
libavfilter.

Reviewed-by: Martin Storsjö <martin@martin.st>
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-16 18:23:52 +02:00
Andreas Rheinhardt fe0a313299 avfilter/vf_colordetect: Avoid sequentially consistent atomics
Reviewed-by: Martin Storsjö <martin@martin.st>
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-16 18:23:45 +02:00
Andreas Rheinhardt a35c91dc14 avfilter/vf_colordetect: Rename header to vf_colordetectdsp.h
It is more in line with our naming conventions.

Reviewed-by: Martin Storsjö <martin@martin.st>
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-16 18:22:24 +02:00
Timo Rothenpieler b8256b82f5 avfilter/vsrc_gfxcapture: remove needless use of atomics 2025-09-16 15:52:11 +00:00
Timo Rothenpieler 61378d6b91 avfilter/vsrc_gfxcapture: fix possible missed wakeup race in capture loop 2025-09-16 15:52:11 +00:00
Jan Ekström af35a13f6d avformat/movenc: add support for fragmented TTML muxing
Attempts to base the fragmentation timing on other streams
as most receivers expect media fragments to be more or less
aligned.

Currently does not support fragmentation on subtitle track
only, as the subtitle packet queue timings would have to be
checked in addition to the current fragmentation timing logic.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2025-09-16 16:29:48 +03:00
Jan Ekström 8dcc65a0fc avcodec/packet: add functionality to prepend to AVPacketLists
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2025-09-16 16:28:12 +03:00
Jan Ekström 5c222d7ade tests/fate-run: add support for specifying the final encode muxer in transcode
This allows for direct dumping of the packets' contents (useful for
text based formats), while getting the timestamps/sizes etc from
ffprobe.

If used via TRANSCODE, the actually utilized muxer should be added
within the last argument as an additional dependency, as that is not
done automatically.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2025-09-16 15:17:12 +03:00
renjianguang 9e4ff4732c swresample/swresample: Delete unused code
The uch option has been removed

Signed-off-by: renjianguang <renjianguang@xiaomi.com>
2025-09-16 11:27:39 +00:00
Zhao Zhili 07ea3b1787 avformat/flvenc: fix event_flags check
AVFormatContext.event_flags is checked against AVSTREAM_EVENT_FLAG,
which belongs to AVStream.event_flags. There is no real issue since
these two flags have the same value.
2025-09-16 02:52:20 +00:00
James Almer 57a29f2e7d avcodec/x86/pngdsp: add missing emms at the end of add_png_paeth_prediction
Fixes unpredictable behavior with floats.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-15 22:18:52 -03:00
Andreas Rheinhardt 162e5a1121 swresample/rematrix_template: Constify get_mix_any_func
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt fe06d5533f swresample/x86/rematrix_init: Avoid allocation for native_simd_one
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt 853229d140 swresample/rematrix: Avoid allocation for native_one
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt c48add609a swresample/swresample_internal: Use union for float, int matrix
Saves 16KiB from SwrContext.
(FATE would also pass if one made the double matrix part of
the union, too, but I don't know whether this is truely correct,
because swri_rematrix() accesses the double matrix (to check whether
it is equal to 1.0) even when one of the other matrices is in use.)

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt f33e62a8b4 avcodec/mjpegdec: Move reference dimension check to mxpegdec.c
Only the mxpeg sets reference at all.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt b5cfabf0f5 avcodec/mjpegdec: Avoid using HpelDSPContext
It is quite big and we only need one function from it.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt 124c856d38 avcodec/mjpegdec: Move initializing HpelDSPContext to mxpegdec.c
Only the mxpeg decoder uses it (and the reference/bitmask feature
of ff_mjpeg_decode_sos()). So only initialize it for mxpeg which
allows to remove the mjpeg->hpeldsp dependency.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt b11c8b76df avcodec/mjpegdec: Avoid mixing return value and error code, avoid branch
mjpeg_decode_dc() currently has a special return value (0xfffff)
for the case of invalid data; this value does not overlap with
the ordinary return values, yet the compiler can't prove this
(at least on x86 where an asm version of NEG_USR32 is used
inside get_xbits()), so the non-error return value has to be checked
for being the special value even if mjpeg_decode_dc() is inlined.

This commit avoids this by separating error code and ordinary return
value. It also means that the ljpeg functions return the proper
error code and not -1 in case of invalid data.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt 3b1673db6a avcodec/mjpegdec: Avoid superfluous secondary error message
Up until now, a DC error in decode_block() or decode_dc_progressive()
would lead to a warning from mjpeg_decode_dc() and a (less verbose)
error from the caller. Upgrade the former to an error status (all
callers treat is an error) and remove the latter.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt a6c899bc6b avcodec/mjpegdec: Remove pointless information from logmessage
There is no reason to add the address of an element of
MJpegDecodeContext (which makes logmessage nonreproducible).
Also avoid always printing a zero.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt ac64c52b96 avcodec/encode: Remove redundant av_image_check_size2()
The dimensions have already been checked during init.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt a2e4ba4df6 avcodec/encode: Remove dead code
Can be readded if needed (likely never).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt 9a130a57cd avcodec/encode: Ignore coded_{width,height}
It is supposed to be unused by encoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt b3ac02eb83 avcodec/encode: Simplify pixel format validity check
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt ed9c8e98cc avcodec/av1dec,libdav1d,wbmpdec: Avoid direct access to GetByteContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt 8872c0c39d avformat/takdec: Don't truncate return value
This is unlikely to matter for real files.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt 057afba13d avformat/tta: Avoid seek when reading header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt bd80640cae avformat/oggdec: Don't skip over data whose checksum is used
The behavior of the ffio_*_checksum feature is not well defined
when using avio_skip(). The code in oggdec.c relied on the skipped
data (four bytes) to be checksummed, which is mostly true
because short_seek_threshold is 32768 by default, so that
avio_seek() will normally read data instead of calling the
underlying seek function. Yet this has two problems:

a) It relies on implementation details of avio_seek().
b) There is an exception, namely if the AVIO_FLAG_DIRECT is set.
In this case the underlying seek function (if set) is always
called and the data is skipped, leading to CRC errors.

So don't skip the data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt 987c955cd7 avformat/aviobuf: Keep checksum_ptr consistent in avio_seek()
Otherwise it might be > buf_ptr in which case ffio_get_checksum()
could segfault (s->buf_ptr - s->checksum_ptr would be negative
which would be converted to something very big when converted
to unsigned for the update_checksum callback).

Fixes ticket #11233.

Reported-by: Du4t
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Marvin Scholz 994bc08325 configure: also initialize objcflags_filter early
Fixes an issue uncovered since 0ce413af9c
where flags were properly separated but without the objcflags_filter
being initialized, if add_objcflags is called early as part of
add_allcflags, it would lead to the append() function using an empty
filter and trying to call the flag instead, leading to errors like:

./configure: line 976: -fsanitize=address: command not found
./configure: line 976: -fno-omit-frame-pointer: command not found
2025-09-15 15:50:11 +00:00
Drew Dunne 76471fb143 vf_colorspace: Add an option to clamp trc LUT output
Add a new flag to the vf_colorspace filter which provides the user an
option to clamp the linear and delinear transfer characteristics LUT
values to the [0, 1] represented range. This helps constrain the
potential value range when converting between colorspaces.

Certain colors when going through the conversion can result in out of
gamut colors after the rotation. The colorspace filter allows that with
the extended range. The added clamping just keeps the colors within the
[0, 1) range rather than using that extended range. I'm not enough of a
color scientist to say which is correct, but there are certain
situations where we would prefer to keep the colors in gamut.

The example I have is:

A solid color image of 8-bit YUV: Y=157, U=164, V=98.

Specify the input as:

Input range: MPEG
In color matrix: BT470BG
In color primaries: BT470M
In color transfer characteristics: Gamma 28

Output as:
Out color range: JPEG
Out color matrix: BT.709
Out color primaries: BT.709
Out color transfer characteristics: BT.709

During the calculation you get:

Input YUV:                             y=157,      u=164,      v-98
Post-yuv2rgb BT.470BG:                 r=0.456055, g=0.684152, b=0.928606
Post-apply gamma28 linear LUT:         r=0.110979, g=0.345494, b=0.812709
Post-color rotation BT.470M to BT.709: r=-0.04161, g=0.384626, b=0.852400
Post-apply Rec.709 delinear LUT:       r=-0.16382, g=0.615932, b=0.923793
Post-rgb2yuv Rec.709 matrix:           y=120,      u=190,      v=25

Where with this change, the delinear LUT output would be clamped to 0,
so the result would be:
r=0.000000, g=0.612390, b=0.918807 and a final output of
y=129, u=185, v=46

As for the long and av_clip64, this was just because lrint returned a
long, so I left it as that and then used av_clip64 to the [0,1) range to
avoid overflow. But re-reading, it looks like av_clip_int16 would
downcast that long to int anyway so the possibility of overflow already
existed there. I've put it back to int just to match the existing
behavior.
2025-09-15 14:39:09 +00:00
Timo Rothenpieler 189d0b83b2 configure: pass CFLAGS to ObjC tests again
It was mistakenly removed in 0ce413af9c.

This matches how the Makefiles actually compile ObjC code, and
unlike C++, this seems to actually be benign and various existing
setups rely on that behaviour.
2025-09-15 14:37:43 +02:00
Timo Rothenpieler f85da32e3a configure: make --extra-objcflags show the right default flags 2025-09-15 14:17:49 +02:00
Martin Storsjö 424d844534 configure: Make -Werror=partial-availability apply to all languages
This was missed in 0ce413af9c.

This fixes proper detection of Objective C APIs (that are missing)
if targeting older macOS versions, such as the check for
AVCaptureSession.
2025-09-15 14:17:52 +03:00
Jack Lau 16b8a7805b avformat/whip: enable RTCP NACK for whip
Refer to RFC 4585 4.2,
Add SDP "a=rtcp-fb" so the peer can request rtx
through sending NACKs.

Add basic parsing for NACK packet.
Decrypt into a newly allocated buffer (do not
overwrite whip->buf) so multiple NACKs in a
bundled packet can be parsed in a loop while
keeping whip->buf available for sending rtx

Broken or wrong NACk are logged and skipped.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-15 06:40:11 +00:00
Timo Rothenpieler faba1501d5 avfilter/vsrc_gfxcapture: switch to std::thread
Combining C++ with our w32pthreads does not work out.
The C++ standard lib headers might include pthread.h, which will then
define clashing types with our w32pthread header.

To solve this, switch to using C++ native std::thread.
2025-09-14 21:46:40 +02:00
Timo Rothenpieler 570949822b avfilter/vsrc_gfxcapture: MapWindowPoints can return 0 and still succeed 2025-09-14 20:46:29 +02:00
Timo Rothenpieler d74d3080ff avfilter/vsrc_gfxcapture: make checkheaders happy 2025-09-14 20:33:24 +02:00
Zhao Zhili 9e3c07f2df avcodec/rkmppdec: fix return EAGAIN during flushing
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-09-14 21:35:54 +08:00
Zhao Zhili 0773343ed7 avcodec/rkmppdec: fix input queue overflow
The strategy to count free slots isn't reliable. The value of
INPUT_MAX_PACKETS is a hardcoded value, and MPP_DEC_GET_STREAM_COUNT
doesn't always work as expected. When freeslots is nonzero, the mpp
decoder still returns MPP_ERR_BUFFER_FULL. Before this patch, all
packets are dropped once went into MPP_ERR_BUFFER_FULL state.

Don't drop packet and return error in MPP_ERR_BUFFER_FULL state.
Receive frame to allow the decoder's state machine to resume.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-09-14 21:35:54 +08:00
Timo Rothenpieler 6e63b978d3 doc/filters: fix missed reference to outdated option name 2025-09-14 15:33:31 +02:00
Timo Rothenpieler 36e374efb0 avfilter: add gfxcapture, Windows.Graphics.Capture based window/monitor capture 2025-09-14 11:45:11 +00:00
Timo Rothenpieler 7856f57533 compat/w32pthreads: fix compatibility with C++ 2025-09-14 11:45:11 +00:00
Timo Rothenpieler 5146b2fb8b configure: don't use MinGW ANSI stdio when using UCRT
MinGWs ANSI stdio is quite slow, and when using UCRT, its extra features
are not needed.
The only troublesome part with ucrt printf is that is disagrees about
the size of "long double", but FFmpeg does not use that anywhere, let
alone prints it.
2025-09-14 11:45:11 +00:00
Timo Rothenpieler 9c8a6ac85c configure: fix naming of some C++/cxx functions being mislabeled as cpp 2025-09-14 11:45:11 +00:00
Timo Rothenpieler 0ce413af9c configure: properly split C/CXX and CPP flags
Right now, CFLAGS like -std=c17 leak onto the C++ compilers commandline,
leading to tons of warnings and even some errors.

Undefining __STRICT_ANSI__ causes strong warnings from the stdlib
headers. So only set it for C.
2025-09-14 11:45:11 +00:00
Timo Rothenpieler 0362cb3806 build: link with CXX when -lstdc++ on linker commandline 2025-09-14 11:45:11 +00:00
Andreas Rheinhardt bdb81d9347 avcodec/rkmppdec: Close decoder generically on init failure
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-14 10:47:57 +00:00
Andreas Rheinhardt b02f1129eb swresample/resample, soxr_resample: Use designated initializers
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-13 21:25:40 +00:00
Timo Rothenpieler 4c80cda08a forgejo: make aarch64 asm linter part of pre-commit
Needed some minor semantical changes to the shell wrapper, since
pre-commit expects it to exit with an error when applying fixes.
2025-09-13 20:58:29 +00:00
Martin Storsjö edd1b93e53 forgejo: Check the aarch64 assembly indentation as part of the lint job
Alternatively, this could be a separate job, potentially keyed
to only run on PRs that touch files matching */aarch64/*. But
as this runs very quickly, it's probably less clutter to just
bundle it here.
2025-09-13 20:58:29 +00:00
Martin Storsjö a3ce337926 tools: Add scripts for indenting and checking aarch64 assembly
The same also applies for arm assembly, but there are more known
deviations within that.

Add a script which checks all files, except for a few known files
that deviate, for various reasons.
2025-09-13 20:58:29 +00:00
Andreas Rheinhardt 0ba0cf94db avcodec/bsf/noise: Avoid allocation for string
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-13 20:45:42 +00:00
Andreas Rheinhardt 9ae42d42e6 avcodec/dvdsubdec: Don't return value != 0 on init success
Currently, any nonnegative return value from an init function
is just treated as success and otherwise ignored; while it is
not explicitly forbidden to return something else than 0 (there
is no documentation whatsoever), the assumption is that
they return zero on success. So change dvdsubdec.c accordingly.

Also change dvdsub_parse_extradata() to return zero on success.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-13 20:37:03 +00:00
Andreas Rheinhardt 1df63acdc4 avcodec: Add av_cold to flush,init,close functions missing it
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-13 20:37:03 +00:00
Andreas Rheinhardt bc545bae3b tests/checkasm/sw_ops: Avoid 1 << 32
It is UB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-13 21:27:27 +02:00
Kacper Michajłow 1294ab5db1 swscale/ops_tmpl_int: remove unused arguments from wrap read decl
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-13 19:12:44 +02:00
Kacper Michajłow 66faef3dbe swscale/ops_chain: add type removed ff_sws_op_chain_free_cb
to avoid pointer casting and UB of calling function with different
pointer type.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-13 18:14:02 +02:00
Andreas Rheinhardt a4fd3f27f4 swscale/x86/ops: Fix leak
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 22:42:30 +02:00
Andreas Rheinhardt c74ee4ceff swscale/ops_chain: Free correct pointer on error
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 22:41:24 +02:00
Andreas Rheinhardt 6384254db2 avcodec/mpegaudiodec_template: Avoid write-only stores
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 21:39:27 +02:00
Andreas Rheinhardt 8728271097 avcodec/mpegaudiodec_template: Mark flush functions as av_cold
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 21:39:22 +02:00
Andreas Rheinhardt f611459e6f avcodec/mpegaudiodec_template: Allocate sub-contexts jointly
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 21:39:16 +02:00
Andreas Rheinhardt 84f4b9fc1f avcodec/mpegaudiodec_template: Don't modify AVCodecContext.priv_data
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 21:38:48 +02:00
Andreas Rheinhardt 87cb7c871b avcodec/pcm_tablegen: Fix hardcoded-tables if alaw,mulaw,vidc codecs disabled
Since ae448e00af the various
tableinit functions are not compiled unconditionally any more,
so that pcm_tablegen.c (which creates the hardcoded tables)
needs to be updated.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 21:37:42 +02:00
Andreas Rheinhardt f49de7018a avcodec/Makefile: Add adpcm_vima->adpcm.o dependency
Forgotten in 9141fe9653.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 17:11:26 +02:00
James Almer 799c133273 avutil/tests/aes_ctr: extend the test to cover payloads smaller than a block
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-11 18:32:24 -03:00
James Almer 335ba4a649 avutil/aes_ctr: reintroduce the block offset state
Wrongly removed in fe73b84879, it's required for
calls with a payload smaller than a full block.

Fixes issue #20474.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-11 18:32:23 -03:00
Zhao Zhili c1dc2e2b7c avcodec/videotoolboxenc: ensure bitrate is set in low_delay mode
VideoToolbox doesn't support automatic bitrate in low delay mode.
Check bitrate and show error message so user knows what's going
wrong.
2025-09-10 20:33:40 +08:00
Cameron Gutman d87210745e avcodec/videotoolboxenc: allow low latency RC with HEVC
It is supported only for H.264 on Intel Macs, but it can be used with
both H.264 and HEVC on Apple Silicon.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-09-10 11:55:18 +00:00
Tong Wu 4691c56238 forgejo/CODEOWNERS: add myself to d3d12va related files
Signed-off-by: Tong Wu <wutong1208@outlook.com>
2025-09-10 11:39:17 +00:00
Marvin Scholz 2a1d5dd720 fftools: use fopen_utf8 to open FFREPORT
Should fix #11240
2025-09-10 11:38:43 +00:00
Georgii Zagoruiko 4fbacb3944 avcodec/aarch64/vvc: Optimised version of classify function.
Macbook Air (M2):
    vvc_alf_classify_8x8_8_c:                                2.6 ( 1.00x)
    vvc_alf_classify_8x8_8_neon:                             1.0 ( 2.47x)
    vvc_alf_classify_8x8_10_c:                               2.7 ( 1.00x)
    vvc_alf_classify_8x8_10_neon:                            0.9 ( 2.98x)
    vvc_alf_classify_8x8_12_c:                               2.7 ( 1.00x)
    vvc_alf_classify_8x8_12_neon:                            0.9 ( 2.97x)
    vvc_alf_classify_16x16_8_c:                              7.3 ( 1.00x)
    vvc_alf_classify_16x16_8_neon:                           3.4 ( 2.12x)
    vvc_alf_classify_16x16_10_c:                             4.3 ( 1.00x)
    vvc_alf_classify_16x16_10_neon:                          2.9 ( 1.47x)
    vvc_alf_classify_16x16_12_c:                             4.3 ( 1.00x)
    vvc_alf_classify_16x16_12_neon:                          3.0 ( 1.44x)
    vvc_alf_classify_32x32_8_c:                             13.7 ( 1.00x)
    vvc_alf_classify_32x32_8_neon:                          10.7 ( 1.29x)
    vvc_alf_classify_32x32_10_c:                            12.3 ( 1.00x)
    vvc_alf_classify_32x32_10_neon:                          8.7 ( 1.42x)
    vvc_alf_classify_32x32_12_c:                            12.2 ( 1.00x)
    vvc_alf_classify_32x32_12_neon:                          8.7 ( 1.40x)
    vvc_alf_classify_64x64_8_c:                             45.8 ( 1.00x)
    vvc_alf_classify_64x64_8_neon:                          37.1 ( 1.23x)
    vvc_alf_classify_64x64_10_c:                            41.3 ( 1.00x)
    vvc_alf_classify_64x64_10_neon:                         32.8 ( 1.26x)
    vvc_alf_classify_64x64_12_c:                            41.4 ( 1.00x)
    vvc_alf_classify_64x64_12_neon:                         32.4 ( 1.28x)
    vvc_alf_classify_128x128_8_c:                          163.7 ( 1.00x)
    vvc_alf_classify_128x128_8_neon:                       138.3 ( 1.18x)
    vvc_alf_classify_128x128_10_c:                         149.1 ( 1.00x)
    vvc_alf_classify_128x128_10_neon:                      120.3 ( 1.24x)
    vvc_alf_classify_128x128_12_c:                         148.7 ( 1.00x)
    vvc_alf_classify_128x128_12_neon:                      119.4 ( 1.25x)

    RPi4 (Cortex-A72):
    vvc_alf_classify_8x8_8_c:                             1251.6 ( 1.00x)
    vvc_alf_classify_8x8_8_neon:                           700.7 ( 1.79x)
    vvc_alf_classify_8x8_10_c:                            1141.9 ( 1.00x)
    vvc_alf_classify_8x8_10_neon:                          659.7 ( 1.73x)
    vvc_alf_classify_8x8_12_c:                            1075.8 ( 1.00x)
    vvc_alf_classify_8x8_12_neon:                          658.7 ( 1.63x)
    vvc_alf_classify_16x16_8_c:                           3574.1 ( 1.00x)
    vvc_alf_classify_16x16_8_neon:                        1849.8 ( 1.93x)
    vvc_alf_classify_16x16_10_c:                          3270.0 ( 1.00x)
    vvc_alf_classify_16x16_10_neon:                       1786.1 ( 1.83x)
    vvc_alf_classify_16x16_12_c:                          3271.7 ( 1.00x)
    vvc_alf_classify_16x16_12_neon:                       1785.5 ( 1.83x)
    vvc_alf_classify_32x32_8_c:                          12451.9 ( 1.00x)
    vvc_alf_classify_32x32_8_neon:                        5984.3 ( 2.08x)
    vvc_alf_classify_32x32_10_c:                         11428.9 ( 1.00x)
    vvc_alf_classify_32x32_10_neon:                       5756.3 ( 1.99x)
    vvc_alf_classify_32x32_12_c:                         11252.8 ( 1.00x)
    vvc_alf_classify_32x32_12_neon:                       5755.7 ( 1.96x)
    vvc_alf_classify_64x64_8_c:                          47625.5 ( 1.00x)
    vvc_alf_classify_64x64_8_neon:                       21071.9 ( 2.26x)
    vvc_alf_classify_64x64_10_c:                         44576.3 ( 1.00x)
    vvc_alf_classify_64x64_10_neon:                      21544.7 ( 2.07x)
    vvc_alf_classify_64x64_12_c:                         44600.5 ( 1.00x)
    vvc_alf_classify_64x64_12_neon:                      21491.2 ( 2.08x)
    vvc_alf_classify_128x128_8_c:                       192143.3 ( 1.00x)
    vvc_alf_classify_128x128_8_neon:                     82387.6 ( 2.33x)
    vvc_alf_classify_128x128_10_c:                      177583.1 ( 1.00x)
    vvc_alf_classify_128x128_10_neon:                    81628.8 ( 2.18x)
    vvc_alf_classify_128x128_12_c:                      177582.2 ( 1.00x)
    vvc_alf_classify_128x128_12_neon:                    81625.1 ( 2.18x)
2025-09-09 22:13:04 +01:00
Krzysztof Pyrkosz de25cb4603 avcodec/aarch64/vvc: Optimize vvc_apply_bdof_block_8x
Before and after:
A53:
apply_bdof_8_8x16_neon:                               3320.5 ( 4.02x)
apply_bdof_10_8x16_neon:                              3317.8 ( 3.90x)
apply_bdof_12_8x16_neon:                              3303.6 ( 3.91x)

apply_bdof_8_8x16_neon:                               3168.1 ( 4.23x)
apply_bdof_10_8x16_neon:                              3127.8 ( 4.13x)
apply_bdof_12_8x16_neon:                              3119.3 ( 4.18x)

A72:
apply_bdof_8_8x16_neon:                               1827.4 ( 5.02x)
apply_bdof_10_8x16_neon:                              1838.5 ( 4.89x)
apply_bdof_12_8x16_neon:                              1841.1 ( 4.83x)

apply_bdof_8_8x16_neon:                               1691.6 ( 5.46x)
apply_bdof_10_8x16_neon:                              1695.9 ( 5.23x)
apply_bdof_12_8x16_neon:                              1695.4 ( 5.29x)

A78
apply_bdof_8_8x16_neon:                                648.9 ( 7.43x)
apply_bdof_10_8x16_neon:                               646.1 ( 7.04x)
apply_bdof_12_8x16_neon:                               643.8 ( 7.04x)

apply_bdof_8_8x16_neon:                                603.2 ( 7.97x)
apply_bdof_10_8x16_neon:                               604.1 ( 7.52x)
apply_bdof_12_8x16_neon:                               604.5 ( 7.52x)
2025-09-09 16:37:28 +00:00
Niklas Haas 5f39965dd6 avfilter/buffersink: remove unneeded parameter
This is a newly added field, so there's no point to try and keep backwards
compatibility with an older API - newer clients should just use the new
fields.
2025-09-09 14:52:01 +02:00
averne 5aa541c690 fate/prores: Fix missing dependency
Signed-off-by: averne <averne381@gmail.com>
2025-09-09 12:04:05 +00:00
James Almer 05b6b30ee1 fftools/ffplay: set the alphamodes buffersink array option instead of the binary one
And add the missing goto fail. This should ensure the alpha mode is set and remove
bogus warnings printed by ffplay.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-08 18:38:16 -03:00
James Almer 23b759e99e avfilter/buffersink: add missing checks for alphamodes
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-08 18:38:16 -03:00
Frank Plowman e9a6b75373 lavc/cbs: Make error message more descriptive 2025-09-08 21:13:09 +00:00
dariusz-f c75439a93b Update libavformat/apvdec.c
Increase au_size limit by 4 times to fit more complex videos.

Signed-off-by: dariusz-f <dariusz-f@noreply.code.ffmpeg.org>
2025-09-08 20:59:31 +00:00
Dariusz Frankiewicz 002a940ca6 avformat/apv: fix range of au_size
Acces unit size is described in documentation as > 0 < 0xFFFFFFFF

Signed-off-by: Dariusz Frankiewicz <d.frankiewic@samsung.com>
2025-09-08 20:59:31 +00:00
Zhao Zhili 09856e4e48 doc/examples/vaapi_encode: fix invalid check on fwrite
enc_pkt->size is 0 after av_packet_unref, which makes the check invalid.

Fix regression from 3e4bfff2.

Co-Authored-by: Jin Bo <jinbo@loongson.cn>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-09-08 20:43:07 +00:00
Krzysztof Pyrkosz 7b21bde34c avcodec/aarch64/vvc: Implemented dmvr_h_10
A78:
dmvr_h_10_12x20_neon:                                   82.2 ( 6.49x)
dmvr_h_10_20x12_neon:                                   69.9 ( 3.66x)
dmvr_h_10_20x20_neon:                                  112.5 ( 3.74x)
dmvr_h_12_12x20_neon:                                   81.4 ( 6.51x)
dmvr_h_12_20x12_neon:                                   69.2 ( 3.74x)
dmvr_h_12_20x20_neon:                                  110.2 ( 3.85x)

A72:
dmvr_h_10_12x20_neon:                                  234.1 ( 4.67x)
dmvr_h_10_20x12_neon:                                  221.4 ( 3.48x)
dmvr_h_10_20x20_neon:                                  356.9 ( 3.59x)
dmvr_h_12_12x20_neon:                                  234.1 ( 4.67x)
dmvr_h_12_20x12_neon:                                  221.5 ( 3.53x)
dmvr_h_12_20x20_neon:                                  357.0 ( 3.64x)
2025-09-08 17:51:20 +00:00
Krzysztof Pyrkosz 189e841cfd avcodec/aarch64/vvc: Implement dmvr_h_8
A78:
dmvr_h_8_12x20_neon:                                    76.6 ( 4.31x)
dmvr_h_8_20x12_neon:                                    65.8 ( 3.49x)
dmvr_h_8_20x20_neon:                                   106.6 ( 3.62x)

A72:
dmvr_h_8_12x20_neon:                                   190.6 ( 4.40x)
dmvr_h_8_20x12_neon:                                   171.1 ( 4.31x)
dmvr_h_8_20x20_neon:                                   275.1 ( 4.50x)
2025-09-08 17:51:20 +00:00
Dmitrii Ovchinnikov 1b97966199 avutil/hwcontext_d3d12va: added resource and heap flags to DeviceContext 2025-09-08 15:44:47 +00:00
DE-AI fbbb2996d5 vc1_parser: Reset unesc_index after extracting header with complete frames
When PARSER_FLAG_COMPLETE_FRAMES is set (e.g. in Matroska),
unesc_index is not reset after the first frame, which causes
subsequent frames to inherit leftover header data.

This leads to incorrect keyframe marking and broken decoding.

See also this bug report: https://trac.ffmpeg.org/ticket/8515

Signed-off-by: DE-AI <max.christoph@pentaxmedical.com>
2025-09-08 14:03:52 +00:00
Niklas Haas 1f2de0f618 avfilter/vf_libplacebo: ensure linear tex is blittable
Required to clear textures to a background color.
2025-09-08 15:42:01 +02:00
Timo Rothenpieler f8a300c673 configure: fix CUDA compilation with SDK version 13 nvcc
Compute Capability 7.5 is now the lowest supported version.

Fixes #20454
2025-09-08 14:25:44 +02:00
Tong Wu 45db6945e9 avcodec/vaapi_encode: avoid potential overflow
The max_frame_size in byte will be filled in
VAEncMiscParameterBufferMaxFrameSize which receives size in bit.
This requires max_frame_size * 8.

Signed-off-by: Tong Wu <wutong1208@outlook.com>
2025-09-08 00:19:06 +00:00
Alan Kelly f4b044bbe3 swscale: Disable avx2 hscale 8to15 on IceLake and below due to Intel Gather Data Sampling mitigation performance loss
Intel provided a microcode update to mitigate this security
    vulnerability which has a huge negative performance impact on gather
    instructions. This means that hscale 8to15 avx2, which uses gather
    extensively, is no longer faster than SSSE3 on impacted CPUs.

    https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/technical-documentation/gather-data-sampling.html

    Broadwell:
    hscale_8_to_15__fs_4_dstW_512_c:                      3379.5 ( 1.00x)
    hscale_8_to_15__fs_4_dstW_512_sse2:                    615.7 ( 5.49x)
    hscale_8_to_15__fs_4_dstW_512_ssse3:                   613.4 ( 5.51x)
    hscale_8_to_15__fs_4_dstW_512_avx2:                    495.7 ( 6.82x)

    Skylake:
    hscale_8_to_15__fs_4_dstW_512_c:                      3411.4 ( 1.00x)
    hscale_8_to_15__fs_4_dstW_512_sse2:                    591.0 ( 5.77x)
    hscale_8_to_15__fs_4_dstW_512_ssse3:                   591.5 ( 5.77x)
    hscale_8_to_15__fs_4_dstW_512_avx2:                   1386.2 ( 2.46x)

    Cascade Lake:
    hscale_8_to_15__fs_4_dstW_512_c:                      3231.3 ( 1.00x)
    hscale_8_to_15__fs_4_dstW_512_sse2:                    517.9 ( 6.24x)
    hscale_8_to_15__fs_4_dstW_512_ssse3:                   521.6 ( 6.19x)
    hscale_8_to_15__fs_4_dstW_512_avx2:                   1775.0 ( 1.82x)

    Sapphire Rapids:
    hscale_8_to_15__fs_4_dstW_512_c:                      1840.0 ( 1.00x)
    hscale_8_to_15__fs_4_dstW_512_sse2:                    287.9 ( 6.39x)
    hscale_8_to_15__fs_4_dstW_512_ssse3:                   293.8 ( 6.26x)
    hscale_8_to_15__fs_4_dstW_512_avx2:                    219.2 ( 8.40x)
2025-09-06 20:57:48 +00:00
Leo Izen 1dcb0c6c3e avcodec/libjxldec: consume input on error
libjxl consumes no input if it returns an error, so this loops over
and over while it spits out the same error many times. If we got an
error from libjxl and consumed no input, then we instead consume the
whole packet.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-09-06 15:51:41 -04:00
Leo Izen 74e61981b5 avcodec/decode: treat orientation 1 as valid displaymatrix
Since 9dc79241d9 we now always pop the
orientation off of the IFD and use a display matrix instead. This means
we should not produce a warning and refuse if the orientation field
indicates a default orientation (i.e. 1).

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reported-by: Ramiro Polla <ramiro.polla@gmail.com>
2025-09-06 13:15:24 -04:00
Zhao Zhili 742474bc24 avformat/mov: fix unused variable entry in parse_exif_item 2025-09-06 15:11:48 +00:00
Zhao Zhili 1ca2c68278 avcodec/pcm: fix some unused variables/functions warning
v is unused when ALAW/MULAW/VIDC are disabled.
2025-09-06 15:11:48 +00:00
Zhao Zhili ca1ab8815c avcodec/pcm: use stricter conditional expressions for compilation 2025-09-06 15:11:48 +00:00
Andreas Rheinhardt 893250a734 avfilter/Makefile: Add dependencies for premultiply_dynamic filter
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-06 16:06:31 +02:00
Jack Lau adc66f30ee configure: remove openssl version check for whip
This version check for whip is unnecessary.
Since several rencet patches to the configure
have already added version checks for OpenSSL.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-06 11:27:54 +00:00
Marton Balint 7321e4b950 avformat/img2dec: support arbitrary path lengths
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
Marton Balint 8703dd74bd avformat/img2dec: remove path limits from find_image_range
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
Marton Balint 69d9c074ef avformat/img2dec: do not use av_get_frame_filename result buffer if the call fails
We have no way of knowing if the string was fully processed or got truncated
because of a parse error so it is better to use the original path if finding an
image sequence fails.

We do this by explicitly falling back to the PT_NONE mode if the provided
filename is not a valid pattern but the file exists or if the IO context is
already open.

This also means that filenames no longer need to be escaped even in sequence
mode if an invalid sequence (a sequence without %d) is provided, so a command
line such as ffmpeg -f image2 -i "100%.jpg" will just work, but "100%%.jpg"
will no longer work.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
Marton Balint 8c1301cf9d avformat/webm_chunk: support for arbitrary path lengths
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
Marton Balint 35ceef40ad avformat/segment: support arbitrary path lengths
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
Marton Balint 4b8be1991c avformat/utils: support arbitrary path lengths for av_filename_number_test
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
Marton Balint 9458a6f8ec avformat/utils: add AV_FRAME_FILENAME_FLAGS_IGNORE_TRUNCATION flag
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
caifan3 7a1c737c35 libavcodec/v4l2_buffers: avoid redefinition of USEC_PER_SEC macro
The macro USEC_PER_SEC is already defined in system headers on some platforms,such as Nuttx nuttx/clock.h.
Check if it's already defined before defining it to avoid compiler warnings.

Signed-off-by: caifan3 <caifan3@xiaomi.com>
2025-09-05 17:21:30 +00:00
Dmitrii Ovchinnikov 6891314db1 MAINTAINERS: Update the entries for AMF
MAINTAINERS: Update the entries for AMF

Alphabetized the records
2025-09-05 17:52:46 +02:00
Dmitrii Ovchinnikov 8450d87ea5 forgejo/CODEOWNERS: add myself for relevant files 2025-09-05 17:52:46 +02:00
Martin Storsjö f6bcd661f0 configure: Improve the check for schannel DTLS constants
This amends 307983b292 to fix
building with older versions of mingw-w64.

The previously checked constant, SP_PROT_DTLS1_X_CLIENT, was
added in mingw-w64 in df36f5deda23192d0ee99ffd661ea36df924e667
in 2020, and is included in released versions since v8.0.0.

The new checked constant SECPKG_ATTR_DTLS_MTU was added in
mingw-w64 in 0792283787cca8fc27dd38671107c791c87f4db3 in 2021,
and first appeared in mingw-w64 v9.0.0.

This fixes building with mingw-w64 v8, which is the version bundled
in Ubuntu 22.04.
2025-09-05 12:20:11 +00:00
Zhao Zhili fc45127bcc avcodec/videotoolboxenc: support global_quality without qscale 2025-09-05 09:20:36 +00:00
Zhao Zhili 73750489a6 avcodec/videotoolboxenc: fix the loss of precision when calculating quality 2025-09-05 09:20:36 +00:00
Krzysztof Pyrkosz fb4407797e Replace uxtl with umull in dmvr_hv_8
Before and after on A78:
dmvr_hv_8_12x20_neon:                                  205.3 ( 5.21x)
dmvr_hv_8_20x12_neon:                                  171.8 ( 3.15x)
dmvr_hv_8_20x20_neon:                                  282.7 ( 3.11x)

dmvr_hv_8_12x20_neon:                                  172.7 ( 5.58x)
dmvr_hv_8_20x12_neon:                                  133.3 ( 3.36x)
dmvr_hv_8_20x20_neon:                                  214.6 ( 3.40x)
2025-09-05 07:20:15 +00:00
Jack Lau 85b5d4adf2 avformat/tls_gnutls: cleanup the pointer name
Pure cleanup, no functional changes
Unify local pointer names to `TLSContext *c` and `TLSShared *s` to
reduce confusion from inconsistent names (e.g. p, s, c)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 04:31:07 +00:00
Jack Lau 3c7315c345 avformat/whip: simplify the udp read in whip_write_packet
Reduce nested if statements to make the code structure clearer

Add logic to check if EOF is received from UDP socket.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 04:29:39 +00:00
Jack Lau 785a4e0d6c avformat/whip: fix potential 8bit overflow for profile_idc
The profile contains profile_idc and constraint_set*_flag,
throws away high 8 bit flags and then we get profile_idc.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 04:28:55 +00:00
Jack Lau 6c2768bf8c avformat/whip: fix 8 bits overflow and map constraint_set bits for H264
profile_iop is an 8 bits field. Previous code copied
AVCodecParameters::profile (which can contain bits
beyond 8 bits) into profile_iop, producing overflow
and wrong values.

This patch maps the constrained flags into the proper
profile_iop bits (constraint_set1 / 3)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 04:28:55 +00:00
Jack Lau 39a63e3d07 avformat/whip: make time measure more precise
Use av_gettime_relative() replace av_gettime() to get
better measure

Changed the display precision from showing only integers
to showing two decimal places (in milliseconds)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 04:28:24 +00:00
Jack Lau b41f8207c4 avformat/whip: fix SDP ICE candidates parsing
fix issue #20407

Refer to RFC 5245 15.1,
the foundation may be any string up to 32 chars.
The old code could misread foundations as transport("udp").
This patch fully parse all these attr to avoid parsing error.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 04:27:51 +00:00
Jack Lau 7fd967c2c1 avformat/whip: add PRIORITY and ICE_CONTROLLING for STUN binding request
fix issue #20402

See RFC 8445 7.1,
The PRIORITY and ICE-CONTROLLED or ICE-CONTROLLING must be included
in a Binding request.

FFmpeg is always ICE Controlling role so we use ICE-CONTROLLING attr.

Co-author-by: Sergio Garcia Murillo <sergio.garcia.murillo@gmail.com>
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 01:21:28 +00:00
Niklas Haas 8ff34b29c7 fate/filter-audio: update acrossfade to test multiple inputs 2025-09-04 23:12:34 +00:00
Niklas Haas dfc3256da1 avfilter/af_afade: support multiple inputs
Instead of just 2 files, generalize this filter to support crossfading
arbitrarily many files. This makes the filter essentially operate similar
to the `concat` filter, chaining multiple files one after another.

Aside from just adding more input pads, this requires rewriting the
activate function. Instead of a finite state machine, we keep track of the
currently active input index; and advance it only once the current input is
fully exhausted.

This results in arguably simpler logic overall.
2025-09-04 23:12:34 +00:00
Niklas Haas 81c1004891 avfilter/af_afade: shorten crossfade on too short inputs
This behavior is currently completely broken, leading to an abrupt end of the
first audio stream. I want to generalize this filter to multiple inputs, but
having too short input files will always represent a significant problem.

I considered a few approaches for how to handle this more gracefully, but
most of them come with their own problems; in particular when a short input
is sandwiched between two longer ones; or when there is a sequence of short
inputs. In the end, it's simplest to just shorten the crossfade window.

I also considered (and tested) padding the input with silence, but this also
has its own aesthetic implications and strange edge cases.

See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20388
2025-09-04 23:12:34 +00:00
Niklas Haas 2e0885a091 avfilter/af_afade: don't leak memory on error
This first frame was never cleaned up if the second input fails.
2025-09-04 23:12:34 +00:00
Niklas Haas 386264ae16 avfilter/af_afade: generalize pass_crossfade() signature
Prerequisite to an upcoming refactor.
2025-09-04 23:12:34 +00:00
Andreas Rheinhardt 2451e06f19 all: Use "" instead of <> to include internal headers
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-04 22:20:58 +02:00
Andreas Rheinhardt 7dc4c4f6f5 swscale/ops: Fix linking with x86 assembly disabled
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-04 22:14:39 +02:00
Ramiro Polla 6696a9b8bd avcodec/mjpegdec: ignore APPx stubs unless AV_EF_EXPLODE is set
Consider APPx fields that are too short to contain an id field (32-bit)
as stubs, and ignore them if AV_EF_EXPLODE is not set.

This has been seen in the MJPEG output from some webcams (such as the
Logitech C270 and C920) and the JPEG images embedded in DNG images
from the Pentax K-1 camera.
2025-09-04 15:28:41 +00:00
Ramiro Polla e207520b82 avcodec/mjpegdec: fix skipping of bytes for unknown APPx markers
The loop to skip the remaining bytes was off by one for all markers
except for Adob.

This patch uses post-decrement instead of pre-decrement in the while
loop to make the len value easier to understand, and updates the len
value to reflect this change for the Adob marker.
2025-09-04 15:28:41 +00:00
Andrey Semashev 9ee7796c54 avcodec/librsvgdec: fix compilation with librsvg 2.50.3
This fixes compilation with librsvg 2.50.3: error: viewport undeclared

This was a regression since commit
86ed68420d.

Fixes #10722.

Reviewed-by: Leo Izen <leo.izen@gmail.com>
2025-09-04 07:01:13 -04:00
Andreas Rheinhardt 2611874a50 avcodec/cbrt_tablegen: Deduplicate common code
Namely the part that creates a temporary LUT.

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-04 10:15:09 +02:00
Andreas Rheinhardt 9bacefc41e avcodec/cbrt_tablegen: Avoid LUT only used once
This can be done by reusing the destination array to store
a temporary LUT (with only half the amount of elements, but
double the element size). This relies on certain assumptions
about sizes, but they are always fulfilled for systems supported
by us (sizeof(double) == 8 is needed/guaranteed since commit
3383a53e7d). Furthermore,
sizeof(uint32_t) is always >= four because CHAR_BIT is eight
(in fact, sizeof(uint32_t) is four, because the exact width
types don't have any padding).

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-04 10:15:03 +02:00
Andreas Rheinhardt cd337c46d5 avcodec/cbrt_tablegen: Reduce size of LUT only used once
ff_cbrt_tableinit{,_fixed}() uses a LUT of doubles of the same size
as the actual LUT to be initialized (8192 elems). Said LUT is only
used to initialize another LUT, but because it is static, the dirty
memory (64KiB) is not released. It is also too large to be put on
the stack.

This commit mitigates this: We only use a LUT for the powers of
odd values, thereby halving its size. The generated LUT stays unchanged.

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-04 10:14:53 +02:00
Andreas Rheinhardt 77e5e61f1a avcodec/cbrt_tablegen: Remove always-false branch
Each ff_cbrt_tableinit*() is called at most once, making this
check always-false.

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-04 10:12:25 +02:00
Cameron Gutman 37f02603b1 avutil/hwcontext_drm: fix mapping when dst format is unset
av_hwframe_map() is documented to work with a blank dst frame, but
hwcontext_drm currently fails if dst->format == AV_PIX_FMT_NONE.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-09-03 20:21:51 -05:00
Wu Jianhua 858aa6176b avutil/version: bump minor after recent change
See c2ce387385

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-09-03 22:34:40 +00:00
Andreas Rheinhardt 79058e7014 avformat/demux: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-03 21:10:21 +00:00
Andreas Rheinhardt e6c03711aa avformat/demux: Avoid always-true branch
Since 9d037c54f2 id3v2_extra_meta
can only be != NULL if the input format wants ID3v2 tags to be
read generically.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-03 21:10:21 +00:00
Andreas Rheinhardt e918e202e0 avformat/avformat: Make AVFMT_FLAG_ID3V2_AUTO private
This flag governs whether avformat_open_input() reads
ID3v2 tags generically; some demuxers without this flag
read these tags themselves in a non-generic way,
e.g. oma. This makes this flag an implementation detail
that should not be exposed to the user, i.e. an internal flag.

Given that 9d037c54f2
did not bump version and added no APIchanges entry
I deemded it inappropriate to bump version or add
an APIchanges entry for the removal of AVFMT_FLAG_ID3V2_AUTO.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-03 21:10:21 +00:00
Martin Storsjö a3360c0eaf swscale: Don't pass a concrete SwsOpPriv as parameter
This fixes the following compiler error, if compiling with MSVC
for ARM (32 bit):

    src/libswscale/ops_chain.c(48): error C2719: 'priv': formal parameter with requested alignment of 16 won't be aligned

This change shouldn't affect the performance of this operation
(which in itself probably isn't relevant); instead of copying the
contents of the SwsOpPriv struct from the stack as parameter,
it gets copied straight from the caller function's stack frame
instead.

Separately from this issue, MSVC 17.8 and 17.9 end up in an
internal compiler error when compiling libswscale/ops.c, but
older and newer versions do compile it successfully.
2025-09-03 20:18:03 +00:00
nilfm 9d037c54f2 avformat/demux: avoid unconditional ID3v2 tag consumption
ID3v2 headers are now only parsed for formats that explicitly support them,
avoiding premature data consumption that broke demuxing in other formats.

Introduces AVFMT_FLAG_ID3V2_AUTO and applies it to mp3, aac, tta, and wav.

Signed-off-by: nilfm <nil.fons@gmail.com>
2025-09-03 10:44:02 -07:00
Andreas Rheinhardt cd21fa41c7 avformat/aviobuf: Don't pretend to support avio_context_free(NULL)
It makes no sense to ever call it that way given that
avio_context_free() accepts a pointer to a pointer to an AVIOContext.
Other double-pointer-free functions like av_freep() also do it
that way (and therefore avio_context_free(NULL) still crashes
even with 870cfed231).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-03 15:51:51 +02:00
Andreas Rheinhardt 66e40840d1 avcodec/pcm_tablegen: Fix CONFIG_HARDCODED_TABLES
Broken in ae448e00af.
Notice that config_components.h is safe to include,
as it is valid for both the host and the target
(in contrast to config.h).

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-03 14:13:37 +02:00
Araz Iusubov c2ce387385 avcodec/d3d12va_encode: texture array support for HEVC
This patch adds support for the texture array feature
used by AMD boards in the D3D12 HEVC encoder.
In texture array mode, a single texture array is shared for all
reference and reconstructed pictures using different subresources.
The implementation ensures compatibility
and has been successfully tested on AMD, Intel, and NVIDIA GPUs.
2025-09-03 11:56:06 +02:00
Zhao Zhili 6ce02bcc3a avcodec/aarch64/vvc: Optimize apply_bdof
Before this patch, prof_grad_filter calculate
gh[0], gh[1], gv[0], gv[1] and save them to stack.

derive_bdof_vx_vy load them from stack and calculate
gh[0] + gh[1], gv[0] + gv[1].

apply_bdof_min_block load them from stack and calculate
gh[0] - gh[1], gv[0] - gv[1]

This patch add bdof_grad_filter, which calculate gh[0] + gh[1],
gh[0] - gh[1], gv[0] + gv[1], gv[0] - gv[1], and save them to
stack, so derive_bdof_vx_vy and apply_bdof_min_block can use the
results directly.

prof_grad_filter is kept for reuse by other functions in the future.

Benchmark on rpi5 with gcc 12
                               Before               After
--------------------------------------------------------------------
apply_bdof_8_8x16_c:       |   7431.4 ( 1.00x)   |   7371.7 ( 1.00x)
apply_bdof_8_8x16_neon:    |   1175.4 ( 6.32x)   |   1036.3 ( 7.11x)
apply_bdof_8_16x8_c:       |   7182.2 ( 1.00x)   |   7201.1 ( 1.00x)
apply_bdof_8_16x8_neon:    |   1021.7 ( 7.03x)   |    879.9 ( 8.18x)
apply_bdof_8_16x16_c:      |  14577.1 ( 1.00x)   |  14589.3 ( 1.00x)
apply_bdof_8_16x16_neon:   |   2012.8 ( 7.24x)   |   1743.3 ( 8.37x)
apply_bdof_10_8x16_c:      |   7292.4 ( 1.00x)   |   7308.5 ( 1.00x)
apply_bdof_10_8x16_neon:   |   1156.3 ( 6.31x)   |   1045.3 ( 6.99x)
apply_bdof_10_16x8_c:      |   7112.4 ( 1.00x)   |   7214.4 ( 1.00x)
apply_bdof_10_16x8_neon:   |   1007.6 ( 7.06x)   |    904.8 ( 7.97x)
apply_bdof_10_16x16_c:     |  14363.3 ( 1.00x)   |  14476.4 ( 1.00x)
apply_bdof_10_16x16_neon:  |   1986.9 ( 7.23x)   |   1783.1 ( 8.12x)
apply_bdof_12_8x16_c:      |   7433.3 ( 1.00x)   |   7374.7 ( 1.00x)
apply_bdof_12_8x16_neon:   |   1155.9 ( 6.43x)   |   1040.8 ( 7.09x)
apply_bdof_12_16x8_c:      |   7171.1 ( 1.00x)   |   7376.3 ( 1.00x)
apply_bdof_12_16x8_neon:   |   1010.8 ( 7.09x)   |    899.4 ( 8.20x)
apply_bdof_12_16x16_c:     |  14515.5 ( 1.00x)   |  14731.5 ( 1.00x)
apply_bdof_12_16x16_neon:  |   1988.4 ( 7.30x)   |   1785.2 ( 8.25x)
2025-09-03 06:55:37 +00:00
Zhao Zhili 2e92417603 avcodec/aarch64/vvc: Optimize derive_bdof_vx_vy
Implement line tricks and pixel tricks. See comments in inter.S
for details.

Benchmark on rpi5 with gcc 12
                               Before             After
-----------------------------------------------------------------
apply_bdof_8_8x16_c:       |   7375.5 ( 1.00x) |  7473.8 ( 1.00x)
apply_bdof_8_8x16_neon:    |   1875.1 ( 3.93x) |  1135.8 ( 6.58x)
apply_bdof_8_16x8_c:       |   7273.9 ( 1.00x) |  7204.0 ( 1.00x)
apply_bdof_8_16x8_neon:    |   1738.2 ( 4.18x) |  1013.0 ( 7.11x)
apply_bdof_8_16x16_c:      |  14744.9 ( 1.00x) | 14712.6 ( 1.00x)
apply_bdof_8_16x16_neon:   |   3446.7 ( 4.28x) |  1997.7 ( 7.36x)
apply_bdof_10_8x16_c:      |   7352.4 ( 1.00x) |  7485.7 ( 1.00x)
apply_bdof_10_8x16_neon:   |   1861.0 ( 3.95x) |  1134.1 ( 6.60x)
apply_bdof_10_16x8_c:      |   7330.5 ( 1.00x) |  7232.8 ( 1.00x)
apply_bdof_10_16x8_neon:   |   1747.2 ( 4.20x) |  1002.6 ( 7.21x)
apply_bdof_10_16x16_c:     |  14522.4 ( 1.00x) | 14664.8 ( 1.00x)
apply_bdof_10_16x16_neon:  |   3490.5 ( 4.16x) |  1978.4 ( 7.41x)
apply_bdof_12_8x16_c:      |   7389.0 ( 1.00x) |  7380.1 ( 1.00x)
apply_bdof_12_8x16_neon:   |   1861.3 ( 3.97x) |  1134.0 ( 6.51x)
apply_bdof_12_16x8_c:      |   7283.1 ( 1.00x) |  7336.9 ( 1.00x)
apply_bdof_12_16x8_neon:   |   1749.1 ( 4.16x) |  1002.3 ( 7.32x)
apply_bdof_12_16x16_c:     |  14580.7 ( 1.00x) | 14502.7 ( 1.00x)
apply_bdof_12_16x16_neon:  |   3472.9 ( 4.20x) |  1978.3 ( 7.33x)

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-09-03 06:55:37 +00:00
damitha 3800421e7c add clamping for escpase coeff 2025-09-03 06:48:02 +00:00
Niklas Haas a700f0f72d avfilter/vf_zscale: simplify and fix alpha handling
There's no reason to use a completely separate graph just to process the
alpha plane in isolation - zimg supports native alpha handling as part of the
main image.

Fixes several issues with this filter when adding or removing alpha planes,
and also adds support for scaling premultiplied alpha (which reduces artefacts
near the image borders).
2025-09-02 17:06:25 +02:00
Niklas Haas c7adeb75ac avfilter/vf_scale: require straight alpha for alpha blending
Fortunately, we only care if this flag is set - otherwise, this filter is
alpha mode agnostic (since it is purely scaling, etc).

That said, there is an argument to be made that we should prefer premul
alpha when scaling, because scaling in straight alpha will leak garbage
pixels; but I think that would be a too backwards-incompatible change to
be worth thinking about at this time.
2025-09-02 17:06:25 +02:00
Niklas Haas 446a25b70f avfilter: add alpha_mode consistency assertion 2025-09-02 17:06:25 +02:00
Niklas Haas 39631c99d4 avfilter/drawutils: add alpha mode support
This allows drawing colors onto images with premultiplied alpha, by first
premultiplying the specified RGBA values.
2025-09-02 17:06:25 +02:00
Niklas Haas a90e8f1c1d avfilter: use ff_draw_init_from_link() where possible 2025-09-02 17:06:25 +02:00
Niklas Haas eddbdc8b7c avfilter/drawutils: add ff_draw_init_from_link()
The overwhelming majority of references to ff_draw_init2() just set the
colorspace properties from a filter link. This wrapper allows us to update
all such referencen automatically.
2025-09-02 17:06:25 +02:00
Niklas Haas d05484757a avfilter/vf_fade: set correct alpha mode requirement
Fading to black in non-alpha mode works for either straight or premultiplied
alpha, but fading to a color does not.
2025-09-02 17:06:25 +02:00
Niklas Haas ba8aa0e7b3 avfilter/x86/vf_overlay: simplify function signature
No reason to pass all the variables again, if we're already passing the
context.
2025-09-02 17:06:25 +02:00
Niklas Haas 59bb51a8f2 avfilter/vf_overlay: support premultiplied base layers
Conceptually, these are pretty simple to handle, since they are basically
equivalent to the case of alpha being absent, since the only thing the
destination alpha plane is used for is unpremultiplyng straight alpha.

For planar formats, the total number of cases doesn't change in principle,
since before this patch we have:

- alpha present, overlay straight
- alpha present, overlay premultiplied
- alpha absent, overlay straight
- alpha absent, overlay premultiplied

And now we have:

- main straight, overlay straight
- main straight, overlay premultiplied
- main premultiplied, overlay straight
- main premultiplied, overlay premultiplied

That said, we do gain some cases now that we used to (incorrectly) ignore,
like premultiplied yuva420p10.

Notably, we can skip defining separate functions for the case of main alpha
being absent, since that can be a single cheap branch inside the function
itself, on whether or not to also process the alpha plane. Otherwise, as long
as we treat "alpha absent" as "main premultiplied", the per-plane logic will
skip touching the nonexistent alpha plane.

The only format that actually needs extra cases is packed rgb, but that's only
two additional cases in total.

Also arguably simplifies the assignment logic massively.
2025-09-02 17:06:25 +02:00
Niklas Haas 6d6bbdaab0 avfilter/vf_overlay: rename variables for clarity
`is_straight`, `alpha_mode` etc. are more consistently named to refer to
either the main image, or the overlay.
2025-09-02 17:06:25 +02:00
Niklas Haas 6f3eddbedd avfilter/vf_overlay: configure alpha mode on the link
And use the link-tagged value instead of the hard-coded parameter.
2025-09-02 17:06:25 +02:00
Niklas Haas 1c8ca56a88 avfilter/vf_libplacebo: add an alpha_mode setting
Chooses the desired output alpha mode. Note that this depends on
an upstream version of libplacebo new enough to respect the corresponding
AVFrame field in pl_map_avframe_ex.
2025-09-02 17:06:25 +02:00
Niklas Haas dc02514f6b avfilter/vf_setparams: add alpha_mode parameter 2025-09-02 17:06:25 +02:00
Niklas Haas e6ab7fe582 avfilter/vf_scale: set correct alpha mode after format change
While vf_scale cannot directly convert between premultiplied and straight
alpha, the effective tagging can still change as a result of a change in
the pixel format (i.e. adding or removing an alpha channel).
2025-09-02 17:06:25 +02:00
Niklas Haas a3d518a57c avfilter/vf_extractplanes: require straight alpha input 2025-09-02 17:06:25 +02:00
Niklas Haas ab1bc440f7 avfilter/vf_alphamerge: configure correct alpha mode 2025-09-02 17:06:25 +02:00
Niklas Haas 2032820e90 fftools/ffprobe: add AVFrame.alpha_mode support 2025-09-02 17:06:25 +02:00
Niklas Haas 4f99026c9f fftools/ffplay: add alpha_mode support
SDL seems to hard-code straight alpha compositing.
2025-09-02 17:06:25 +02:00
Niklas Haas f07573f496 fftools/ffmpeg: add alpha_mode support
The implementation exactly mirrors the existing plumbing for color_ranges
and color_spaces.
2025-09-02 17:06:25 +02:00
Niklas Haas 2e2ca4e740 avfilter/vf_showinfo: print alpha mode when relevant 2025-09-02 17:06:25 +02:00
Niklas Haas 2b1ef029eb avfilter/vf_format: add alpha_modes parameter 2025-09-02 17:06:25 +02:00
Niklas Haas de297ae2fc avfilter/buffersrc: add alpha_mode parameter 2025-09-02 17:06:25 +02:00
Niklas Haas 0fbd90d78f avfilter/buffersink: add support for alpha modes 2025-09-02 17:06:25 +02:00
Niklas Haas 65580592c9 avcodec/jpegxl: parse and signal correct alpha mode
This header bit ("alpha_associated") was incorrectly ignored.
2025-09-02 17:06:25 +02:00
Niklas Haas 51572ff08a avcodec/libjxlenc: also attach extra channel info
Works around a bug where older versions of libjxl don't correctly forward
the alpha channel information to the extra channel info.
2025-09-02 17:06:25 +02:00
Niklas Haas a88cc0a53e avcodec/libjxl: set correct alpha mode
JPEG XL supports both premultiplied and straight alpha, and the basic info
struct contains signalling for this. Forward the correct tagging on decode
and encode.
2025-09-02 17:06:25 +02:00
Niklas Haas 702a5ac29b avcodec/exr: set correct alpha mode
OpenEXR always uses premultiplied alpha, as per the spec.

cf. https://openexr.com/en/latest/TechnicalIntroduction.html

> By convention, all color channels are premultiplied by alpha, so that
> `foreground + (1-alpha) x background` performs a correct “over” operation.
> (See Premultiplied vs. Un-Premultiplied Color Channels)
>
> In the visual effects industry premultiplied color channels are the norm,
> and application software packages typically use internal image
> representations that are also premultiplied.
2025-09-02 17:06:25 +02:00
Niklas Haas d6ce720765 avcodec/png: set correct alpha mode
PNG always uses straight alpha.

cf. https://www.w3.org/TR/PNG-Rationale.html

> Although each form of alpha storage has its advantages, we did not want to
> require all PNG viewers to handle both forms. We standardized on non-
> premultiplied alpha as being the lossless and more general case.
2025-09-02 17:06:25 +02:00
Niklas Haas 02d531ca05 avcodec/encode: enforce alpha mode compatibility at encode time
Error out if trying to encode frames with an incompatible alpha mode.
2025-09-02 17:06:25 +02:00
Niklas Haas ecebf9c693 avcodec/avcodec: add AVCodecContext.alpha_mode
Following in the footsteps of the previous commit, this commit adds the
new fields to AVCodecContext so we can start properly setting it on codecs,
as well as limiting the list of supported options to detect a format mismatch
during encode.

This commit also sets up the necessary infrastructure to start using the
newly added field in all codecs.
2025-09-02 17:06:24 +02:00
Niklas Haas fb3a4f6180 avfilter/formats: use vf_premultiply_dynamic for alpha mode autoconversion 2025-09-02 17:06:09 +02:00
Niklas Haas c39a67e64f avfilter/vf_premultiply: add dynamic variant of this filter
We need a filter that can premultiply and unpremultiply the alpha channel
dynamically, on demand, in response to the negotiated alpha mode, analogous
to how vf_scale operates. Introduce a new filter "vf_premultiply_dynamic"
that accomplishes this.
2025-09-02 17:06:09 +02:00
Niklas Haas 6bac13d20a avfilter/vf_premultiply: signal correct alpha mode
Set the output link according to the chosen direction, and the input link
to its opposite (unless the input is not in-place, in which case there is no
alpha channel).

Also update the alpha mode on the output frame, since it may differ.
2025-09-02 17:06:09 +02:00
Niklas Haas eea99a77ed avfilter: add link negotiation for AVAlphaMode 2025-09-02 17:06:08 +02:00
Niklas Haas 8b375b2ffd avfilter/avfiltergraph: allow different conversion filters per merger
Instead of hard-coding the assumption that all video properties are handled
by vf_scale, generalize the struct slightly to allow different conversion
filters for each property being merged. The avfiltergraph code creates a list
of conversion filters needed and inserts all of them at once.

Because a conversion filter might itself e.g. not support all formats,
it's possible that we need to go through the whole process of negotiating
formats multiple times, and keep adding conversion filters until all of them
are settled. Do this by simply jumping back to the beginning of the loop
to ensure that the `convertor_count` field remains contiguous.
2025-09-02 17:05:51 +02:00
Niklas Haas dbcdcaede8 avfilter/formats: fix param name on ff_set_common_color_spaces*
Purely cosmetic.
2025-09-02 17:05:51 +02:00
Niklas Haas 22929bd044 avutil/frame: add AVFrame.alpha_mode
FFmpeg currently handles alpha in a quasi-arbitrary way. Some filters/codecs
assume alpha is premultiplied, others assume it is independent. If there is
to be any hope for order in this chaos, we need to start by defining an enum
for the possible range of values.
2025-09-02 17:05:50 +02:00
Nicolas Gaullier f24474dcfc avcodec/aac_ac3_parser: do not override the profile set by the decoder
Parsing the ADTS header is not enough to detect HE-AAC v1/v2.

Regression since 64bb91fd3b.

Fixes #11600

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 16:05:46 +02:00
Nicolas Gaullier 593b426902 avcodec/aac_ac3_parser: simplify
Use ff_adts_header_parse_buf() wrapper to simplify as GetBitContext is
no longer needed (it was introduced for USAC).

Partially reverts 64bb91fd3b.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 16:05:46 +02:00
Nicolas Gaullier 9bd10fa32c avcodec/aac_ac3_parser: remove unused USAC/ADTS code
ff_adts_header_parse() parse the object_type from a 2 bits field.
See also 696ea1c223.

Partially reverts 64bb91fd3b.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 16:05:46 +02:00
Maryla Ustarroz-Calonge 5e210f0552 avcodec/libaom: Add test for HDR10+ metadata support
Signed-off-by: Maryla Ustarroz-Calonge <maryla@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 16:05:45 +02:00
Maryla Ustarroz-Calonge a282500087 avcodec/libaom: Add HDR10+ metadata support
Signed-off-by: Maryla Ustarroz-Calonge <maryla@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 15:56:56 +02:00
Patrick Wang d7173e982e fftools/ffmpeg: fix gracefully shutdown
d119ae2fd8 removed the loop-breaking condition
received_sigterm.
Thus, signals no longer gracefully shutdown ffmpeg.

Fixes: #10834

Signed-off-by: Patrick Wang <mail6543210@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 15:56:27 +02:00
Zsolt Vadasz 173988aa0c libavfilter/vf_minterpolate: Use local variable in array
Signed-off-by: Zsolt Vadasz <zsolt_vadasz@protonmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 15:56:23 +02:00
Zsolt Vadasz 5d7e4b7496 libavfilter/vf_minterpolate: Hoist hot loop in set_frame_data
Signed-off-by: Zsolt Vadasz <zsolt_vadasz@protonmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 15:56:02 +02:00
Niklas Haas 5d3538b8dc .forgejo/CODEOWNERS: add myself for various files 2025-09-02 13:17:02 +00:00
Martin Storsjö 5a893c1806 checkasm: sw_ops: Avoid division by zero
If we're invoked with range == UINT_MAX, we end up doing
"rnd() % (UINT_MAX + 1)", which is equal to "rnd() % 0". On
arm (on all platforms) and on MSVC i386, this ends up crashing
at runtime.

This fixes the crash.
2025-09-02 14:28:56 +03:00
Zhao Zhili a0e00bed88 swscale/ops: fix build with msvc
x86/ops.c(500): error C2099: initializer is not a constant
2025-09-02 10:28:56 +00:00
Niklas Haas ef856ef93e avfilter/vf_libplacebo: also output a frame during input gaps
In constant FPS mode, it's possible for there no be *no* input active at
the current timestamp, even though there would be active inputs later in
the timeline (nb_active > 0). This would previously hit the AVERROR_BUG case.

With this change, we can instead output an empty frame.
2025-09-02 09:55:31 +00:00
Niklas Haas 68c083c43f avfilter/vf_libplacebo: refactor status handling
Instead of having a single s->status field to track the most recently
EOF'd stream, track the number of active streams directly and only query
the most recent status at the end.

The reason this worked before is because we implicitly relied on the
assumption that `ok` would always be true until all streams are EOF, but
because it's possible to have gaps in the timeline when mixing multiple
streams, this is not always the case in principle.

In practice, this fixes a bug where the filter would early-exit (EOF)
too soon, when any input reached EOF and there is a gap in the timeline.
2025-09-02 09:55:31 +00:00
Niklas Haas fc5a6a3b39 avfilter/vf_libplacebo: allow rendering empty frames
When using libplacebo to composite multiple streams with complex PTS
values, it's possible for there to be a "hole" in the output stream; in
particular in constant FPS mode. This commit refactors output_frame() to
allow it to handle the case of there being no active input.
2025-09-02 09:55:31 +00:00
James Almer 1069d457c6 configure: report if unstable is enabled
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 22:37:17 -03:00
James Almer eed5843392 configure: fix logic for the unstable option
A --enable-* option should not have a condition where it's enabled by some
other mean, as is the case here if swscale is enabled.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 22:31:07 -03:00
Niklas Haas 4ec2bffe62 configure: allow disabling experimental swscale code
In theory we can also expand this to disable e.g. experimental codecs.
2025-09-01 19:28:36 +02:00
Niklas Haas cc42bc1f4b swscale/graph: allow experimental use of new format handler
The humor originally contained in this commit message has been
redacted to comply with the strict FFmpeg code quality standards.
2025-09-01 19:28:36 +02:00
Niklas Haas f8f7935a97 swscale/format: add new format decode/encode logic
This patch adds format handling code for the new operations. This entails
fully decoding a format to standardized RGB, and the inverse.

Handling it this way means we can always guarantee that a conversion path
exists from A to B without having to explicitly cover logic for each path;
and choosing RGB instead of YUV as the intermediate (as was done in swscale
v1) is more flexible with regards to enabling further operations such as
primaries conversions, linear scaling, etc.

In the case of YUV->YUV transform, the redundant matrix multiplication will
be canceled out anyways.
2025-09-01 19:28:36 +02:00
Niklas Haas 5e6ffa0376 tests/checkasm: add checkasm tests for swscale ops
Because of the lack of an external ABI on low-level kernels, we cannot
directly test internal functions. Instead, we construct a minimal op chain
consisting of a read, the op to be tested, and a write.

The bigger complication arises from the fact that the backend may generate
arbitrary internal state that needs to be passed back to the implementation,
which means we cannot directly call `func_ref` on the generated chain. To get
around this, always compile the op chain twice - once using the backend to be
tested, and once using the reference C backend.

The actual entry point may also just be a shared wrapper, so we need to
be very careful to run checkasm_check_func() on a pseudo-pointer that will
actually be unique for each combination of backend and active CPU flags.
2025-09-01 19:28:36 +02:00
Niklas Haas 982d3a98d0 swscale/x86: add SIMD backend
This covers most 8-bit and 16-bit ops, and some 32-bit ops. It also covers all
floating point operations. While this is not yet 100% coverage, it's good
enough for the vast majority of formats out there.

Of special note is the packed shuffle fast path, which uses pshufb at vector
sizes up to AVX512.
2025-09-01 19:28:36 +02:00
Niklas Haas a151b426f9 swscale/ops_memcpy: add 'memcpy' backend for plane->plane copies
Provides a generic fast path for any operation list that can be decomposed
into a series of memcpy and memset operations.

25% faster than the x86 backend for yuv444p -> yuva444p
33% faster than the x86 backend for gray -> yuvj444p
2025-09-01 19:28:36 +02:00
Niklas Haas 5aef513fb4 swscale/ops_backend: add reference backend basend on C templates
This will serve as a reference for the SIMD backends to come. That said,
with auto-vectorization enabled, the performance of this is not atrocious.
It easily beats the old C code and sometimes even the old SIMD.

In theory, we can dramatically speed it up by using GCC vectors instead of
arrays, but the performance gains from this are too dependent on exact GCC
versions and flags, so it practice it's not a substitute for a SIMD
implementation.
2025-09-01 19:28:36 +02:00
Niklas Haas 99d73064f5 swscale/ops_chain: add internal abstraction for kernel linking
See doc/swscale-v2.txt for design details.
2025-09-01 19:28:36 +02:00
Niklas Haas 696f3be322 swscale/optimizer: add packed shuffle solver
This can turn any compatible sequence of operations into a single packed
shuffle, including packed swizzling, grayscale->RGB conversion, endianness
swapping, RGB bit depth conversions, rgb24->rgb0 alpha clearing and more.
2025-09-01 19:28:36 +02:00
Niklas Haas db2bc11a97 swscale/ops: add dispatch layer
This handles the low-level execution of an op list, and integration into
the SwsGraph infrastructure. To handle frames with insufficient padding in
the stride (or a width smaller than one block size), we use a fallback loop
that pads the last column of pixels using `memcpy` into an appropriately
sized buffer.
2025-09-01 19:28:36 +02:00
Niklas Haas d3ca0e300d swscale/ops_internal: add internal ops backend API
This adds an internal API for ops backends, which are responsible for
compiling op lists into executable functions.
2025-09-01 19:28:36 +02:00
Niklas Haas ea9ca3ff35 swscale/optimizer: add high-level ops optimizer
This is responsible for taking a "naive" ops list and optimizing it
as much as possible. Also includes a small analyzer that generates component
metadata for use by the optimizer.
2025-09-01 19:28:36 +02:00
Niklas Haas 16e191c8ef swscale/ops: introduce new low level framework
See docs/swscale-v2.txt for an in-depth introduction to the new approach.

This commit merely introduces the ops definitions and boilerplate functions.
The subsequent commits will flesh out the underlying implementation.
2025-09-01 19:28:36 +02:00
Niklas Haas ce0938da8c swscale: add SWS_UNSTABLE flag
Give users and developers a way to opt in to the new format conversion code,
and more code from the swscale rewrite in general, even while development is
still ongoing.
2025-09-01 19:28:35 +02:00
Niklas Haas 8406c56b0c tests/checkasm: generalize DEF_CHECKASM_CHECK_FUNC to floats
We split the standard macro into its body (implementation) and declaration,
and use a macro argument in place of the raw `memcmp` call, with the major
difference that we now take the number of pixels to compare instead of the
number of bytes (to match the signature of float_near_ulp_array).
2025-09-01 19:27:53 +02:00
Niklas Haas faf62cbdf5 tests/checkasm: increase number of runs in between measurements
Sometimes, when measuring very small functions, rdtsc is not accurate enough
to get a reliable measurement. This increases the number of runs inside the
inner loop from 4 to 32, which should help a lot. Less important when using
the more precise linux-perf API, but still useful.

There should be no user-visible change since the number of runs is adjusted
to keep the total time spent measuring the same.
2025-09-01 19:27:53 +02:00
Niklas Haas 5a28f392b9 tests/swscale: avoid binary literals
These are C23-only.
2025-09-01 19:27:53 +02:00
Niklas Haas 322f606fa8 swscale/format: add ff_fmt_clear()
Reset an SwsFormat to its fully unset/invalid state.
2025-09-01 19:27:53 +02:00
Niklas Haas 041a318299 swscale/format: rename legacy format conversion table 2025-09-01 19:27:53 +02:00
Niklas Haas c18676aae4 swscale/graph: pass per-pass image pointers to setup()
This behavior had no real justification and was just incredibly confusing,
since the in/out pointers passet to setup() did not match those passed to
run(), all for what is arguably an exception anyways (the palette setup).
2025-09-01 19:27:53 +02:00
Zhao Zhili eb14d45824 avfilter/vf_colordetect: add aarch64 asm
| rpi5 gcc 12  | m1 clang -fno-vectorize | m1 clang
---------------------------------------------------------------------------
alpha_8_full_c:        | 32159.2 ( 1.00x) | 135.8 ( 1.00x) |  26.4 ( 1.00x)
alpha_8_full_neon:     |  1266.0 (25.40x) |   8.0 (17.03x) |   8.4 ( 3.15x)
alpha_8_limited_c:     | 37561.9 ( 1.00x) | 169.1 ( 1.00x) |  47.7 ( 1.00x)
alpha_8_limited_neon:  |  3967.0 ( 9.47x) |  12.5 (13.53x) |  13.3 ( 3.59x)
alpha_16_full_c:       | 15867.9 ( 1.00x) |  64.5 ( 1.00x) |  13.7 ( 1.00x)
alpha_16_full_neon:    |  1256.9 (12.62x) |   7.9 ( 8.15x) |   8.3 ( 1.64x)
alpha_16_limited_c:    | 16723.7 ( 1.00x) |  88.7 ( 1.00x) | 103.3 ( 1.00x)
alpha_16_limited_neon: |  4031.3 ( 4.15x) |  12.5 ( 7.08x) |  13.2 ( 7.86x)
range_8_c:             | 21819.7 ( 1.00x) | 120.0 ( 1.00x) |   9.4 ( 1.00x)
range_8_neon:          |  1148.3 (19.00x) |   4.3 (27.60x) |   4.8 ( 1.97x)
range_16_c:            | 10757.1 ( 1.00x) |  45.7 ( 1.00x) |   7.9 ( 1.00x)
range_16_neon:         |  1141.5 ( 9.42x) |   4.4 (10.38x) |   4.6 ( 1.72x)
2025-09-01 15:35:16 +00:00
Zhao Zhili 6450e01446 checkasm/vf_colordetect: test non-aligned width 2025-09-01 15:35:16 +00:00
Niklas Haas f07c12d806 avfilter/x86/vf_colordetect: fix alpha detect tail handling
This wrapping logic still considered any nonzero return from the ASM function
to be the overall result, but this is not true since the addition of
FF_ALPHA_TRANSPARENT.

Fix it by only early returning if FF_ALPHA_STRAIGHT is detected.

Fixes: 9b8b78a815
See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20301#issuecomment-4802
2025-09-01 15:33:43 +00:00
James Almer 9dc79241d9 avcodec/decode: always extract display matrix from Exif in frames
Should help ensure no conflicting values are propagated.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:08:04 -03:00
James Almer 6a15183e6a avcodec/decode: parse Exif packet side data before passing it to frames
Extract Orientation and export it as a display matrix if present, and set the
frame's metadata with the remaining Exif entries.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:59 -03:00
James Almer fa1938c574 avcodec/decode: use ff_frame_new_side_data() to export Exif side data
Otherwise, the user requested priority of packet side data will be ignored.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:41 -03:00
James Almer 75bd5056a4 avcodec/decode: use av_exif_get_tag_id() where useful
Removes dependency on exif_internal.h

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:41 -03:00
James Almer 310be1c5a4 avformat/mov: export Exif metadata from HEIF streams
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:35 -03:00
James Almer 74e430202d avformat/mov: make items referencing items generic
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:14 -03:00
James Almer 6a115e2066 avformat/mov: reduce code duplication when setting tile group properties
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:14 -03:00
James Almer 11d9d7b8f3 avformat/dump: print side data type names generically
Based on vf_showinfo behavior.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:14 -03:00
James Almer e62f9a071b ffprobe: print EXIF packet side data size
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:14 -03:00
James Almer 4ffd621523 avcodec/packet: add an Exif side data type
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:07 -03:00
James Almer 45dcfb2d60 avcodec/version_major: remove unnecessary define for an internal function
It being avpriv and not public, it can be removed in the next bump regardless of when it
happens.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 11:00:44 -03:00
Henrik Gramner a66a260ae9 vp9: Add 8bpc intra prediction AVX2 asm 2025-09-01 13:54:52 +00:00
Zhao Zhili 9a34ddc345 avformat/movenc: remove mvex from final mp4 in hybrid_fragmented mode
In hybrid_fragmented mode, the first moov at start should contain
mvex tag, since it's fmp4. When writing the moov at the second time,
it's not fmp4 any more, so mvex should be skipped.
2025-09-01 12:41:38 +00:00
Cameron Gutman 126671e730 avcodec/mfenc: add AVLowLatencyMode support
Set CODECAPI_AVLowLatencyMode when AV_CODEC_FLAG_LOW_DELAY is enabled on
the AVCodecContext. AVLowLatencyMode can acheive lower latency encoding
that may not be accessible using eAVScenarioInfo options alone.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-09-01 12:40:36 +00:00
Zhao Zhili f2414fb1aa .forgejo/CODEOWNERS: add myself for various files
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-09-01 11:14:30 +00:00
Martin Storsjö 3ea6c2fe25 aacencdsp: Improve consistency with assembly, for x87 math
Currently, the aacencdsp checkasm tests fails for many seeds,
if the C code has been built with x87 math. This happens because
the excess precision of x87 math can make it end up rounding
to a different integer, and the checkasm tests checks that the
output integers match exactly between C and assembly.

One such failing case is "tests/checkasm/checkasm --test=aacencdsp
41" when compiled with GCC. When compiled with Clang, the test
seed 21 produces a failure.

To avoid the issue, we need to limit the precision of intermediates
to their nominal float range, matching the assembly implementations.

This can be achieved when compiling with GCC, by just adding a single
cast.

To observe the effect of this cast, compile the following
snippet,

    int cast(float a, float b) {
        return (int)
    #ifdef CAST
            (float)
    #endif
            (a + b);
    }

with "gcc -m32 -std=c17 -O2", with/without -DCAST. For x86_64
cases (without the "-m32"), the cast doesn't make any difference
on the generated code.

This cast would seem to not have any effect, as a binary expression
with float inputs also would have the type float.

However, if compiling with GCC with -fexcess-precision=standard,
the cast forces limiting the precision according to the language
standard here - according to the GCC docs [1]:

> When compiling C or C++, if -fexcess-precision=standard is
> specified then excess precision follows the rules specified in
> ISO C99 or C++; in particular, both casts and assignments cause
> values to be rounded to their semantic types (whereas -ffloat-store
> only affects assignments). This option is enabled by default for
> C or C++ if a strict conformance option such as -std=c99 or
> -std=c++17 is used.

Ffmpeg's configure scripts enables -std=c17 by default.

This only helps with GCC though - the cast doesn't make any
difference for Clang. (Although, upstream Clang seems to default
to SSE math, while Ubuntu provided Clang defaults to x87 math.)
Limiting the precision with Clang would require casting to volatile
float for both intermediates here - and that does have a code
generation effect on all architectures.

[1] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
2025-09-01 09:22:39 +00:00
Timo Rothenpieler 883162d5b4 forgejo/workflows: make autolabel workflow always use token from secrets
Using the built-in token seems to only partially work.
And in the latest Forgejo release the issue forcing the use of the
built-in token was fixed with:

https://codeberg.org/forgejo/forgejo/pulls/9025
2025-09-01 03:02:51 +02:00
Cameron Gutman b2910ec92e avcodec/mfenc: fix memory leak with D3D11 input surfaces
Fixes: d56522c6eb ("avcodec/mfenc: add support for D3D11 input surfaces")
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-08-31 14:36:20 -05:00
YiboFang ae448e00af avcodec/pcm: use compile-time guards for PCM table init
Change the PCM table init to use compile-time #if instead of a runtime
`if (CONFIG_...)`. This makes sure code for disabled encoders never gets
built, without depending on compiler dead-code elimination.

Signed-off-by: YiboFang <fangyibo@xiaomi.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-08-31 21:40:29 +08:00
Gyan Doshi f317b6c052 lavc/codec_desc: add lossless flags for hevc and av1
Both codecs support a lossless mode akin to H.264/AVC
2025-08-31 16:48:03 +05:30
Tong Wu 9893d66add avcodec/d3d12va_encode: add max_frame_size option
Add the max_frame_size option to support setting max frame size in
bytes. Max frame size is the maximum cap in the bitrate algorithm per
each encoded frame.

Signed-off-by: Tong Wu <wutong1208@outlook.com>
2025-08-31 10:46:11 +00:00
Marton Balint 2296a9c1bc avutil/bprint: fix av_bprint_strftime with %p format string reporting truncated output
strftime returns 0 in case of an empty output (e.g. %p format string with some
locales), there is no way to distinguish this from a buffer-too-small error
condition. So we must use some heuristics to handle this case, and not consume
INT_MAX RAM and falsely report a truncated output.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-08-31 09:37:59 +02:00
Marton Balint 50e94aadb2 avutil/bprint: make av_bprintf use av_vbprintf
No reason to duplicate the code.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-08-31 09:37:59 +02:00
Peter Ross 16d32a1c1d libavcodec/dpxenc: map AVCodecContext color transfer and color primaries fields 2025-08-31 07:05:36 +00:00
Peter Ross 6d7daaab0a avcodec/dpx: move enum DPX_TRC and DPX_COL_SPEC to dpx.h 2025-08-31 07:05:36 +00:00
Marton Balint 7a774829f9 avutil/opt: also print option names on parse error
It is more user-friendly to print which option caused the parse error.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-08-30 18:46:15 +00:00
Vittorio Palmisano 73d411c399 avfilter/af_whisper: fix srt file format
The SRT file format requires commas in the time string, not periods.
2025-08-30 14:30:51 +00:00
Leo Izen 3a0e324ab9 .forge/CODEOWNERS: add myself to EXIF code
Now that the major EXIF overhaul has been merged, I should be suggested
to review patches that modify it.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-30 08:34:34 -04:00
James Almer 2fffa01ddb avcodec/x86/vp9dsp_init: remove preprocessor checks for some prototypes
Fixes compilation with --disable-avx512icl

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-29 14:02:49 -03:00
Nicolas Gaullier 7252f6c0bf avcodec/version: update the codec_ids
The counters should be incremented for each new codec.
Catch-up to be in sync with codec_id.h again.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2025-08-29 17:32:52 +02:00
Niklas Haas 4ede75b5f4 swscale/graph: fix double-free when legacy pass fails initializing
If this function returns an error after ff_sws_graph_add_pass() has been
called, and the pass->free callback is therefore already set up to free the
context, the graph will end up freed twice: once by the pass->free callback
(during ff_sws_graph_free()), and once before that by failure path of the
caller (e.g. add_legacy_sws_pass(), or init_legacy_subpass() itself for
cascaded contexts.)

The solution is to redefine the ownership of SwsGraph to pass clearly from
the caller of add_legacy_sws_pass() to init_legacy_subpass(), which can then
deal with appropriately freeing the context conditional on whether or not the
pass was already registered in the pass list.

Reported-by: 김영민 <kunshim@naver.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2025-08-29 13:22:03 +00:00
Daniil Cherednik 0828a3b636 avcodec/atrac3: fix inconsistent band num calculation
'decode_spectrum' reads 5 bits from bitstream to get
number of encoded subbands – so 31 means all 32
subbands are encoded. This value also is used to
determinate the number of used band in the hybrid
filterbank.

'subband_tab' array contains 33 values of MDCT spec
line positions started from 0 line and used to map
subband number in to the range of mdct lines.

Since the subband_num returned by decode_spectrum
actually is number – 1 and subband_tab started from 0
we need to add 1 to make num_bands calculation correct.
2025-08-29 12:29:52 +00:00
Timo Rothenpieler e3f01682d7 forgejo/labeler: react to 'labeled' action as well 2025-08-29 01:12:20 +02:00
Henrik Gramner 10a061ba99 vp9: Add AVX-512ICL asm for 8bpc subpel mc 2025-08-28 12:45:52 +00:00
Michael Niedermayer 76645e096f avcodec/exif: also copy zero termination for AV_TIFF_STRING
Fixes: out of array read
Fixes: 441131173/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_DEC_fuzzer-6700429212975104

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-27 15:46:35 +00:00
Leo Izen 041651841a avcodec/libjxlenc: fix leaked EXIF ifd
We're missing a call to av_exif_free here. We leak the internal heap-
allocated objects when &ifd goes out of scope.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-27 05:28:31 -04:00
Leo Izen a8d6b87a44 avcodec/libjxldec: fix leaked EXIF ifd
We're missing a call to av_exif_free here. We leak the internal heap-
allocated objects when &ifd goes out of scope.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-27 05:26:03 -04:00
Levi Zim c2d17c4db8 avutil/riscv: avoid redefinition of _GNU_SOURCE
Add #ifndef to avoid potential redefinition of _GNU_SOURCE macro.

Signed-off-by: Levi Zim <rsworktech@outlook.com>
2025-08-26 15:08:52 +00:00
James Almer 70a6ad6c74 fftools/ffmpeg_demux: ensure the display_rotation option is honored
If requested, it should have priotity over any coded value.
Fixes ticket #11649.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-26 11:44:09 -03:00
Raphaël Zumer ae14930176 avcodec/webp: simplify special-case handling when building Huffman reader
Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
2025-08-26 14:42:47 +00:00
Raphaël Zumer d1a7a20cb1 avcodec/webp: fix incorrectly returning AVERROR_INVALIDDATA when building Huffman reader
This corrects an error in commit c33f16d.

Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
2025-08-26 14:42:47 +00:00
Marton Balint a8097d32ae avformat/img2dec: remove deprecated glob_sequence pattern type
"glob_sequence" was deprecated since 2012. This also changes the default pattern
to "sequence", because "glob_sequence" was also the default.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-08-26 14:41:44 +00:00
Jack Lau 4811518143 avformat/whip: set the first sequence number for video and audio
simply whip->audio_first_seq + 1 for video could be
faster than generating a new one.

this patch will make whip be able to get the first
rtp seq easily and compute something sequence-based
(e.g. NACK and RTX handling)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-26 02:36:06 +00:00
James Almer db2af6fd42 configure: support linking to base profile libxev{d,e}
Addresses issue #20328.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-25 18:47:56 +00:00
James Almer fa23202cc7 configure: bump LCEVCdec minimum required version to 4.0.0
The project introduced API breaking changes to some of their public functions,
and given the library is relatively new, just bump the minimum supported
version instead of adding ifdeffery to the source files.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-25 10:43:23 -03:00
yangsen5 6c07a4f558 avformat/file: add pkt_size option
The min_packet_size/max_packet_size were hardcoded to 256KB for
performance. The new option makes it possible to configure a
smaller packet size on embedded devices with limited memory
resources.

Signed-off-by: yangsen5 <1441923451@qq.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-08-25 18:15:17 +08:00
Robert Nagy 1b62f9d3ae avfilter/vf_scale: add more color_matrix aliases
Add more color_matrix aliases to make vf_scale consistent with e.g. vf_setparams aliases.
2025-08-25 08:12:37 +00:00
Muiz Yusuff 2ffc138e8a mov demuxer: use int64_t for next_ts
d1b96c3808 fixes some hevc seeking issues
but will int overflow when timestamp is >int_max.
2025-08-25 02:25:50 +00:00
James Almer 7df9fae4f7 Changelog: move the latest entries to the correct section
They are not in 8.0

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-24 23:23:48 -03:00
Leo Izen ef9fe0fe0b avcodec/exif: avoid allocation failure on empty EXIF metadata
An EXIF IFD with 0 entries is legal, but does not contain metadata. We
should not attempt to allocate a struct with size zero in this case, as
this causes an allocation failure. Instead, we just leave the struct
empty.

Fixes: #20305.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-24 20:20:10 +00:00
Leo Izen 2398fddf6e avcodec/exif: avoid writing native-endian EXIF buffers
Currently there's platform-dependent behavior where if no endianness
is requested, it writes the buffers in native-endian. This breaks FATE
tests on big-endian architecture. This commit changes the default to
little-endian buffers upon writing.

Fixes: #20291.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-24 20:20:10 +00:00
James Almer 2298d4d072 doc/APIchanges: add 8.0 cut line
Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-24 12:08:27 -03:00
Damiano Galassi b2f5bc7fd3 movenc: ensure chapters track extradata is not null and populated
fix a regression introduced in 4eca8df,
writing chapters failed if chapters where
not available before mov_write_header().
2025-08-24 13:31:53 +00:00
James Almer 368b5e0ffc avcodec/exif: make the get and remove helpers take a flags argument as input
This makes the functions extensible, as future behavior change flags can be
introduced.

This is strictly speaking not an API break. Only if a user was setting
recursive to anything other than 1 it would now behave differently, but given
these functions have been in the tree for only a few days, the chances for that
are practically zero.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-24 12:34:15 +00:00
Jack Lau b3ea558492 avformat/whip: fix ssrc might be same
use audio_ssrc + 1 for video_ssrc to avoid ssrc collision

See RFC 3550 Section 8,
The SSRC identifier carried in the RTP header and in various fields
of RTCP packets is a random 32 bit number that is required to be
globally unique within an RTP session.

simply + 1 also can get an unique ssrc, and faster than generating
new unique ssrc.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-23 17:20:32 +08:00
Frank Plowman 673f28b6cb lavc/Makefile: Make exif.o compulsory
av_exif_* functions are part of libavcodec's public API since
ad77345a5d, so the EXIF objects can't
be disabled.

Fixes compilation with --disable-everything.
2025-08-22 22:44:07 +00:00
Timo Rothenpieler 0f873fc07a forgejo/workflows: use built-in token for autolabeler whenever possible 2025-08-22 21:07:33 +02:00
iddq 4e9a184d5c avformat/tcp: add option for enabling TCP keepalive 2025-08-22 18:20:08 +00:00
Peter Ross f62d878911 .forgejo/CODEOWNERS: add myself for various files 2025-08-22 08:01:26 +00:00
James Almer 5ed1d72792 avcodec/decode: remove Exif Orientation tag after adding it as display matrix
Don't replace it with a conflicting value.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-21 22:48:16 +00:00
James Almer 5a9e5d8031 avcodec/exif: use ff_frame_new_side_data() to export display matrix
Otherwise, the user requested priority of packet side data will be ignored.
For this, move the relevant functions to decode.c, as they need access to an
AVCodecContext.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-21 22:48:16 +00:00
Manuel Lauss d311382c38 avcodec/sanm: fix issues with FTCH offset hack
Just add an extra x/y offset parameter pair to process_frame_obj(),
and store the size of the data to FTCH in a separate context member.
The only valid sizes for FTCH are 6 and 12, reject any other.
Finally, if a FOBJ uses codecs37 and above, enforce it to be subversion 2,
to use the simpler STOR/FTCH method.

Fixes BIGSLEEP-440183164/process_ftch.anim

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-21 21:02:40 +00:00
Michael Niedermayer c41a70b6bb avcodec/sanm: Eliminate reference into reallocated frame
AFAIK the original decoder uses the frame buffers in very strange ways
our implementation seems to mimic that and that results in the
bitstream input to point into a frame buffer while code then
parses that and potentially reallocates the frame buffer
leaving pointers hanging into dealllocated space

This simply uses a temporary buffer

Fixes: Writing into freed buffers
Fixes: BIGSLEEP-440183164/old_codec21.anim
Fixes: BIGSLEEP-440183164/old_codec4.anim

Found-by: Google Big Sleep

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-21 21:02:40 +00:00
Michael Niedermayer d4e28917af avcodec/sanm: Replace impossible bitstream check by assert
the space left and size have already been cross checked by the caller

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-21 21:02:40 +00:00
Leo Izen 7caa2a65d9 avcodec/exif: fix some coverity errors
This commit fixes some memory and security issues due to improper
sanitizing and checks.

Fixes:
 - CID 1665100..1665107

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reportedy-by: James Almer <jamrial@gmail.com>
2025-08-21 15:40:45 -04:00
Manuel Lauss d4eb01f281 avcodec/sanm: handle xpal cmd 0
It's like cmd 2. Fixes the Rebel Assault 1 Intro Video "C1BLOCK.ANM"
crossfade from planet view to space view and subsequent wrong colors.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-08-21 16:24:26 +00:00
Niklas Haas 6825f6f1e2 avfilter/vf_libplacebo: add bwdif option
See-Also: https://code.videolan.org/videolan/libplacebo/-/merge_requests/737
2025-08-21 15:34:03 +00:00
Timo Rothenpieler 5bd866b6ed forgejo/workflows: cat config.log on configure failure 2025-08-21 15:08:50 +00:00
Timo Rothenpieler 8591227e1f forgejo/workflows: also run 32bit fate tests 2025-08-21 15:08:50 +00:00
Niklas Haas 8e0de5d811 avfilter/setpts: also preserve duration when not stripping fps
It makes sense to treat the presence of a frame duration and the presence
of frame rate metadata identically - because both convey effectively the same
amount of information.

In f121d95 and fa110c3 respectively, this information was stripped by default,
originally to work-around bugs when changing the PTS information of a stream
being fed to some encoders. (See https://trac.ffmpeg.org/ticket/10886)

Later, commit 959b799c restored the ability to preserve the frame rate
medatata via the `strip_fps` option, but this option did not extend to also
include the frame duration.

This commit resolves the scenario by making `frame_rate` and `duration`
handled in a consistent manner, so that the frame rate information is
generally preserved unless explicitly stripped by the user.

While it does regress the exact invocation presented in the trac ticket unless
using `strip_fps=yes`, I consider this an acceptable trade-off, especially in
light of the fact that the `fps` filter also exists and is arguably the better
tool for the task at hand.
2025-08-21 14:55:12 +02:00
Zhao Zhili 2796ce20d9 avfilter/vf_colordetect: Reorder to avoid null pointer check
Follow the general practice to assign the C implementation to DSP,
then the SIMD-optimized version.
2025-08-21 11:01:35 +08:00
Ronald S. Bultje 4d7c609be3 .forgejo/CODEOWNERS: add myself for vp8, vp9, wmavoice and csp. 2025-08-20 19:50:01 +00:00
Jacob Lifshay b9695c45c3 forgejo/CODEOWNERS: add myself
Signed-off-by: Jacob Lifshay <programmerjake@gmail.com>
2025-08-20 18:17:14 +00:00
Niklas Haas 67c15cf541 avutil/hwcontext_vulkan: add debug option to avoid host ptr imports
In some environments, these are prohibitively slow. Add a debug option
to prefer memcpy instead of importing host pointers.
2025-08-20 15:05:41 +00:00
Niklas Haas a7efcbd0e3 avutil/hwcontext_vulkan: check driver ID instead of hard-coded vendor check 2025-08-20 15:05:41 +00:00
Niklas Haas 78beb4f5f4 avutil/hwcontext_vulkan: don't re-query driver props in qf setup
This is already queried when the device is selected, so there's no need
to re-query the exact same struct.
2025-08-20 15:05:41 +00:00
Niklas Haas 881224b213 avutil/hwcontext_vulkan: also re-query dprops in device_init()
This can be unset if using an externally provided device, as in this case
device_create() never gets called.
2025-08-20 15:05:41 +00:00
James Almer d151d3aecb avcodec/exif: don't expose a private function in an installed header
And it doesn't need an entry in APIChanges, given it's not public API.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-20 10:44:12 -03:00
Lynne 451e6bed43 lavfi/bwdif_vulkan: fix typo in temp_diff assignment
Thanks to Niklas Haas for pointing this out.
2025-08-20 22:06:21 +09:00
Zhao Zhili b8856c5fc5 avcodec/hevc: Fix invalid null pointer check
c5287178b4 added a null pointer check, but checked the wrong
variable. &s->cur_frame->f->data[c_idx] cannot be null.
2025-08-20 11:52:32 +00:00
Manuel Lauss 990edfee5b libavcodec/vima: reindent
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-08-20 11:20:14 +02:00
Manuel Lauss 9141fe9653 avcodec/vima: IMA4 subtag support
Support decoding of the IMA4 ADPCM QT scheme used in some LucasArts
SANM files.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-08-20 11:20:14 +02:00
Manuel Lauss 1e95f1b269 avcodec/adpcm: export ff_adpcm_ima_qt_expand_nibble
For use in the LucasArts VIMA decoder, where it is used as a subvariant.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-08-20 11:20:11 +02:00
Leo Izen 4c3f94f265 doc/APIChanges: document EXIF API additions
Many of these additions are in separate commits in one set, so in the
interest of clarity, the API changes are all documented in one commmit
here.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:32:06 -04:00
Leo Izen fe496b0308 avcodec/libjxlenc: apply displaymatrix side data orientation to output
If the output is tagged with AV_FRAME_DATA_DISPLAYMATRIX we will read
it and apply it to the output file.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 535a07d14e avcodec/exif: add ff_exif_sanitize_ifd
This commit takes some of the sanitize code used by ff_exif_get_buffer
and exposes it as an ff_ API, so encoders who wish to modify the
sanitized IFD before calling av_exif_write can do so.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 8132ee046d avcodec/libjxldec: read EXIF metadata from container JPEG XL files
libjxl provides the ability to get EXIF metadata from an ISO18181-2
JPEG XL container file. This commit enables reading it and attaching
it to an AVFrame using the new EXIF API.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 5d4f873ff3 fftools/ffprobe: print EXIF side data size
We don't need to print the tags here because they're added as dict
elements to AVFrame->metadata and are printed elsewhere with ffprobe
-show_frames.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 1e816ebefe avcodec/tiff: decode TIFF non-image-data tags into EXIF metadata struct
This commit will cause TIFF files to store their tags in the EXIF
struct so tags such as orientation can be transfered to other formats
(such as PNG) in a way that doesn't corrupt the IFD.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 93a8091015 avcodec/exif: add av_exif_get_entry
Add an API function to retrieve am AVExifEntry struct with a given TIFF
tag ID from the AVExifMetadata ifd struct.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 303f60684f avcodec/exif: add av_exif_remove_entry
Add an API function that allows popping an exif entry out of the struct
entirely rather than requiring it be replaced with a default value.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 5caaadee79 avcodec/exif: add orientation ID and matrix conversion routines
Takes existing code that makes display matricies work with EXIF
orientation tags and expose the conversion as a public API.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen d3190a64c3 avcodec/pngenc: support writing EXIF profiles
Add support to write EXIF profiles using the new EXIF framework, namely
ff_exif_get_buffer, and writing them into eXIf chunks.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen 44af382979 avcodec/pngdec: support reading EXIF profiles
Add support to parse eXIf chunks using the new EXIF framework, as well
as EXIF profiles in zTXt and tEXt with Raw profile type exif.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen f5ad1c910c avcodec/exif: add ff_exif_get_buffer
Add a function to allow encoders to get a self-contained EXIF
buffer to write into an EXIF chunk.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen e3aa1154aa avcodec/exif: remove ff_exif_decode_ifd
This function is no longer called and its functionality
can be accessed using the new API in exif.h as well as the
various internal attach functions in exif_internal.h.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen c6cc2115f4 avcodec/webp: use new EXIF parse API
Switch over to the new API to parse EXIF metadata.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen 52dba25661 avcodec/mjpegdec: use new EXIF parse API
Switch over to the new API to parse EXIF metadata.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen bfb17d2630 avcodec/exif: add deprecation guards for old avpriv_
Add FF_API_OLD_EXIF deprecation guard based on lavc version < 62 in
order to allow removing the avpriv_ next major version bump.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen ba2ea285e0 avformat/avidec: use new EXIF metadata API instead of avpriv_
This commit switches avidec to use the new metadata API exposed by
the previous commit instead of relying on the existing avipriv_ function
exposed by lavc.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:46 -04:00
Leo Izen ad77345a5d avcodec/exif: add EXIF parser and struct API
This commit adds a structure to contain parsed EXIF metadata, as well
as code to read and write that struct from/to binary EXIF buffers. Some
internal functions have been moved to exif_internal.h. Code to read
from this new struct and write to an AVDictionary **dict has been added
as well in order to preserve interoperability with existing callers.
The only codec changes so far as of this commit are to call these
interop functions, but in future commits there will be codec changes to
use the new parsing routines instead.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:46 -04:00
Leo Izen bb90b262d6 avutil/side_data: add EXIF side data type
This commit adds support for the additional side data type
AV_FRAME_DATA_EXIF, which contains a buffer of an EXIF metadata
payload.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:46 -04:00
Leo Izen a99fff4e2d avcodec/tiff_common: rename TIFF enum constants
This makes the enum TiffTypes public by moving it to the public header
exif.h and renaming it to AVTiffDataType, as well as adding an AV_
prefix in front of each of the entry names. This allows callers to use
enum AVTiffDataType without pulling in all of tiff_common.h, as that
header is not public.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:40 -04:00
vytskalt a6b5a382dd hwcontext_vulkan: transfer EXCLUSIVE images to correct queue families 2025-08-19 14:34:17 +00:00
Lynne c05fc27dd3 aacdec_usac: use RefStruct to track unfinished extension buffers
Extensions in AAC USAC can be stored across multiple frames (mainly to keep CBR compliance).
This means that we need to reallocate a buffer when new data is received, accumulate the bitstream data,
and so on until the end of extension flag is signalled and the extension can be decoded.

This is made more complicated by the way in which the AAC channel layout switching is performed.
After decades of evolution, our AAC decoder evolved to double-buffer its entire configuration.
All changes are buffered, verified, and applied, on a per-frame basis if required, in often
random order.

Since we allocate the extension data on heap, this means that if configuration is applied,
in order to avoid double-freeing, we have to keep track of what we've allocated.

It should be noted that extensions which are spread in multiple frames are generally rare,
so an optimization to introduce av_refstruct_realloc() wouldn't generally be useful across the codebase.
Therefore, a copy is good enough for now.

Thanks to Michael Niedermayer for additional fixing.

Fixes: double free
Fixes: 393523547/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-6740617236905984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2025-08-19 14:32:21 +00:00
Michael Niedermayer cdee519d40 avcodec/dxv: Check coded_height, to avoid invalid av_clip()
Fixes: assertion failure
Fixes: 438961582/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5850827739955200

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-19 11:25:39 -03:00
Michael Niedermayer 0a5046c099 avcode: Use av_fast_realloc() in ff_lzf_uncompress()
Fixes: 438961582/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5850827739955200
Fixes: mixed up realloc() functions

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Co-Authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-19 11:25:39 -03:00
Benjamin Cheng 7bfaa6d662 vulkan_vp9: Read segment and lf data from cbs
The previous change 26a2a76346 broke Vulkan decoding because the lf and
segmentation values contained within VP9RawFrameHeader can no longer be
updated.

Read the propogated values from the CBS instead.
2025-08-19 10:07:01 -04:00
Michael Niedermayer fcf180d9ea avcodec/aac/aacdec: dont allow ff_aac_output_configure() allocating a new frame if it has no frame
Fixes: null pointer dereference
Fixes: crash_test.mp4

Found-by: Intel PSIRT
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-19 12:58:38 +00:00
Levi Zim 163518ffab avutil/riscv: add fallthrough comment to switch
This fixes the following warning:

libavutil/riscv/cpu.c:85:9: warning: label at end of compound statement is a C23 extension [-Wc23-extensions]

Signed-off-by: Levi Zim <rsworktech@outlook.com>
2025-08-19 11:29:18 +08:00
Michael Niedermayer 0243cf89b1 avformat/lrcdec: Fix fate-sub-lrc-ms-remux on x86-32
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-18 22:02:47 +00:00
Michael Niedermayer ca20d42cd7 swscale/swscale_internal: Use more precisse gamma
Avoids failure of xyz12 fate tests on mingw and linux x86-32

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-18 19:12:46 +00:00
Niklas Haas 9b8b78a815 avfilter/vf_colordetect: detect fully opaque alpha planes
It can be useful to know if the alpha plane consists of fully opaque
pixels or not, in which case it can e.g. safely be stripped.

This only requires a very minor modification to the AVX2 routines, adding
an extra AND on the read alpha value with the reference alpha value, and a
single extra cheap test per line.

detect_alpha_8_full_c:                                2849.1 ( 1.00x)
detect_alpha_8_full_avx2:                              260.3 (10.95x)
detect_alpha_8_full_avx512icl:                         130.2 (21.87x)
detect_alpha_8_limited_c:                             8349.2 ( 1.00x)
detect_alpha_8_limited_avx2:                           756.6 (11.04x)
detect_alpha_8_limited_avx512icl:                      364.2 (22.93x)
detect_alpha_16_full_c:                               1652.8 ( 1.00x)
detect_alpha_16_full_avx2:                             236.5 ( 6.99x)
detect_alpha_16_full_avx512icl:                        134.6 (12.28x)
detect_alpha_16_limited_c:                            5263.1 ( 1.00x)
detect_alpha_16_limited_avx2:                          797.4 ( 6.60x)
detect_alpha_16_limited_avx512icl:                     400.3 (13.15x)
2025-08-18 18:50:00 +00:00
Niklas Haas ae3c5ac2c1 avfilter/vf_colordetect: remove extra safety margin on premul check
This safety margin was motivated by the fact that vf_premultiply sometimes
produces such illegally high values, but this has since been fixed by
603334a043, so there's no more reason to have this safety margin, at
least for our own code. (Of course, other sources may also produce such
broken files, but we shouldn't work around that - garbage in, garbage out.)

See-Also: 603334a043
2025-08-18 18:50:00 +00:00
Niklas Haas c96ccd78fc avfilter/vf_colordetect: rename p, q, k variables for clarity
Purely cosmetic.

Motivated in part because I want to depend on the assumption that P
represents the maximum alpha channel value.
2025-08-18 18:50:00 +00:00
Niklas Haas 2968f30a15 tests/checkasm/vf_colordetect: also test opaque alpha base case
Preemptively adding a check for a following commit.
2025-08-18 18:50:00 +00:00
Niklas Haas 34ad857d2b avfilter/vf_colordetect: slightly change detect_alpha() signature
Basically cosmetic.

I want to expand this to detect more than a single property about the alpha
channel at the same time; so we first need a way for this function to
return a more complex result.

Move the enum AlphaMode to the header and formally generalize the return
signature a bit to allow returning more than just one value.
2025-08-18 18:50:00 +00:00
Andreas Hartmann 11a89bfe7b ffmpeg_opt: Parse regular options in ffpreset files
instead of only AV-specific options. The previous code assumed that any
option not defining the codec in an `ffpreset` file is an AVOption. This
for example prevented the use of options defined in `OptionDef[]`, like
`-pix_fmt`, as part of preset files, requiring users to type these out
every time.

Closes: #1530
Signed-off-by: Andreas Hartmann <hartan@7x.de>
2025-08-18 13:54:30 +00:00
Zane van Iperen d5c8f2268f .forgejo/CODEOWNERS: add myself to relevant files
To formats I've written in lavf, and adpcm-related things in lavc.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2025-08-18 09:51:41 -04:00
Manuel Lauss 0226b6fb2c avcodec/sanm: bl16: fix artifacts in larger videos
The DOS/Windows decoder precomputes a table of linear offsets of
all motion vectors given the current image width.
For larger widths (>=762), the pairs starting at indices 1 and 254
of motion_vectors[] will overflow the int16_t, changing the sign.

Playing back the 800x600 "jonesopn_8.snm" video of "Indiana Jones and
the Infernal Machine" reveals a lot of artifacts and a lot of
"Ignoring invalid motion vector (149, -41)->(136, 0), block size = 8"
messages, hinting at the wrong direction of the motion vectors.

Fix this by doing the calculation that the DOS/Windows players do,
let the value overflow and reextract the "new" mvec x/y components.
2025-08-18 09:11:09 +00:00
Valerii Zapodovnikov 8426622bb9 avformat/avio: clarify that AVSEEK_FORCE has no effect
avio_seek() never supported SEEK_END and returned AVERROR(EINVAL) when
specified, so the later check "(whence != SEEK_END || force)" was always true.

This also means that AVSEEK_FORCE had no effect since 7a6fe01f99, that is 15
years ago. Rather than changing behaviour, let's document instead that the flag
has no effect.

Also fixed other commit 41ed7ab45f which confused ORing / passing AVSEEK_FORCE
and AVSEEK_SIZE in the docs.

Signed-off-by: Valerii Zapodovnikov <val.zapod.vz@gmail.com>
2025-08-17 20:47:11 +00:00
Michael Niedermayer 134fbfd1dc avcodec/sanm: Check w,h,left,top
The setup code fow w,h,left,top is complex, the code using it also falls in
at least 2 different classes, one using left/top the other not.

To ensure no out of array access happens we add this clear check.

Fixes: out of array access
Fixes: 439261995/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5383455572819968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-17 15:39:33 +02:00
James Almer a2cfaf1b91 avformat/mov: pass stream index to sanity_checks on HEIF images
Instead of item_id. Same behavior as with standard video tracks.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-16 21:59:18 -03:00
James Almer a28e01a6c1 avformat/mov: don't use an allocated array for sample_size with HEIF images
The array is only ever needed for streams where each sample entry may have a
different value. Given that for non animated HEIF there's a single value that
applies to the image, use the field defined for that.

Fixes: NULL pointer dereference
Fixes: 437528618/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6537287645331456

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-16 21:59:18 -03:00
Gyan Doshi 7df9271272 avfilter/whisper: correct option formatting 2025-08-17 00:58:03 +00:00
Zhao Zhili 1d06e8ddcd avfilter/af_whisper: fix broken output for multibyte character
text + 1 can break a multibyte character, e.g., Chinese in UTF-8.
There is no space at the beginning in this case.
2025-08-16 13:58:14 +00:00
Leo Izen 30e6956920 .forgejo/CODEOWNERS: add myself to JPEG XL and PNG
Add myself to JPEG XL and PNG decoders/encoders/parsers/etc. as a
suggested reviewer. I'm the maintainer of the JXL files and I know the
PNG code very well.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-16 05:07:19 -04:00
Jack Lau 37507c6a78 avformat/whip: remove DTLSState enum
This patch aims to simplify the dtls handshake process
since dtls handshake use force block mode

We can just use the return code instead of DTLSState enum

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-16 06:25:04 +00:00
Michael Niedermayer 50affd2b09 avcodec/rv60dec: clear pu_info
pu_info is read uninitialized on damaged input and at that point the following codepath is dependant
on the uninitialized data. In one of these pathes out of array accesses happen.
None of this is replicatable

Less uninitialized data also should result in more reproducable reports

Fixes: Use of uninitialized memory
Fixes: 418335931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-5103986067963904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-16 00:24:52 +00:00
Kacper Michajłow 61d0050924 avformat/tls_openssl: simplify fingerprint generation
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-16 00:15:30 +00:00
Kacper Michajłow 4676f97928 avformat/tls_openssl: clean keys serialization
It was unnecessary convoluted, remove not needed memory allocations,
snprintf.

Also fixes posibility to call snprinft with NULL as %s input.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-16 00:15:30 +00:00
Kacper Michajłow 113c9c6cf3 configure: require at least OpenSSL 1.1.1 (LTS)
Commit f256487cd8 bumped requirement to
1.1.0 for OPENSSL_init_ssl.

Bump this again to 1.1.1, because it was an LTS version. Although it has
no mainline support anymore, it still has paid/premium support. 1.1.0 has
no support at all.

Motivated for use of BIO_read_ex() for next commits.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-16 00:15:30 +00:00
Kacper Michajłow 3a8b3dfeca avformat/tls_openssl: use ascii - (0x2D) instead of 0x2010 hyphen
Too much AI is bad for you...

Fixes: 167e343bbe
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-16 00:15:30 +00:00
Kacper Michajłow 1f4fed5cc3 w32pthreads: add support for setting thread name
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-15 19:54:01 +00:00
Kacper Michajłow 5ff2500514 avcodec/x86/Makefile: add missing x86/proresdsp.o for prores raw 2025-08-15 20:45:20 +02:00
wangbin 6e48050568 configure: fix -L flags for lld-link 2025-08-15 18:20:33 +00:00
Michael Niedermayer 2a22972db3 avcodec/utvideodec: Clear plane_start array
in pack mode the array is passed into decode_plane() without being initialized or used

Fixes: use of uninitialized memory
Fixes: 438780119/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_DEC_fuzzer-5464037027807232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-15 18:00:11 +02:00
Oliver Chang c9e93df4ee avcodec/prores_raw: Fix heap buffer overflow
When dimensions differ from context, those were updated using
ff_set_dimensions, however this overwrote the aligned coded_width and
coded_height that were set before, leading to a buffer overflow when
writing the frame data.

Fixes: OssFuzz 438771336
Fixes: Heap-buffer-overflow

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
Reviewed-by: Marvin Scholz <epirat07@gmail.com>
2025-08-15 15:06:58 +00:00
David Rosca ac5303a5b9 hw_base_encode: Support refs option to limit number of references
Set default value to 0 to keep the old behavior of using maximum number
of references.
2025-08-15 13:55:51 +00:00
Michael Niedermayer 7d606ef0cc .forgejo/CODEOWNERS: remove reference to secret apparently uncommited code
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-15 00:51:23 +02:00
Kacper Michajłow 47c6af7d29 avutil/avassert: always implement av_assume with av_unreachable
One of the design goals of this macro is the ability to support static
inline predicate functions. Which is emitting warning in clang that a
function may have side-effects and the condition will be ignored. MSVC
doesn't emit warning, but also ignore predicate in such cases.

Instead of using assume builtins, implement it using unreachable. Which
solves this case for MSVC and Clang.

This reverts ea56fe60ac, but also extends
it to MSVC, which is affected in the similar way.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 19:42:13 +00:00
Kacper Michajłow 3ab9eebba7 avcodec/Makefile: add missing dependency for prores raw decoder (again)
proresdata.o is also needed, missed in a9e7b5aa07

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 18:06:49 +02:00
Pavel Koshevoy a7c8c4ee1c lavc/mfenc: set output packet duration
Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-14 11:13:09 -03:00
Leo Izen 1532caaab0 RELEASE: update to 8.0 2025-08-14 08:42:29 -04:00
devjeonghwan 243b392d83 avformat/apngdec: allow other chunks between fcTL and fdAT/IDAT 2025-08-14 08:05:21 -04:00
Kacper Michajłow a9e7b5aa07 avcodec/Makefile: add missing dependency for prores raw decoder
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 04:43:16 +02:00
Michael Niedermayer cdbb5f1b93 fftools/ffmpeg_mux_init: Use 64bit for score computation in map_auto_video()
Fixes: signed integer overflow: 10 * 1952737655 cannot be represented in type 'int'
Fixes: PoC_avi_demux

Found-by: 2ourc3 (Salim LARGO)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-14 00:36:29 +00:00
Kacper Michajłow 589b934417 compat/getopt: constify opts
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 00:08:10 +00:00
Kacper Michajłow d3375101fe avcodec/vp8: remove set, but never used variable
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 00:08:10 +00:00
Kacper Michajłow 218ef98ea3 avcodec/j2kenc: remove set, but never used variable
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 00:08:10 +00:00
Kacper Michajłow c5093f59c8 avcodec/x86/vc1dsp: add missing header for HAVE_6REGS
x86/vc1dsp_init.c already includes asm.h before, so this is mostly
cosmetic change and only to clean checkheaders warning.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 00:08:10 +00:00
softworkz 1ad97b82f3 fftools/resources: Update .gitignore
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-08-13 17:39:49 +00:00
softworkz a125f5db03 ffbuild/commonmak: Consolidate pattern rules for compression
This commit simplifies and consolidates all the rules around
ptx and resource file compression.

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-08-13 17:39:49 +00:00
softworkz f52d9dd869 fftools/resources: Fix double-build by disabling .d file generation
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-08-13 17:39:49 +00:00
James Almer 230fafe68a tests/fate/cbs: add a test for gray apv
Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-13 11:42:50 -03:00
James Almer 64b6cfe7fb tests/fate/cbs: move redundant_pps tests to the proper location
cbs.mak is meant to contain tests strictly for the CBS framework, not for any
bsf that happens to use it under the hood.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-13 11:36:22 -03:00
Kacper Michajłow 8eca3fa619 configure: use proper Windows-style static library naming
On Windows, static libraries are typically named with a .lib extension.
An exception to this is MinGW targets, which are treated as a distinct
target-os.

Using Windows-style naming allows `clang` to be used as the linker
driver, instead of invoking link or lld-link directly. The latter
approach requires manually specifying standard libraries when compiling
with `clang` rather than `clang-cl`, and manually specifying standard
libraries may be error-prone or incomplete.

Using Windows-style naming allows Clang to be used as the linker driver,
instead of invoking link or lld-link directly. The latter approach
requires manually specifying standard libraries, which may be
error-prone or incomplete.

This change also improves support for LTO and sanitizer builds, where
it's significantly easier to let the compiler driver manage the
necessary linker flags.

It fixes issues where Clang is asked to link `-lavcodec`, which gets
passed to the linker as avcodec.lib, resulting in an error like:
lld-link: error: could not open 'avcodec.lib': no such file or directory
This happens because `libavcodec.a` was unexpectedly generated, not
`avcodec.lib` expected by tooling.

Additionally, using `clang` (not `clang-cl`) is simplified, as it does
not use autolinking like MSVC/clang-cl does. Now `--ld=clang` can be
used to add all the required libraries. Previously, building with
`clang` was only possible by using `--ld=lld-link` and manually
specifying system dependencies in `extra-ldflags`.

Note that those changes doesn't affect mingw build. MSVC builds will
produce .lib static libraries now, but the linking process itself is not
affected, because filenames are passed directly.

To summarize in Windows non-mingw builds:
Static builds now produce `lib/avcodec.lib` instead of `lib/libavcodec.a`.
Shared builds remain unchanged, producing `bin/avcodec.lib` together with
`bin/avcodec-62.dll`.

This also removes setting LD_LIB from Win32/64 target as there is one
type of .lib in practice. We cannot build both shared and static at the
same time as noted by the next line.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-13 13:17:53 +00:00
Jiasheng Jiang b8d5f65b9e libavfilter/dnn/dnn_backend_tf: Remove redundant av_freep() to avoid double free
Remove redundant av_freep() to avoid double free since task will be freed in dnn_free_model_tf() after the success of ff_queue_push_back().

Fixes: af052f9066 ("lavfi/dnn: fix mem leak in TF backend error handle")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
2025-08-13 19:50:26 +08:00
Michael Niedermayer fd31df4306 tools: Split the list of source plugins out of "merge-all-source-plugins" 2025-08-13 11:50:52 +00:00
Michael Niedermayer b5b306ca31 tools/merge-all-source-plugins: Fix merge_internal() return code
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 11:50:52 +00:00
Michael Niedermayer 373bd80b16 avcodec/dxv: Use av_fast_realloc() for op_data
makes things consistent

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 10:12:07 +00:00
Michael Niedermayer 4e5f25c0a5 avcodec/dxv: Clear ctex
same issue as with tex

Fixes: 431665305/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5339599339847680
Fixes: use of uninitialized memory

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 10:12:07 +00:00
Michael Niedermayer 6a8c41dcac avcodec/dxv: Check that we initialize op_data
Fixes: 431665305/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5339599339847680
Fixes: use of uninitialized memory

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 10:12:07 +00:00
Michael Niedermayer 4a0b793737 avcodec/dxv: Use av_fast_realloc() and clear all new space
The code writing in the buffer has a wide range of error checks
which simply leave it partly uninitialized.

Initializing it on allocation ensures no sensitive data leaks and that
bugs are more reliably reproduceable

Fixes: use of uninitialized memory
Fixes: 435225510/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-4521918634196992

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 10:12:07 +00:00
Michael Niedermayer d5bdb0b705 avcodec/sanm: Check mv in codec48_block()
Fixes: out of array read
Fixes: 436943287/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5011037029203968

This issue did oddly enough, not replicate

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 10:12:07 +00:00
Andy Nguyen 870cfed231 avformat/aviobuf: Free white/black list in avio_context_free()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 09:46:36 +00:00
Marton Balint b61e510e75 swscale/swscale_unscaled: use 8 line alignment for planarCopyWrapper with dithering
Dithering relies on a 8 line dithering table and the code always uses it from
the beginning. So in order to make dithering independent from height of the
slices used we must enforce a 8 line alignment.

Fixes issue #20071.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-08-12 21:56:09 +00:00
James Almer 3ef2ea890b avcodec/apv_decode: set decoder as skip frame fill param capable
No need to decode potentially huge frames just to get stream params.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-12 19:59:21 +00:00
James Almer 084b67f6e3 avcodec/apv: port to the receive_frame() API
You can technically feed the decoder a single packet with more than one AU in
it, even if a demuxer is unlikely to ever export such a thing.
Given the parser does no packetization to ensure we get a single AU, in order
to not discard any frame beyond the first, the decoupled input/output API
should be used.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-12 19:59:21 +00:00
James Almer 4b39d776c3 avcodec/cbs_apv: store derived tile information in a per frame basis
If a single fragment contains more than one frame unit, the tile information stored
in the private context will only correspond to one of them.

Fixes: crash (out of array access)
Fixes: 435489659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APV_fuzzer-6194885205229568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-12 19:59:21 +00:00
Michael Niedermayer 0469d68acb avcodec/exr: Check for pixel type consistency in DWA
Fixes: out of array access
Fixes: BIGSLEEP-436511754/testcase.exr

Found-by: Google Big Sleep
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-12 12:21:09 +02:00
Dale Curtis 069201c535 avcodec/h264_refs: Make ff_h264_build_ref_list stricter with AV_EF_EXPLODE
Don't silently skip errors when AV_EF_EXPLODE is specified.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-12 11:38:45 +02:00
Dash Santosh 6f9e8a599d checkasm/swscale: fix whitespace issues 2025-08-12 09:05:00 +00:00
Dash Santosh ca2a88c1b3 swscale/output: Implement yuv2nv12cx neon assembly
yuv2nv12cX_2_512_accurate_c:                          3540.1 ( 1.00x)
yuv2nv12cX_2_512_accurate_neon:                        408.0 ( 8.68x)
yuv2nv12cX_2_512_approximate_c:                       3521.4 ( 1.00x)
yuv2nv12cX_2_512_approximate_neon:                     409.2 ( 8.61x)
yuv2nv12cX_4_512_accurate_c:                          4740.0 ( 1.00x)
yuv2nv12cX_4_512_accurate_neon:                        604.4 ( 7.84x)
yuv2nv12cX_4_512_approximate_c:                       4681.9 ( 1.00x)
yuv2nv12cX_4_512_approximate_neon:                     603.3 ( 7.76x)
yuv2nv12cX_8_512_accurate_c:                          7273.1 ( 1.00x)
yuv2nv12cX_8_512_accurate_neon:                       1012.2 ( 7.19x)
yuv2nv12cX_8_512_approximate_c:                       7223.0 ( 1.00x)
yuv2nv12cX_8_512_approximate_neon:                    1015.8 ( 7.11x)
yuv2nv12cX_16_512_accurate_c:                        13762.0 ( 1.00x)
yuv2nv12cX_16_512_accurate_neon:                      1761.4 ( 7.81x)
yuv2nv12cX_16_512_approximate_c:                     13884.0 ( 1.00x)
yuv2nv12cX_16_512_approximate_neon:                   1766.8 ( 7.86x)

Benchmarked on:
Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) CPU
3417 Mhz, 12 Core(s), 12 Logical Processor(s)
2025-08-12 09:05:00 +00:00
Logaprakash Ramajayam 49477972b7 swscale/aarch64/output: Implement neon assembly for yuv2planeX_10_c_template()
yuv2yuvX_8_2_0_512_accurate_c:                        2213.4 ( 1.00x)
yuv2yuvX_8_2_0_512_accurate_neon:                      147.5 (15.01x)
yuv2yuvX_8_2_0_512_approximate_c:                     2203.9 ( 1.00x)
yuv2yuvX_8_2_0_512_approximate_neon:                   154.1 (14.30x)
yuv2yuvX_8_2_16_512_accurate_c:                       2147.2 ( 1.00x)
yuv2yuvX_8_2_16_512_accurate_neon:                     150.8 (14.24x)
yuv2yuvX_8_2_16_512_approximate_c:                    2149.7 ( 1.00x)
yuv2yuvX_8_2_16_512_approximate_neon:                  146.8 (14.64x)
yuv2yuvX_8_2_32_512_accurate_c:                       2078.9 ( 1.00x)
yuv2yuvX_8_2_32_512_accurate_neon:                     139.0 (14.95x)
yuv2yuvX_8_2_32_512_approximate_c:                    2083.7 ( 1.00x)
yuv2yuvX_8_2_32_512_approximate_neon:                  140.5 (14.84x)
yuv2yuvX_8_2_48_512_accurate_c:                       2010.7 ( 1.00x)
yuv2yuvX_8_2_48_512_accurate_neon:                     138.2 (14.55x)
yuv2yuvX_8_2_48_512_approximate_c:                    2012.6 ( 1.00x)
yuv2yuvX_8_2_48_512_approximate_neon:                  141.2 (14.26x)
yuv2yuvX_10LE_16_0_512_accurate_c:                    7874.1 ( 1.00x)
yuv2yuvX_10LE_16_0_512_accurate_neon:                  831.6 ( 9.47x)
yuv2yuvX_10LE_16_0_512_approximate_c:                 7918.1 ( 1.00x)
yuv2yuvX_10LE_16_0_512_approximate_neon:               836.1 ( 9.47x)
yuv2yuvX_10LE_16_16_512_accurate_c:                   7630.9 ( 1.00x)
yuv2yuvX_10LE_16_16_512_accurate_neon:                 804.5 ( 9.49x)
yuv2yuvX_10LE_16_16_512_approximate_c:                7724.7 ( 1.00x)
yuv2yuvX_10LE_16_16_512_approximate_neon:              808.6 ( 9.55x)
yuv2yuvX_10LE_16_32_512_accurate_c:                   7436.4 ( 1.00x)
yuv2yuvX_10LE_16_32_512_accurate_neon:                 780.4 ( 9.53x)
yuv2yuvX_10LE_16_32_512_approximate_c:                7366.7 ( 1.00x)
yuv2yuvX_10LE_16_32_512_approximate_neon:              780.5 ( 9.44x)
yuv2yuvX_10LE_16_48_512_accurate_c:                   7099.9 ( 1.00x)
yuv2yuvX_10LE_16_48_512_accurate_neon:                 761.0 ( 9.33x)
yuv2yuvX_10LE_16_48_512_approximate_c:                7097.6 ( 1.00x)
yuv2yuvX_10LE_16_48_512_approximate_neon:              754.6 ( 9.41x)

Benchmarked on:
Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) CPU
3417 Mhz, 12 Core(s), 12 Logical Processor(s)
2025-08-12 09:05:00 +00:00
Niklas Haas 5929d46f7b avfilter/vf_vignette: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas ec3c9ecaa7 avfilter/vf_tonemap: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas a75f673713 avfilter/vf_selectivecolor: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 2cdf4f08b4 avfilter/vf_scdet_vulkan: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 7751f261de avfilter/vf_scdet: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas dee56511b0 avfilter/vf_scale_vulkan: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas bd59c6651b avfilter/vf_photosensitivity: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 663a37f7f9 avfilter/vf_libvmaf: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas a45113c28a avfilter/vf_libplacebo: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas ea72804295 avfilter/vf_gblur_vulkan: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas d1d64c804e avfilter/vf_freezedetect: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas d276875c90 avfilter/vf_drawtext: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 029f501a95 avfilter/vf_drawbox: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 86387038f8 avfilter/vf_delogo: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas b02d6fc556 avfilter/vf_dctdnoiz: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas d84a21a023 avfilter/vf_curves: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 8c51a8b954 avfilter/vf_blackdetect_vulkan: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 0b7827cd10 avfilter/vf_blackdetect: log with correct filter ID
If we use the private BlackDetectContext for logging, the filter ID does
not get printed alongside the filter name. Using the parent AVFilterContext
makes this consistent with other filters.
2025-08-12 09:01:39 +00:00
Niklas Haas a47ebee7df avfilter/f_bench: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 0913576225 avfilter/avf_aphasemeter: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 96f860853e avfilter/asrc_sine: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas dcd378ad04 avfilter/asrc_sinc: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas d360c212af avfilter/asrc_hilbert: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 2e8d3548e1 avfilter/asrc_afirsrc: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 4cc71fb806 avfilter/af_silencedetect: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 892c439525 avfilter/af_lv2: use AVFilterContext when logging 2025-08-12 09:01:39 +00:00
Niklas Haas fb8f52d66c avfilter/af_afftdn: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Ramiro Polla 5733e08c97 avcodec/mjpegdec: decode only SOF fields when finding stream info
When called from avformat_find_stream_info(), we are only interested in
decoding SOF fields.

This patch makes the decoder skip all other fields (including SOI, SOS,
and EOI). This also prevents the decoder from incorrectly printing the
warning "EOI missing, emulating" (which is the case since 2ae82788).

Fixes: #20119
2025-08-11 21:23:38 +00:00
Niklas Haas f610b55525 avfilter/vf_libplacebo: fix possible segfault when frame mixing
pl_frame_mix_current() will return NULL if all frames are in the future,
but when libplacebo is using a frame mixer with a radius greater than 1,
future frames are expected to already be partially renderered. Instead, use
pl_frame_mix_nearest(), which is guaranteed to give us a valid frame for any
nonempty frame mix.

Fixes: 3091bca3ed
2025-08-11 21:21:55 +00:00
Martin Storsjö 13139d6d83 fate: Fix the sub-mcc tests on Windows in eastern time zones
Previously, these tests failed when running on Windows, if the
system is configured with a time zone east of Greenwich, i.e.
with a positive GMT offset.

The muxer converts the creation_date given by the user using
av_parse_time to unix time, as a time_t. The creation_date is
interpreted as a local time, i.e. according to the current time
zone. (This time_t value is then converted back to a broken out
local time form with localtime_r.)

The given reference date/time, "1970-01-01T00:00:00", is the
origin point for unix time, corresponding to time_t zero. However
when interpreted as local time, this doesn't map to exactly zero.
Time zones east of Greenwich reached this time a number of hours
before the point of zero time_t - so the corresponding time_t
value essentially is minus the GMT offset, in seconds.

Windows mktime returns an error, returning (time_t)-1, when given
such a "struct tm", while e.g. glibc mktime happily returns a
negative time_t. av_parse_time doesn't check the return value of
mktime for potential errors.

This is observable with the following test snippet:

    struct tm tm = { 0 };
    tm.tm_year = 70;
    tm.tm_isdst = -1;
    tm.tm_mday = 1;
    tm.tm_hour = 0;
    time_t t = mktime(&tm);
    printf("%d-%02d-%02d %02d:%02d:%02d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
    printf("t %d\n", (int)t);

By varying the value of tm_hour and the system time zone, one
can observe that Windows mktime returns -1 for all time_t values
that would have been negative.

This range limit is also documented by Microsoft in detail at
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/mktime-mktime32-mktime64.

To avoid the issue, pick a different, arbitrary reference time,
which should have a nonnegative time_t for all time zones.
2025-08-11 23:14:35 +03:00
Kacper Michajłow 9b94b652db doc/examples/decode_filter_video: use av_usleep
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 5a768e8dd0 doc/examples/decode_filter_audio: remove unused unistd.h include
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 1a1377c53d avfilter/stack_internal: fix checkheaders test
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 48b941d543 tools/fourcc2pixfmt: fix getopt return value type
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 082e2b26d4 tools/graph2dot: fix getopt return value type
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 01cfb01c9c avutil/tests/pca: comment out unused code
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow eec391993e avcodec/prores_raw: add missing includes
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow a6380c35d6 avfilter/vf_blackdetect: add missing config.h include
For ARCH_X86.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow b7a3c426ea avcodec/vulkan_encode_av1: use CODEC_PIXFMTS to define pix_fmts
Fixes deprecation warnings.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow ac6db22e37 avcodec/d3d12va_encode: fix label followed by a declaration warning
Fixes: d3d12va_encode.c: warning: label followed by a declaration is a
       C23 extension

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 98c4b9dbbd swscale/input: don't generate unused functions
Fixes: input.c:1271:1: warning: unused function 'planar_rgb16_s12_to_a'
Fixes: input.c:1272:1: warning: unused function 'planar_rgb16_s10_to_a'

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 0798f58abe avcodec/mpeg4videodec: add av_unreachable for unexpected startcode
Fixes: mpeg4videodec.c:3679:22: warning: variable 'name' is used
       uninitialized whenever 'if' condition is false
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 2287a19abb avcodec/libvorbisdec: avoid overflow when assinging sample rate from long to int
Fixes: 416134551/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBVORBIS_DEC_fuzzer-6096101407260672
Found-by: OSS-Fuzz
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 20:31:09 +02:00
Kacper Michajłow 286a3892a8 avcodec/g728dec: init missing sample rate
Fixes: BAD BUILD: fuzzing /tmp/not-out/tmp0d_svy0e/ffmpeg_AV_CODEC_ID_G728_DEC_fuzzer with afl-fuzz failed
Found-by: OSS-Fuzz
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 20:31:09 +02:00
Kacper Michajłow c2f7dae70d avcodec/g726: init missing sample rate
Fixes: 416134551/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_G726_DEC_fuzzer-5695764455292928
Found-by: OSS-Fuzz
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 20:31:09 +02:00
Kacper Michajłow db05b656b8 avformat/lrcdec: use av_sscanf to avoid possible locale issues
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 20:31:09 +02:00
Kacper Michajłow c74bc74398 avformat/lrcdec: limit input timestamp range to avoid overflows
Fixes: clusterfuzz-testcase-ffmpeg_dem_LRC_fuzzer-5226140131459072
Found-by: OSS-Fuzz
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 20:31:09 +02:00
Kacper Michajłow e6635ada64 avfilter/vf_colordetect: optimize C functions a bit
They are used to process tail, so it's still good to have them faster.
Even if AVX version are used.

GCC 14.2.0 | x86_64 (default config) | Before:

detect_alpha_8_full_c:                                3803.0 ( 1.00x)
detect_alpha_8_full_avx2:                              166.4 (22.86x)
detect_alpha_8_full_avx512icl:                         144.2 (26.37x)
detect_alpha_8_limited_c:                            10454.4 ( 1.00x)
detect_alpha_8_limited_avx2:                           616.5 (16.96x)
detect_alpha_8_limited_avx512icl:                      509.4 (20.52x)
detect_alpha_16_full_c:                               1903.0 ( 1.00x)
detect_alpha_16_full_avx2:                             172.4 (11.04x)
detect_alpha_16_full_avx512icl:                        163.4 (11.65x)
detect_alpha_16_limited_c:                            3703.6 ( 1.00x)
detect_alpha_16_limited_avx2:                          644.4 ( 5.75x)
detect_alpha_16_limited_avx512icl:                     558.0 ( 6.64x)
detect_range_8_c:                                     5855.9 ( 1.00x)
detect_range_8_avx2:                                   150.4 (38.94x)
detect_range_8_avx512icl:                              146.7 (39.91x)
detect_range_16_c:                                    2702.2 ( 1.00x)
detect_range_16_avx2:                                  256.7 (10.53x)
detect_range_16_avx512icl:                             116.8 (23.13x)

GCC 14.2.0 | x86_64 (default config) | After:

detect_alpha_8_full_c:                                 376.3 ( 1.00x)
detect_alpha_8_full_avx2:                              169.2 ( 2.22x)
detect_alpha_8_full_avx512icl:                         134.6 ( 2.80x)
detect_alpha_8_limited_c:                             6024.1 ( 1.00x)
detect_alpha_8_limited_avx2:                           641.8 ( 9.39x)
detect_alpha_8_limited_avx512icl:                      493.0 (12.22x)
detect_alpha_16_full_c:                                436.4 ( 1.00x)
detect_alpha_16_full_avx2:                             156.3 ( 2.79x)
detect_alpha_16_full_avx512icl:                        151.8 ( 2.87x)
detect_alpha_16_limited_c:                            3679.9 ( 1.00x)
detect_alpha_16_limited_avx2:                          642.0 ( 5.73x)
detect_alpha_16_limited_avx512icl:                     555.2 ( 6.63x)
detect_range_8_c:                                      655.2 ( 1.00x)
detect_range_8_avx2:                                   153.9 ( 4.26x)
detect_range_8_avx512icl:                              147.4 ( 4.45x)
detect_range_16_c:                                     743.3 ( 1.00x)
detect_range_16_avx2:                                  258.6 ( 2.87x)
detect_range_16_avx512icl:                             107.7 ( 6.90x)

Clang 19.1.7 | x86_64 (default config) | Before:

detect_alpha_8_full_c:                                7013.4 ( 1.00x)
detect_alpha_8_full_avx2:                              141.8 (49.46x)
detect_alpha_8_full_avx512icl:                         133.8 (52.40x)
detect_alpha_8_limited_c:                             7038.8 ( 1.00x)
detect_alpha_8_limited_avx2:                           605.0 (11.63x)
detect_alpha_8_limited_avx512icl:                      506.5 (13.90x)
detect_alpha_16_full_c:                               1799.5 ( 1.00x)
detect_alpha_16_full_avx2:                             143.0 (12.59x)
detect_alpha_16_full_avx512icl:                        127.5 (14.12x)
detect_alpha_16_limited_c:                            3499.6 ( 1.00x)
detect_alpha_16_limited_avx2:                          633.6 ( 5.52x)
detect_alpha_16_limited_avx512icl:                     551.9 ( 6.34x)
detect_range_8_c:                                     5253.6 ( 1.00x)
detect_range_8_avx2:                                   125.0 (42.01x)
detect_range_8_avx512icl:                              123.2 (42.65x)
detect_range_16_c:                                    3055.2 ( 1.00x)
detect_range_16_avx2:                                  230.0 (13.28x)
detect_range_16_avx512icl:                              95.9 (31.86x)

Clang 19.1.7 | x86_64 (default config) | After:

detect_alpha_8_full_c:                                 323.3 ( 1.00x)
detect_alpha_8_full_avx2:                              149.7 ( 2.16x)
detect_alpha_8_full_avx512icl:                         127.7 ( 2.53x)
detect_alpha_8_limited_c:                             5075.9 ( 1.00x)
detect_alpha_8_limited_avx2:                           625.4 ( 8.12x)
detect_alpha_8_limited_avx512icl:                      493.0 (10.30x)
detect_alpha_16_full_c:                                421.0 ( 1.00x)
detect_alpha_16_full_avx2:                             238.8 ( 1.76x)
detect_alpha_16_full_avx512icl:                        126.0 ( 3.34x)
detect_alpha_16_limited_c:                            3516.8 ( 1.00x)
detect_alpha_16_limited_avx2:                          624.7 ( 5.63x)
detect_alpha_16_limited_avx512icl:                     544.7 ( 6.46x)
detect_range_8_c:                                      609.1 ( 1.00x)
detect_range_8_avx2:                                   239.4 ( 2.54x)
detect_range_8_avx512icl:                               89.0 ( 6.84x)
detect_range_16_c:                                     463.9 ( 1.00x)
detect_range_16_avx2:                                  127.4 ( 3.64x)
detect_range_16_avx512icl:                              86.4 ( 5.37x)

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 17:39:23 +00:00
Lynne 85e8e59001 Revert "doc/developer: Basic documentation for Source Plugins"
This reverts commit 67320e0627.

We do not want random forks or features.
2025-08-11 19:53:28 +09:00
Michael Niedermayer 67320e0627 doc/developer: Basic documentation for Source Plugins
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-11 12:33:16 +02:00
Michael Niedermayer 3542260376 avcodec/scpr3: Clear clr
clr is passing into decode_run_p() its not used when not set
but this possibly triggers msan (it doesnt locally)

Fixes?: use of uninintialized memory
Fixes?: 436997807/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-6253316466606080

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-11 11:54:31 +02:00
Michael Niedermayer 9686fdd729 avcodec/ilbcdec: Clear cbvec when used with create_augmented_vector()
Fixes: use of uninitialized memory
Fixes: 42538134/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ILBC_fuzzer-6322020827070464

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-11 11:54:31 +02:00
Niklas Haas e29a99a975 fftools/ffmpeg_enc: don't ignore user selected chroma location
This code always ignored the user-provided enc_ctx->chroma_sample_location
in favor of the location tagged on the frame. This leads to a very (IMHO)
unexpected outcome where -chroma_sample_location works differently from the
related options like -colorspace and -color_range, the latter of which
override the frame properties as a consequence of being configured on the
filter graph output.

The discrepancy comes from the fact that the chroma sample location does not
itself participate in filter graph negotiation.

Solve the situation by only overriding the enc_ctx option if it was left
unspecified by the user, and otherwise printing a warning if the requested
parameter does not match the frame parameter.
2025-08-11 09:38:38 +02:00
Kacper Michajłow 3bf8bf965f avformat/mov: clear old name from infe
heif_items are reused and to avoid leaking memory or using stale name,
clear it first.

Fixes: 432505829/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6654363487764480
Found-by: OSS-Fuzz
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 01:25:05 +00:00
Leo Izen cd83161ff6 avcodec/vp9: fix leaked cbs fragment AVBufferRef
When this function returns, the fragment is never reset, so
current_frag->data_ref is never unref-ed, which ends up leaking it.
We call ff_cbs_fragment_reset to release the reference on its buffer.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-10 13:23:33 -04:00
Maryla Ustarroz-Calonge via ffmpeg-devel 6711c6a89b ffprobe: add -codec:<media_spec> option and -c:<media_spec> variant
opt_codec() is mostly copied over from ffplay.c.

This is useful when different decoders have different capabilities,
or to test a specific decoder.

Signed-off-by: Maryla Ustarroz-Calonge <maryla@google.com>
2025-08-10 10:19:57 +02:00
Gyan Doshi 9895c4222c doc/filters: correct psnr option name (#20199)
Correct doc entry from stats_add_max to output_max
2025-08-10 11:02:22 +05:30
Michael Niedermayer cfce595572 avcodec/apv_decode: make apv_format_table consistent with the code and check it
Fixes: writing in a null pointer
Fixes: 435278398/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APV_fuzzer-4566392923029504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-10 02:29:09 +00:00
Martin Storsjö 8e4c904c8e checkasm: ac3dsp: Increase the float tolerance for sum_square_butterfly_float
Accept up to 13 ULP difference.

This fixes running "checkasm --test=ac3dsp 3044836819" on ARM.

Depending on how the SIMD implementations aggregate numbers,
larger/smaller values might not end up accumulated in exactly
the same way; the current NEON implementation for ARM aggregates
into vectors of 2 elements. If it would aggregate into vectors
of 4 elements instead, like the AArch64 version does, this particular
case would end up with a smaller difference.
2025-08-10 02:27:44 +00:00
Martin Storsjö 0400e05a1a checkasm: ac3dsp: Fix function name typos for sum_square_butterfly 2025-08-10 02:27:44 +00:00
winlin a72cc49e8a avformat/tls_openssl: fix X509 cert serial number might be negative
See RFC5280 4.1.2.2

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-10 02:26:16 +00:00
nyanmisaka 49f4ef9e79 lavu/log: fix color for AV_CLASS_CATEGORY_HWDEVICE on non-Win32
AV_CLASS_CATEGORY_HWDEVICE was introduced in the past but
no corresponding colors were added for non-Win32 platforms.

Fixes bf1579c ("avutil/log,hwcontext: Add AV_CLASS_CATEGORY_HWDEVICE")

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2025-08-10 02:24:56 +00:00
Jacob Lifshay f6c4a64ee0 tests/fate/subtitles: add test for smpte436m_to_eia608 bsf
Signed-off-by: Jacob Lifshay <programmerjake@gmail.com>
2025-08-10 01:21:44 +00:00
Jacob Lifshay 925fad499d lavc/bsf/smpte436m_to_eia608: fix memory leak -- forgot to free input av_packet
Signed-off-by: Jacob Lifshay <programmerjake@gmail.com>
2025-08-10 01:21:44 +00:00
Jacob Lifshay f0a53917e3 lavc/bsf/eia608_to_smpte436m: fix memory leak -- forgot to free input av_packet
reported in https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20024#issuecomment-2405

Reported-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Jacob Lifshay <programmerjake@gmail.com>
2025-08-10 01:21:44 +00:00
Jacob Lifshay 1d76302eb6 tests/fate/subtitles: fix mcc test input file paths
they use tests/ref/fate/sub-mcc-remux as input,
so prefix them with $(SRC_PATH) so building works
when not in the source directory.

Fixes: #20183
Reported-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Jacob Lifshay <programmerjake@gmail.com>
2025-08-10 01:21:44 +00:00
Timo Rothenpieler 274e00ea84 forgejo/autolabeler: clean up logic a bit and prevent self-looping
The loop-protection only takes effect for the automatic token, not for
ffmpeg-devels PAT.
2025-08-10 01:50:46 +02:00
Mark Thompson 26a2a76346 cbs_vp9: Fix VP9 passthrough
Don't overwrite the bitstream values when updating the top-level loop
filter and segmentation state, instead do the update separately at the
end of the frame parsing.

This also reverts the change to the passthrough tests which made them
have output not matching the input.
2025-08-09 22:46:08 +00:00
Mark Thompson 19473362fc hwcontext_vulkan: Fix build 2025-08-09 22:46:08 +00:00
Mark Thompson 4a42e5a1e2 hwcontext_vulkan: Fix build with older Vulkan headers 2025-08-09 22:46:08 +00:00
Leon Grutters 777408d149 doc/community.texi: fix spelling error
Fixes: 262d41c804 ("all: fix typos found by codespell")
Signed-off-by: Leon Grutters <gruttersleonbot2@gmail.com>
2025-08-09 22:01:42 +00:00
Jack Lau 037fc47f35 doc/protocols: add doc for dtls
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Jack Lau dc9f676b99 avformat/tls: add new option use_srtp to control whether enable it
The SRTP profile string "SRTP_AES128_CM_SHA1_80" is only used when
use_srtp is enabled. Move its declaration inside the "if (s->use_srtp)"
block to limit scope

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Jack Lau fd55c4b5f7 avformat/tls_openssl: add av_assert0() for tls_shared
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Jack Lau d7bc024476 avformat/tls_openssl: simplify the external_sock check
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Jack Lau 553fa9e3df avformat/tls_openssl: cleanup the pointer name of TLSContext and TLSShared
Pure cleanup, no functional changes
Unify local pointer names to `TLSContext *c` and `TLSShared *s` to
reduce confusion from inconsistent names (e.g. p, ctx, s, c)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Timo Rothenpieler e992464f0f forgejo/autolabeler: add some logic to also auto-remove the "New" label 2025-08-09 23:18:57 +02:00
2676 changed files with 139400 additions and 49169 deletions
+166 -8
View File
@@ -12,48 +12,175 @@
# =======
libavcodec/.*aac.* @lynne
libavcodec/.*ac3.* @lynne
libavcodec/.*adpcm.* @zane @pross
libavcodec/anm.* @pross
libavcodec/amf.* @OvchinnikovDmitrii @ArazIusubov
libavcodec/ansi.* @pross
libavcodec/aom_film_grain.* @haasn
libavcodec/.*atrac9.* @lynne
libavcodec/bink.* @pross
libavcodec/bintext.* @pross
libavcodec/.*bitpacked.* @lynne
libavcodec/.*d3d12va.* @jianhuaw
libavcodec/.*d3d12va.* @jianhuaw @tong1wu @younengxiao
libavcodec/.*dirac.* @lynne
libavcodec/.*dovi_rpu.* @haasn
libavcodec/dpx.* @pross
libavcodec/dsd.* @pross
libavcodec/eacmv.* @pross
libavcodec/eaidct.* @pross
libavcodec/eamad.* @pross
libavcodec/eat.* @pross
libavcodec/.*exif.* @Traneptora
libavcodec/.*ffv1.* @lynne @michaelni
libavcodec/g728.* @pross
libavcodec/gem.* @pross
libavcodec/golomb.* @michaelni
libavcodec/.*h266.* @frankplow @NuoMi @jianhuaw
libavcodec/h26x/.* @frankplow @NuoMi @jianhuaw
libavcodec/.*jpegxl.* @lynne
libavcodec/.*jxl.* @lynne
libavcodec/.*h274.* @haasn
libavcodec/iff.* @pross
libavcodec/.*jpegxl.* @lynne @Traneptora
libavcodec/jpeg2000htdec.* @cae
libavcodec/jv.* @pross
libavcodec/.*jxl.* @lynne @Traneptora
libavcodec/.*lcms2.* @haasn
libavcodec/lead.* @pross
libavcodec/mediacodec* @quink
libavcodec/mjpeg* @michaelni
libavcodec/mmvideo.* @pross
libavcodec/msp2.* @pross
libavcodec/mvc.* @pross
libavcodec/oh* @quink
libavcodec/.*opus.* @lynne
libavcodec/pictor.* @pross
libavcodec/.*png.* @Traneptora
libavcodec/.*prores.* @lynne
libavcodec/rangecoder.* @michaelni
libavcodec/ratecontrol.* @michaelni
libavcodec/rkmpp* @quink
libavcodec/rv60.* @pross
libavcodec/sgirle.* @pross
libavcodec/.*siren.* @lynne
libavcodec/smpte_436m.* @programmerjake
libavcodec/svq1.* @pross
libavcodec/svq3.* @pross
libavcodec/.*vc2.* @lynne
libavcodec/videotoolbox.* @ePirat
libavcodec/vp3.* @pross
libavcodec/vp4.* @pross
libavcodec/vp5.* @pross
libavcodec/vp6.* @pross
libavcodec/vp8.* @rbultje @pross
libavcodec/vp9.* @rbultje
libavcodec/vpx.* @rbultje @pross
libavcodec/vqc.* @pross
libavcodec/.*vvc.* @frankplow @NuoMi @jianhuaw
libavcodec/wmavoice.* @rbultje
libavcodec/wbmp.* @pross
# bitstream filters
libavcodec/bsf/eia608_to_smpte436m.* @programmerjake
libavcodec/bsf/smpte436m_to_eia608.* @programmerjake
# architecture-specific
libavcodec/aarch64/.* @lynne @mstorsjo
libavcodec/arm/.* @mstorsjo
libavcodec/ppc/.* @sean_mcg
libavcodec/riscv/.* @Courmisch
libavcodec/wasm/hevc/.* @quink
libavcodec/x86/.* @lynne
libavcodec/x86/vp8.* @rbultje
libavcodec/x86/vp9.* @rbultje
libavcodec/x86/vpx.* @rbultje
# avfilter
# =======
libavfilter/aarch64/.* @mstorsjo
libavfilter/af_loudnorm.* @kylophone
libavfilter/af_whisper.* @vpalmisano
libavfilter/.*_amf* @OvchinnikovDmitrii @ArazIusubov
libavfilter/avfiltergraph.* @haasn
libavfilter/colorspace.* @rbultje
libavfilter/formats.* @haasn
libavfilter/.*f_ebur128.* @haasn
libavfilter/vf_blackdetect.* @haasn
libavfilter/vf_colordetect.* @haasn
libavfilter/vf_colorspace.* @rbultje
libavfilter/.*drawvg.* @ayosec
libavfilter/vf_find_rect.* @michaelni
libavfilter/vf_icc.* @haasn
libavfilter/vf_libplacebo.* @haasn
libavfilter/vf_libvmaf.* @kylophone
libavfilter/vf_mpdecimate.* @dana-feng
libavfilter/vf_premultiply.* @haasn
libavfilter/vf_scale.* @haasn
libavfilter/vf_scale_vt.* @quink
libavfilter/vf_thumbnail.* @haasn
libavfilter/vf_transpose_vt.* @quink
libavfilter/vf_yadif.* @michaelni
libavfilter/vsrc_mandelbrot.* @michaelni
libavfilter/aarch64/.* @mstorsjo
libavfilter/riscv/.* @Courmisch
libavfilter/x86/colorspace.* @rbultje
libavfilter/x86/scene_sad.* @haasn
# avformat
# =======
libavformat/alp.* @zane
libavformat/amv.* @zane
libavformat/anm.* @pross
libavformat/apm.* @zane
libavformat/argo_.* @zane
libavformat/bink.* @pross
libavformat/bintext.* @pross
libavformat/caf.* @pross
libavformat/cine.* @pross
libavformat/dsf.* @pross
libavformat/eacdata.* @pross
libavformat/electronicarts.* @pross
libavformat/.*exif.* @Traneptora
libavformat/filmstrip.* @pross
libavformat/frm.* @pross
libavformat/hls.* @kasper93
libavformat/hxvs.* @quink
libavformat/iamf.* @jamrial
libavformat/icecast.c @ePirat
libavformat/ico.* @pross
libavformat/iff.* @pross
libavformat/.*jpegxl.* @Traneptora
libavformat/jv.* @pross
libavformat/.*jxl.* @Traneptora
libavformat/kvag.* @zane
libavformat/mccdec.* @programmerjake
libavformat/mccenc.* @programmerjake
libavformat/mlv.* @pross
libavformat/mm.* @pross
libavformat/msp.* @pross
libavformat/mv.* @pross
libavformat/ogg.* @toots
libavformat/pp_bnk.* @zane
libavformat/rm.* @pross
libavformat/sauce.* @pross
libavformat/scd.* @zane
libavformat/tty.* @pross
libavformat/whip.c @JackLau
libavformat/wsd.* @pross
libavformat/wtv.* @pross
# avutil
# ======
libavutil/.*_amf* @OvchinnikovDmitrii @ArazIusubov
libavutil/.*crc.* @lynne @michaelni
libavutil/.*d3d12va.* @jianhuaw
libavutil/.*d3d12va.* @jianhuaw @tong1wu @younengxiao
libavutil/csp.* @rbultje @haasn
libavutil/eval.* @michaelni
libavutil/film_grain.* @haasn
libavutil/dovi_meta.* @haasn
libavutil/hwcontext_oh.* @quink
libavutil/hwcontext_mediacodec.* @quink
libavutil/hwcontext_videotoolbox.* @ePirat
libavutil/iamf.* @jamrial
libavutil/integer.* @michaelni
libavutil/kiss99.* @michaelni
libavutil/lfg.* @michaelni
libavutil/lls.* @michaelni
libavutil/md5.* @michaelni
@@ -70,6 +197,8 @@ libavutil/tx.* @lynne
libavutil/aarch64/.* @lynne @mstorsjo
libavutil/arm/.* @mstorsjo
libavutil/ppc/.* @sean_mcg
libavutil/riscv/.* @Courmisch
libavutil/wasm/.* @quink
libavutil/x86/.* @lynne
# swresample
@@ -83,6 +212,13 @@ libswresample/.* @michaelni
libswscale/aarch64/.* @mstorsjo
libswscale/arm/.* @mstorsjo
libswscale/ppc/.* @sean_mcg
libswscale/riscv/.* @Courmisch
libswscale/.* @haasn
# tools
# =====
fftools/ffplay_renderer.* @haasn
tools/target_dec_fuzzer.c @michaelni
# doc
# ===
@@ -90,5 +226,27 @@ doc/.* @GyanD
# Frameworks
# ==========
.*d3d12va.* @jianhuaw
.*vulkan.* @lynne
.*d3d12va.* @jianhuaw @tong1wu @younengxiao
.*vulkan.* @lynne @haasn
# tests
# =====
tests/checkasm/riscv/.* @Courmisch
libavutil/tests/buffer.* @MarcosAsh
libavutil/tests/hdr_dynamic_vivid_metadata.* @MarcosAsh
libavutil/tests/tdrdi.* @MarcosAsh
libavutil/tests/timestamp.* @MarcosAsh
tests/ref/.*drawvg.* @ayosec
tests/ref/fate/buffer @MarcosAsh
tests/ref/fate/hdr_dynamic_vivid_metadata @MarcosAsh
tests/ref/fate/sub-mcc.* @programmerjake
tests/ref/fate/tdrdi @MarcosAsh
tests/ref/fate/timestamp @MarcosAsh
# Forgejo
# =======
.forgejo/CODEOWNERS @michaelni
# /
# =
MAINTAINERS @michaelni
+45 -7
View File
@@ -1,6 +1,7 @@
module.exports = async ({github, context}) => {
const title = (context.payload.pull_request?.title || context.payload.issue?.title || '').toLowerCase();
const labels = [];
const issueNumber = context.payload.pull_request?.number || context.payload.issue?.number;
const kwmap = {
'avcodec': 'avcodec',
@@ -10,18 +11,55 @@ module.exports = async ({github, context}) => {
'avutil': 'avutil',
'swresample': 'swresample',
'swscale': 'swscale',
'fftools': 'CLI'
'fftools': 'CLI',
'vulkan': 'vulkan'
};
if (context.payload.action === 'opened') {
async function isOrgMember(username) {
try {
const response = await github.rest.orgs.checkMembershipForUser({
org: context.repo.owner,
username: username
});
return response.status === 204;
} catch (error) {
return false;
}
}
if (context.payload.action === 'closed' ||
(context.payload.action !== 'opened' && (
context.payload.action === 'assigned' ||
context.payload.action === 'label_updated' ||
context.payload.action === 'labeled' ||
context.payload.comment) &&
await isOrgMember(context.payload.sender.login))
) {
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
// this should say 'new', but forgejo deviates from GitHub API here and expects the ID
name: '41'
});
console.log('Removed "new" label');
} catch (error) {
if (error.status !== 404 && error.status !== 410) {
console.log('Could not remove "new" label');
}
}
} else if (context.payload.action === 'opened') {
labels.push('new');
console.log('Detected label: new');
}
for (const [kw, label] of Object.entries(kwmap)) {
if (title.includes(kw)) {
labels.push(label);
console.log('Detected label: ' + label);
if ((context.payload.action === 'opened' || context.payload.action === 'edited') && context.eventName !== 'issue_comment') {
for (const [kw, label] of Object.entries(kwmap)) {
if (title.includes(kw)) {
labels.push(label);
console.log('Detected label: ' + label);
}
}
}
@@ -29,7 +67,7 @@ module.exports = async ({github, context}) => {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request?.number || context.payload.issue?.number,
issue_number: issueNumber,
labels: labels,
});
}
+12 -8
View File
@@ -1,31 +1,35 @@
avcodec:
- changed-files:
- any-glob-to-any-file: libavcodec/**
- any-glob-to-any-file: 'libavcodec/**'
avdevice:
- changed-files:
- any-glob-to-any-file: libavdevice/**
- any-glob-to-any-file: 'libavdevice/**'
avfilter:
- changed-files:
- any-glob-to-any-file: libavfilter/**
- any-glob-to-any-file: 'libavfilter/**'
avformat:
- changed-files:
- any-glob-to-any-file: libavformat/**
- any-glob-to-any-file: 'libavformat/**'
avutil:
- changed-files:
- any-glob-to-any-file: libavutil/**
- any-glob-to-any-file: 'libavutil/**'
swresample:
- changed-files:
- any-glob-to-any-file: libswresample/**
- any-glob-to-any-file: 'libswresample/**'
swscale:
- changed-files:
- any-glob-to-any-file: libswscale/**
- any-glob-to-any-file: 'libswscale/**'
CLI:
- changed-files:
- any-glob-to-any-file: fftools/**
- any-glob-to-any-file: 'fftools/**'
vulkan:
- changed-files:
- any-glob-to-any-file: '**/*vulkan*'
+8
View File
@@ -18,6 +18,14 @@ repos:
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
- repo: local
hooks:
- id: arm-asm-indent
name: fix arm/aarch64 assembly indentation
files: ^.*/(arm|aarch64)/.*\.S$
language: script
entry: ./tools/check_arm_indent.sh --apply
pass_filenames: false
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
+1
View File
@@ -69,6 +69,7 @@ pEvents
PixelX
Psot
quater
re-use
readd
recuse
redY
+12 -5
View File
@@ -1,23 +1,30 @@
name: Autolabel
on:
pull_request_target:
types: [opened, edited, synchronize]
types: [opened, edited, synchronize, closed, assigned, labeled, unlabeled]
issues:
types: [opened, edited]
types: [opened, edited, closed, assigned, labeled, unlabeled]
issue_comment:
types: [created]
jobs:
pr_labeler:
name: Labeler
runs-on: utilities
if: ${{ github.event.sender.login != 'ffmpeg-devel' }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Label by file-changes
uses: https://github.com/actions/labeler@v5
uses: actions/labeler@v6
if: ${{ forge.event_name == 'pull_request_target' }}
with:
configuration-path: .forgejo/labeler/labeler.yml
repo-token: ${{ secrets.AUTOLABELER_TOKEN }}
sync-labels: true
- name: Label by title-match
uses: https://github.com/actions/github-script@v7
uses: actions/github-script@v8
with:
script: |
const script = require('.forgejo/labeler/labeler.js')
+8 -2
View File
@@ -1,15 +1,21 @@
name: Lint
on:
push:
branches:
- master
pull_request:
concurrency:
cancel-in-progress: ${{ forge.event_name == 'pull_request' }}
jobs:
lint:
name: Pre-Commit
runs-on: utilities
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Install pre-commit CI
id: install
run: |
@@ -18,7 +24,7 @@ jobs:
~/pre-commit/bin/pip install pre-commit
echo "envhash=$({ python3 --version && cat .forgejo/pre-commit/config.yaml; } | sha256sum | cut -d' ' -f1)" >> $FORGEJO_OUTPUT
- name: Cache
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ steps.install.outputs.envhash }}
+70 -11
View File
@@ -1,26 +1,47 @@
name: Test
on:
push:
branches:
- master
pull_request:
concurrency:
cancel-in-progress: ${{ forge.event_name == 'pull_request' }}
jobs:
run_fate:
name: Fate (${{ matrix.runner }}, ${{ matrix.shared }}, ${{ matrix.bits }} bit)
strategy:
fail-fast: false
matrix:
runner: [linux-amd64,linux-aarch64]
runner: [linux-aarch64]
shared: ['static']
bits: ['64']
include:
- runner: linux-amd64
shared: 'static'
bits: '32'
- runner: linux-amd64
shared: 'shared'
bits: '64'
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Configure
run: ./configure --enable-gpl --enable-nonfree --enable-memory-poisoning --assert-level=2
run: |
./configure --enable-gpl --enable-nonfree --enable-memory-poisoning --assert-level=2 \
$([ "${{ matrix.bits }}" != "32" ] || echo --arch=x86_32 --extra-cflags=-m32 --extra-cxxflags=-m32 --extra-ldflags=-m32) \
$([ "${{ matrix.shared }}" != "shared" ] || echo --enable-shared --disable-static) \
|| CFGRES=$?
cat ffbuild/config.log
exit ${CFGRES:-0}
- name: Build
run: make -j$(nproc)
- name: Restore Cached Fate-Suite
id: cache
uses: actions/cache/restore@v4
uses: actions/cache/restore@v5
with:
path: fate-suite
key: fate-suite
@@ -30,30 +51,68 @@ jobs:
id: fate
run: |
make fate-rsync SAMPLES=$PWD/fate-suite
echo "hash=$(find fate-suite -type f | sort | sha256sum | cut -d' ' -f1)" >> $FORGEJO_OUTPUT
echo "hash=$(find fate-suite -type f -printf "%P %s %T@\n" | sort | sha256sum | cut -d' ' -f1)" >> $FORGEJO_OUTPUT
- name: Cache Fate-Suite
uses: actions/cache/save@v4
uses: actions/cache/save@v5
if: ${{ format('fate-suite-{0}', steps.fate.outputs.hash) != steps.cache.outputs.cache-matched-key }}
with:
path: fate-suite
key: fate-suite-${{ steps.fate.outputs.hash }}
- name: Run Fate
run: make fate SAMPLES=$PWD/fate-suite -j$(nproc)
compile_only:
run: |
LD_LIBRARY_PATH="$(printf "%s:" "$PWD"/lib*)$PWD" make fate fate-build SAMPLES="$PWD/fate-suite" -j$(nproc) || FATERES=$?
find . -name "*.err" -exec printf '::group::%s\n' {} \; -exec cat {} \; -exec printf '::endgroup::\n' \;
exit ${FATERES:-0}
run_fate_full:
name: Fate (Full, ${{ matrix.target_exec }})
strategy:
fail-fast: false
matrix:
image: ["ghcr.io/btbn/ffmpeg-builds/win64-gpl:latest"]
image: ['ghcr.io/btbn/ffmpeg-builds/win64-gpl:latest']
target_exec: ['wine']
runs-on: linux-amd64
container: ${{ matrix.image }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Configure
run: |
./configure --pkg-config-flags="--static" $FFBUILD_TARGET_FLAGS $FF_CONFIGURE \
--cc="$CC" --cxx="$CXX" --ar="$AR" --ranlib="$RANLIB" --nm="$NM" \
--extra-cflags="$FF_CFLAGS" --extra-cxxflags="$FF_CXXFLAGS" \
--extra-libs="$FF_LIBS" --extra-ldflags="$FF_LDFLAGS" --extra-ldexeflags="$FF_LDEXEFLAGS"
--extra-libs="$FF_LIBS" --extra-ldflags="$FF_LDFLAGS" --extra-ldexeflags="$FF_LDEXEFLAGS" \
--enable-memory-poisoning --assert-level=2 --target-exec="${{ matrix.target_exec }}" \
--enable-hardcoded-tables \
|| CFGRES=$?
cat ffbuild/config.log
exit ${CFGRES:-0}
- name: Build
run: make -j$(nproc)
- name: Restore Cached Fate-Suite
id: cache
uses: actions/cache/restore@v5
with:
path: fate-suite
key: fate-suite
restore-keys: |
fate-suite-
- name: Sync Fate-Suite
id: fate
run: |
make fate-rsync SAMPLES=$PWD/fate-suite
echo "hash=$(find fate-suite -type f -printf "%P %s %T@\n" | sort | sha256sum | cut -d' ' -f1)" >> $FORGEJO_OUTPUT
- name: Cache Fate-Suite
uses: actions/cache/save@v5
if: ${{ format('fate-suite-{0}', steps.fate.outputs.hash) != steps.cache.outputs.cache-matched-key }}
with:
path: fate-suite
key: fate-suite-${{ steps.fate.outputs.hash }}
- name: Run Fate
run: |
if [[ "${{ matrix.target_exec }}" == "wine" ]]; then
export WINEDEBUG=-all
export FREI0R_PATH="$(winepath -w "$FREI0R_PATH")"
fi
LD_LIBRARY_PATH="$(printf "%s:" "$PWD"/lib*)$PWD" make fate fate-build SAMPLES="$PWD/fate-suite" -j$(nproc) || FATERES=$?
find . -name "*.err" -exec printf '::group::%s\n' {} \; -exec cat {} \; -exec printf '::endgroup::\n' \;
exit ${FATERES:-0}
+6
View File
@@ -23,6 +23,11 @@
*.metal.air
*.metallib
*.metallib.c
*.spv
*.spv.c
*.spv.gz
*.gen.c
*.gen.S
*.ptx
*.ptx.c
*.ptx.gz
@@ -36,6 +41,7 @@
/ffprobe
/config.asm
/config.h
/config_components.asm
/config_components.h
/coverage.info
/lcov/
+2 -1
View File
@@ -1,4 +1,5 @@
# Note to Github users
Patches should be submitted to the [ffmpeg-devel mailing list](https://ffmpeg.org/mailman/listinfo/ffmpeg-devel) using `git format-patch` or `git send-email`. Github pull requests should be avoided because they are not part of our review process and **will be ignored**.
Patches should be submitted to [Forgejo](https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls) or the [ffmpeg-devel mailing list](https://ffmpeg.org/mailman/listinfo/ffmpeg-devel) using `git format-patch` or `git send-email`. Github pull requests should be avoided because they are not part of our review process and **will be ignored**.
See [https://ffmpeg.org/developer.html#Contributing](https://ffmpeg.org/developer.html#Contributing) for more information.
+42
View File
@@ -2,12 +2,52 @@ Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest.
version <next>:
- Extend AMF Color Converter (vf_vpp_amf) HDR capabilities
- LCEVC track muxing support in MP4 muxer
- Playdate video encoder and muxer
- Add v360_vulkan filter
- HE-AAC 960 decoding (DAB+)
- transpose_cuda filter
- Add AMF Frame Rate Converter (vf_frc_amf) filter
- SMPTE 2094-50 metadata support and passthrough
version 8.1:
- ffprobe -codec option
- EXIF Metadata Parsing
- gfxcapture: Windows.Graphics.Capture based window/monitor capture
- hxvs demuxer for HXVS/HXVT IP camera format
- MPEG-H 3D Audio decoding via mpeghdec
- D3D12 H.264 encoder
- drawvg filter via libcairo
- ffmpeg CLI tiled HEIF support
- D3D12 AV1 encoder
- ProRes Vulkan hwaccel
- DPX Vulkan hwaccel
- Rockchip H.264/HEVC hardware encoder
- Add vf_scale_d3d12 filter
- JPEG-XS parser
- JPEG-XS decoder and encoder through libsvtjpegxs
- JPEG-XS raw bitstream muxer and demuxer
- IAMF Projection mode Ambisonic Audio Elements muxing and demuxing
- Add vf_mestimate_d3d12 filter
- xHE-AAC Mps212 decoding support (experimental)
- Remove the old HLS protocol handler
- Vulkan compute codec optimizations
- swscale Vulkan support
- LCEVC metadata bitstream filter
- Add vf_deinterlace_d3d12 filter
- ffprobe: only show refs field in stream section when reading frames
- ProRes Vulkan encoder
- LCEVC parser
- LCEVC enhancement layer exporting in MPEG-TS
version 8.0:
- Whisper filter
- Drop support for OpenSSL < 1.1.0
- Enable TLS peer certificate verification by default (on next major version bump)
- Drop support for OpenSSL < 1.1.1
- yasm support dropped, users need to use nasm
- VVC VAAPI decoder
- RealVideo 6.0 decoder
@@ -36,6 +76,8 @@ version 8.0:
- AV1 Vulkan encoder
- ProRes RAW decoder
- ProRes RAW Vulkan hwaccel
- ffprobe -codec option
- HDR10+ metadata passthrough when decoding/encoding with libaom-av1
version 7.1:
+6 -10
View File
@@ -1,4 +1,4 @@
## Installing FFmpeg
# Installing FFmpeg
0. If you like to include source plugins, merge them before configure
for example run tools/merge-all-source-plugins
@@ -14,15 +14,11 @@ path when launching `configure`, e.g. `/ffmpegdir/ffmpeg/configure`.
3. Type `make install` to install all binaries and libraries you built.
NOTICE
------
## NOTICE
- Non system dependencies (e.g. libx264, libvpx) are disabled by default.
- Non system dependencies (e.g. libx264, libvpx) are disabled by default.
NOTICE for Package Maintainers
------------------------------
## NOTICE for Package Maintainers
- It is recommended to build FFmpeg twice, first with minimal external dependencies so
that 3rd party packages, which depend on FFmpegs libavutil/libavfilter/libavcodec/libavformat
can then be built. And last build FFmpeg with full dependencies (which may in turn depend on
some of these 3rd party packages). This avoids circular dependencies during build.
- It is recommended to build FFmpeg twice, first with minimal external dependencies so that 3rd party packages, which depend on FFmpegs libavutil/libavfilter/libavcodec/libavformat
can then be built. And last build FFmpeg with full dependencies (which may in turn depend on some of these 3rd party packages). This avoids circular dependencies during build.
+21 -7
View File
@@ -93,6 +93,7 @@ Other:
hash Reimar Doeffinger
hwcontext_cuda* Timo Rothenpieler
hwcontext_d3d12va* Wu Jianhua
hwcontext_oh* Zhao Zhili
hwcontext_vulkan* [2] Lynne
intfloat* Michael Niedermayer
integer.c, integer.h Michael Niedermayer
@@ -152,13 +153,13 @@ Codecs:
adpcm.c Zane van Iperen
alacenc.c Jaikrishnan Menon
alsdec.c Thilo Borgmann, Umair Khan
amfenc* Dmitrii Ovchinnikov
amfdec*,amfenc* [2] Dmitrii Ovchinnikov, Araz Iusubov
aptx.c Aurelien Jacobs
ass* Aurelien Jacobs
asv* Michael Niedermayer
atrac3plus* Maxim Poliakovski
audiotoolbox* rcombs
avs2* Huiwen Ren
avs2* Huiwen Ren, Zhao Zhili
bgmc.c, bgmc.h Thilo Borgmann
binkaudio.c Peter Ross
cavs* Stefan Gehrer
@@ -211,7 +212,7 @@ Codecs:
libkvazaar.c Arttu Ylä-Outinen
libopenh264enc.c Martin Storsjo, Linjie Fu
libopenjpegenc.c Michael Bradshaw
libtheoraenc.c David Conrad
libtheoraenc.c [0]
libvorbis.c David Conrad
libvpx* James Zern
libxavs.c Stefan Gehrer
@@ -232,6 +233,7 @@ Codecs:
msvideo1.c Mike Melanson
nuv.c Reimar Doeffinger
nvdec*, nvenc* Timo Rothenpieler
oh* Zhao Zhili
omx.c Martin Storsjo, Aman Gupta
opus* Rostislav Pehlivanov
pcx.c Ivo van Poorten
@@ -243,6 +245,7 @@ Codecs:
qtrle.c Mike Melanson
ra144.c, ra144.h, ra288.c, ra288.h Roberto Togni
resample2.c Michael Niedermayer
rkmppenc* Zhao Zhili
rl2.c Sascha Sommer
rpza.c Roberto Togni
rtjpeg.c, rtjpeg.h Reimar Doeffinger
@@ -278,6 +281,7 @@ Codecs:
xface Stefano Sabatini
Hardware acceleration:
amf* [2] Dmitrii Ovchinnikov, Araz Iusubov
dxva2* Hendrik Leppkes, Laurent Aimar, Steve Lhomme
d3d11va* Steve Lhomme
d3d12va* Wu Jianhua
@@ -316,6 +320,10 @@ libavfilter
===========
Generic parts:
Framework and orphaned filters Nicolas George
(except hardware acceleration)
graphdump.c Nicolas George
motion_estimation.c Davinder Singh
@@ -347,7 +355,9 @@ Filters:
vf_minterpolate.c Davinder Singh
vf_readvitc.c Tobias Rapp (CC t.rapp at noa-archive dot com)
vf_scale.c [2] Michael Niedermayer
vf_scale_vt.c Zhao Zhili
vf_tonemap_opencl.c Ruiling Song
vf_transpose_vt.c Zhao Zhili
vf_yadif.c [2] Michael Niedermayer
vf_xfade_vulkan.c [2] Marvin Scholz (CC <epirat07@gmail.com>)
@@ -405,7 +415,9 @@ Muxers/Demuxers:
flvenc.c Michael Niedermayer, Steven Liu
gxf.c Reimar Doeffinger
gxfenc.c Baptiste Coudurier
hls.c Kacper Michajłow
hlsenc.c Christian Suloway, Steven Liu
hxvs.c Zhao Zhili
iamf* [2] James Almer
idcin.c Mike Melanson
idroqdec.c Mike Melanson
@@ -441,9 +453,9 @@ Muxers/Demuxers:
nsvdec.c Francois Revol
nut* Michael Niedermayer
nuv.c Reimar Doeffinger
oggdec.c, oggdec.h David Conrad
oggenc.c Baptiste Coudurier
oggparse*.c David Conrad
oggdec.c, oggdec.h David Conrad, Romain Beauxis
oggenc.c Baptiste Coudurier, Romain Beauxis
oggparse*.c David Conrad, Romain Beauxis
oma.c Maxim Poliakovski
pp_bnk.c Zane van Iperen
psxstr.c Mike Melanson
@@ -482,6 +494,7 @@ Muxers/Demuxers:
webm dash (matroskaenc.c) Vignesh Venkatasubramanian
webvtt* Matthew J Heaney
westwood.c Mike Melanson
whip.c [2] Jack Lau
wtv.c Peter Ross
Protocols:
@@ -521,7 +534,7 @@ LoongArch [2] Shiyou Yin
Darwin (macOS, iOS) [2] Marvin Scholz
Mac OS X / PowerPC [0]
Amiga / PowerPC Colin Ward
Linux / PowerPC [1] Lauri Kasanen
Linux / PowerPC [2] Sean McGovern (CC <gseanmcg@gmail.com>), Lauri Kasanen
RISC-V [2] Rémi Denis-Courmont
Windows MinGW Alex Beregszaszi, Ramiro Polla
Windows Cygwin Victor Paesa
@@ -617,6 +630,7 @@ Reinhard Tartler 9300 5DC2 7E87 6C37 ED7B CA9A 9808 3544 9453 48A4
Reynaldo H. Verdejo Pinochet 6E27 CD34 170C C78E 4D4F 5F40 C18E 077F 3114 452A
Robert Swain EE7A 56EA 4A81 A7B5 2001 A521 67FA 362D A2FC 3E71
Sascha Sommer 38A0 F88B 868E 9D3A 97D4 D6A0 E823 706F 1E07 0D3C
Sean McGovern (Sean_McG) 6D03 BC60 3A33 E615 6E2E 06AD 8C06 8175 6F59 8684
Stefano Sabatini 0D0B AD6B 5330 BBAD D3D6 6A0C 719C 2839 FC43 2D5F
Steinar H. Gunderson C2E9 004F F028 C18E 4EAD DB83 7F61 7561 7797 8F76
Stephan Hilb 4F38 0B3A 5F39 B99B F505 E562 8D5C 5554 4E17 8863
+16 -13
View File
@@ -11,6 +11,8 @@ vpath %.asm $(SRC_PATH)
vpath %.rc $(SRC_PATH)
vpath %.v $(SRC_PATH)
vpath %.texi $(SRC_PATH)
vpath %.glsl $(SRC_PATH)
vpath %.spv $(SRC_PATH)
vpath %.cu $(SRC_PATH)
vpath %.ptx $(SRC_PATH)
vpath %.metal $(SRC_PATH)
@@ -53,31 +55,31 @@ FF_DEP_LIBS := $(DEP_LIBS)
FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS)
$(TOOLS): %$(EXESUF): %.o
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter-out $(FF_DEP_LIBS), $^) $(EXTRALIBS-$(*F)) $(EXTRALIBS) $(ELIBS)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter-out $(FF_DEP_LIBS), $^) $(EXTRALIBS-$(*F)) $(EXTRALIBS) $(ELIBS))
target_dec_%_fuzzer$(EXESUF): target_dec_%_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
target_enc_%_fuzzer$(EXESUF): target_enc_%_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
tools/target_bsf_%_fuzzer$(EXESUF): tools/target_bsf_%_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
target_dem_%_fuzzer$(EXESUF): target_dem_%_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
tools/target_dem_fuzzer$(EXESUF): tools/target_dem_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
tools/target_io_dem_fuzzer$(EXESUF): tools/target_io_dem_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
tools/target_sws_fuzzer$(EXESUF): tools/target_sws_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
tools/target_swr_fuzzer$(EXESUF): tools/target_swr_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
tools/enum_options$(EXESUF): ELIBS = $(FF_EXTRALIBS)
tools/enum_options$(EXESUF): $(FF_DEP_LIBS)
@@ -107,10 +109,11 @@ ffbuild/.config: $(CONFIGURABLE_COMPONENTS)
SUBDIR_VARS := CLEANFILES FFLIBS HOSTPROGS TESTPROGS TOOLS \
HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \
ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS \
ALTIVEC-OBJS VSX-OBJS MMX-OBJS X86ASM-OBJS \
ALTIVEC-OBJS VSX-OBJS X86ASM-OBJS \
MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS \
MMI-OBJS LSX-OBJS LASX-OBJS RV-OBJS RVV-OBJS RVVB-OBJS \
OBJS SHLIBOBJS STLIBOBJS HOSTOBJS TESTOBJS SIMD128-OBJS
OBJS SHLIBOBJS STLIBOBJS HOSTOBJS TESTOBJS SIMD128-OBJS \
SVE-OBJS SVE2-OBJS SME-OBJS SME2-OBJS
define RESET
$(1) :=
@@ -144,7 +147,7 @@ else
endif
%$(PROGSSUF)_g$(EXESUF): $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS))
VERSION_SH = $(SRC_PATH)/ffbuild/version.sh
ifeq ($(VERSION_TRACKING),yes)
@@ -184,7 +187,7 @@ clean::
$(RM) -rf coverage.info coverage.info.in lcov
distclean:: clean
$(RM) .version config.asm config.h config_components.h mapfile \
$(RM) .version config.asm config.h config_components.* mapfile \
ffbuild/.config ffbuild/config.* libavutil/avconfig.h \
version.h libavutil/ffversion.h libavcodec/codec_names.h \
libavcodec/bsf_list.c libavformat/protocol_list.c \
+1 -2
View File
@@ -1,5 +1,4 @@
FFmpeg README
=============
# FFmpeg README
FFmpeg is a collection of libraries and tools to process multimedia content
such as audio, video, subtitles and related metadata.
+1 -1
View File
@@ -1 +1 @@
7.1.git
8.0.git
+114
View File
@@ -0,0 +1,114 @@
/*
* Android Binder handler
*
* Copyright (c) 2025 Dmitrii Okunev
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if defined(__ANDROID__)
#include <dlfcn.h>
#include <stdint.h>
#include <stdlib.h>
#include "libavutil/log.h"
#include "binder.h"
#define THREAD_POOL_SIZE 1
static void *dlopen_libbinder_ndk(void)
{
/*
* libbinder_ndk.so often does not contain the functions we need, so making
* this dependency optional, thus using dlopen/dlsym instead of linking.
*
* See also: https://source.android.com/docs/core/architecture/aidl/aidl-backends
*/
void *h = dlopen("libbinder_ndk.so", RTLD_NOW | RTLD_LOCAL);
if (h != NULL)
return h;
av_log(NULL, AV_LOG_WARNING,
"android/binder: unable to load libbinder_ndk.so: '%s'; skipping binder threadpool init (MediaCodec likely won't work)\n",
dlerror());
return NULL;
}
static void android_binder_threadpool_init(void)
{
typedef int (*set_thread_pool_max_fn)(uint32_t);
typedef void (*start_thread_pool_fn)(void);
set_thread_pool_max_fn set_thread_pool_max = NULL;
start_thread_pool_fn start_thread_pool = NULL;
void *h = dlopen_libbinder_ndk();
if (h == NULL)
return;
unsigned thead_pool_size = THREAD_POOL_SIZE;
set_thread_pool_max =
(set_thread_pool_max_fn) dlsym(h,
"ABinderProcess_setThreadPoolMaxThreadCount");
start_thread_pool =
(start_thread_pool_fn) dlsym(h, "ABinderProcess_startThreadPool");
if (start_thread_pool == NULL) {
av_log(NULL, AV_LOG_WARNING,
"android/binder: ABinderProcess_startThreadPool not found; skipping threadpool init (MediaCodec likely won't work)\n");
return;
}
if (set_thread_pool_max != NULL) {
int ok = set_thread_pool_max(thead_pool_size);
av_log(NULL, AV_LOG_DEBUG,
"android/binder: ABinderProcess_setThreadPoolMaxThreadCount(%u) => %s\n",
thead_pool_size, ok ? "ok" : "fail");
} else {
av_log(NULL, AV_LOG_DEBUG,
"android/binder: ABinderProcess_setThreadPoolMaxThreadCount is unavailable; using the library default\n");
}
start_thread_pool();
av_log(NULL, AV_LOG_DEBUG,
"android/binder: ABinderProcess_startThreadPool() called\n");
}
void android_binder_threadpool_init_if_required(void)
{
#if __ANDROID_API__ >= 24
if (android_get_device_api_level() < 35) {
// the issue with the thread pool was introduced in Android 15 (API 35)
av_log(NULL, AV_LOG_DEBUG,
"android/binder: API<35, thus no need to initialize a thread pool\n");
return;
}
android_binder_threadpool_init();
#else
// android_get_device_api_level was introduced in API 24, so we cannot use it
// to detect the API level in API<24. For simplicity we just assume
// libbinder_ndk.so on the system running this code would have API level < 35;
av_log(NULL, AV_LOG_DEBUG,
"android/binder: is built with API<24, assuming this is not Android 15+\n");
#endif
}
#endif /* __ANDROID__ */
@@ -1,5 +1,7 @@
/*
* Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com)
* Android Binder handler
*
* Copyright (c) 2025 Dmitrii Okunev
*
* This file is part of FFmpeg.
*
@@ -18,16 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/attributes.h"
#include "libavutil/mips/cpu.h"
#include "libavcodec/mpegvideoenc.h"
#include "mpegvideo_mips.h"
#ifndef COMPAT_ANDROID_BINDER_H
#define COMPAT_ANDROID_BINDER_H
av_cold void ff_mpvenc_dct_init_mips(MPVEncContext *s)
{
int cpu_flags = av_get_cpu_flags();
/**
* Initialize Android Binder thread pool.
*/
void android_binder_threadpool_init_if_required(void);
if (have_mmi(cpu_flags)) {
s->denoise_dct = ff_denoise_dct_mmi;
}
}
#endif // COMPAT_ANDROID_BINDER_H
+1
View File
@@ -182,6 +182,7 @@ static inline __device__ float fabsf(float a) { return __builtin_fabsf(a); }
static inline __device__ float fabs(float a) { return __builtin_fabsf(a); }
static inline __device__ double fabs(double a) { return __builtin_fabs(a); }
static inline __device__ float sqrtf(float a) { return __builtin_sqrtf(a); }
static inline __device__ float rintf(float a) { return __builtin_rintf(a); }
static inline __device__ float __saturatef(float a) { return __nvvm_saturate_f(a); }
static inline __device__ float __sinf(float a) { return __nvvm_sin_approx_f(a); }
+1 -1
View File
@@ -38,7 +38,7 @@ static int optind = 1;
static int optopt;
static char *optarg;
static int getopt(int argc, char *argv[], char *opts)
static int getopt(int argc, char *argv[], const char *opts)
{
static int sp = 1;
int c;
+41 -6
View File
@@ -44,8 +44,9 @@
#include "libavutil/internal.h"
#include "libavutil/mem.h"
#include "libavutil/time.h"
#include "libavutil/wchar_filename.h"
typedef struct pthread_t {
typedef struct w32pthread_t {
void *handle;
void *(*func)(void* arg);
void *arg;
@@ -71,7 +72,7 @@ typedef CONDITION_VARIABLE pthread_cond_t;
#define THREADFUNC_RETTYPE unsigned
#endif
static av_unused THREADFUNC_RETTYPE
av_unused static THREADFUNC_RETTYPE
__stdcall attribute_align_arg win32thread_worker(void *arg)
{
pthread_t h = (pthread_t)arg;
@@ -79,12 +80,12 @@ __stdcall attribute_align_arg win32thread_worker(void *arg)
return 0;
}
static av_unused int pthread_create(pthread_t *thread, const void *unused_attr,
av_unused static int pthread_create(pthread_t *thread, const void *unused_attr,
void *(*start_routine)(void*), void *arg)
{
pthread_t ret;
ret = av_mallocz(sizeof(*ret));
ret = (pthread_t)av_mallocz(sizeof(*ret));
if (!ret)
return EAGAIN;
@@ -108,7 +109,7 @@ static av_unused int pthread_create(pthread_t *thread, const void *unused_attr,
return 0;
}
static av_unused int pthread_join(pthread_t thread, void **value_ptr)
av_unused static int pthread_join(pthread_t thread, void **value_ptr)
{
DWORD ret = WaitForSingleObject(thread->handle, INFINITE);
if (ret != WAIT_OBJECT_0) {
@@ -148,7 +149,7 @@ static inline int pthread_mutex_unlock(pthread_mutex_t *m)
typedef INIT_ONCE pthread_once_t;
#define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT
static av_unused int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
av_unused static int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
{
BOOL pending = FALSE;
InitOnceBeginInitialize(once_control, 0, &pending, NULL);
@@ -209,4 +210,38 @@ static inline int pthread_setcancelstate(int state, int *oldstate)
return 0;
}
static inline int win32_thread_setname(const char *name)
{
#if !HAVE_UWP
typedef HRESULT (WINAPI *SetThreadDescriptionFn)(HANDLE, PCWSTR);
// Although SetThreadDescription lives in kernel32.dll, on Windows Server 2016,
// Windows 10 LTSB 2016 and Windows 10 version 1607, it was only available in
// kernelbase.dll. So, load it from there for maximum coverage.
HMODULE kernelbase = GetModuleHandleW(L"kernelbase.dll");
if (!kernelbase)
return AVERROR(ENOSYS);
SetThreadDescriptionFn pSetThreadDescription =
(SetThreadDescriptionFn)GetProcAddress(kernelbase, "SetThreadDescription");
if (!pSetThreadDescription)
return AVERROR(ENOSYS);
wchar_t *wname;
if (utf8towchar(name, &wname) < 0)
return AVERROR(ENOMEM);
HRESULT hr = pSetThreadDescription(GetCurrentThread(), wname);
av_free(wname);
return SUCCEEDED(hr) ? 0 : AVERROR(EINVAL);
#else
// UWP is not supported because we cannot use LoadLibrary/GetProcAddress to
// detect the availability of the SetThreadDescription API. There is a small
// gap in Windows builds 1507-1607 where it was not available. UWP allows
// querying the availability of APIs with QueryOptionalDelayLoadedAPI, but it
// requires /DELAYLOAD:kernel32.dll during linking, and we cannot enforce that.
return AVERROR(ENOSYS);
#endif
}
#endif /* COMPAT_W32PTHREADS_H */
+20 -5
View File
@@ -48,7 +48,13 @@ trap 'rm -f -- $libname' EXIT
if [ -n "$AR" ]; then
$AR rcs ${libname} $@ >/dev/null
else
lib.exe -out:${libname} $@ >/dev/null
machine_flag=""
case "$LDFLAGS" in
*"machine:arm64ec"*)
machine_flag="-machine:arm64ec"
;;
esac
lib.exe ${machine_flag} -out:${libname} $@ >/dev/null
fi
if [ $? != 0 ]; then
echo "Could not create temporary library." >&2
@@ -106,12 +112,21 @@ if [ -n "$NM" ]; then
grep -v : |
grep -v ^$ |
cut -d' ' -f3 |
sed -e "s/^${prefix}//")
sed -e "s/^${prefix}//" -e "s/^#//" |
grep -v '\$entry_thunk' |
grep -v '\$exit_thunk')
else
dump=$(dumpbin.exe -linkermember:1 ${libname} |
sed -e '/public symbols/,$!d' -e '/^ \{1,\}Summary/,$d' -e "s/ \{1,\}${prefix}/ /" -e 's/ \{1,\}/ /g' |
member=1
case "$LDFLAGS" in
*"machine:arm64ec"*)
member=32
;;
esac
dump=$(dumpbin.exe -linkermember:${member} ${libname} |
sed -e '/public symbols/,$!d' -e '/^ \{1,\}Summary/,$d' -e 's/^[[:space:]]*[0-9A-Fa-f]\{1,\}[[:space:]]\{1,\}//' -e "s/^${prefix}//" -e 's/^#//' |
tail -n +2 |
cut -d' ' -f3)
grep -v '\$entry_thunk' |
grep -v '\$exit_thunk')
fi
rm ${libname}
Vendored
+643 -256
View File
File diff suppressed because it is too large Load Diff
+173
View File
@@ -2,6 +2,179 @@ The last version increases of all libraries were on 2025-03-28
API changes, most recent first:
2026-05-16 - xxxxxxxxxxx - lavf 62.16.100 - avformat.h
Add AVFMT_FIXED_FRAMESIZE.
2026-05-16 - xxxxxxxxxxx - lavc 62.33.100 - avcodec.h
Add AV_CODEC_FLAG2_FIXED_FRAME_SIZE.
2026-05-12 - xxxxxxxxxx - lavu 60.31.100 - frame.h
Add IAMF frame side data types to enum AVFrameSideDataType:
- AV_FRAME_DATA_IAMF_MIX_GAIN_PARAM
- AV_FRAME_DATA_IAMF_DEMIXING_INFO_PARAM
- AV_FRAME_DATA_IAMF_RECON_GAIN_INFO_PARAM
2026-05-05 - xxxxxxxxxxx - lavf 62.15.100 - avformat.h
Add av_program_copy().
2026-05-05 - xxxxxxxxxxx - lavf 62.14.100 - avformat.h
Add av_program_add_stream_index2().
2026-04-14 - 7faa6ee2aa - lavc 62.30.100 - packet.h
Add AV_PKT_DATA_DYNAMIC_HDR_SMPTE_2094_APP5 side data type.
2026-04-09 - 6ba6db4f19 - lavu 60.30.100 - hdr_dynamic_metadata.h frame.h
Add AVDynamicHDRSmpte2094App5 struct and functions.
Add AV_FRAME_DATA_DYNAMIC_HDR_SMPTE_2094_APP5 side data type.
2026-03-14 - xxxxxxxxxx - lavu 60.29.100 - hwcontext_vulkan.h
Deprecate AVVulkanDeviceContext.lock_queue and
AVVulkanDeviceContext.unlock_queue without replacement.
2026-03-12 - xxxxxxxxxx - lsws 9.7.100 - swscale.h
Add enum SwsScaler, and SwsContext.scaler/scaler_sub.
2026-03-11 - 910000fe59d - lavu 60.28.100 - hwcontext_amf.h
Add av_amf_display_mastering_meta_to_hdrmeta(), av_amf_light_metadata_to_hdrmeta().
Add av_amf_extract_hdr_metadata(), av_amf_attach_hdr_metadata().
Add av_amf_get_color_profile().
2026-03-07 - c23d56b173a - lavc 62.26.100 - codec_desc.h
Add AV_CODEC_PROP_ENHANCEMENT.
2026-03-07 - f37cfb370f8 - lavc 62.25.100 - avcodec.h
Deprecate AVCodecContext.intra_dc_precision.
2026-02-26 - 26d6ac56c10 - lsws 9.4.100 - swscale.h
Add sws_test_hw_format().
2026-02-19 - ca011ee7547 - lavf 62.10.100 - avformat.h
Add demuxer command API consisting of:
- Add avformat_send_command().
- Add avformat_receive_command_reply().
- Add enum AVFormatCommandID.
2026-02-13 - 66766bb1c76 - lavu 60.25.100 - avassert.h
Deprecate av_assert0_fpu() and av_assert2_fpu() without replacement.
2026-02-09 - f2b13f783ac - lavf 62.9.100 - avformat.h
Add AVFormatContext.name.
2026-01-26 - 714152dd9a0 - lavu 60.24.100 - hwcontext_d3d11va.h
Add BindFlags and MiscFlags to AVD3D11VADeviceContext
2026-01-04 - 0645c484537 - lavu 60.23.100 - cpu.h
Add AV_CPU_FLAG_ARM_CRC.
2026-01-04 - e382772e4a1 - lavu 60.22.100 - cpu.h
Add AV_CPU_FLAG_CLMUL.
2025-12-29 - a6e5fa3fbb5 - lavu 60.21.100 - iamf.h
Add nb_demixing_matrix to AVIAMFLayer
2025-12-13 - b8ee68cffe - lavc 62.23.100 - codec_id.h
Add AV_CODEC_ID_JPEGXS.
2025-12-12 - c9b5e145b71 - lavf 62.7.100 - avformat.h
Add av_mime_codec_str
2025-12-08 - 212eb8413a6 - lavu 60.20.100 - hwcontext_vulkan.h
Add av_vk_get_optional_instance_extensions().
Add av_vk_get_optional_device_extensions().
2025-12-07 - 00caeba050d - lavc 62.22.101 - avcodec.h
Add avcodec_receive_frame_flags().
Add AV_CODEC_RECEIVE_FRAME_FLAG_SYNCHRONOUS.
2025-11-26 - 623669a02cd - lavfi 11.10.100 - buffersrc.h
Add av_buffersrc_get_status().
2025-11-18 - 140b4f28c30 - lavu 60.19.100 - hwcontext_amf.h
avutil/hwcontext_amf: add lock and unlock for AVAMFDeviceContext.
2025-11-16 - 643e2e10f98 - lavu 60.18.100 - cpu.h
Deprecate AV_CPU_FLAG_FORCE without replacement.
2025-11-01 - 8a322c956f3 - lavc 62.19.100 - avcodec.h
Schedule AVCodecParser and av_parser_init() to use enum AVCodecID
for codec ids on the next major version bump.
2025-11-01 - e0b0ca81112 - lavc 62.18.100 - avcodec.h
Deprecate AVCodecParser fields priv_data_size, parser_init,
parser_parse, parser_close, and split with no replacement.
2025-10-30 - 6879c8ee5dd - lavc 62.17.100 - packet.h
Add av_packet_side_data_from_frame() and av_packet_side_data_to_frame().
2025-10-28 - 71c7b9156bd - lavu 60.16.100 - pixfmt.h
Add AVCOL_TRC_EXT_BASE, AVCOL_TRC_V_LOG,
AVCOL_PRI_EXT_BASE and AVCOL_PRI_V_GAMUT.
2025-10-24 - 00e43619cd3 - lavu 60.14.100 - csp.h
Add av_csp_approximate_eotf_gamma().
2025-08-xx - xxxxxxxxxx - lavf 62.6.100 - oggparsevorbis.h oggparseopus.h oggparseflac.h
Drop header packets from secondary chained ogg/{flac, opus, vorbis} streams
from demuxer output.
2025-09-08 - 1b97966199f - lavu 60.13.100 - hwcontext_d3d12va.h
Add resource_flags and heap_flags to AVD3D12VADeviceContext
Add heap_flags to AVD3D12VAFramesContext
2025-09-05 - 9458a6f8ec2 - lavf 62.5.100 - avformat.h
Add AV_FRAME_FILENAME_FLAGS_IGNORE_TRUNCATION
2025-09-03 - c2ce3873859 - lavu 60.12.100 - hwcontext_d3d12va.h
Add support for texture array mode AVD3D12VAFrame.subresource_index,
AVD3D12VAFramesContext.texture_array
Add enum AVD3D12VAFrameFlags to define the behaviours of frame allocation.
Renanme AVD3D12VAFramesContext.flags to AVD3D12VAFramesContext.resource_flags.
Add flags to AVD3D12VAFramesContext
Add flags to AVD3D12VAFrame
2025-09-02 - de297ae2fca - lavfi 11.8.100 - buffersrc.h
Add AVBufferSrcParameters.alpha_mode.
2025-09-02 - 0fbd90d78f8 - lavfi 11.7.100 - buffersink.h
Add av_buffersink_get_alpha_mode().
2025-09-02 - ecebf9c6935 - lavc 62.15.100 - avcodec.h codec_par.h
Add AVCodecContext.alpha_mode, AVCodecParameters.alpha_mode, and
AV_CODEC_CONFIG_ALPHA_MODE.
2025-09-02 - eea99a77eda - lavfi 11.6.100 - avfilter.h
Add AVFilterLink.alpha_mode.
2025-09-02 - 22929bd044c - lavu 60.11.100 - frame.h pixfmt.h
Add AVAlphaMode, AVFrame.alpha_mode, av_alpha_mode_name() and
av_alpha_mode_from_name().
2025-09-01 - ce0938da8cd - lsws 9.3.100 - swscale.h
Add SWS_UNSTABLE flag.
2025-09-01 - 4ffd621523e - lavc 62.14.100 - packet.h
Add AV_PKT_DATA_EXIF
2025-08-24 - 368b5e0ffc2 - lavc 62.13.101 - exif.h
Add AV_EXIF_FLAG_RECURSIVE
2025-08-19 - ad77345a5d1..fe496b0308f - lavc 62.13.100 - exif.h
Add:
- enum AVTiffDataType, enum AVExifHeaderMode
- struct AVExifMetadata, struct AVExifEntry
- av_exif_get_tag_name, av_exif_get_tag_id,
av_exif_set_entry, av_exif_get_entry,
av_exif_remove_entry, av_exif_parse_buffer,
av_exif_write, av_exif_free,
av_exif_ifd_to_dict, av_exif_clone_ifd,
av_exif_matrix_to_orientation,
av_exif_orientation_to_matrix,
2025-08-19 - bb90b262d6d - lavu 60.10.100 - frame.h
Add AV_FRAME_DATA_EXIF.
-------- 8< --------- FFmpeg 8.0 was cut here -------- 8< ---------
2025-07-29 - 1c85a3832af - lavc 62.10.100 - smpte_436m.h
Add a new public header smpte_436m.h with API for
manipulating AV_CODEC_ID_SMPTE_436M_ANC data.
+40
View File
@@ -0,0 +1,40 @@
This document is work in progress
*What is CVSS*
The Common Vulnerability Scoring System (CVSS) is an open, industry-standard framework used to measure and communicate the severity of software vulnerabilities, ranging from 0.0 to 10.0.
*Why we need this Document*
It is important that FFmpeg CVEs have consistent and correct CVSS, not only for the obvious reason that one can recognize the severity of an issue at first glance.
But also as these numbers form the basis of rewards paid in bug bounty systems. Inconsistent CVSS could lead to unfair payouts.
*What is this Document*
Prior 2026, FFmpeg had no guideline about CVSS.
This document describes how to select the CVSS for a FFmpeg related CVE. It currently only covers the Base Score.
*What is the CVSS Base Score*
AV Attack Vector (Network, Adjacent, Local, Physical)
AC Attack Complexity (Low, High)
PR Privileges Required (None, Low, High)
UI User Interaction (None, Required)
S Scope (Unchanged, Changed)
C Confidentiality (None, Low, High)
I Integrity (None, Low, High)
A Availability (None, Low, High)
*Things people have set incorrectly*
Below are general guidelines and in specific cases other things may apply.
Attack Vector.
Quote from https://www.first.org/cvss/v3.1/user-guide
"Specifically, analysts should only score for Network or Adjacent when a vulnerability is bound to the network stack.
Vulnerabilities which require user interaction to download or receive malicious content (which could also be delivered locally, e.g., via USB drives) should be scored as Local."
Availability.
FFmpeg Crashes -> AVAILABILITY IMPACT: Low
FFmpeg is frequently used as a short-lived, single-run process instead of a continuously running service that handles ongoing streams of user input. In that usage model, a crash usually causes only limited disruption.
User Interaction
Please consider if an attacker can actually set the parameters required for an attack.
In general arbitrary filter parameters cannot be set by an attacker and require the user/account owner/admin to set them
+1 -1
View File
@@ -295,7 +295,7 @@ MARKDOWN_SUPPORT = YES
# When enabled doxygen tries to link words that correspond to documented
# classes, or namespaces to their corresponding documentation. Such a link can
# be prevented in individual cases by by putting a % sign in front of the word
# be prevented in individual cases by putting a % sign in front of the word
# or globally by setting AUTOLINK_SUPPORT to NO.
# The default value is: YES.
+4 -3
View File
@@ -28,6 +28,7 @@ HTMLPAGES = $(AVPROGS-yes:%=doc/%.html) $(AVPROGS-yes:%=doc/%-all.html) $(COMP
doc/mailing-list-faq.html \
doc/nut.html \
doc/platform.html \
doc/drawvg-reference.html \
$(SRC_PATH)/doc/bootstrap.min.css \
$(SRC_PATH)/doc/style.min.css \
$(SRC_PATH)/doc/default.css \
@@ -53,7 +54,7 @@ TEXIDEP = perl $(SRC_PATH)/doc/texidep.pl $(SRC_PATH) $< $@ >$(@:%=%.d)
doc/%.txt: TAG = TXT
doc/%.txt: doc/%.texi
$(Q)$(TEXIDEP)
$(M)makeinfo --force --no-headers -o $@ $< 2>/dev/null
$(M)$(MAKEINFO) --force --no-headers -o $@ $< 2>/dev/null
GENTEXI = format codec
GENTEXI := $(GENTEXI:%=doc/avoptions_%.texi)
@@ -68,11 +69,11 @@ doc/%-all.html: TAG = HTML
ifdef HAVE_MAKEINFO_HTML
doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.pm $(GENTEXI)
$(Q)$(TEXIDEP)
$(M)makeinfo --html -I doc --no-split -D config-not-all --init-file=$(SRC_PATH)/doc/t2h.pm --output $@ $<
$(M)$(MAKEINFO) --html -I doc --no-split -D config-not-all --init-file=$(SRC_PATH)/doc/t2h.pm --output $@ $<
doc/%-all.html: doc/%.texi $(SRC_PATH)/doc/t2h.pm $(GENTEXI)
$(Q)$(TEXIDEP)
$(M)makeinfo --html -I doc --no-split -D config-all --init-file=$(SRC_PATH)/doc/t2h.pm --output $@ $<
$(M)$(MAKEINFO) --html -I doc --no-split -D config-all --init-file=$(SRC_PATH)/doc/t2h.pm --output $@ $<
else
doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(GENTEXI)
$(Q)$(TEXIDEP)
+3 -1
View File
@@ -913,6 +913,8 @@ Set expressions for PTS, DTS or both.
Set expression for duration.
@item time_base
Set output time base.
@item prescale
Set whether to convert time fields to user-set output time base before evaluation of expressions. Defaults to 0.
@end table
The expressions are evaluated through the eval API and can contain the following
@@ -973,7 +975,7 @@ The next input PTS.
The next input duration.
@item TB
The timebase of stream packet belongs.
The timebase in which time fields are denominated. The user-set output timebase if prescale is enabled, else the input timebase.
@item TB_OUT
The output timebase.
-5
View File
@@ -7,11 +7,6 @@ V
Disable the default terse mode, the full command issued by make and its
output will be shown on the screen.
DBG
Preprocess x86 external assembler files to a .dbg.asm file in the object
directory, which then gets compiled. Helps in developing those assembler
files.
DESTDIR
Destination directory for the install targets, useful to prepare packages
or install FFmpeg in cross-environments.
+10
View File
@@ -646,6 +646,8 @@ Do not skip samples and export skip information as frame side data.
Do not reset ASS ReadOrder field on flush.
@item icc_profiles
Generate/parse embedded ICC profiles from/to colorimetry tags.
@item fixed_frame_size
Force audio encoders to use a fixed frame size.
@end table
@item export_side_data @var{flags} (@emph{decoding/encoding,audio,video,subtitles})
@@ -913,6 +915,14 @@ Possible values:
@end table
@item alpha_mode @var{integer} (@emph{decoding/encoding,video})
Possible values:
@table @samp
@item premultiplied
@item straight
@end table
@item log_level_offset @var{integer}
Set the log level offset.
+1 -1
View File
@@ -123,7 +123,7 @@ Internally, the TC should take decisions with a majority, or using ranked-choice
Each TC member must vote on such decision according to what is, in their view, best for the project.
If a TC member feels they are affected by a conflict of interest with regards to the case, they should announce it and recurse themselves from the TC
If a TC member feels they are affected by a conflict of interest with regards to the case, they should announce it and recuse themselves from the TC
discussion and vote.
A conflict of interest is presumed to occur when a TC member has a personal interest (e.g. financial) in a specific outcome of the case.
+9 -10
View File
@@ -119,16 +119,6 @@ The following options are supported by the libdav1d wrapper.
@table @option
@item framethreads
Set amount of frame threads to use during decoding. The default value is 0 (autodetect).
This option is deprecated for libdav1d >= 1.0 and will be removed in the future. Use the
option @code{max_frame_delay} and the global option @code{threads} instead.
@item tilethreads
Set amount of tile threads to use during decoding. The default value is 0 (autodetect).
This option is deprecated for libdav1d >= 1.0 and will be removed in the future. Use the
global option @code{threads} instead.
@item max_frame_delay
Set max amount of frames the decoder may buffer internally. The default value is 0
(autodetect).
@@ -356,6 +346,15 @@ value is 0 (disabled).
@end table
@section libmpeghdec
libmpeghdec decoder wrapper.
libmpeghdec allows libmpeghdec to decode the MPEG-H 3D audio codec.
Requires the presence of the libmpeghdec headers and library during
configuration. You need to explicitly configure the build with
@code{--enable-libmpeghdec --enable-nonfree}.
@section libopencore-amrnb
libopencore-amrnb decoder wrapper.
+23 -24
View File
@@ -281,7 +281,11 @@ This demuxer accepts the following option:
@table @option
@item cenc_decryption_key
16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
Default 16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
@item cenc_decryption_keys
Dictionary of 16-byte key ID => 16-byte key, both in hex, to decrypt files encrypted using ISO Common Encryption
(CENC/AES-128 CTR; ISO/IEC 23001-7).
@end table
@@ -664,30 +668,9 @@ Select a glob wildcard pattern type.
The pattern is interpreted like a @code{glob()} pattern. This is only
selectable if libavformat was compiled with globbing support.
@item glob_sequence @emph{(deprecated, will be removed)}
Select a mixed glob wildcard/sequence pattern.
If your version of libavformat was compiled with globbing support, and
the provided pattern contains at least one glob meta character among
@code{%*?[]@{@}} that is preceded by an unescaped "%", the pattern is
interpreted like a @code{glob()} pattern, otherwise it is interpreted
like a sequence pattern.
All glob special characters @code{%*?[]@{@}} must be prefixed
with "%". To escape a literal "%" you shall use "%%".
For example the pattern @code{foo-%*.jpeg} will match all the
filenames prefixed by "foo-" and terminating with ".jpeg", and
@code{foo-%?%?%?.jpeg} will match all the filenames prefixed with
"foo-", followed by a sequence of three characters, and terminating
with ".jpeg".
This pattern type is deprecated in favor of @var{glob} and
@var{sequence}.
@end table
Default value is @var{glob_sequence}.
Default value is @var{sequence}.
@item pixel_format
Set the pixel format of the images to read. If not specified the pixel
format is guessed from the first image file in the sequence.
@@ -961,7 +944,11 @@ Fixed key used for handling Audible AAX/AAX+ files. It has been pre-set so shoul
specify.
@item decryption_key
16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
Default 16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
@item decryption_keys
Dictionary of 16-byte key ID => 16-byte key, both in hex, to decrypt files encrypted using ISO Common Encryption
(CENC/AES-128 CTR; ISO/IEC 23001-7).
@item max_stts_delta
Very high sample deltas written in a trak's stts box may occasionally be intended but usually they are written in
@@ -1056,6 +1043,11 @@ Set input video frame rate. Default value is 25.
@item pixel_format
Set the input video pixel format. Default value is @code{yuv420p}.
@item stride
Set frame line size in bytes, only required if there are extra padding.
For multiplane formats, @option{stride} is a list of line size for each
plane.
@item video_size
Set the input video size. This value must be specified explicitly.
@end table
@@ -1068,6 +1060,13 @@ the command:
ffplay -f rawvideo -pixel_format rgb24 -video_size 320x240 -framerate 10 input.raw
@end example
Read a rawvideo with @command{ffplay}, assuming a pixel format of @code{yuv420p},
a video size of @code{1080x1920}, has 8 bytes of padding in each line of Y plane,
and 4 bytes of padding with UV plane,
@example
ffplay -f rawvideo -pixel_format yuv420p -video_size 1080x1920 -stride 1088,544,544 input.raw
@end example
@anchor{rcwtdec}
@section rcwt
+33 -4
View File
@@ -45,6 +45,7 @@ maintained and developed.
@end itemize
All proposed code changes should be submitted for review to
@url{https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls, Forgejo} or
@url{mailto:ffmpeg-devel@@ffmpeg.org, the development mailing list}, as
described in more detail in the @ref{Submitting patches} chapter. The code
should comply with the @ref{Development Policy} and follow the @ref{Coding Rules}.
@@ -224,6 +225,25 @@ AVStream *stream;
AVStream* stream;
@end example
@item
When sensible, prefer a narrow variable scope, especially in for loops:
@example c, good
// Good
for (unsigned i = 0; i < submix->nb_elements; i++) @{
// Do something...
@}
@end example
@example c, bad
// Bad style
unsigned i;
//...
for (i = 0; i < submix->nb_elements; i++) @{
// Do something...
@}
@end example
@end itemize
If you work on a file that does not follow these guidelines consistently,
@@ -366,6 +386,9 @@ symbols. If in doubt, just avoid names starting with @code{_} altogether.
@item
Casts should be used only when necessary. Unneeded parentheses
should also be avoided if they don't make the code easier to understand.
@item
Where applicable, SI units shall be used. For example timeouts should use seconds as the fundamental unit not microseconds.
That means a bare value like @samp{1.0} must mean 1 second, @samp{50m} means 50 milliseconds. For weight, gram shall be used.
@end itemize
@anchor{Development Policy}
@@ -467,13 +490,18 @@ ask/discuss it on the developer mailing list.
@subheading Cosmetic changes should be kept in separate patches.
We refuse source indentation and other cosmetic changes if they are mixed
with functional changes, such commits will be rejected and removed. Every
with functional changes, such commits will be rejected and removed. However,
indentation changes that can be ignored by @code{git diff --ignore-all-space}
(e.g. changes in whitespace amount, leading/trailing spaces) may be mixed with
functional changes, since reviewers can use @code{git diff -w} or
@code{git log -p --ignore-all-space} to review only the functional parts of
the change. Forgejo's pull request interface also provides a
``Hide whitespace changes'' option for this purpose. Every
developer has his own indentation style, you should not change it. Of course
if you (re)write something, you can use your own style, even though we would
prefer if the indentation throughout FFmpeg was consistent (Many projects
force a given indentation style - we do not.). If you really need to make
indentation changes (try to avoid this), separate them strictly from real
changes.
non-whitespace cosmetic changes, separate them strictly from real changes.
NOTE: If you had to put if()@{ .. @} over a large (> 5 lines) chunk of code,
then either do NOT change the indentation of the inner part within (do not
@@ -722,7 +750,8 @@ and has no lrint()')
Also please if you send several patches, send each patch as a separate mail,
do not attach several unrelated patches to the same mail.
Patches should be posted to the
Patches should be posted to
@uref{https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls, Forgejo} or the
@uref{https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-devel, ffmpeg-devel}
mailing list. Use @code{git send-email} when possible since it will properly
send patches without requiring extra care. If you cannot, then send patches
File diff suppressed because it is too large Load Diff
+138 -2
View File
@@ -1045,6 +1045,10 @@ Other values include 0 for mono and stereo, 1 for surround sound with masking
and LFE bandwidth optimizations, and 255 for independent streams with an
unspecified channel layout.
@item dtx (N.A.)
Allow discontinuous transmission when set to 1. The default value is 0
(disabled).
@item apply_phase_inv (N.A.) (requires libopus >= 1.2)
If set to 0, disables the use of phase inversion for intensity stereo,
improving the quality of mono downmixes, but slightly reducing normal stereo
@@ -1996,6 +2000,49 @@ by ":". See the SVT-AV1 encoder user guide for a list of accepted parameters.
@end table
@section libsvtjpegxs
SVT-JPEG-XS encoder wrapper.
Requires the presence of the SVT-JPEG-XS headers and library during configuration.
You need to explicitly configure the build with @code{--enable-libsvtjpegxs}.
@subsection Options
@table @option
@item decomp_v
Set vertical decomposition level
@item decomp_h
Set horizontal decomposition level
@item quantization
Set the quantization algorithm.
@table @samp
@item deadzone
@item uniform
@end table
@item coding-signs
Enable Signs handling strategy
@table @samp
@item disable
@item fast
@item full
@end table
@item coding-sigf
Enable Significance coding
@item coding-vpred
Enable Vertical Prediction coding
@table @samp
@item disable
@item no_residuals
@item no_coeffs
@end table
@end table
@section libjxl
libjxl JPEG XL encoder wrapper.
@@ -3040,6 +3087,10 @@ Quantizer curve compression factor
Normally, when forcing a I-frame type, the encoder can select any type
of I-frame. This option forces it to choose an IDR-frame.
@item x265-stats
Specify the file name for 2-pass stats. This is set automatically when using
the @option{-passlogfile} option.
@item udu_sei @var{boolean}
Import user data unregistered SEI if available into output. Default is 0 (off).
@@ -3413,12 +3464,97 @@ Maximum quantization parameter for B frame.
@section MediaFoundation
This provides wrappers to encoders (both audio and video) in the
MediaFoundation framework. It can access both SW and HW encoders.
The following wrappers for encoders in the MediaFoundation framework are
available:
@itemize
@item h264_mf
@item hevc_mf
@item av1_mf
@end itemize
These support both software and hardware encoding.
Video encoders can take input in either of nv12 or yuv420p form
(some encoders support both, some support only either - in practice,
nv12 is the safer choice, especially among HW encoders).
Hardware-accelerated encoding requires D3D11, including hardware
scaling capabilities through the scale_d3d11 filter.
To list all available options for the MediaFoundation encoders, use:
@command{ffmpeg -h encoder=<encoder>} e.g. @command{ffmpeg -h encoder=h264_mf}
@subsection Options
@table @option
@item rate_control
Select rate control mode. Available modes:
@table @samp
@item default
Default mode
@item cbr
CBR mode
@item pc_vbr
Peak constrained VBR mode
@item u_vbr
Unconstrained VBR mode
@item quality
Quality mode
@item ld_vbr
Low delay VBR mode (requires Windows 8+)
@item g_vbr
Global VBR mode (requires Windows 8+)
@item gld_vbr
Global low delay VBR mode (requires Windows 8+)
@end table
@item scenario
Select usage scenario. Available scenarios:
@table @samp
@item default
Default scenario
@item display_remoting
Display remoting scenario
@item video_conference
Video conference scenario
@item archive
Archive scenario
@item live_streaming
Live streaming scenario
@item camera_record
Camera record scenario
@item display_remoting_with_feature_map
Display remoting with feature map scenario
@end table
@item quality
Set encoding quality (0-100). -1 means default quality.
@item hw_encoding
Force hardware encoding (0-1). Default is 0 (disabled).
@end table
@subsection Examples
Hardware encoding:
@example
ffmpeg -i input.mp4 -c:v h264_mf -hw_encoding 1 output.mp4
@end example
Hardware-accelerated decoding with hardware encoding:
@example
ffmpeg -hwaccel d3d11va -i input.mp4 -c:v h264_mf -hw_encoding 1 output.mp4
@end example
Hardware-accelerated decoding, HW scaling and encoding with quality setting:
@example
ffmpeg -hwaccel d3d11va -hwaccel_output_format d3d11 -i input.mp4 -vf scale_d3d11=1920:1080 -c:v hevc_mf -hw_encoding 1 -quality 80 output.mp4
@end example
@section Microsoft RLE
Microsoft RLE aka MSRLE encoder.
-2
View File
@@ -30,8 +30,6 @@
* file to be played with ffplay.
*/
#include <unistd.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavfilter/buffersink.h>
+2 -3
View File
@@ -27,8 +27,6 @@
* @example decode_filter_video.c
*/
#define _XOPEN_SOURCE 600 /* for usleep */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -38,6 +36,7 @@
#include <libavfilter/buffersrc.h>
#include <libavutil/mem.h>
#include <libavutil/opt.h>
#include <libavutil/time.h>
const char *filter_descr = "scale=78:24,transpose=cclock";
/* other way:
@@ -195,7 +194,7 @@ static void display_frame(const AVFrame *frame, AVRational time_base)
delay = av_rescale_q(frame->pts - last_pts,
time_base, AV_TIME_BASE_Q);
if (delay > 0 && delay < 1000000)
usleep(delay);
av_usleep(delay);
}
last_pts = frame->pts;
}
+5 -1
View File
@@ -42,7 +42,11 @@ static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
FILE *f;
int i;
f = fopen(filename,"wb");
f = fopen(filename, "wb");
if (!f) {
fprintf(stderr, "Could not open %s\n", filename);
return;
}
fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
for (i = 0; i < ysize; i++)
fwrite(buf + i * wrap, 1, xsize, f);
+10 -5
View File
@@ -336,15 +336,17 @@ int main (int argc, char **argv)
if (video_stream) {
printf("Play the output video file with the command:\n"
"ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n",
"ffplay -f rawvideo -pixel_format %s -video_size %dx%d %s\n",
av_get_pix_fmt_name(pix_fmt), width, height,
video_dst_filename);
}
if (audio_stream) {
enum AVSampleFormat sfmt = audio_dec_ctx->sample_fmt;
int n_channels = audio_dec_ctx->ch_layout.nb_channels;
AVChannelLayout mono = AV_CHANNEL_LAYOUT_MONO;
AVChannelLayout *ch_layout = &audio_dec_ctx->ch_layout;
const char *fmt;
char buf[64];
if (av_sample_fmt_is_planar(sfmt)) {
const char *packed = av_get_sample_fmt_name(sfmt);
@@ -352,15 +354,18 @@ int main (int argc, char **argv)
"(%s). This example will output the first channel only.\n",
packed ? packed : "?");
sfmt = av_get_packed_sample_fmt(sfmt);
n_channels = 1;
ch_layout = &mono;
}
if ((ret = get_format_from_sample_fmt(&fmt, sfmt)) < 0)
goto end;
if ((ret = av_channel_layout_describe(ch_layout, buf, sizeof(buf))) < 0)
goto end;
printf("Play the output audio file with the command:\n"
"ffplay -f %s -ac %d -ar %d %s\n",
fmt, n_channels, audio_dec_ctx->sample_rate,
"ffplay -f %s -ch_layout %s -sample_rate %d %s\n",
fmt, buf, audio_dec_ctx->sample_rate,
audio_dst_filename);
}
+2 -2
View File
@@ -218,10 +218,10 @@ int main(int argc, char **argv)
samples = (uint16_t*)frame->data[0];
for (j = 0; j < c->frame_size; j++) {
samples[2*j] = (int)(sin(t) * 10000);
samples[c->ch_layout.nb_channels*j] = (int)(sin(t) * 10000);
for (k = 1; k < c->ch_layout.nb_channels; k++)
samples[2*j + k] = samples[2*j];
samples[c->ch_layout.nb_channels*j + k] = samples[c->ch_layout.nb_channels*j];
t += tincr;
}
encode(c, frame, pkt, f);
+1
View File
@@ -109,6 +109,7 @@ static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type)
ret = avcodec_parameters_to_context(dec_ctx, st->codecpar);
if (ret < 0) {
fprintf(stderr, "Failed to copy codec parameters to codec context\n");
avcodec_free_context(&dec_ctx);
return ret;
}
+9 -2
View File
@@ -132,8 +132,9 @@ static int decode_write(AVCodecContext *avctx, AVPacket *packet)
goto fail;
}
if ((ret = fwrite(buffer, 1, size, output_file)) < 0) {
if (fwrite(buffer, 1, size, output_file) != size) {
fprintf(stderr, "Failed to dump raw data.\n");
ret = -1;
goto fail;
}
@@ -215,8 +216,10 @@ int main(int argc, char *argv[])
return AVERROR(ENOMEM);
video = input_ctx->streams[video_stream];
if (avcodec_parameters_to_context(decoder_ctx, video->codecpar) < 0)
if (avcodec_parameters_to_context(decoder_ctx, video->codecpar) < 0) {
avcodec_free_context(&decoder_ctx);
return -1;
}
decoder_ctx->get_format = get_hw_format;
@@ -230,6 +233,10 @@ int main(int argc, char *argv[])
/* open the file to dump raw data */
output_file = fopen(argv[3], "w+b");
if (!output_file) {
fprintf(stderr, "Cannot open output file '%s'\n", argv[3]);
return -1;
}
/* actual decoding and dump the raw data */
while (ret >= 0) {
+11 -3
View File
@@ -39,6 +39,7 @@
#include <libavutil/error.h>
#include <libavutil/hwcontext.h>
#include <libavutil/hwcontext_qsv.h>
#include <libavutil/imgutils.h>
#include <libavutil/mem.h>
static int get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts)
@@ -88,9 +89,16 @@ static int decode_packet(AVCodecContext *decoder_ctx,
goto fail;
}
for (i = 0; i < FF_ARRAY_ELEMS(sw_frame->data) && sw_frame->data[i]; i++)
for (j = 0; j < (sw_frame->height >> (i > 0)); j++)
avio_write(output_ctx, sw_frame->data[i] + j * sw_frame->linesize[i], sw_frame->width);
for (i = 0; i < FF_ARRAY_ELEMS(sw_frame->data) && sw_frame->data[i]; i++) {
int h = sw_frame->height >> (i > 0);
int linesize = av_image_get_linesize(sw_frame->format, sw_frame->width, i);
if (linesize < 0) {
ret = linesize;
goto fail;
}
for (j = 0; j < h; j++)
avio_write(output_ctx, sw_frame->data[i] + j * sw_frame->linesize[i], linesize);
}
fail:
av_frame_unref(sw_frame);
+7 -1
View File
@@ -351,6 +351,10 @@ int main(int argc, char **argv)
}
setting_number = (argc - 5) / 2;
dynamic_setting = av_malloc(setting_number * sizeof(*dynamic_setting));
if (!dynamic_setting) {
ret = AVERROR(ENOMEM);
goto end;
}
current_setting_number = 0;
for (int i = 0; i < setting_number; i++) {
dynamic_setting[i].frame_number = atoi(argv[i*2 + 5]);
@@ -426,7 +430,9 @@ int main(int argc, char **argv)
end:
avformat_close_input(&ifmt_ctx);
avformat_close_input(&ofmt_ctx);
if (ofmt_ctx && !(ofmt_ctx->oformat->flags & AVFMT_NOFILE))
avio_closep(&ofmt_ctx->pb);
avformat_free_context(ofmt_ctx);
avcodec_free_context(&decoder_ctx);
avcodec_free_context(&encoder_ctx);
av_buffer_unref(&hw_device_ctx);
+1 -1
View File
@@ -184,7 +184,7 @@ end:
avformat_close_input(&ifmt_ctx);
/* close output */
if (ofmt_ctx && !(ofmt->flags & AVFMT_NOFILE))
if (ofmt_ctx && !(ofmt_ctx->oformat->flags & AVFMT_NOFILE))
avio_closep(&ofmt_ctx->pb);
avformat_free_context(ofmt_ctx);
+2 -2
View File
@@ -177,7 +177,7 @@ static int open_output_file(const char *filename)
enc_ctx->width = dec_ctx->width;
enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
ret = avcodec_get_supported_config(dec_ctx, NULL,
ret = avcodec_get_supported_config(enc_ctx, NULL,
AV_CODEC_CONFIG_PIX_FORMAT, 0,
(const void**)&pix_fmts, NULL);
@@ -195,7 +195,7 @@ static int open_output_file(const char *filename)
if (ret < 0)
return ret;
ret = avcodec_get_supported_config(dec_ctx, NULL,
ret = avcodec_get_supported_config(enc_ctx, NULL,
AV_CODEC_CONFIG_SAMPLE_FORMAT, 0,
(const void**)&sample_fmts, NULL);
+4 -4
View File
@@ -88,7 +88,7 @@ static int encode_write(AVCodecContext *avctx, AVFrame *frame, FILE *fout)
enc_pkt->stream_index = 0;
ret = fwrite(enc_pkt->data, enc_pkt->size, 1, fout);
av_packet_unref(enc_pkt);
if (ret != enc_pkt->size) {
if (!ret) {
ret = AVERROR(errno);
break;
}
@@ -96,7 +96,6 @@ static int encode_write(AVCodecContext *avctx, AVFrame *frame, FILE *fout)
end:
av_packet_free(&enc_pkt);
ret = ((ret == AVERROR(EAGAIN)) ? 0 : -1);
return ret;
}
@@ -118,7 +117,7 @@ int main(int argc, char *argv[])
height = atoi(argv[2]);
size = width * height;
if (!(fin = fopen(argv[3], "r"))) {
if (!(fin = fopen(argv[3], "rb"))) {
fprintf(stderr, "Fail to open input file : %s\n", strerror(errno));
return -1;
}
@@ -198,7 +197,8 @@ int main(int argc, char *argv[])
goto close;
}
if ((err = (encode_write(avctx, hw_frame, fout))) < 0) {
err = encode_write(avctx, hw_frame, fout);
if (err != AVERROR(EAGAIN) && err < 0) {
fprintf(stderr, "Failed to encode.\n");
goto close;
}
+3 -1
View File
@@ -294,7 +294,9 @@ int main(int argc, char **argv)
end:
avformat_close_input(&ifmt_ctx);
avformat_close_input(&ofmt_ctx);
if (ofmt_ctx && !(ofmt_ctx->oformat->flags & AVFMT_NOFILE))
avio_closep(&ofmt_ctx->pb);
avformat_free_context(ofmt_ctx);
avcodec_free_context(&decoder_ctx);
avcodec_free_context(&encoder_ctx);
av_buffer_unref(&hw_device_ctx);
+38 -18
View File
@@ -42,41 +42,60 @@ targets and variables.
@chapter Using FATE from your FFmpeg source directory
If you want to run FATE on your machine you need to have the samples
in place. You can get the samples via the build target fate-rsync.
Use this command from the top-level source directory:
If you want to run FATE on your machine, FFmpeg needs to be configured first.
You may specify the location of samples during configuration by adding the
argument @code{--samples=/path/to/fate-suite}.
@example
make fate-rsync SAMPLES=fate-suite/
make fate SAMPLES=fate-suite/
./configure --enable-somelib --samples=/path/to/fate-suite
@end example
The above commands set the samples location by passing a makefile
variable via command line. It is also possible to set the samples
location at source configuration time by invoking configure with
@option{--samples=<path to the samples directory>}. Afterwards you can
invoke the makefile targets without setting the @var{SAMPLES} makefile
variable. This is illustrated by the following commands:
After successful configuration, you need to add and/or update the samples in place:
@example
./configure --samples=fate-suite/
make fate-rsync
@end example
Now you are ready to run FATE:
@example
make fate
@end example
See @ref{makefile variables} for a list of arguments that can be added.
If you did not set the samples path during configuration, or if you wish to
override it just before starting FATE, you can do so in one of three ways.
Either by setting a make variable:
@example
make fate-rsync SAMPLES=/path/to/fate-suite
make fate SAMPLES=/path/to/fate-suite
@end example
or by setting an environment variable for the current session:
@example
export FATE_SAMPLES=/path/to/fate-suite
make fate-rsync
make fate
@end example
Yet another way to tell FATE about the location of the sample
directory is by making sure the environment variable FATE_SAMPLES
contains the path to your samples directory. This can be achieved
by e.g. putting that variable in your shell profile or by setting
it in your interactive session.
or in isolation for a single command by prepending it:
@example
FATE_SAMPLES=fate-suite/ make fate
FATE_SAMPLES=/path/to/fate-suite make fate-rsync
FATE_SAMPLES=/path/to/fate-suite make fate
@end example
This variable can also be set in your shell profile to make it permanent.
@float NOTE
Do not put a '~' character in the samples path to indicate a home
directory. Because of shell nuances, this will cause FATE to fail.
Also, on Windows the path has to be relative to the build path
which in this case is the FFmpeg source directory.
@end float
Beware that some assertions are disabled by default, so mind setting
@@ -220,6 +239,7 @@ Run the FATE test suite (requires the fate-suite dataset).
@end table
@section Makefile variables
@anchor{makefile variables}
@table @env
@item V
+7
View File
@@ -6,21 +6,28 @@ workdir= # directory in which to do all the work
#fate_recv="ssh -T fate@fate.ffmpeg.org" # command to submit report
comment= # optional description
build_only= # set to "yes" for a compile-only instance that skips tests
skip_clean= # set to "yes" to preserve build/install directories
ignore_tests=
# the following are optional and map to configure options
arch=
cpu=
toolchain=
cross_prefix=
ar=
as=
cc=
cxx=
ld=
nm=
target_os=
sysroot=
target_exec=
target_path=
target_samples=
extra_cflags=
extra_cxxflags=
extra_objcflags=
extra_ldflags=
extra_libs=
extra_conf= # extra configure options not covered above
+30
View File
@@ -1569,6 +1569,27 @@ Set whether on display the image should be vertically flipped.
See the @code{-display_rotation} option for more details.
@item -mastering_display[:@var{stream_specifier}] @var{G(%u,%u)B(%u,%u)R(%u,%u)WP(%u,%u)L(%u,%u)} (@emph{input,per-stream})
Set video mastering display metadata.
@var{G(%u,%u)B(%u,%u)R(%u,%u)WP(%u,%u)L(%u,%u)} is a string specifying
X,Y display primaries for GBR channels and white point (WP) in units of
0.00002, and max-min luminance (L) values in units of 0.0001 candela per
meter square. The values are unsigned integers representing the numerator
of a rational with an implicit denominator of 50000 for GBR and (WP), and
implicit denominator 10000 for (L).
This option overrides the mastering display metadata stored in the file,
if any.
@item -content_light[:@var{stream_specifier}] @var{%u,%u} (@emph{input,per-stream})
Set video content light metadata.
@var{%u,%u} is a string specifying max content light level and maximum picture
average light level.
This option overrides the content light metadata stored in the file, if any.
@item -vn (@emph{input/output})
As an input option, blocks all video streams of a file from being filtered or
being automatically selected or mapped for any output. See @code{-discard}
@@ -1665,6 +1686,7 @@ Force video tag/fourcc. This is an alias for @code{-tag:v}.
@item -force_key_frames[:@var{stream_specifier}] @var{time}[,@var{time}...] (@emph{output,per-stream})
@item -force_key_frames[:@var{stream_specifier}] expr:@var{expr} (@emph{output,per-stream})
@item -force_key_frames[:@var{stream_specifier}] source (@emph{output,per-stream})
@item -force_key_frames[:@var{stream_specifier}] scd_metadata (@emph{output,per-stream})
@var{force_key_frames} can take arguments of the following form:
@@ -1728,6 +1750,14 @@ the current frame being encoded is marked as a key frame in its source.
In cases where this particular source frame has to be dropped,
enforce the next available frame to become a key frame instead.
@item scd_metadata
If the argument is @code{scd_metadata}, ffmpeg will force a key frame if
the current frame contains a metadata entry with the key @code{lavfi.scd.time}.
The metadata can be added by filters like @code{scdet} and @code{scdet_vulkan}.
Avoid inserting filters that duplicate frames after @code{scdet}, as this can
cause duplicate metadata for multiple frames and repeated insertion of key
frames.
@end table
Note that forcing too many keyframes is very harmful for the lookahead
+10 -4
View File
@@ -208,6 +208,14 @@ Vulkan configuration using a list of @var{key}=@var{value} pairs separated by
Use HW accelerated decoding. Enable this option will enable vulkan renderer
automatically.
@item -video_bg @var{pattern}
Set the video background pattern used for transparent videos. For solid color
patterns you can use the color name or color code as specified in the
@ref{color syntax,,Color section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
You can also use the special @code{tiles} keyword for a checker board style
pattern. This is also the default. The @code{none} pattern does rendering
without alpha blending effectively ignoring alpha channel.
@end table
@section While playing
@@ -251,15 +259,13 @@ Pause if the stream is not already paused, step to the next video
frame, and pause.
@item left/right
Seek backward/forward 10 seconds.
Seek backward/forward by 10 seconds or a custom interval if -seek_interval is set.
@item down/up
Seek backward/forward 1 minute.
@item page down/page up
Seek to the previous/next chapter.
or if there are no chapters
Seek backward/forward 10 minutes.
Seek to previous/next chapter or backward/forward 10 minutes if no chapters.
@item right mouse click
Seek to percentage in file corresponding to fraction of width.
+13 -1
View File
@@ -117,7 +117,8 @@ ffprobe -show_packets -select_streams v:1 INPUT
@end example
@item -show_data
Show payload data, as a hexadecimal and ASCII dump. Coupled with
Show payload data, as a hexadecimal and ASCII dump (other formats can be
selected using @option{-data_dump_format}). Coupled with
@option{-show_packets}, it will dump the packets' data. Coupled with
@option{-show_streams}, it will dump the codec extradata.
@@ -127,6 +128,11 @@ The dump is printed as the "data" field. It may contain newlines.
Show a hash of payload data, for packets with @option{-show_packets} and for
codec extradata with @option{-show_streams}.
@item -data_dump_format @var{format}
Select a format used for the data dumps enabled with the @option{-show_data}
option. The default is @code{xxd} which is a hexdump format compatible with the
well-known @command{xxd} program. @code{base64} is also supported.
@item -show_error
Show information about the error found when trying to probe the input.
@@ -368,6 +374,12 @@ Read @var{input_url}.
Write output to @var{output_url}. If not specified, the output is sent
to stdout.
@item -c:@var{media_specifier} @var{codec_name}
@itemx -codec:@var{media_specifier} @var{codec_name}
Force a specific decoder implementation for the stream identified by
@var{media_specifier}, which can assume the values @code{a} (audio),
@code{v} (video), @code{s} (subtitle), and @code{d} (data).
@end table
@c man end
+2
View File
@@ -276,6 +276,7 @@
<xsd:attribute name="extradata" type="xsd:string" />
<xsd:attribute name="extradata_size" type="xsd:int" />
<xsd:attribute name="extradata_hash" type="xsd:string" />
<xsd:attribute name="mime_codec_string" type="xsd:string" />
<!-- video attributes -->
<xsd:attribute name="width" type="xsd:int"/>
@@ -356,6 +357,7 @@
<xsd:complexType name="streamGroupComponentType">
<xsd:sequence>
<xsd:element name="subcomponents" type="ffprobe:streamGroupSubComponentList" minOccurs="0" maxOccurs="1"/>
<xsd:element name="side_data_list" type="ffprobe:packetSideDataListType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="component_entry" type="ffprobe:streamGroupEntryType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
+1 -1
View File
@@ -98,7 +98,7 @@ These options are shared amongst the ff* tools.
@table @option
@item -L
@item -L, -license
Show license.
@item -h, -?, -help, --help [@var{arg}]
+909 -107
View File
File diff suppressed because it is too large Load Diff
+21
View File
@@ -250,6 +250,14 @@ Go to @url{http://sourceforge.net/projects/opencore-amr/} and follow the
instructions for installing the library.
Then pass @code{--enable-libfdk-aac} to configure to enable it.
@subsection Fraunhofer MPEG-H 3D Audio decoder library
FFmpeg can make use of the Fraunhofer MPEG-H decoder library for MPEG-H 3DA decoding.
Go to @url{https://github.com/Fraunhofer-IIS/mpeghdec} and follow the
instructions for installing the library.
Then pass @code{--enable-libmpeghdec --enable-nonfree} to configure to enable it.
@subsection LC3 library
FFmpeg can make use of the Google LC3 library for LC3 decoding & encoding.
@@ -295,6 +303,15 @@ Go to @url{https://gitlab.com/AOMediaCodec/SVT-AV1/} and follow the instructions
for installing the library. Then pass @code{--enable-libsvtav1} to configure to
enable it.
@section SVT-JPEG-XS
FFmpeg can make use of the Scalable Video Technology for JPEG-XS library for JPEG-XS
decoding and encoding.
Go to @url{https://github.com/OpenVisualCloud/SVT-JPEG-XS} and follow the instructions
for installing the library. Then pass @code{--enable-libsvtjpegxs} to configure to
enable it.
@section TwoLAME
FFmpeg can make use of the TwoLAME library for MP2 encoding.
@@ -811,6 +828,8 @@ following image formats are supported:
@tab Progressive JPEG is not supported.
@item JPEG 2000 @tab X @tab X
@item JPEG-LS @tab X @tab X
@item JPEG-XS @tab E @tab E
@tab Supported through external library libsvtjpegxs
@item LJPEG @tab X @tab
@tab Lossless JPEG
@item Media 100 @tab @tab X
@@ -1344,6 +1363,8 @@ following image formats are supported:
@item MP3 (MPEG audio layer 3) @tab E @tab IX
@tab encoding supported through external library LAME, ADU MP3 and MP3onMP4 also supported
@item MPEG-4 Audio Lossless Coding (ALS) @tab @tab X
@item MPEG-H 3D Audio @tab @tab E
@tab decoding supported through external library libmpeghdec
@item MobiClip FastAudio @tab @tab X
@item Musepack SV7 @tab @tab X
@item Musepack SV8 @tab @tab X
+1
View File
@@ -4,3 +4,4 @@ ffmpeg-formats mono ./ffmpeg-formats.html
ffmpeg-resampler mono ./ffmpeg-resampler.html
ffmpeg-scaler mono ./ffmpeg-scaler.html
ffmpeg-utils mono ./ffmpeg-utils.html
drawvg-reference mono ./drawvg-reference.html
+20
View File
@@ -24,6 +24,26 @@ Our Main server is hosted at telepoint.bg
for more details see: https://www.ffmpeg.org/#thanks_sponsor_0001
Nothing runs on our main server directly, instead several VMs run on it.
Main server security:
---------------------
Telepoint is one of the largest Bulgarian DC providers with multiple sibling companies offering
Internet, SDH, DWDM, peering exchange and hosting. They have multiple DC buildings in Sofia and
FFmpeg is hosted in XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. The building is locked down and accessible
only with personal key cards that are registered. People who are granted access to a rack have
to go through the access center with their ID to get logged and receive a one-time access card
that can open the service elevator and only the hall where the destination rack is. All racks are
locked, once access is granted to someone they will get a key for the rack for the duration of
their visit. There are security cameras everywhere and personnel in the access center 24/7. As for
software security, our BIOS and IPMI are protected by password and encrypted connection, and
the machines can be accessed only by root administrators with their SSH keys. They're using
a Ubuntu LTS release and get regular security updates as they are released. We also get
notified by email for various security related events (e.g. failed sudo).
Side note - Telepoint provides the rack and physical infrastructure, their sibling company called
Telehouse which is an ISP provides the connectivity, they are directly connected with
over 15 tier-1 service providers and have over 100 PoPs (points of presence)
in various cities. You can see more on www.telehouse.bg
ffmpeg.org VM:
--------------
+1 -1
View File
@@ -341,7 +341,7 @@ recommended.
Avoid sending the same message to multiple mailing lists.
@item
Please follow our @url{https://ffmpeg.org/community.html#Code-of-conduct, Code of Conduct}.
Please follow our @url{https://ffmpeg.org/community.html#Code-of-Conduct, Code of Conduct}.
@end itemize
@chapter Help
+38 -3
View File
@@ -1759,7 +1759,7 @@ See also the @ref{framehash} and @ref{md5} muxers.
Animated GIF muxer.
Note that the GIF format has a very large time base: the delay between two frames can
therefore not be smaller than one centi second.
therefore not be smaller than one centisecond.
@subsection Options
@table @option
@@ -3069,7 +3069,7 @@ Default is @code{0x0001}.
Set the @samp{original_network_id}. This is unique identifier of a
network in DVB. Its main use is in the unique identification of a service
through the path @samp{Original_Network_ID, Transport_Stream_ID}. Default
is @code{0x0001}.
is @code{0xff01}.
@item mpegts_service_id @var{integer}
Set the @samp{service_id}, also known as program in DVB. Default is
@@ -3096,6 +3096,8 @@ MPEG2 Digital HDTV service.
Advanced Codec Digital SDTV service.
@item advanced_codec_digital_hdtv
Advanced Codec Digital HDTV service.
@item hevc_digital_hdtv
HEVC Digital Television service.
@end table
@item mpegts_pmt_start_pid @var{integer}
@@ -3272,6 +3274,19 @@ ogg files can be safely chained.
@end table
@section pdv
Playdate Video muxer.
This muxer writes the Playdate video container used by Panic's Playdate SDK.
It requires a seekable output and a single PDV video stream.
@table @option
@item max_frames @var{frames}
Reserve space for at most @var{frames} video frames in the file header. This
option is mandatory.
@end table
@anchor{rcwtenc}
@section rcwt
@@ -3951,9 +3966,29 @@ This muxer supports the following options:
Set the timeout in milliseconds for ICE and DTLS handshake.
Default value is 5000.
@item timeout @var{integer}
Set timeout in seconds for socket I/O operations. Applicable only for HTTP output.
Default value is -1.
@item pkt_size @var{integer}
Set the maximum size, in bytes, of RTP packets that send out.
Default value is 1500.
Default value is 1200.
@item ts_buffer_size @var{integer}
Set the buffer size, in bytes, of underlying protocol.
Default value is -1(auto). The UDP auto selects a reasonable value.
@item whip_flags @var{flags}
Possible values:
@table @samp
@item dtls_active
The muxer will try to set dtls active role and send the first client hello.
@end table
@item rtp_history @var{integer}
Set the number of RTP history items to store.
Default value is 512.
@item authorization @var{string}
The optional Bearer token for WHIP Authorization.
+2 -7
View File
@@ -5,7 +5,7 @@ What to optimize:
-----------------
If you plan to do non-x86 architecture specific optimizations (SIMD normally),
then take a look in the x86/ directory, as most important functions are
already optimized for MMX.
already optimized for x86.
If you want to do x86 optimizations then you can either try to fine-tune the
stuff in the x86 directory or find some other functions in the C source to
@@ -20,7 +20,7 @@ architecture-specific versions. It is recommended to look at older
revisions of the interesting files (web frontends for the various FFmpeg
branches are listed at http://ffmpeg.org/download.html).
Alternatively, look into the other architecture-specific versions in
the x86/, ppc/, alpha/ subdirectories. Even if you don't exactly
the x86/, ppc/, aarch64/ subdirectories. Even if you don't exactly
comprehend the instructions, it could help understanding the functions
and how they can be optimized.
@@ -191,11 +191,6 @@ __asm__() block.
Use external asm (nasm) or inline asm (__asm__()), do not use intrinsics.
The latter requires a good optimizing compiler which gcc is not.
When debugging a x86 external asm compilation issue, if lost in the macro
expansions, add DBG=1 to your make command-line: the input file will be
preprocessed, stripped of the debug/empty lines, then compiled, showing the
actual lines causing issues.
Inline asm vs. external asm
---------------------------
Both inline asm (__asm__("..") in a .c file, handled by a compiler such as gcc)
+16
View File
@@ -330,4 +330,20 @@ and for a build with shared libraries
./configure --target-os=mingw32 --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
@end example
@section ARM64EC
FFmpeg does not intend to support the Windows ARM64EC build configuration;
patches for changing the individual libraries for the purposes of ARM64EC will
not be accepted.
It may still be possible to build FFmpeg in this build configuration;
such a build may seem to work to some extent. Such a build may have some
amounts of ABI inconsistencies though - which we are not willing to fix.
(Changing aarch64 assembly code to strictly support ARM64EC would require
ifdeffing/changing essentially all such assembly code, and would be a
huge maintenance burden. Additionally, changing the library ABI
surfaces to fix ABI inconsistencies could require extensive and intrusive
changes.)
@bye
+184 -46
View File
@@ -352,6 +352,17 @@ means auto (seekable for normal files, non-seekable for named pipes).
Many demuxers handle seekable and non-seekable resources differently,
overriding this might speed up opening certain files at the cost of losing some
features (e.g. accurate seeking).
@item pkt_size
Set the maximum packet size used for file I/O. A smaller value may reduce
memory usage. A higher value may increase throughput especially with networked
filesystems.
For reading, if explicitly set, it overrides the default internal buffer size
(32 KB) and limits the maximum amount of data read per operation.
For writing, this sets the size of each write operation. The default is 256 KB
for regular files, 32 KB otherwise.
@end table
@section ftp
@@ -406,26 +417,6 @@ Gophers protocol.
The Gopher protocol with TLS encapsulation.
@section hls
Read Apple HTTP Live Streaming compliant segmented stream as
a uniform one. The M3U8 playlists describing the segments can be
remote HTTP resources or local files, accessed using the standard
file protocol.
The nested protocol is declared by specifying
"+@var{proto}" after the hls URI scheme name, where @var{proto}
is either "file" or "http".
@example
hls+http://host/path/to/remote/resource.m3u8
hls+file://path/to/local/resource.m3u8
@end example
Using this protocol is discouraged - the hls demuxer should work
just as well (if not, please report the issues) and is more complete.
To use the hls demuxer instead, simply use the direct URLs to the
m3u8 files.
@section http
HTTP (Hyper Text Transfer Protocol).
@@ -462,6 +453,28 @@ Set the Referer header. Include 'Referer: URL' header in HTTP request.
@item multiple_requests
Use persistent connections if set to 1, default is 0.
@item request_size
Limit the size of requests made. This is useful for some pathological servers
that throttle unbounded range requests, as well as when expecting to seek
frequently. Disabled (set to 0) by default.
Note that if enabling this option, it's strongly recommended to also enable
the @option{multiple_requests} option, as well as setting
@option{short_seek_size} to the same value or higher. Doing so allows FFmpeg
to reuse a single HTTP connection wherever possible.
@item initial_request_size
Limit the size of initial requests. Similar to @code{request_size}, but only
used during initial format parsing. Useful for formats like MXF or MOV that
require frequent seeks during header parsing. Lasts until the demuxer makes a
read request larger than this size (without a seek in between), after which
the implementation will continue using requests as usual. Disabled (set to 0)
by default.
Note that if enabling this option, it's strongly recommended to also enable
the @option{multiple_requests} option, as well as setting
@option{short_seek_size} to the same value or higher.
@item post_data
Set custom HTTP post data.
@@ -986,6 +999,11 @@ Set TCP_NODELAY to disable Nagle's algorithm. Default value is 0.
@emph{Remark: Writing to the socket is currently not optimized to minimize system calls and reduces the efficiency / effect of TCP_NODELAY.}
@item tcp_keepalive=@var{1|0}
Enable the TCP keepalive mechanism to detect dead peers and help maintain long-lived idle connections. Default value is 0.
Only the basic keepalive option (SO_KEEPALIVE) can be enabled or disabled. Platform-specific tuning parameters such as TCP_KEEPIDLE, TCP_KEEPINTVL, or TCP_KEEPCNT are not configurable and will use the operating system's default values.
@end table
For example to read with @command{ffplay} a multimedia resource named
@@ -1157,9 +1175,13 @@ rtp://@var{hostname}[:@var{port}][?@var{options}]
@var{port} specifies the RTP port to use.
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}.
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
The following URL options are supported:
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
The list of supported options follows.
@table @option
@@ -1169,10 +1191,12 @@ Set the TTL (Time-To-Live) value (for multicast only).
@item rtcpport=@var{n}
Set the remote RTCP port to @var{n}.
@item localrtpport=@var{n}
@item localport, local_rtpport, localrtpport=@var{n}
Set the local RTP port to @var{n}.
@item localrtcpport=@var{n}'
Using the localport option name is deprecated and should not be used.
@item local_rtcpport, localrtcpport=@var{n}'
Set the local RTCP port to @var{n}.
@item pkt_size=@var{n}
@@ -1195,12 +1219,6 @@ List disallowed (blocked) source IP addresses.
Send packets to the source address of the latest received packet (if
set to 1) or to a default remote address (if set to 0).
@item localport=@var{n}
Set the local RTP port to @var{n}.
This is a deprecated option. Instead, @option{localrtpport} should be
used.
@item localaddr=@var{addr}
Local IP address of a network interface used for sending packets or joining
multicast groups.
@@ -1534,7 +1552,15 @@ The accepted URL syntax is:
sctp://@var{host}:@var{port}[?@var{options}]
@end example
The protocol accepts the following options:
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
The list of supported options follows.
@table @option
@item listen
If set to any value, listen for an incoming connection. Outgoing connection is done by default.
@@ -1553,18 +1579,13 @@ srt://@var{hostname}:@var{port}[?@var{options}]
@end example
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}.
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
or
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
@example
@var{options} srt://@var{hostname}:@var{port}
@end example
@var{options} contains a list of '-@var{key} @var{val}'
options.
This protocol accepts the following options.
The list of supported options follows.
@table @option
@item connect_timeout=@var{milliseconds}
@@ -1917,7 +1938,11 @@ tcp://@var{hostname}:@var{port}[?@var{options}]
@end example
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}.
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
The list of supported options follows.
@@ -1972,8 +1997,14 @@ The required syntax for a TLS/SSL url is:
tls://@var{hostname}:@var{port}[?@var{options}]
@end example
The following parameters can be set via command line options
(or in code via @code{AVOption}s):
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
The list of supported options follows.
@table @option
@@ -1984,7 +2015,7 @@ need to be specified for verification to work, but not all libraries and
setups have defaults built in.
The file must be in OpenSSL PEM format.
@item tls_verify=@var{1|0}
@item tls_verify, verify=@var{1|0}
If enabled, try to verify the peer that we are communicating with.
Note, if using OpenSSL, this currently only makes sure that the
peer certificate is signed by one of the root certificates in the CA
@@ -2028,6 +2059,94 @@ To play back a stream from the TLS/SSL server using @command{ffplay}:
ffplay tls://@var{hostname}:@var{port}
@end example
@section dtls
Datagram Transport Layer Security (DTLS)
The required syntax for a DTLS URL is:
@example
dtls://@var{hostname}:@var{port}[?@var{options}]
@end example
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
DTLS shares most options with TLS, but operates over UDP instead of TCP.
The list of supported options follows.
@table @option
@item ca_file, cafile=@var{filename}
A file containing certificate authority (CA) root certificates to treat
as trusted. If the linked TLS library contains a default this might not
need to be specified for verification to work, but not all libraries and
setups have defaults built in.
The file must be in OpenSSL PEM format.
@item tls_verify, verify=@var{1|0}
If enabled, try to verify the peer that we are communicating with.
Note, if using OpenSSL, this currently only makes sure that the
peer certificate is signed by one of the root certificates in the CA
database, but it does not validate that the certificate actually
matches the host name we are trying to connect to.
This is disabled by default since it requires a CA database to be
provided by the caller in many cases.
@item cert_file, cert=@var{filename}
A file containing a certificate to use in the handshake with the peer.
(When operating as server, in listen mode, this is more often required
by the peer, while client certificates only are mandated in certain
setups.)
@item key_file, key=@var{filename}
A file containing the private key for the certificate.
@item cert_pem=@var{string}
Certificate PEM string
@item key_pem=@var{string}
Private key PEM string
@item listen=@var{1|0}
If enabled, listen for connections on the provided port, and assume
the server role in the handshake instead of the client role.
@item mtu=@var{size}
Set the Maximum Transmission Unit (MTU) for DTLS packets.
@item use_srtp=@var{1|0}
Enable the use_srtp DTLS extension.
This is used in WebRTC applications to establish SRTP encryption keys
through the DTLS handshake. Default is disabled.
@item external_sock=@var{1|0}
Use an external socket instead of creating a new one.
This option only makes sense to pass when interacting with the code via
API, enabling this from CLI will cause immediate failure.
Default is disabled.
@end table
Example command lines:
To create a DTLS server:
@example
ffmpeg -listen 1 -i dtls://@var{hostname}:@var{port} @var{output}
@end example
To create a DTLS client and send data to server:
@example
ffmpeg -i @var{input} -f @var{format} dtls://@var{hostname}:@var{port}
@end example
@section udp
User Datagram Protocol.
@@ -2037,7 +2156,12 @@ The required syntax for an UDP URL is:
udp://@var{hostname}:@var{port}[?@var{options}]
@end example
@var{options} contains a list of &-separated options of the form @var{key}=@var{val}.
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
In case threading is enabled on the system, a circular buffer is used
to store the incoming data, which allows one to reduce loss of data due to
@@ -2076,6 +2200,9 @@ Explicitly allow or disallow reusing UDP sockets.
@item ttl=@var{ttl}
Set the time to live value (for multicast only).
@item dscp=@var{dscp}
Set the 6-bit DSCP field for outgoing packets.
@item connect=@var{1|0}
Initialize the UDP socket with @code{connect()}. In this case, the
destination address can't be changed with ff_udp_set_remote_url later.
@@ -2157,6 +2284,17 @@ The following parameters can be set via command line options
Timeout in ms.
@item listen
Create the Unix socket in listening mode.
@item type
Select socket type.
@table @samp
@item stream Corresponds to SOCK_STREAM (reliable stream-oriented)
@item datagram Corresponds to SOCK_DGRAM (unreliable packet-oriented)
@item seqpacket Corresponds to SOCK_SEQPACKET (reliable packet-oriented)
@end table
@item pkt_size
Maximum packet size for packet-oriented sockets (SOCK_DGRAM and
SOCK_SEQPACKET). If greater than zero, this value is used as
@code{max_packet_size}. Ignored for SOCK_STREAM. Default is @code{0}.
@end table
@section zmq
+57 -13
View File
@@ -11,48 +11,88 @@ For programmatic use, they can be set explicitly in the
@table @option
@anchor{scaler}
@item scaler, scaler_sub
Choose the scaling algorithm to use. Default value is @samp{auto} for both.
It accepts the following values:
@table @samp
@item auto
Aumotic choice. For @samp{scaler_sub}, this means the same algorithm as
@samp{scaler}. For @samp{scaler}, this defaults to the scaler flag selected
by @samp{sws_flags}.
@item bilinear
Bilinear filter. (AKA triangle filter)
@item bicubic
2-tap cubic BC-spline (AKA Mitchell-Netravali spline). The B and C parameters
can be configured by setting @code{param0} and @code{param1}, defaulting to
0.0 and 0.6 respectively.
@item point, neighbor
Point sampling (AKA nearest neighbor).
@item area
Area averaging. Equivalent to @samp{bilinear} for upscaling.
@item gaussian
2-tap Gaussian filter approximation. The sharpness parameter can be configured
by setting @code{param0}, defaulting to 3.0.
@item sinc
Unwindowed sinc filter.
@item lanczos
Lanczos resampling (sinc windowed sinc). The number of filter taps can
be configured by setting @code{param0}, defaulting to 3.
@item spline
Unwindowed natural bicubic spline.
@end table
@anchor{sws_flags}
@item sws_flags
Set the scaler flags. This is also used to set the scaling
algorithm. Only a single algorithm should be selected. Default
value is @samp{bicubic}.
algorithm, though this usage is deprecated in favor of setting @samp{scaler}.
Only a single algorithm may be selected. Default value is @samp{bicubic}.
It accepts the following values:
@table @samp
@item fast_bilinear
Select fast bilinear scaling algorithm.
Select fast bilinear scaling algorithm. (Deprecated)
@item bilinear
Select bilinear scaling algorithm.
Select bilinear scaling algorithm. (Deprecated)
@item bicubic
Select bicubic scaling algorithm.
Select bicubic scaling algorithm. (Deprecated)
@item experimental
Select experimental scaling algorithm.
Select experimental scaling algorithm. (Deprecated)
@item neighbor
Select nearest neighbor rescaling algorithm.
Select nearest neighbor rescaling algorithm. (Deprecated)
@item area
Select averaging area rescaling algorithm.
Select averaging area rescaling algorithm. (Deprecated)
@item bicublin
Select bicubic scaling algorithm for the luma component, bilinear for
chroma components.
chroma components. (Deprecated)
@item gauss
Select Gaussian rescaling algorithm.
Select Gaussian rescaling algorithm. (Deprecated)
@item sinc
Select sinc rescaling algorithm.
Select sinc rescaling algorithm. (Deprecated)
@item lanczos
Select Lanczos rescaling algorithm. The default width (alpha) is 3 and can be
changed by setting @code{param0}.
changed by setting @code{param0}. (Deprecated)
@item spline
Select natural bicubic spline rescaling algorithm.
Select natural bicubic spline rescaling algorithm. (Deprecated)
@item print_info
Enable printing/debug logging.
@@ -68,6 +108,10 @@ Select full chroma input.
@item bitexact
Enable bitexact output.
@item unstable
Allow the use of experimental new code. May subtly affect the output or even
produce wrong results. For testing only.
@end table
@item srcw @var{(API only)}
+1 -1
View File
@@ -62,7 +62,7 @@ This overall approach has a considerable number of benefits:
multiple levels of complicated, interwoven format handling code that is
legacy swscale.
2. Because most of the brains lives inside the the powerful optimizer, we get
2. Because most of the brains lives inside the powerful optimizer, we get
fast paths "for free" for any suitable format conversion, rather than having
to enumerate them one by one. SIMD code itself can be written in a very
general way and does need to be tied to specific pixel formats - subsequent
+53 -73
View File
@@ -55,7 +55,8 @@ sub get_formatting_function($$) {
# determine texinfo version
my $package_version = ff_get_conf('PACKAGE_VERSION');
$package_version =~ s/\+dev$//;
$package_version =~ s/\+nc$//;
$package_version =~ s/\+?dev$//;
my $program_version_num = version->declare($package_version)->numify;
my $program_version_6_8 = $program_version_num >= 6.008000;
@@ -119,29 +120,8 @@ sub ffmpeg_heading_command($$$$$)
}
my $heading_level;
# node is used as heading if there is nothing else.
if ($cmdname eq 'node') {
if (!$output_unit or
(((!$output_unit->{'extra'}->{'section'}
and $output_unit->{'extra'}->{'node'}
and $output_unit->{'extra'}->{'node'} eq $command)
or
((($output_unit->{'extra'}->{'unit_command'}
and $output_unit->{'extra'}->{'unit_command'} eq $command)
or
($output_unit->{'unit_command'}
and $output_unit->{'unit_command'} eq $command))
and $command->{'extra'}
and not $command->{'extra'}->{'associated_section'}))
# bogus node may not have been normalized
and defined($command->{'extra'}->{'normalized'}))) {
if ($command->{'extra'}->{'normalized'} eq 'Top') {
$heading_level = 0;
} else {
$heading_level = 3;
}
}
} else {
# Never use node for heading
if ($cmdname ne 'node') {
if (defined($command->{'extra'})
and defined($command->{'extra'}->{'section_level'})) {
$heading_level = $command->{'extra'}->{'section_level'};
@@ -153,58 +133,58 @@ sub ffmpeg_heading_command($$$$$)
}
}
my $heading = $self->command_text($command);
# $heading not defined may happen if the command is a @node, for example
# if there is an error in the node.
if (defined($heading) and $heading ne '' and defined($heading_level)) {
if ($root_commands{$cmdname}
and $sectioning_commands{$cmdname}) {
my $content_href = $self->command_contents_href($command, 'contents',
$self->{'current_filename'});
if ($content_href) {
my $this_href = $content_href =~ s/^\#toc-/\#/r;
$heading .= '<span class="pull-right">'.
'<a class="anchor hidden-xs" '.
"href=\"$this_href\" aria-hidden=\"true\">".
($ENV{"FA_ICONS"} ? '<i class="fa fa-link"></i>'
: '#').
'</a> '.
'<a class="anchor hidden-xs"'.
"href=\"$content_href\" aria-hidden=\"true\">".
($ENV{"FA_ICONS"} ? '<i class="fa fa-navicon"></i>'
: 'TOC').
'</a>'.
'</span>';
if (defined($heading_level)) {
my $heading = $self->command_text($command);
# empty heading corresponds to an empty @top
if ($heading ne '') {
if ($root_commands{$cmdname}
and $sectioning_commands{$cmdname}) {
my $content_href = $self->command_contents_href($command, 'contents',
$self->{'current_filename'});
if ($content_href) {
my $this_href = $content_href =~ s/^\#toc-/\#/r;
$heading .= '<span class="pull-right">'.
'<a class="anchor hidden-xs" '.
"href=\"$this_href\" aria-hidden=\"true\">".
($ENV{"FA_ICONS"} ? '<i class="fa fa-link"></i>'
: '#').
'</a> '.
'<a class="anchor hidden-xs"'.
"href=\"$content_href\" aria-hidden=\"true\">".
($ENV{"FA_ICONS"} ? '<i class="fa fa-navicon"></i>'
: 'TOC').
'</a>'.
'</span>';
}
}
}
my $in_preformatted;
if ($program_version_num >= 7.001090) {
$in_preformatted = $self->in_preformatted_context();
} else {
$in_preformatted = $self->in_preformatted();
}
if ($in_preformatted) {
$result .= $heading."\n";
} else {
# if the level was changed, set the command name right
if ($cmdname ne 'node'
and $heading_level ne $Texinfo::Common::command_structuring_level{$cmdname}) {
$cmdname
= $Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
}
if ($program_version_num >= 7.000000) {
$result .= &{get_formatting_function($self,'format_heading_text')}($self,
$cmdname, [$cmdname], $heading,
$heading_level +$self->get_conf('CHAPTER_HEADER_LEVEL') -1,
$heading_id, $command);
my $in_preformatted;
if ($program_version_num >= 7.001090) {
$in_preformatted = $self->in_preformatted_context();
} else {
$result .= &{get_formatting_function($self,'format_heading_text')}(
$self, $cmdname, $heading,
$heading_level +
$self->get_conf('CHAPTER_HEADER_LEVEL') - 1, $command);
$in_preformatted = $self->in_preformatted();
}
if ($in_preformatted) {
$result .= $heading."\n";
} else {
# if the level was changed, set the command name right
if ($cmdname ne 'node'
and $heading_level ne $Texinfo::Common::command_structuring_level{$cmdname}) {
$cmdname
= $Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
}
if ($program_version_num >= 7.000000) {
$result .= &{get_formatting_function($self,'format_heading_text')}($self,
$cmdname, [$cmdname], $heading,
$heading_level +$self->get_conf('CHAPTER_HEADER_LEVEL') -1,
$heading_id, $command);
} else {
$result .= &{get_formatting_function($self,'format_heading_text')}(
$self, $cmdname, $heading,
$heading_level +
$self->get_conf('CHAPTER_HEADER_LEVEL') - 1, $command);
}
}
}
}
+17 -9
View File
@@ -1,14 +1,17 @@
The basis transforms used for FFT and various other derived functions are based
on the following unrollings.
# Transforms
The basis transforms used for FFT and various other derived functions are based on the following unrollings.
The functions can be easily adapted to double precision floats as well.
# Parity permutation
## Parity permutation
The basis transforms described here all use the following permutation:
``` C
void ff_tx_gen_split_radix_parity_revtab(int *revtab, int len, int inv,
int basis, int dual_stride);
```
Parity means even and odd complex numbers will be split, e.g. the even
coefficients will come first, after which the odd coefficients will be
placed. For example, a 4-point transform's coefficients after reordering:
@@ -33,7 +36,8 @@ register or 0. This allows to reuse SSE functions as dual-transform
functions in AVX mode.
If length is smaller than basis/2 this function will not do anything.
# 4-point FFT transform
## 4-point FFT transform
The only permutation this transform needs is to swap the `z[1]` and `z[2]`
elements when performing an inverse transform, which in the assembly code is
hardcoded with the function itself being templated and duplicated for each
@@ -80,7 +84,8 @@ static void fft4(FFTComplex *z)
}
```
# 8-point AVX FFT transform
## 8-point AVX FFT transform
Input must be pre-permuted using the parity lookup table, generated via
`ff_tx_gen_split_radix_parity_revtab`.
@@ -193,7 +198,8 @@ This theme continues throughout the document. Note that in the actual assembly c
the paths are interleaved to improve unit saturation and CPU dependency tracking, so
to more clearly see them, you'll need to deinterleave the instructions.
# 8-point SSE/ARM64 FFT transform
## 8-point SSE/ARM64 FFT transform
Input must be pre-permuted using the parity lookup table, generated via
`ff_tx_gen_split_radix_parity_revtab`.
@@ -305,7 +311,8 @@ static void fft8(FFTComplex *z)
Most functions here are highly tuned to use x86's addsub instruction to save on
external sign mask loading.
# 16-point AVX FFT transform
## 16-point AVX FFT transform
This version expects the output of the 8 and 4-point transforms to follow the
even/odd convention established above.
@@ -445,7 +452,8 @@ static void fft16(FFTComplex *z)
}
```
# AVX split-radix synthesis
## AVX split-radix synthesis
To create larger transforms, the following unrolling of the C split-radix
function is used.
@@ -705,8 +713,8 @@ beginning to overlap, particularly `[o1]` with `[0]` after the second iteration.
To iterate further, set `z = &z[16]` via `z += 8` for the second iteration. After
the 4th iteration, the layout resets, so repeat the same.
## 15-point AVX FFT transform
# 15-point AVX FFT transform
The 15-point transform is based on the following unrolling. The input
must be permuted via the following loop:
+2 -1
View File
@@ -5,6 +5,8 @@ OBJS-$(HAVE_VFP) += $(VFP-OBJS) $(VFP-OBJS-yes)
OBJS-$(HAVE_NEON) += $(NEON-OBJS) $(NEON-OBJS-yes)
OBJS-$(HAVE_SVE) += $(SVE-OBJS) $(SVE-OBJS-yes)
OBJS-$(HAVE_SVE2) += $(SVE2-OBJS) $(SVE2-OBJS-yes)
OBJS-$(HAVE_SME) += $(SME-OBJS) $(SME-OBJS-yes)
OBJS-$(HAVE_SME2) += $(SME2-OBJS) $(SME2-OBJS-yes)
OBJS-$(HAVE_MIPSFPU) += $(MIPSFPU-OBJS) $(MIPSFPU-OBJS-yes)
OBJS-$(HAVE_MIPSDSP) += $(MIPSDSP-OBJS) $(MIPSDSP-OBJS-yes)
@@ -23,5 +25,4 @@ OBJS-$(HAVE_RV_ZVBB) += $(RVVB-OBJS) $(RVVB-OBJS-yes)
OBJS-$(HAVE_SIMD128) += $(SIMD128-OBJS) $(SIMD128-OBJS-yes)
OBJS-$(HAVE_MMX) += $(MMX-OBJS) $(MMX-OBJS-yes)
OBJS-$(HAVE_X86ASM) += $(X86ASM-OBJS) $(X86ASM-OBJS-yes)
+50 -48
View File
@@ -2,24 +2,25 @@
# common bits used by all libraries
#
DEFAULT_X86ASMD=.dbg
ifeq ($(DBG),1)
X86ASMD=$(DEFAULT_X86ASMD)
else
X86ASMD=
endif
ifndef SUBDIR
LINK = $(LD) $(1)
ifeq ($(LD),$(CC))
ifneq ($(CXX),)
LDXX := $(CXX)
LINK = $(if $(filter -lstdc++,$(1)),$(LDXX) $(filter-out -lstdc++,$(1)),$(LD) $(1))
endif
endif
BIN2CEXE = ffbuild/bin2c$(HOSTEXESUF)
BIN2C = $(BIN2CEXE)
ifndef V
Q = @
ECHO = printf "$(1)\t%s\n" $(2)
BRIEF = CC CXX OBJCC HOSTCC HOSTLD AS X86ASM AR LD STRIP CP WINDRES NVCC BIN2C METALCC METALLIB
SILENT = DEPCC DEPHOSTCC DEPAS DEPX86ASM RANLIB RM
BRIEF = CC CXX OBJCC HOSTCC HOSTLD AS X86ASM AR LD LDXX STRIP CP WINDRES GLSLC NVCC BIN2C METALCC METALLIB
SILENT = DEPCC DEPCXX DEPHOSTCC DEPAS DEPX86ASM RANLIB RM
MSG = $@
M = @$(call ECHO,$(TAG),$@);
@@ -42,7 +43,7 @@ OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
# Use PREPEND here so that later (target-dependent) additions to CPPFLAGS
# end up in CXXFLAGS.
$(call PREPEND,CXXFLAGS, CPPFLAGS CFLAGS)
$(call PREPEND,CXXFLAGS, CPPFLAGS)
X86ASMFLAGS += $(IFLAGS:%=%/) -I$(<D)/ -Pconfig.asm
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
@@ -59,6 +60,7 @@ COMPILE_S = $(call COMPILE,AS)
COMPILE_M = $(call COMPILE,OBJCC)
COMPILE_X86ASM = $(call COMPILE,X86ASM)
COMPILE_HOSTC = $(call COMPILE,HOSTCC)
COMPILE_GLSLC = $(call COMPILE,GLSLC)
COMPILE_NVCC = $(call COMPILE,NVCC)
COMPILE_MMI = $(call COMPILE,CC,MMIFLAGS)
COMPILE_MSA = $(call COMPILE,CC,MSAFLAGS)
@@ -95,10 +97,6 @@ COMPILE_LASX = $(call COMPILE,CC,LASXFLAGS)
%_host.o: %.c
$(COMPILE_HOSTC)
%$(DEFAULT_X86ASMD).asm: %.asm
$(DEPX86ASM) $(X86ASMFLAGS) -M -o $@ $< > $(@:.asm=.d)
$(X86ASM) $(X86ASMFLAGS) -e $< | sed '/^%/d;/^$$/d;' > $@
%.o: %.asm
$(COMPILE_X86ASM)
-$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@)
@@ -115,6 +113,26 @@ COMPILE_LASX = $(call COMPILE,CC,LASXFLAGS)
$(BIN2CEXE): ffbuild/bin2c_host.o
$(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTEXTRALIBS)
RUN_BIN2C = $(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst .,_,$(basename $(notdir $@)))
RUN_GZIP = $(M)gzip -nc9 $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) >$@
RUN_MINIFY = $(M)sed 's!/\\*.*\\*/!!g' $< | tr '\n' ' ' | tr -s ' ' | sed 's/^ //; s/ $$//' > $@
%.gz: TAG = GZIP
%.min: TAG = MINIFY
%.spv: %.glsl
$(COMPILE_GLSLC)
ifdef CONFIG_SHADER_COMPRESSION
%.spv.gz: %.spv
$(RUN_GZIP)
%.spv.c: %.spv.gz $(BIN2CEXE)
$(RUN_BIN2C)
else
%.spv.c: %.spv $(BIN2CEXE)
$(RUN_BIN2C)
endif
%.metal.air: %.metal
$(METALCC) $< -o $@
@@ -122,67 +140,52 @@ $(BIN2CEXE): ffbuild/bin2c_host.o
$(METALLIB) --split-module-without-linking $< -o $@
%.metallib.c: %.metallib $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
%.ptx: %.cu $(SRC_PATH)/compat/cuda/cuda_runtime.h
$(COMPILE_NVCC)
ifdef CONFIG_PTX_COMPRESSION
%.ptx.gz: TAG = GZIP
ifdef CONFIG_SHADER_COMPRESSION
%.ptx.gz: %.ptx
$(M)gzip -nc9 $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) >$@
$(RUN_GZIP)
%.ptx.c: %.ptx.gz $(BIN2CEXE)
$(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
else
%.ptx.c: %.ptx $(BIN2CEXE)
$(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
endif
# 1) Preprocess CSS to a minified version
%.css.min: TAG = SED
%.css.min: %.css
$(M)sed 's!/\\*.*\\*/!!g' $< \
| tr '\n' ' ' \
| tr -s ' ' \
| sed 's/^ //; s/ $$//' \
> $@
$(RUN_MINIFY)
ifdef CONFIG_RESOURCE_COMPRESSION
# 2) Gzip the minified CSS
%.css.min.gz: TAG = GZIP
%.css.min.gz: %.css.min
$(M)gzip -nc9 $< > $@
$(RUN_GZIP)
# 3) Convert the gzipped CSS to a .c array
%.css.c: %.css.min.gz $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
# 4) Gzip the HTML file (no minification needed)
%.html.gz: TAG = GZIP
%.html.gz: %.html
$(M)gzip -nc9 $< > $@
$(RUN_GZIP)
# 5) Convert the gzipped HTML to a .c array
%.html.c: %.html.gz $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
else # NO COMPRESSION
# 2) Convert the minified CSS to a .c array
%.css.c: %.css.min $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
# 3) Convert the plain HTML to a .c array
%.html.c: %.html $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
endif
clean::
$(RM) $(BIN2CEXE) $(CLEANSUFFIXES:%=ffbuild/%)
%.c %.h %.pc %.ver %.version: TAG = GEN
%.c %.h %.S %.pc %.ver %.version: TAG = GEN
# Dummy rule to stop make trying to rebuild removed or renamed headers
%.h %_template.c:
@@ -228,12 +231,11 @@ ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)
SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
SPVOBJS = $(filter %.spv.o,$(OBJS))
PTXOBJS = $(filter %.ptx.o,$(OBJS))
RESOURCEOBJS = $(filter %.css.o %.html.o,$(OBJS))
$(HOBJS): CCFLAGS += $(CFLAGS_HEADERS)
checkheaders: $(HOBJS)
.SECONDARY: $(HOBJS:.o=.c) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=.gz) $(PTXOBJS:.o=) $(RESOURCEOBJS:.o=.c) $(RESOURCEOBJS:%.css.o=%.css.min) $(RESOURCEOBJS:%.css.o=%.css.min.gz) $(RESOURCEOBJS:%.html.o=%.html.gz) $(RESOURCEOBJS:.o=)
.SECONDARY: $(HOBJS:.o=.c) $(SPVOBJS:.o=.c) $(SPVOBJS:.o=.gz) $(SPVOBJS:.o=) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=.gz) $(PTXOBJS:.o=)
alltools: $(TOOLS)
$(HOSTOBJS): %.o: %.c
@@ -252,7 +254,7 @@ $(TOOLOBJS): | tools
OUTDIRS := $(OUTDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SHLIBOBJS) $(STLIBOBJS) $(TESTOBJS))
CLEANSUFFIXES = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.objs *.pc *.ptx *.ptx.gz *.ptx.c *.ver *.version *.html.gz *.html.c *.css.gz *.css.c *$(DEFAULT_X86ASMD).asm *~ *.ilk *.pdb
CLEANSUFFIXES = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.objs *.pc *.ptx *.ptx.gz *.ptx.c *.spv *.spv.gz *.spv.c *.gen.c *.gen.S *.ver *.version *.html.gz *.html.c *.css.min.gz *.css.min *.css.c *~ *.ilk *.pdb
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
define RULES
@@ -262,4 +264,4 @@ endef
$(eval $(RULES))
-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SHLIBOBJS:.o=.d) $(STLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_X86ASMD).d)
-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SHLIBOBJS:.o=.d) $(STLIBOBJS:.o=.d) $(SPVOBJS:.spv.o=.d))
+7 -3
View File
@@ -55,8 +55,12 @@ $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME)
$(LIBOBJS): CPPFLAGS += -DBUILDING_$(NAME)
$(NAME)LINK_EXE_ARGS = $(LDFLAGS) $(LDEXEFLAGS)
$(NAME)LINK_SO_ARGS = $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS)
$(NAME)LINK_EXTRA = $(FFEXTRALIBS)
$(TESTPROGS) $(TOOLS): %$(EXESUF): %.o
$$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(EXTRALIBS-$$(*F)) $$(ELIBS)
$$(call LINK,$$(call $(NAME)LINK_EXE_ARGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $$(call $(NAME)LINK_EXTRA) $$(EXTRALIBS-$$(*F)) $$(ELIBS))
$(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h $(SUBDIR)version_major.h | $(SUBDIR)
$$(M) $$(SRC_PATH)/ffbuild/libversion.sh $(NAME) $$^ > $$@
@@ -74,9 +78,9 @@ $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SHLIBOBJS) $(SUBDIR)lib$(NAME).ver
$(SLIB_CREATE_DEF_CMD)
ifeq ($(RESPONSE_FILES),yes)
$(Q)echo $$(filter %.o,$$^) > $$@.objs
$$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) @$$@.objs $(FFEXTRALIBS)
$$(call LINK,$$(call $(NAME)LINK_SO_ARGS) $$(LD_O) @$$@.objs $$(call $(NAME)LINK_EXTRA))
else
$$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
$$(call LINK,$$(call $(NAME)LINK_SO_ARGS) $$(LD_O) $$(filter %.o,$$^) $$(call $(NAME)LINK_EXTRA))
endif
$(SLIB_EXTRA_CMD)
-$(RM) $$@.objs
+2
View File
@@ -36,6 +36,7 @@ OBJS-ffmpeg += \
fftools/textformat/tw_buffer.o \
fftools/textformat/tw_stdout.o \
$(OBJS-resman) \
$(RESOBJS) \
OBJS-ffprobe += \
fftools/textformat/avtextformat.o \
@@ -50,6 +51,7 @@ OBJS-ffprobe += \
fftools/textformat/tw_buffer.o \
fftools/textformat/tw_stdout.o \
OBJS-ffmpeg += $(COMPAT_OBJS:%=compat/%)
OBJS-ffplay += fftools/ffplay_renderer.o
define DOFFTOOL
+101 -6
View File
@@ -263,7 +263,7 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
return AVERROR(EINVAL);
}
arg_allocated = file_read(arg);
arg_allocated = read_file_to_string(arg);
if (!arg_allocated) {
av_log(NULL, AV_LOG_FATAL,
"Error reading the value for option '%s' from file: %s\n",
@@ -275,7 +275,7 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
}
if (po->flags & OPT_FLAG_SPEC) {
char *p = strchr(opt, ':');
const char *p = strchr(opt, ':');
char *str;
sol = dst;
@@ -962,8 +962,7 @@ FILE *get_preset_file(char *filename, size_t filename_size,
datadir, desired_size, sizeof *datadir);
if (new_datadir) {
datadir = new_datadir;
datadir[datadir_len] = 0;
strncat(datadir, "/ffpresets", desired_size - 1 - datadir_len);
strcpy(datadir + datadir_len, "/ffpresets");
base[2] = datadir;
}
}
@@ -1268,7 +1267,7 @@ unsigned stream_specifier_match(const StreamSpecifier *ss,
break;
}
}
// fall-through
av_fallthrough;
case STREAM_LIST_GROUP_IDX:
if (ss->stream_list == STREAM_LIST_GROUP_IDX &&
ss->list_id >= 0 && ss->list_id < s->nb_stream_groups)
@@ -1350,6 +1349,77 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
return ret;
}
unsigned stream_group_specifier_match(const StreamSpecifier *ss,
const AVFormatContext *s, const AVStreamGroup *stg,
void *logctx)
{
int start_stream_group = 0, nb_stream_groups;
int nb_matched = 0;
if (ss->idx >= 0)
return 0;
switch (ss->stream_list) {
case STREAM_LIST_STREAM_ID:
case STREAM_LIST_ALL:
case STREAM_LIST_PROGRAM:
return 0;
case STREAM_LIST_GROUP_ID:
// <n-th> stream with given ID makes no sense and should be impossible to request
av_assert0(ss->idx < 0);
// return early if we know for sure the stream does not match
if (stg->id != ss->list_id)
return 0;
start_stream_group = stg->index;
nb_stream_groups = stg->index + 1;
break;
case STREAM_LIST_GROUP_IDX:
start_stream_group = ss->list_id >= 0 ? 0 : stg->index;
nb_stream_groups = stg->index + 1;
break;
default: av_assert0(0);
}
for (int i = start_stream_group; i < nb_stream_groups; i++) {
const AVStreamGroup *candidate = s->stream_groups[i];
if (ss->meta_key) {
const AVDictionaryEntry *tag = av_dict_get(candidate->metadata,
ss->meta_key, NULL, 0);
if (!tag)
continue;
if (ss->meta_val && strcmp(tag->value, ss->meta_val))
continue;
}
if (ss->usable_only) {
switch (candidate->type) {
case AV_STREAM_GROUP_PARAMS_TILE_GRID: {
const AVStreamGroupTileGrid *tg = candidate->params.tile_grid;
if (!tg->coded_width || !tg->coded_height || !tg->nb_tiles ||
!tg->width || !tg->height || !tg->nb_tiles)
continue;
break;
}
default:
continue;
}
}
if (ss->disposition &&
(candidate->disposition & ss->disposition) != ss->disposition)
continue;
if (stg == candidate)
return ss->list_id < 0 || ss->list_id == nb_matched;
nb_matched++;
}
return 0;
}
int filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id,
AVFormatContext *s, AVStream *st, const AVCodec *codec,
AVDictionary **dst, AVDictionary **opts_used)
@@ -1498,7 +1568,7 @@ double get_rotation(const int32_t *displaymatrix)
}
/* read file contents into a string */
char *file_read(const char *filename)
char *read_file_to_string(const char *filename)
{
AVIOContext *pb = NULL;
int ret = avio_open(&pb, filename, AVIO_FLAG_READ);
@@ -1542,3 +1612,28 @@ int check_avoptions(AVDictionary *m)
return 0;
}
void dump_dictionary(void *ctx, const AVDictionary *m,
const char *name, const char *indent,
int log_level)
{
const AVDictionaryEntry *tag = NULL;
if (!m)
return;
av_log(ctx, log_level, "%s%s:\n", indent, name);
while ((tag = av_dict_iterate(m, tag))) {
const char *p = tag->value;
av_log(ctx, log_level, "%s %-16s: ", indent, tag->key);
while (*p) {
size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
av_log(ctx, log_level, "%.*s", (int)(FFMIN(255, len)), p);
p += len;
if (*p == 0xd) av_log(ctx, log_level, " ");
if (*p == 0xa) av_log(ctx, log_level, "\n%s %-16s: ", indent, "");
if (*p) p++;
}
av_log(ctx, log_level, "\n");
}
}
+13 -1
View File
@@ -158,6 +158,10 @@ unsigned stream_specifier_match(const StreamSpecifier *ss,
const AVFormatContext *s, const AVStream *st,
void *logctx);
unsigned stream_group_specifier_match(const StreamSpecifier *ss,
const AVFormatContext *s, const AVStreamGroup *stg,
void *logctx);
void stream_specifier_uninit(StreamSpecifier *ss);
typedef struct SpecifierOpt {
@@ -535,7 +539,7 @@ void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems);
double get_rotation(const int32_t *displaymatrix);
/* read file contents into a string */
char *file_read(const char *filename);
char *read_file_to_string(const char *filename);
/* Remove keys in dictionary b from dictionary a */
void remove_avoptions(AVDictionary **a, AVDictionary *b);
@@ -545,4 +549,12 @@ int check_avoptions(AVDictionary *m);
int cmdutils_isalnum(char c);
/**
* This does the same as libavformat/dump.c corresponding function
* and should probably be kept in sync when the other one changes.
*/
void dump_dictionary(void *ctx, const AVDictionary *m,
const char *name, const char *indent,
int log_level);
#endif /* FFTOOLS_CMDUTILS_H */
+25 -3
View File
@@ -78,6 +78,9 @@
#include "libavdevice/avdevice.h"
#include "cmdutils.h"
#if CONFIG_MEDIACODEC
#include "compat/android/binder.h"
#endif
#include "ffmpeg.h"
#include "ffmpeg_sched.h"
#include "ffmpeg_utils.h"
@@ -250,7 +253,6 @@ void term_init(void)
/* read a key without blocking */
static int read_key(void)
{
unsigned char ch;
#if HAVE_TERMIOS_H
int n = 1;
struct timeval tv;
@@ -262,6 +264,7 @@ static int read_key(void)
tv.tv_usec = 0;
n = select(1, &rfds, NULL, NULL, &tv);
if (n > 0) {
unsigned char ch;
n = read(0, &ch, 1);
if (n == 1)
return ch;
@@ -286,6 +289,7 @@ static int read_key(void)
}
//Read it
if(nchars != 0) {
unsigned char ch;
if (read(0, &ch, 1) == 1)
return ch;
return 0;
@@ -400,6 +404,7 @@ static void frame_data_free(void *opaque, uint8_t *data)
{
FrameData *fd = (FrameData *)data;
av_frame_side_data_free(&fd->side_data, &fd->nb_side_data);
avcodec_parameters_free(&fd->par_enc);
av_free(data);
@@ -429,6 +434,8 @@ static int frame_data_ensure(AVBufferRef **dst, int writable)
memcpy(fd, fd_src, sizeof(*fd));
fd->par_enc = NULL;
fd->side_data = NULL;
fd->nb_side_data = 0;
if (fd_src->par_enc) {
int ret = 0;
@@ -444,6 +451,16 @@ static int frame_data_ensure(AVBufferRef **dst, int writable)
}
}
if (fd_src->nb_side_data) {
int ret = clone_side_data(&fd->side_data, &fd->nb_side_data,
fd_src->side_data, fd_src->nb_side_data, 0);
if (ret < 0) {
av_buffer_unref(dst);
av_buffer_unref(&src);
return ret;
}
}
av_buffer_unref(&src);
} else {
fd->dec.frame_num = UINT64_MAX;
@@ -806,8 +823,6 @@ static int check_keyboard_interaction(int64_t cur_time)
{
int i, key;
static int64_t last_time;
if (received_nb_signals)
return AVERROR_EXIT;
/* read_key() returns 0 on EOF */
if (cur_time - last_time >= 100000) {
key = read_key();
@@ -891,6 +906,9 @@ static int transcode(Scheduler *sch)
while (!sch_wait(sch, stats_period, &transcode_ts)) {
int64_t cur_time= av_gettime_relative();
if (received_nb_signals)
break;
/* if 'q' pressed, exits */
if (stdin_interaction)
if (check_keyboard_interaction(cur_time) < 0)
@@ -1005,6 +1023,10 @@ int main(int argc, char **argv)
goto finish;
}
#if CONFIG_MEDIACODEC
android_binder_threadpool_init_if_required();
#endif
current_time = ti = get_benchmark_time_stamps();
ret = transcode(sch);
if (ret >= 0 && do_benchmark) {
+61 -5
View File
@@ -136,6 +136,7 @@ typedef struct StreamMap {
int disabled; /* 1 is this mapping is disabled by a negative map */
int file_index;
int stream_index;
int group_index;
char *linklabel; /* name of an output link, for mapping lavfi outputs */
ViewSpecifier vs;
@@ -217,6 +218,8 @@ typedef struct OptionsContext {
SpecifierOptList display_rotations;
SpecifierOptList display_hflips;
SpecifierOptList display_vflips;
SpecifierOptList mastering_displays;
SpecifierOptList content_lights;
SpecifierOptList rc_overrides;
SpecifierOptList intra_matrices;
SpecifierOptList inter_matrices;
@@ -257,6 +260,8 @@ typedef struct OptionsContext {
SpecifierOptList enc_stats_pre_fmt;
SpecifierOptList enc_stats_post_fmt;
SpecifierOptList mux_stats_fmt;
int depth;
} OptionsContext;
enum IFilterFlags {
@@ -299,6 +304,8 @@ enum OFilterFlags {
// produce 24-bit audio
OFILTER_FLAG_AUDIO_24BIT = (1 << 1),
OFILTER_FLAG_AUTOSCALE = (1 << 2),
OFILTER_FLAG_AUTOROTATE = (1 << 3),
OFILTER_FLAG_CROP = (1 << 4),
};
typedef struct OutputFilterOptions {
@@ -330,6 +337,12 @@ typedef struct OutputFilterOptions {
int height;
enum AVColorSpace color_space;
enum AVColorRange color_range;
enum AVAlphaMode alpha_mode;
unsigned crop_top;
unsigned crop_bottom;
unsigned crop_left;
unsigned crop_right;
enum VideoSyncMethod vsync_method;
AVRational frame_rate;
@@ -338,12 +351,19 @@ typedef struct OutputFilterOptions {
int sample_rate;
AVChannelLayout ch_layout;
const int *formats;
union {
const enum AVPixelFormat *pix_fmts;
const enum AVSampleFormat *sample_fmts;
};
const int *sample_rates;
const AVChannelLayout *ch_layouts;
const AVRational *frame_rates;
const enum AVColorSpace *color_spaces;
const enum AVColorRange *color_ranges;
const enum AVAlphaMode *alpha_modes;
AVFrameSideData **side_data;
int nb_side_data;
// for simple filtergraphs only, view specifier passed
// along to the decoder
@@ -400,6 +420,11 @@ typedef struct FilterGraph {
OutputFilter **outputs;
int nb_outputs;
// true when the filtergraph is created internally for
// purposes like stream group merging. Meant to be freed
// if unbound.
int is_internal;
const char *graph_desc;
struct AVBPrint graph_print_buf;
} FilterGraph;
@@ -489,6 +514,18 @@ typedef struct InputStream {
int nb_filters;
} InputStream;
typedef struct InputStreamGroup {
const AVClass *class;
/* parent source */
struct InputFile *file;
int index;
FilterGraph *fg;
AVStreamGroup *stg;
} InputStreamGroup;
typedef struct InputFile {
const AVClass *class;
@@ -510,6 +547,10 @@ typedef struct InputFile {
* if new streams appear dynamically during demuxing */
InputStream **streams;
int nb_streams;
/* stream groups that ffmpeg is aware of; */
InputStreamGroup **stream_groups;
int nb_stream_groups;
} InputFile;
enum forced_keyframes_const {
@@ -568,6 +609,8 @@ enum {
#if FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP
KF_FORCE_SOURCE_NO_DROP = 2,
#endif
// force keyframe if lavfi.scd.time metadata is set
KF_FORCE_SCD_METADATA = 3,
};
typedef struct KeyframeForceCtx {
@@ -696,6 +739,9 @@ typedef struct FrameData {
int64_t wallclock[LATENCY_PROBE_NB];
AVCodecParameters *par_enc;
AVFrameSideData **side_data;
int nb_side_data;
} FrameData;
extern InputFile **input_files;
@@ -769,12 +815,12 @@ int check_avoptions_used(const AVDictionary *opts, const AVDictionary *opts_used
int assert_file_overwrite(const char *filename);
int find_codec(void *logctx, const char *name,
enum AVMediaType type, int encoder, const AVCodec **codec);
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global);
int parse_and_set_vsync(const char *arg, enum VideoSyncMethod *vsync_var, int file_idx, int st_idx, int is_global);
int filtergraph_is_simple(const FilterGraph *fg);
int fg_create_simple(FilterGraph **pfg,
InputStream *ist,
char *graph_desc,
char **graph_desc,
Scheduler *sch, unsigned sched_idx_enc,
const OutputFilterOptions *opts);
int fg_finalise_bindings(void);
@@ -797,10 +843,11 @@ int ofilter_bind_enc(OutputFilter *ofilter,
/**
* Create a new filtergraph in the global filtergraph list.
*
* @param graph_desc Graph description; an av_malloc()ed string, filtergraph
* @param graph_desc Pointer to graph description; an av_malloc()ed string, filtergraph
* takes ownership of it.
*/
int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch);
int fg_create(FilterGraph **pfg, char **graph_desc, Scheduler *sch,
const OutputFilterOptions *opts);
void fg_free(FilterGraph **pfg);
@@ -927,6 +974,15 @@ void opt_match_per_stream_int64(void *logctx, const SpecifierOptList *sol,
void opt_match_per_stream_dbl(void *logctx, const SpecifierOptList *sol,
AVFormatContext *fc, AVStream *st, double *out);
void opt_match_per_stream_group_str(void *logctx, const SpecifierOptList *sol,
AVFormatContext *fc, AVStreamGroup *stg, const char **out);
void opt_match_per_stream_group_int(void *logctx, const SpecifierOptList *sol,
AVFormatContext *fc, AVStreamGroup *stg, int *out);
void opt_match_per_stream_group_int64(void *logctx, const SpecifierOptList *sol,
AVFormatContext *fc, AVStreamGroup *stg, int64_t *out);
void opt_match_per_stream_group_dbl(void *logctx, const SpecifierOptList *sol,
AVFormatContext *fc, AVStreamGroup *stg, double *out);
int view_specifier_parse(const char **pspec, ViewSpecifier *vs);
int muxer_thread(void *arg);
+7 -2
View File
@@ -744,11 +744,14 @@ static int packet_decode(DecoderPriv *dp, AVPacket *pkt, AVFrame *frame)
while (1) {
FrameData *fd;
unsigned outputs_mask = 1;
unsigned flags = 0;
if (!dp->dec.frames_decoded)
flags |= AV_CODEC_RECEIVE_FRAME_FLAG_SYNCHRONOUS;
av_frame_unref(frame);
update_benchmark(NULL);
ret = avcodec_receive_frame(dec, frame);
ret = avcodec_receive_frame_flags(dec, frame, flags);
update_benchmark("decode_%s %s", type_desc, dp->parent_name);
if (ret == AVERROR(EAGAIN)) {
@@ -1007,7 +1010,7 @@ static int decoder_thread(void *arg)
ret = 0;
err_rate = (dp->dec.frames_decoded || dp->dec.decode_errors) ?
dp->dec.decode_errors / (dp->dec.frames_decoded + dp->dec.decode_errors) : 0.f;
(float)dp->dec.decode_errors / (dp->dec.frames_decoded + dp->dec.decode_errors) : 0.f;
if (err_rate > max_error_rate) {
av_log(dp, AV_LOG_FATAL, "Decode error rate %g exceeds maximum %g\n",
err_rate, max_error_rate);
@@ -1018,6 +1021,7 @@ static int decoder_thread(void *arg)
finish:
dec_thread_uninit(&dt);
avcodec_free_context(&dp->dec_ctx);
return ret;
}
@@ -1635,6 +1639,7 @@ static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts,
param_out->sample_aspect_ratio = dp->dec_ctx->sample_aspect_ratio;
param_out->colorspace = dp->dec_ctx->colorspace;
param_out->color_range = dp->dec_ctx->color_range;
param_out->alpha_mode = dp->dec_ctx->alpha_mode;
}
av_frame_side_data_free(&param_out->side_data, &param_out->nb_side_data);
+385 -3
View File
@@ -28,6 +28,7 @@
#include "libavutil/display.h"
#include "libavutil/error.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mastering_display_metadata.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
@@ -67,6 +68,9 @@ typedef struct DemuxStream {
int reinit_filters;
int autorotate;
int apply_cropping;
int force_display_matrix;
int force_mastering_display;
int force_content_light;
int drop_changed;
@@ -103,6 +107,13 @@ typedef struct DemuxStream {
int64_t lag;
} DemuxStream;
typedef struct DemuxStreamGroup {
InputStreamGroup istg;
// name used for logging
char log_name[32];
} DemuxStreamGroup;
typedef struct Demuxer {
InputFile f;
@@ -517,7 +528,10 @@ static void readrate_sleep(Demuxer *d)
pts = av_rescale(ds->dts, 1000000, AV_TIME_BASE);
now = av_gettime_relative();
wc_elapsed = now - d->wallclock_start;
max_pts = stream_ts_offset + initial_burst + wc_elapsed * d->readrate;
if (pts <= stream_ts_offset + initial_burst) continue;
max_pts = stream_ts_offset + initial_burst + (int64_t)(wc_elapsed * d->readrate);
lag = FFMAX(max_pts - pts, 0);
if ( (!ds->lag && lag > 0.3 * AV_TIME_BASE) || ( lag > ds->lag + 0.3 * AV_TIME_BASE) ) {
ds->lag = lag;
@@ -531,7 +545,7 @@ static void readrate_sleep(Demuxer *d)
ds->lag = ds->resume_wc = ds->resume_pts = 0;
if (ds->resume_wc) {
elapsed = now - ds->resume_wc;
limit_pts = ds->resume_pts + elapsed * d->readrate_catchup;
limit_pts = ds->resume_pts + (int64_t)(elapsed * d->readrate_catchup);
} else {
elapsed = wc_elapsed;
limit_pts = max_pts;
@@ -885,6 +899,16 @@ static void ist_free(InputStream **pist)
av_freep(pist);
}
static void istg_free(InputStreamGroup **pistg)
{
InputStreamGroup *istg = *pistg;
if (!istg)
return;
av_freep(pistg);
}
void ifile_close(InputFile **pf)
{
InputFile *f = *pf;
@@ -900,6 +924,10 @@ void ifile_close(InputFile **pf)
ist_free(&f->streams[i]);
av_freep(&f->streams);
for (int i = 0; i < f->nb_stream_groups; i++)
istg_free(&f->stream_groups[i]);
av_freep(&f->stream_groups);
avformat_close_input(&f->ctx);
av_packet_free(&d->pkt_heartbeat);
@@ -1183,6 +1211,7 @@ static int add_display_matrix_to_stream(const OptionsContext *o,
AVFormatContext *ctx, InputStream *ist)
{
AVStream *st = ist->st;
DemuxStream *ds = ds_from_ist(ist);
AVPacketSideData *sd;
double rotation = DBL_MAX;
int hflip = -1, vflip = -1;
@@ -1217,6 +1246,127 @@ static int add_display_matrix_to_stream(const OptionsContext *o,
hflip_set ? hflip : 0,
vflip_set ? vflip : 0);
ds->force_display_matrix = 1;
return 0;
}
static int add_mastering_display_to_stream(const OptionsContext *o,
AVFormatContext *ctx, InputStream *ist)
{
AVStream *st = ist->st;
DemuxStream *ds = ds_from_ist(ist);
AVMasteringDisplayMetadata *master_display;
AVPacketSideData *sd;
const char *p = NULL;
const int chroma_den = 50000;
const int luma_den = 10000;
size_t size;
int ret;
opt_match_per_stream_str(ist, &o->mastering_displays, ctx, st, &p);
if (!p)
return 0;
master_display = av_mastering_display_metadata_alloc_size(&size);
if (!master_display)
return AVERROR(ENOMEM);
ret = sscanf(p,
"G(%u,%u)B(%u,%u)R(%u,%u)WP(%u,%u)L(%u,%u)",
(unsigned*)&master_display->display_primaries[1][0].num,
(unsigned*)&master_display->display_primaries[1][1].num,
(unsigned*)&master_display->display_primaries[2][0].num,
(unsigned*)&master_display->display_primaries[2][1].num,
(unsigned*)&master_display->display_primaries[0][0].num,
(unsigned*)&master_display->display_primaries[0][1].num,
(unsigned*)&master_display->white_point[0].num,
(unsigned*)&master_display->white_point[1].num,
(unsigned*)&master_display->max_luminance.num,
(unsigned*)&master_display->min_luminance.num);
if (ret != 10 ||
(unsigned)(master_display->display_primaries[1][0].num | master_display->display_primaries[1][1].num |
master_display->display_primaries[2][0].num | master_display->display_primaries[2][1].num |
master_display->display_primaries[0][0].num | master_display->display_primaries[0][1].num |
master_display->white_point[0].num | master_display->white_point[1].num) > UINT16_MAX ||
(unsigned)(master_display->max_luminance.num | master_display->min_luminance.num) > INT_MAX ||
master_display->min_luminance.num > master_display->max_luminance.num) {
av_freep(&master_display);
av_log(ist, AV_LOG_ERROR, "Failed to parse mastering display option\n");
return AVERROR(EINVAL);
}
master_display->display_primaries[1][0].den = chroma_den;
master_display->display_primaries[1][1].den = chroma_den;
master_display->display_primaries[2][0].den = chroma_den;
master_display->display_primaries[2][1].den = chroma_den;
master_display->display_primaries[0][0].den = chroma_den;
master_display->display_primaries[0][1].den = chroma_den;
master_display->white_point[0].den = chroma_den;
master_display->white_point[1].den = chroma_den;
master_display->max_luminance.den = luma_den;
master_display->min_luminance.den = luma_den;
master_display->has_primaries = 1;
master_display->has_luminance = 1;
sd = av_packet_side_data_add(&st->codecpar->coded_side_data,
&st->codecpar->nb_coded_side_data,
AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
(uint8_t *)master_display, size, 0);
if (!sd) {
av_freep(&master_display);
return AVERROR(ENOMEM);
}
ds->force_mastering_display = 1;
return 0;
}
static int add_content_light_to_stream(const OptionsContext *o,
AVFormatContext *ctx, InputStream *ist)
{
AVStream *st = ist->st;
DemuxStream *ds = ds_from_ist(ist);
AVContentLightMetadata *cll;
AVPacketSideData *sd;
const char *p = NULL;
size_t size;
int ret;
opt_match_per_stream_str(ist, &o->content_lights, ctx, st, &p);
if (!p)
return 0;
cll = av_content_light_metadata_alloc(&size);
if (!cll)
return AVERROR(ENOMEM);
ret = sscanf(p, "%u,%u",
(unsigned*)&cll->MaxCLL,
(unsigned*)&cll->MaxFALL);
if (ret != 2 || (unsigned)(cll->MaxCLL | cll->MaxFALL) > UINT16_MAX) {
av_freep(&cll);
av_log(ist, AV_LOG_ERROR, "Failed to parse content light option\n");
return AVERROR(EINVAL);
}
sd = av_packet_side_data_add(&st->codecpar->coded_side_data,
&st->codecpar->nb_coded_side_data,
AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
(uint8_t *)cll, size, 0);
if (!sd) {
av_freep(&cll);
return AVERROR(ENOMEM);
}
ds->force_content_light = 1;
return 0;
}
@@ -1273,6 +1423,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
const char *bsfs = NULL;
char *next;
const char *discard_str = NULL;
AVBPrint bp;
int ret;
ds = demux_stream_alloc(d, st);
@@ -1338,6 +1489,14 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
if (ret < 0)
return ret;
ret = add_mastering_display_to_stream(o, ic, ist);
if (ret < 0)
return ret;
ret = add_content_light_to_stream(o, ic, ist);
if (ret < 0)
return ret;
opt_match_per_stream_str(ist, &o->hwaccels, ic, st, &hwaccel);
opt_match_per_stream_str(ist, &o->hwaccel_output_formats, ic, st,
&hwaccel_output_format);
@@ -1455,6 +1614,26 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
av_dict_set_int(&ds->decoder_opts, "apply_cropping",
ds->apply_cropping && ds->apply_cropping != CROP_CONTAINER, 0);
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
if (ds->force_display_matrix) {
if (av_dict_get(ds->decoder_opts, "side_data_prefer_packet", NULL, 0))
av_bprintf(&bp, ",");
av_bprintf(&bp, "displaymatrix");
}
if (ds->force_mastering_display) {
if (bp.len || av_dict_get(ds->decoder_opts, "side_data_prefer_packet", NULL, 0))
av_bprintf(&bp, ",");
av_bprintf(&bp, "mastering_display_metadata");
}
if (ds->force_content_light) {
if (bp.len || av_dict_get(ds->decoder_opts, "side_data_prefer_packet", NULL, 0))
av_bprintf(&bp, ",");
av_bprintf(&bp, "content_light_level");
}
if (bp.len)
av_dict_set(&ds->decoder_opts, "side_data_prefer_packet", bp.str, AV_DICT_APPEND);
av_bprint_finalize(&bp, NULL);
/* Attached pics are sparse, therefore we would not want to delay their decoding
* till EOF. */
if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)
@@ -1573,6 +1752,194 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
return 0;
}
static const char *input_stream_group_item_name(void *obj)
{
const DemuxStreamGroup *dsg = obj;
return dsg->log_name;
}
static const AVClass input_stream_group_class = {
.class_name = "InputStreamGroup",
.version = LIBAVUTIL_VERSION_INT,
.item_name = input_stream_group_item_name,
.category = AV_CLASS_CATEGORY_DEMUXER,
};
static DemuxStreamGroup *demux_stream_group_alloc(Demuxer *d, AVStreamGroup *stg)
{
InputFile *f = &d->f;
DemuxStreamGroup *dsg;
dsg = allocate_array_elem(&f->stream_groups, sizeof(*dsg), &f->nb_stream_groups);
if (!dsg)
return NULL;
dsg->istg.stg = stg;
dsg->istg.file = f;
dsg->istg.index = stg->index;
dsg->istg.class = &input_stream_group_class;
snprintf(dsg->log_name, sizeof(dsg->log_name), "istg#%d:%d/%s",
d->f.index, stg->index, avformat_stream_group_name(stg->type));
return dsg;
}
static int istg_parse_tile_grid(const OptionsContext *o, Demuxer *d, InputStreamGroup *istg)
{
InputFile *f = &d->f;
AVFormatContext *ic = d->f.ctx;
AVStreamGroup *stg = istg->stg;
const AVStreamGroupTileGrid *tg = stg->params.tile_grid;
OutputFilterOptions opts;
AVBPrint bp;
char *graph_str;
int autorotate = 1;
const char *apply_cropping = NULL;
int ret;
if (tg->nb_tiles == 1)
return 0;
memset(&opts, 0, sizeof(opts));
opt_match_per_stream_group_int(istg, &o->autorotate, ic, stg, &autorotate);
if (autorotate)
opts.flags |= OFILTER_FLAG_AUTOROTATE;
opts.flags |= OFILTER_FLAG_CROP;
opt_match_per_stream_group_str(istg, &o->apply_cropping, ic, stg, &apply_cropping);
if (apply_cropping) {
char *p;
int crop = strtol(apply_cropping, &p, 0);
if (*p)
return AVERROR(EINVAL);
if (!crop)
opts.flags &= ~OFILTER_FLAG_CROP;
}
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
for (int i = 0; i < tg->nb_tiles; i++)
av_bprintf(&bp, "[%d:g:%d:%d]", f->index, stg->index, tg->offsets[i].idx);
av_bprintf(&bp, "xstack=inputs=%d:layout=", tg->nb_tiles);
for (int i = 0; i < tg->nb_tiles - 1; i++)
av_bprintf(&bp, "%d_%d|", tg->offsets[i].horizontal,
tg->offsets[i].vertical);
av_bprintf(&bp, "%d_%d:fill=0x%02X%02X%02X@0x%02X", tg->offsets[tg->nb_tiles - 1].horizontal,
tg->offsets[tg->nb_tiles - 1].vertical,
tg->background[0], tg->background[1],
tg->background[2], tg->background[3]);
av_bprintf(&bp, "[%d:g:%d]", f->index, stg->index);
ret = av_bprint_finalize(&bp, &graph_str);
if (ret < 0)
return ret;
if (tg->coded_width != tg->width || tg->coded_height != tg->height) {
opts.crop_top = tg->vertical_offset;
opts.crop_bottom = tg->coded_height - tg->height - tg->vertical_offset;
opts.crop_left = tg->horizontal_offset;
opts.crop_right = tg->coded_width - tg->width - tg->horizontal_offset;
}
for (int i = 0; i < tg->nb_coded_side_data; i++) {
const AVPacketSideData *sd = &tg->coded_side_data[i];
ret = av_packet_side_data_to_frame(&opts.side_data, &opts.nb_side_data, sd, 0);
if (ret < 0 && ret != AVERROR(EINVAL))
goto fail;
}
ret = fg_create(NULL, &graph_str, d->sch, &opts);
if (ret < 0)
goto fail;
istg->fg = filtergraphs[nb_filtergraphs-1];
istg->fg->is_internal = 1;
ret = 0;
fail:
if (ret < 0)
av_freep(&graph_str);
return ret;
}
static int istg_add(const OptionsContext *o, Demuxer *d, AVStreamGroup *stg)
{
DemuxStreamGroup *dsg;
InputStreamGroup *istg;
int ret;
dsg = demux_stream_group_alloc(d, stg);
if (!dsg)
return AVERROR(ENOMEM);
istg = &dsg->istg;
switch (stg->type) {
case AV_STREAM_GROUP_PARAMS_TILE_GRID:
ret = istg_parse_tile_grid(o, d, istg);
if (ret < 0)
return ret;
break;
default:
break;
}
return 0;
}
static int is_windows_reserved_device_name(const char *f)
{
#if HAVE_DOS_PATHS
for (const char *p = f; p && *p; ) {
char stem[6], *s;
av_strlcpy(stem, p, sizeof(stem));
if ((s = strchr(stem, '.')))
*s = 0;
if ((s = strpbrk(stem, "123456789")))
*s = '1';
if( !av_strcasecmp(stem, "AUX") ||
!av_strcasecmp(stem, "CON") ||
!av_strcasecmp(stem, "NUL") ||
!av_strcasecmp(stem, "PRN") ||
!av_strcasecmp(stem, "COM1") ||
!av_strcasecmp(stem, "LPT1")
)
return 1;
p = strchr(p, '/');
if (p)
p++;
}
#endif
return 0;
}
static int safe_filename(const char *f, int allow_subdir)
{
const char *start = f;
if (!*f || is_windows_reserved_device_name(f))
return 0;
for (; *f; f++) {
/* A-Za-z0-9_- */
if (!((unsigned)((*f | 32) - 'a') < 26 ||
(unsigned)(*f - '0') < 10 || *f == '_' || *f == '-')) {
if (f == start)
return 0;
else if (allow_subdir && *f == '/')
start = f + 1;
else if (*f != '.')
return 0;
}
}
return 1;
}
static int dump_attachment(InputStream *ist, const char *filename)
{
AVStream *st = ist->st;
@@ -1584,8 +1951,13 @@ static int dump_attachment(InputStream *ist, const char *filename)
av_log(ist, AV_LOG_WARNING, "No extradata to dump.\n");
return 0;
}
if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0)))
if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0))) {
filename = e->value;
if (!safe_filename(filename, 0)) {
av_log(ist, AV_LOG_ERROR, "Filename %s is unsafe\n", filename);
return AVERROR(EINVAL);
}
}
if (!*filename) {
av_log(ist, AV_LOG_FATAL, "No filename specified and no 'filename' tag");
return AVERROR(EINVAL);
@@ -1704,6 +2076,7 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
ic = avformat_alloc_context();
if (!ic)
return AVERROR(ENOMEM);
ic->name = av_strdup(d->log_name);
if (o->audio_sample_rate.nb_opt) {
av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate.opt[o->audio_sample_rate.nb_opt - 1].u.i, 0);
}
@@ -1792,6 +2165,8 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
av_strlcat(d->log_name, "/", sizeof(d->log_name));
av_strlcat(d->log_name, ic->iformat->name, sizeof(d->log_name));
av_freep(&ic->name);
ic->name = av_strdup(d->log_name);
if (scan_all_pmts_set)
av_dict_set(&o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
@@ -1941,6 +2316,13 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
}
}
/* Add all the stream groups from the given input file to the demuxer */
for (int i = 0; i < ic->nb_stream_groups; i++) {
ret = istg_add(o, d, ic->stream_groups[i]);
if (ret < 0)
return ret;
}
/* dump the file content */
av_dump_format(ic, f->index, filename, 0);
+28 -15
View File
@@ -205,19 +205,10 @@ int enc_open(void *opaque, const AVFrame *frame)
av_assert0(frame->opaque_ref);
fd = (FrameData*)frame->opaque_ref->data;
for (int i = 0; i < frame->nb_side_data; i++) {
const AVSideDataDescriptor *desc = av_frame_side_data_desc(frame->side_data[i]->type);
if (!(desc->props & AV_SIDE_DATA_PROP_GLOBAL))
continue;
ret = av_frame_side_data_clone(&enc_ctx->decoded_side_data,
&enc_ctx->nb_decoded_side_data,
frame->side_data[i],
AV_FRAME_SIDE_DATA_FLAG_UNIQUE);
if (ret < 0)
return ret;
}
ret = clone_side_data(&enc_ctx->decoded_side_data, &enc_ctx->nb_decoded_side_data,
fd->side_data, fd->nb_side_data, AV_FRAME_SIDE_DATA_FLAG_UNIQUE);
if (ret < 0)
return ret;
}
if (ist)
@@ -236,6 +227,9 @@ int enc_open(void *opaque, const AVFrame *frame)
frame->ch_layout.nb_channels > 0);
enc_ctx->sample_fmt = frame->format;
enc_ctx->sample_rate = frame->sample_rate;
if (!enc_ctx->frame_size && (!(enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) ||
(enc_ctx->flags2 & AV_CODEC_FLAG2_FIXED_FRAME_SIZE)))
enc_ctx->frame_size = frame->nb_samples;
ret = av_channel_layout_copy(&enc_ctx->ch_layout, &frame->ch_layout);
if (ret < 0)
return ret;
@@ -266,11 +260,27 @@ int enc_open(void *opaque, const AVFrame *frame)
enc_ctx->bits_per_raw_sample = FFMIN(fd->bits_per_raw_sample,
av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth);
/**
* The video color properties should always be in sync with the user-
* requested values, since we forward them to the filter graph.
*/
enc_ctx->color_range = frame->color_range;
enc_ctx->color_primaries = frame->color_primaries;
enc_ctx->color_trc = frame->color_trc;
enc_ctx->colorspace = frame->colorspace;
enc_ctx->chroma_sample_location = frame->chroma_location;
enc_ctx->alpha_mode = frame->alpha_mode;
/* Video properties which are not part of filter graph negotiation */
if (enc_ctx->chroma_sample_location == AVCHROMA_LOC_UNSPECIFIED) {
enc_ctx->chroma_sample_location = frame->chroma_location;
} else if (enc_ctx->chroma_sample_location != frame->chroma_location &&
frame->chroma_location != AVCHROMA_LOC_UNSPECIFIED) {
av_log(e, AV_LOG_WARNING,
"Requested chroma sample location '%s' does not match the "
"frame tagged sample location '%s'; result may be incorrect.\n",
av_chroma_location_name(enc_ctx->chroma_sample_location),
av_chroma_location_name(frame->chroma_location));
}
if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) ||
(frame->flags & AV_FRAME_FLAG_INTERLACED)
@@ -721,7 +731,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame,
}
}
av_assert0(0);
av_unreachable("encode_frame() loop should return");
}
static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf,
@@ -761,6 +771,9 @@ static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf,
}
} else if (kf->type == KF_FORCE_SOURCE && (frame->flags & AV_FRAME_FLAG_KEY)) {
goto force_keyframe;
} else if (kf->type == KF_FORCE_SCD_METADATA &&
av_dict_get(frame->metadata, "lavfi.scd.time", NULL, 0)) {
goto force_keyframe;
}
return AV_PICTURE_TYPE_NONE;
+315 -67
View File
@@ -27,6 +27,7 @@
#include "libavfilter/buffersink.h"
#include "libavfilter/buffersrc.h"
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
@@ -40,9 +41,6 @@
#include "libavutil/time.h"
#include "libavutil/timestamp.h"
// FIXME private header, used for mid_pred()
#include "libavcodec/mathops.h"
typedef struct FilterGraphPriv {
FilterGraph fg;
@@ -109,6 +107,9 @@ typedef struct InputFilterPriv {
// used to hold submitted input
AVFrame *frame;
// For inputs bound to a filtergraph output
OutputFilter *ofilter_src;
// source data type: AVMEDIA_TYPE_SUBTITLE for sub2video,
// same as type otherwise
enum AVMediaType type_src;
@@ -125,6 +126,7 @@ typedef struct InputFilterPriv {
AVRational sample_aspect_ratio;
enum AVColorSpace color_space;
enum AVColorRange color_range;
enum AVAlphaMode alpha_mode;
int sample_rate;
AVChannelLayout ch_layout;
@@ -189,6 +191,8 @@ typedef struct OutputFilterPriv {
void *log_parent;
char log_name[32];
int needed;
/* desired output stream properties */
int format;
int width, height;
@@ -196,6 +200,12 @@ typedef struct OutputFilterPriv {
AVChannelLayout ch_layout;
enum AVColorSpace color_space;
enum AVColorRange color_range;
enum AVAlphaMode alpha_mode;
unsigned crop_top;
unsigned crop_bottom;
unsigned crop_left;
unsigned crop_right;
AVFrameSideData **side_data;
int nb_side_data;
@@ -214,11 +224,17 @@ typedef struct OutputFilterPriv {
// those are only set if no format is specified and the encoder gives us multiple options
// They point directly to the relevant lists of the encoder.
const int *formats;
union {
const enum AVPixelFormat *pix_fmts;
const enum AVSampleFormat *sample_fmts;
};
const AVChannelLayout *ch_layouts;
const int *sample_rates;
const enum AVColorSpace *color_spaces;
const enum AVColorRange *color_ranges;
const enum AVAlphaMode *alpha_modes;
int32_t displaymatrix[9];
AVRational enc_timebase;
int64_t trim_start_us;
@@ -268,6 +284,7 @@ static int sub2video_get_blank_frame(InputFilterPriv *ifp)
frame->format = ifp->format;
frame->colorspace = ifp->color_space;
frame->color_range = ifp->color_range;
frame->alpha_mode = ifp->alpha_mode;
ret = av_frame_get_buffer(frame, 0);
if (ret < 0)
@@ -386,10 +403,10 @@ static void choose_ ## name (OutputFilterPriv *ofp, AVBPrint *bprint) \
av_bprint_chars(bprint, ':', 1); \
}
DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, formats,
DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, pix_fmts,
AV_PIX_FMT_NONE, "%s", av_get_pix_fmt_name)
DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats,
DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, sample_fmts,
AV_SAMPLE_FMT_NONE, "%s", av_get_sample_fmt_name)
DEF_CHOOSE_FORMAT(sample_rates, int, sample_rate, sample_rates, 0,
@@ -401,6 +418,9 @@ DEF_CHOOSE_FORMAT(color_spaces, enum AVColorSpace, color_space, color_spaces,
DEF_CHOOSE_FORMAT(color_ranges, enum AVColorRange, color_range, color_ranges,
AVCOL_RANGE_UNSPECIFIED, "%s", av_color_range_name);
DEF_CHOOSE_FORMAT(alpha_modes, enum AVAlphaMode, alpha_mode, alpha_modes,
AVALPHA_MODE_UNSPECIFIED, "%s", av_alpha_mode_name);
static void choose_channel_layouts(OutputFilterPriv *ofp, AVBPrint *bprint)
{
if (av_channel_layout_check(&ofp->ch_layout)) {
@@ -500,7 +520,7 @@ static int filter_opt_apply(void *logctx, AVFilterContext *f,
ret = av_opt_set_bin(f, key, data, len, AV_OPT_SEARCH_CHILDREN);
av_freep(&data);
} else {
char *data = file_read(val);
char *data = read_file_to_string(val);
if (!data) {
ret = AVERROR(EIO);
goto err_load;
@@ -650,6 +670,7 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg, enum AVMediaType type)
ofp->format = -1;
ofp->color_space = AVCOL_SPC_UNSPECIFIED;
ofp->color_range = AVCOL_RANGE_UNSPECIFIED;
ofp->alpha_mode = AVALPHA_MODE_UNSPECIFIED;
ofilter->index = fg->nb_outputs - 1;
snprintf(ofp->log_name, sizeof(ofp->log_name), "%co%d",
@@ -802,10 +823,10 @@ int ofilter_bind_enc(OutputFilter *ofilter, unsigned sched_idx_enc,
av_assert0(!opts->enc ||
ofilter->type == opts->enc->type);
ofilter->bound = 1;
ofp->needed = ofilter->bound = 1;
av_freep(&ofilter->linklabel);
ofp->flags = opts->flags;
ofp->flags |= opts->flags;
ofp->ts_offset = opts->ts_offset;
ofp->enc_timebase = opts->output_tb;
@@ -842,7 +863,7 @@ int ofilter_bind_enc(OutputFilter *ofilter, unsigned sched_idx_enc,
if (opts->format != AV_PIX_FMT_NONE) {
ofp->format = opts->format;
} else
ofp->formats = opts->formats;
ofp->pix_fmts = opts->pix_fmts;
if (opts->color_space != AVCOL_SPC_UNSPECIFIED)
ofp->color_space = opts->color_space;
@@ -854,6 +875,11 @@ int ofilter_bind_enc(OutputFilter *ofilter, unsigned sched_idx_enc,
else
ofp->color_ranges = opts->color_ranges;
if (opts->alpha_mode != AVALPHA_MODE_UNSPECIFIED)
ofp->alpha_mode = opts->alpha_mode;
else
ofp->alpha_modes = opts->alpha_modes;
fgp->disable_conversions |= !!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT);
ofp->fps.last_frame = av_frame_alloc();
@@ -876,7 +902,7 @@ int ofilter_bind_enc(OutputFilter *ofilter, unsigned sched_idx_enc,
if (opts->format != AV_SAMPLE_FMT_NONE) {
ofp->format = opts->format;
} else {
ofp->formats = opts->formats;
ofp->sample_fmts = opts->sample_fmts;
}
if (opts->sample_rate) {
ofp->sample_rate = opts->sample_rate;
@@ -908,13 +934,15 @@ static int ofilter_bind_ifilter(OutputFilter *ofilter, InputFilterPriv *ifp,
av_assert0(!ofilter->bound);
av_assert0(ofilter->type == ifp->ifilter.type);
ofilter->bound = 1;
ofp->needed = ofilter->bound = 1;
av_freep(&ofilter->linklabel);
ofilter->output_name = av_strdup(opts->name);
if (!ofilter->output_name)
return AVERROR(EINVAL);
ifp->ofilter_src = ofilter;
av_strlcatf(ofp->log_name, sizeof(ofp->log_name), "->%s", ofilter->output_name);
return 0;
@@ -977,6 +1005,7 @@ static InputFilter *ifilter_alloc(FilterGraph *fg)
ifp->format = -1;
ifp->color_space = AVCOL_SPC_UNSPECIFIED;
ifp->color_range = AVCOL_RANGE_UNSPECIFIED;
ifp->alpha_mode = AVALPHA_MODE_UNSPECIFIED;
ifp->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW);
if (!ifp->frame_queue)
@@ -1057,7 +1086,8 @@ static const AVClass fg_class = {
.category = AV_CLASS_CATEGORY_FILTER,
};
int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
int fg_create(FilterGraph **pfg, char **graph_desc, Scheduler *sch,
const OutputFilterOptions *opts)
{
FilterGraphPriv *fgp;
FilterGraph *fg;
@@ -1068,7 +1098,7 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
fgp = av_mallocz(sizeof(*fgp));
if (!fgp) {
av_freep(&graph_desc);
av_freep(graph_desc);
return AVERROR(ENOMEM);
}
fg = &fgp->fg;
@@ -1079,7 +1109,7 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
} else {
ret = av_dynarray_add_nofree(&filtergraphs, &nb_filtergraphs, fgp);
if (ret < 0) {
av_freep(&graph_desc);
av_freep(graph_desc);
av_freep(&fgp);
return ret;
}
@@ -1088,11 +1118,13 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
}
fg->class = &fg_class;
fg->graph_desc = graph_desc;
fg->graph_desc = *graph_desc;
fgp->disable_conversions = !auto_conversion_filters;
fgp->nb_threads = -1;
fgp->sch = sch;
*graph_desc = NULL;
snprintf(fgp->log_name, sizeof(fgp->log_name), "fc#%d", fg->index);
fgp->frame = av_frame_alloc();
@@ -1154,11 +1186,13 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
const enum AVMediaType type = avfilter_pad_get_type(cur->filter_ctx->output_pads,
cur->pad_idx);
OutputFilter *const ofilter = ofilter_alloc(fg, type);
OutputFilterPriv *ofp;
if (!ofilter) {
ret = AVERROR(ENOMEM);
goto fail;
}
ofp = ofp_from_ofilter(ofilter);
ofilter->linklabel = cur->name;
cur->name = NULL;
@@ -1168,6 +1202,25 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
ret = AVERROR(ENOMEM);
goto fail;
}
// opts should only be needed in this function to fill fields from filtergraphs
// whose output is meant to be treated as if it was stream, e.g. merged HEIF
// tile groups.
if (opts) {
ofp->flags = opts->flags;
ofp->side_data = opts->side_data;
ofp->nb_side_data = opts->nb_side_data;
ofp->crop_top = opts->crop_top;
ofp->crop_bottom = opts->crop_bottom;
ofp->crop_left = opts->crop_left;
ofp->crop_right = opts->crop_right;
const AVFrameSideData *sd = av_frame_side_data_get(ofp->side_data, ofp->nb_side_data,
AV_FRAME_DATA_DISPLAYMATRIX);
if (sd)
memcpy(ofp->displaymatrix, sd->data, sizeof(ofp->displaymatrix));
}
}
if (!fg->nb_outputs) {
@@ -1195,7 +1248,7 @@ fail:
int fg_create_simple(FilterGraph **pfg,
InputStream *ist,
char *graph_desc,
char **graph_desc,
Scheduler *sch, unsigned sched_idx_enc,
const OutputFilterOptions *opts)
{
@@ -1204,7 +1257,7 @@ int fg_create_simple(FilterGraph **pfg,
FilterGraphPriv *fgp;
int ret;
ret = fg_create(pfg, graph_desc, sch);
ret = fg_create(pfg, graph_desc, sch, NULL);
if (ret < 0)
return ret;
fg = *pfg;
@@ -1220,7 +1273,7 @@ int fg_create_simple(FilterGraph **pfg,
"to have exactly 1 input and 1 output. "
"However, it had %d input(s) and %d output(s). Please adjust, "
"or use a complex filtergraph (-filter_complex) instead.\n",
graph_desc, fg->nb_inputs, fg->nb_outputs);
*graph_desc, fg->nb_inputs, fg->nb_outputs);
return AVERROR(EINVAL);
}
if (fg->outputs[0]->type != type) {
@@ -1245,7 +1298,7 @@ int fg_create_simple(FilterGraph **pfg,
return 0;
}
static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter, int commit)
{
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
InputStream *ist = NULL;
@@ -1296,15 +1349,20 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
if (!ofilter->bound && ofilter->linklabel &&
!strcmp(ofilter->linklabel, ifilter->linklabel)) {
av_log(fg, AV_LOG_VERBOSE,
"Binding input with label '%s' to filtergraph output %d:%d\n",
ifilter->linklabel, i, j);
if (commit) {
av_log(fg, AV_LOG_VERBOSE,
"Binding input with label '%s' to filtergraph output %d:%d\n",
ifilter->linklabel, i, j);
ret = ifilter_bind_fg(ifp, fg_src, j);
if (ret < 0)
av_log(fg, AV_LOG_ERROR, "Error binding filtergraph input %s\n",
ifilter->linklabel);
return ret;
ret = ifilter_bind_fg(ifp, fg_src, j);
if (ret < 0) {
av_log(fg, AV_LOG_ERROR, "Error binding filtergraph input %s\n",
ifilter->linklabel);
return ret;
}
} else
ofp_from_ofilter(ofilter)->needed = 1;
return 0;
}
}
}
@@ -1352,10 +1410,38 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
}
ist = input_files[file_idx]->streams[st->index];
av_log(fg, AV_LOG_VERBOSE,
"Binding input with label '%s' to input stream %d:%d\n",
ifilter->linklabel, ist->file->index, ist->index);
if (commit)
av_log(fg, AV_LOG_VERBOSE,
"Binding input with label '%s' to input stream %d:%d\n",
ifilter->linklabel, ist->file->index, ist->index);
} else {
// try finding an unbound filtergraph output
for (int i = 0; i < nb_filtergraphs; i++) {
FilterGraph *fg_src = filtergraphs[i];
if (fg == fg_src)
continue;
for (int j = 0; j < fg_src->nb_outputs; j++) {
OutputFilter *ofilter = fg_src->outputs[j];
if (!ofilter->bound) {
if (commit) {
av_log(fg, AV_LOG_VERBOSE,
"Binding unlabeled filtergraph input to filtergraph output %d:%d\n", i, j);
ret = ifilter_bind_fg(ifp, fg_src, j);
if (ret < 0) {
av_log(fg, AV_LOG_ERROR, "Error binding filtergraph input %d:%d\n", i, j);
return ret;
}
} else
ofp_from_ofilter(ofilter)->needed = 1;
return 0;
}
}
}
ist = ist_find_unused(type);
if (!ist) {
av_log(fg, AV_LOG_FATAL,
@@ -1365,24 +1451,27 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
return AVERROR(EINVAL);
}
av_log(fg, AV_LOG_VERBOSE,
"Binding unlabeled input %d to input stream %d:%d\n",
ifilter->index, ist->file->index, ist->index);
if (commit)
av_log(fg, AV_LOG_VERBOSE,
"Binding unlabeled input %d to input stream %d:%d\n",
ifilter->index, ist->file->index, ist->index);
}
av_assert0(ist);
ret = ifilter_bind_ist(ifilter, ist, &vs);
if (ret < 0) {
av_log(fg, AV_LOG_ERROR,
"Error binding an input stream to complex filtergraph input %s.\n",
ifilter->name);
return ret;
if (commit) {
ret = ifilter_bind_ist(ifilter, ist, &vs);
if (ret < 0) {
av_log(fg, AV_LOG_ERROR,
"Error binding an input stream to complex filtergraph input %s.\n",
ifilter->name);
return ret;
}
}
return 0;
}
static int bind_inputs(FilterGraph *fg)
static int bind_inputs(FilterGraph *fg, int commit)
{
// bind filtergraph inputs to input streams or other filtergraphs
for (int i = 0; i < fg->nb_inputs; i++) {
@@ -1392,7 +1481,7 @@ static int bind_inputs(FilterGraph *fg)
if (ifp->bound)
continue;
ret = fg_complex_bind_input(fg, &ifp->ifilter);
ret = fg_complex_bind_input(fg, &ifp->ifilter, commit);
if (ret < 0)
return ret;
}
@@ -1405,27 +1494,49 @@ int fg_finalise_bindings(void)
int ret;
for (int i = 0; i < nb_filtergraphs; i++) {
ret = bind_inputs(filtergraphs[i]);
ret = bind_inputs(filtergraphs[i], 0);
if (ret < 0)
return ret;
}
// check that all outputs were bound
for (int i = 0; i < nb_filtergraphs; i++) {
for (int i = nb_filtergraphs - 1; i >= 0; i--) {
FilterGraph *fg = filtergraphs[i];
FilterGraphPriv *fgp = fgp_from_fg(filtergraphs[i]);
for (int j = 0; j < fg->nb_outputs; j++) {
OutputFilter *output = fg->outputs[j];
if (!output->bound) {
av_log(fg, AV_LOG_FATAL,
"Filter '%s' has output %d (%s) unconnected\n",
if (!ofp_from_ofilter(output)->needed) {
if (!fg->is_internal) {
av_log(fg, AV_LOG_FATAL,
"Filter '%s' has output %d (%s) unconnected\n",
output->name, j,
output->linklabel ? (const char *)output->linklabel : "unlabeled");
return AVERROR(EINVAL);
}
av_log(fg, AV_LOG_DEBUG,
"Internal filter '%s' has output %d (%s) unconnected. Removing graph\n",
output->name, j,
output->linklabel ? (const char *)output->linklabel : "unlabeled");
return AVERROR(EINVAL);
sch_remove_filtergraph(fgp->sch, fgp->sch_idx);
fg_free(&filtergraphs[i]);
nb_filtergraphs--;
if (nb_filtergraphs > 0)
memmove(&filtergraphs[i],
&filtergraphs[i + 1],
(nb_filtergraphs - i) * sizeof(*filtergraphs));
break;
}
}
}
for (int i = 0; i < nb_filtergraphs; i++) {
ret = bind_inputs(filtergraphs[i], 1);
if (ret < 0)
return ret;
}
return 0;
}
@@ -1524,7 +1635,57 @@ static int configure_output_video_filter(FilterGraphPriv *fgp, AVFilterGraph *gr
if (ret < 0)
return ret;
if ((ofp->width || ofp->height) && (ofp->flags & OFILTER_FLAG_AUTOSCALE)) {
if (ofp->flags & OFILTER_FLAG_CROP) {
char crop_buf[64];
snprintf(crop_buf, sizeof(crop_buf), "w=iw-%u-%u:h=ih-%u-%u:x=%u:y=%u",
ofp->crop_left, ofp->crop_right,
ofp->crop_top, ofp->crop_bottom,
ofp->crop_left, ofp->crop_top);
ret = insert_filter(&last_filter, &pad_idx, "crop", crop_buf);
if (ret < 0)
return ret;
}
if (ofp->flags & OFILTER_FLAG_AUTOROTATE) {
int32_t *displaymatrix = ofp->displaymatrix;
double theta;
theta = get_rotation(displaymatrix);
if (fabs(theta - 90) < 1.0) {
ret = insert_filter(&last_filter, &pad_idx, "transpose",
displaymatrix[3] > 0 ? "cclock_flip" : "clock");
} else if (fabs(theta - 180) < 1.0) {
if (displaymatrix[0] < 0) {
ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL);
if (ret < 0)
return ret;
}
if (displaymatrix[4] < 0) {
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
}
} else if (fabs(theta - 270) < 1.0) {
ret = insert_filter(&last_filter, &pad_idx, "transpose",
displaymatrix[3] < 0 ? "clock_flip" : "cclock");
} else if (fabs(theta) > 1.0) {
char rotate_buf[64];
snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta);
ret = insert_filter(&last_filter, &pad_idx, "rotate", rotate_buf);
} else if (fabs(theta) < 1.0) {
if (displaymatrix && displaymatrix[4] < 0) {
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
}
}
if (ret < 0)
return ret;
av_frame_side_data_remove(&ofp->side_data, &ofp->nb_side_data, AV_FRAME_DATA_DISPLAYMATRIX);
}
if ((ofp->width || ofp->height) && (ofp->flags & OFILTER_FLAG_AUTOSCALE) &&
// skip add scale for hardware format
!(ofp->format != AV_PIX_FMT_NONE &&
av_pix_fmt_desc_get(ofp->format)->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
char args[255];
AVFilterContext *filter;
const AVDictionaryEntry *e = NULL;
@@ -1548,11 +1709,12 @@ static int configure_output_video_filter(FilterGraphPriv *fgp, AVFilterGraph *gr
}
av_assert0(!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT) ||
ofp->format != AV_PIX_FMT_NONE || !ofp->formats);
ofp->format != AV_PIX_FMT_NONE || !ofp->pix_fmts);
av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
choose_pix_fmts(ofp, &bprint);
choose_color_spaces(ofp, &bprint);
choose_color_ranges(ofp, &bprint);
choose_alpha_modes(ofp, &bprint);
if (!av_bprint_is_complete(&bprint))
return AVERROR(ENOMEM);
@@ -1723,6 +1885,7 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
ifp->sample_aspect_ratio : (AVRational){ 0, 1 };
par->color_space = ifp->color_space;
par->color_range = ifp->color_range;
par->alpha_mode = ifp->alpha_mode;
par->hw_frames_ctx = ifp->hw_frames_ctx;
par->side_data = ifp->side_data;
par->nb_side_data = ifp->nb_side_data;
@@ -2000,6 +2163,7 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt)
ofp->height = av_buffersink_get_h(sink);
ofp->color_space = av_buffersink_get_colorspace(sink);
ofp->color_range = av_buffersink_get_color_range(sink);
ofp->alpha_mode = av_buffersink_get_alpha_mode(sink);
// If the timing parameters are not locked yet, get the tentative values
// here but don't lock them. They will only be used if no output frames
@@ -2018,12 +2182,11 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt)
ret = av_buffersink_get_ch_layout(sink, &ofp->ch_layout);
if (ret < 0)
goto fail;
av_frame_side_data_free(&ofp->side_data, &ofp->nb_side_data);
sd = av_buffersink_get_side_data(sink, &nb_sd);
if (nb_sd)
for (int j = 0; j < nb_sd; j++) {
ret = av_frame_side_data_clone(&ofp->side_data, &ofp->nb_side_data,
sd[j], 0);
sd[j], AV_FRAME_SIDE_DATA_FLAG_REPLACE);
if (ret < 0) {
av_frame_side_data_free(&ofp->side_data, &ofp->nb_side_data);
goto fail;
@@ -2096,6 +2259,7 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr
ifp->sample_aspect_ratio = frame->sample_aspect_ratio;
ifp->color_space = frame->colorspace;
ifp->color_range = frame->color_range;
ifp->alpha_mode = frame->alpha_mode;
ifp->sample_rate = frame->sample_rate;
ret = av_channel_layout_copy(&ifp->ch_layout, &frame->ch_layout);
@@ -2106,7 +2270,8 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr
for (int i = 0; i < frame->nb_side_data; i++) {
const AVSideDataDescriptor *desc = av_frame_side_data_desc(frame->side_data[i]->type);
if (!(desc->props & AV_SIDE_DATA_PROP_GLOBAL))
if (!(desc->props & AV_SIDE_DATA_PROP_GLOBAL) ||
frame->side_data[i]->type == AV_FRAME_DATA_DISPLAYMATRIX)
continue;
ret = av_frame_side_data_clone(&ifp->side_data,
@@ -2137,6 +2302,27 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr
return 0;
}
static int ifilter_parameters_from_ofilter(InputFilter *ifilter, OutputFilter *ofilter)
{
const OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
if (!ifp->opts.framerate.num) {
ifp->opts.framerate = ofp->fps.framerate;
if (ifp->opts.framerate.num > 0 && ifp->opts.framerate.den > 0)
ifp->opts.flags |= IFILTER_FLAG_CFR;
}
for (int i = 0; i < ofp->nb_side_data; i++) {
int ret = av_frame_side_data_clone(&ifp->side_data, &ifp->nb_side_data,
ofp->side_data[i], AV_FRAME_SIDE_DATA_FLAG_REPLACE);
if (ret < 0)
return ret;
}
return 0;
}
int filtergraph_is_simple(const FilterGraph *fg)
{
const FilterGraphPriv *fgp = cfgp_from_cfg(fg);
@@ -2307,6 +2493,23 @@ early_exit:
return float_pts;
}
static int64_t median3(int64_t a, int64_t b, int64_t c)
{
int64_t max2, min2, m;
if (a >= b) {
max2 = a;
min2 = b;
} else {
max2 = b;
min2 = a;
}
m = (c >= max2) ? max2 : c;
return (m >= min2) ? m : min2;
}
/* Convert frame timestamps to the encoder timebase and decide how many times
* should this (and possibly previous) frame be repeated in order to conform to
* desired target framerate (if any).
@@ -2319,9 +2522,9 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame,
double delta0, delta, sync_ipts, duration;
if (!frame) {
*nb_frames_prev = *nb_frames = mid_pred(fps->frames_prev_hist[0],
fps->frames_prev_hist[1],
fps->frames_prev_hist[2]);
*nb_frames_prev = *nb_frames = median3(fps->frames_prev_hist[0],
fps->frames_prev_hist[1],
fps->frames_prev_hist[2]);
if (!*nb_frames && fps->last_dropped) {
atomic_fetch_add(&ofilter->nb_frames_drop, 1);
@@ -2370,6 +2573,7 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame,
delta0 = 0;
ofp->next_pts = llrint(sync_ipts);
}
av_fallthrough;
case VSYNC_CFR:
// FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
if (frame_drop_threshold && delta < frame_drop_threshold && fps->frame_number) {
@@ -2434,6 +2638,16 @@ finish:
fps->dropped_keyframe |= fps->last_dropped && (frame->flags & AV_FRAME_FLAG_KEY);
}
static void close_input(InputFilterPriv *ifp)
{
FilterGraphPriv *fgp = fgp_from_fg(ifp->ifilter.graph);
if (!ifp->eof) {
sch_filter_receive_finish(fgp->sch, fgp->sch_idx, ifp->ifilter.index);
ifp->eof = 1;
}
}
static int close_output(OutputFilterPriv *ofp, FilterGraphThread *fgt)
{
FilterGraphPriv *fgp = fgp_from_fg(ofp->ofilter.graph);
@@ -2458,16 +2672,17 @@ static int close_output(OutputFilterPriv *ofp, FilterGraphThread *fgt)
if (ret < 0)
return ret;
}
av_frame_side_data_free(&frame->side_data, &frame->nb_side_data);
ret = clone_side_data(&frame->side_data, &frame->nb_side_data,
ofp->side_data, ofp->nb_side_data, 0);
if (ret < 0)
return ret;
fd = frame_data(frame);
if (!fd)
return AVERROR(ENOMEM);
av_frame_side_data_free(&fd->side_data, &fd->nb_side_data);
ret = clone_side_data(&fd->side_data, &fd->nb_side_data,
ofp->side_data, ofp->nb_side_data, 0);
if (ret < 0)
return ret;
fd->frame_rate_filter = ofp->fps.framerate;
av_assert0(!frame->buf[0]);
@@ -2622,6 +2837,16 @@ static int fg_output_step(OutputFilterPriv *ofp, FilterGraphThread *fgt,
return AVERROR(ENOMEM);
}
av_frame_side_data_free(&fd->side_data, &fd->nb_side_data);
if (!fgt->got_frame) {
ret = clone_side_data(&fd->side_data, &fd->nb_side_data,
ofp->side_data, ofp->nb_side_data, 0);
if (ret < 0) {
av_frame_unref(frame);
return ret;
}
}
fd->wallclock[LATENCY_PROBE_FILTER_POST] = av_gettime_relative();
// only use bits_per_raw_sample passed through from the decoder
@@ -2809,6 +3034,7 @@ static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter,
ifp->sample_aspect_ratio = ifp->opts.fallback->sample_aspect_ratio;
ifp->color_space = ifp->opts.fallback->colorspace;
ifp->color_range = ifp->opts.fallback->color_range;
ifp->alpha_mode = ifp->opts.fallback->alpha_mode;
ifp->time_base = ifp->opts.fallback->time_base;
ret = av_channel_layout_copy(&ifp->ch_layout,
@@ -2859,6 +3085,7 @@ static const char *unknown_if_null(const char *str)
static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
InputFilter *ifilter, AVFrame *frame)
{
FilterGraphPriv *fgp = fgp_from_fg(fg);
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
FrameData *fd;
AVFrameSideData *sd;
@@ -2877,7 +3104,8 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
ifp->width != frame->width ||
ifp->height != frame->height ||
ifp->color_space != frame->colorspace ||
ifp->color_range != frame->color_range)
ifp->color_range != frame->color_range ||
ifp->alpha_mode != frame->alpha_mode)
need_reinit |= VIDEO_CHANGED;
break;
}
@@ -2914,6 +3142,14 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
ret = ifilter_parameters_from_frame(ifilter, frame);
if (ret < 0)
return ret;
/* Inputs bound to a filtergraph output will have some fields unset.
* Handle them here */
if (ifp->ofilter_src) {
ret = ifilter_parameters_from_ofilter(ifilter, ifp->ofilter_src);
if (ret < 0)
return ret;
}
}
/* (re)init the graph if possible, otherwise buffer the frame and return */
@@ -2951,9 +3187,11 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
const char *pixel_format_name = av_get_pix_fmt_name(frame->format);
const char *color_space_name = av_color_space_name(frame->colorspace);
const char *color_range_name = av_color_range_name(frame->color_range);
av_bprintf(&reason, "video parameters changed to %s(%s, %s), %dx%d, ",
const char *alpha_mode = av_alpha_mode_name(frame->alpha_mode);
av_bprintf(&reason, "video parameters changed to %s(%s, %s), %dx%d, %s alpha, ",
unknown_if_null(pixel_format_name), unknown_if_null(color_range_name),
unknown_if_null(color_space_name), frame->width, frame->height);
unknown_if_null(color_space_name), frame->width, frame->height,
unknown_if_null(alpha_mode));
}
if (need_reinit & MATRIX_CHANGED)
av_bprintf(&reason, "display matrix changed, ");
@@ -2964,6 +3202,11 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
if (reason.len > 1)
reason.str[reason.len - 2] = '\0'; // remove last comma
av_log(fg, AV_LOG_INFO, "Reconfiguring filter graph%s%s\n", reason.len ? " because " : "", reason.str);
} else {
/* Choke all input to avoid buffering excessive frames while the
* initial filter graph is being configured, and before we have a
* preferred input */
sch_filter_choke_inputs(fgp->sch, fgp->sch_idx);
}
ret = configure_filtergraph(fg, fgt);
@@ -3101,8 +3344,6 @@ static int filter_thread(void *arg)
o = (intptr_t)fgt.frame->opaque;
o = (intptr_t)fgt.frame->opaque;
// message on the control stream
if (input_idx == fg->nb_inputs) {
FilterCommand *fc;
@@ -3134,7 +3375,7 @@ static int filter_thread(void *arg)
if (ret == AVERROR_EOF) {
av_log(fg, AV_LOG_VERBOSE, "Input %u no longer accepts new data\n",
input_idx);
sch_filter_receive_finish(fgp->sch, fgp->sch_idx, input_idx);
close_input(ifp);
continue;
}
if (ret < 0)
@@ -3153,6 +3394,13 @@ read_frames:
av_err2str(ret));
goto finish;
}
// ensure all inputs no longer accepting data are closed
for (int i = 0; fgt.graph && i < fg->nb_inputs; i++) {
InputFilterPriv *ifp = ifp_from_ifilter(fg->inputs[i]);
if (av_buffersrc_get_status(ifp->ifilter.filter))
close_input(ifp);
}
}
for (unsigned i = 0; i < fg->nb_outputs; i++) {
+98 -21
View File
@@ -453,7 +453,7 @@ static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc,
}
if (filters_script)
*dst = file_read(filters_script);
*dst = read_file_to_string(filters_script);
else
#endif
if (filters)
@@ -482,9 +482,9 @@ static int parse_matrix_coeffs(void *logctx, uint16_t *dest, const char *str)
return 0;
}
static int fmt_in_list(const int *formats, int format)
static int pixfmt_in_list(const enum AVPixelFormat *formats, enum AVPixelFormat format)
{
for (; *formats != -1; formats++)
for (; *formats != AV_PIX_FMT_NONE; formats++)
if (*formats == format)
return 1;
return 0;
@@ -544,7 +544,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name)
* endianness by av_get_pix_fmt();
* the following code handles the case when the native endianness is not
* supported by the encoder, but the other one is */
if (fmts && !fmt_in_list(fmts, fmt)) {
if (fmts && !pixfmt_in_list(fmts, fmt)) {
const char *name_canonical = av_get_pix_fmt_name(fmt);
int len = strlen(name_canonical);
@@ -557,7 +557,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name)
snprintf(name_other, sizeof(name_other), "%s%ce",
name, name_canonical[len - 2] == 'l' ? 'b' : 'l');
fmt_other = av_get_pix_fmt(name_other);
if (fmt_other != AV_PIX_FMT_NONE && fmt_in_list(fmts, fmt_other)) {
if (fmt_other != AV_PIX_FMT_NONE && pixfmt_in_list(fmts, fmt_other)) {
av_log(ost, AV_LOG_VERBOSE, "Mapping pixel format %s->%s\n",
name, name_other);
fmt = fmt_other;
@@ -565,7 +565,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name)
}
}
if (fmts && !fmt_in_list(fmts, fmt))
if (fmts && !pixfmt_in_list(fmts, fmt))
fmt = choose_pixel_fmt(ost->enc->enc_ctx, fmt);
return fmt;
@@ -730,9 +730,14 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
AV_OPT_SEARCH_CHILDREN) > 0)
av_opt_set(video_enc, "stats", logfilename,
AV_OPT_SEARCH_CHILDREN);
} else if (!strcmp(video_enc->codec->name, "libx265")) {
if (av_opt_is_set_to_default_by_name(video_enc, "x265-stats",
AV_OPT_SEARCH_CHILDREN) > 0)
av_opt_set(video_enc, "x265-stats", logfilename,
AV_OPT_SEARCH_CHILDREN);
} else {
if (video_enc->flags & AV_CODEC_FLAG_PASS2) {
char *logbuffer = file_read(logfilename);
char *logbuffer = read_file_to_string(logfilename);
if (!logbuffer) {
av_log(ost, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
@@ -917,6 +922,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
.height = enc_ctx->height,
.color_space = enc_ctx->colorspace,
.color_range = enc_ctx->color_range,
.alpha_mode = enc_ctx->alpha_mode,
.vsync_method = vsync_method,
.frame_rate = ms->frame_rate,
.max_frame_rate = ms->max_frame_rate,
@@ -943,7 +949,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
if (!keep_pix_fmt) {
ret = avcodec_get_supported_config(enc_ctx, NULL,
AV_CODEC_CONFIG_PIX_FORMAT, 0,
(const void **) &opts.formats, NULL);
(const void **) &opts.pix_fmts, NULL);
if (ret < 0)
return ret;
}
@@ -964,10 +970,15 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
(const void **) &opts.color_ranges, NULL);
if (ret < 0)
return ret;
ret = avcodec_get_supported_config(enc_ctx, NULL,
AV_CODEC_CONFIG_ALPHA_MODE, 0,
(const void **) &opts.alpha_modes, NULL);
if (ret < 0)
return ret;
} else {
ret = avcodec_get_supported_config(enc_ctx, NULL,
AV_CODEC_CONFIG_SAMPLE_FORMAT, 0,
(const void **) &opts.formats, NULL);
(const void **) &opts.sample_fmts, NULL);
if (ret < 0)
return ret;
ret = avcodec_get_supported_config(enc_ctx, NULL,
@@ -997,7 +1008,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
ost->filter = ofilter;
ret = ofilter_bind_enc(ofilter, ms->sch_idx_enc, &opts);
} else {
ret = fg_create_simple(&ost->fg_simple, ost->ist, filters,
ret = fg_create_simple(&ost->fg_simple, ost->ist, &filters,
mux->sch, ms->sch_idx_enc, &opts);
if (ret >= 0)
ost->filter = ost->fg_simple->outputs[0];
@@ -1520,6 +1531,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
if (oc->oformat->flags & AVFMT_GLOBALHEADER && ost->enc)
ost->enc->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
if (oc->oformat->flags & AVFMT_FIXED_FRAMESIZE && ost->enc)
ost->enc->enc_ctx->flags2 |= AV_CODEC_FLAG2_FIXED_FRAME_SIZE;
opt_match_per_stream_int(ost, &o->copy_initial_nonkeyframes,
oc, st, &ms->copy_initial_nonkeyframes);
@@ -1592,8 +1605,9 @@ fail:
static int map_auto_video(Muxer *mux, const OptionsContext *o)
{
AVFormatContext *oc = mux->fc;
InputStreamGroup *best_istg = NULL;
InputStream *best_ist = NULL;
int best_score = 0;
int64_t best_score = 0;
int qcr;
/* video: highest resolution */
@@ -1603,17 +1617,52 @@ static int map_auto_video(Muxer *mux, const OptionsContext *o)
qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0);
for (int j = 0; j < nb_input_files; j++) {
InputFile *ifile = input_files[j];
InputStreamGroup *file_best_istg = NULL;
InputStream *file_best_ist = NULL;
int file_best_score = 0;
for (int i = 0; i < ifile->nb_streams; i++) {
InputStream *ist = ifile->streams[i];
int score;
int64_t file_best_score = 0;
for (int i = 0; i < ifile->nb_stream_groups; i++) {
InputStreamGroup *istg = ifile->stream_groups[i];
int64_t score = 0;
if (ist->user_set_discard == AVDISCARD_ALL ||
ist->st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
if (!istg->fg)
continue;
score = ist->st->codecpar->width * ist->st->codecpar->height
for (int j = 0; j < istg->stg->nb_streams; j++) {
AVStream *st = istg->stg->streams[j];
if (st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) {
score = 100000000;
break;
}
}
switch (istg->stg->type) {
case AV_STREAM_GROUP_PARAMS_TILE_GRID: {
const AVStreamGroupTileGrid *tg = istg->stg->params.tile_grid;
score += tg->width * (int64_t)tg->height
+ 5000000*!!(istg->stg->disposition & AV_DISPOSITION_DEFAULT);
break;
}
default:
continue;
}
if (score > file_best_score) {
file_best_score = score;
file_best_istg = istg;
}
}
for (int i = 0; i < ifile->nb_streams; i++) {
InputStream *ist = ifile->streams[i];
const AVCodecDescriptor *desc = avcodec_descriptor_get(ist->st->codecpar->codec_id);
int64_t score;
if (ist->user_set_discard == AVDISCARD_ALL ||
ist->st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
(desc && (desc->props & AV_CODEC_PROP_ENHANCEMENT)))
continue;
score = ist->st->codecpar->width * (int64_t)ist->st->codecpar->height
+ 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS)
+ 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT);
if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
@@ -1624,6 +1673,15 @@ static int map_auto_video(Muxer *mux, const OptionsContext *o)
continue;
file_best_score = score;
file_best_ist = ist;
file_best_istg = NULL;
}
}
if (file_best_istg) {
file_best_score -= 5000000*!!(file_best_istg->stg->disposition & AV_DISPOSITION_DEFAULT);
if (file_best_score > best_score) {
best_score = file_best_score;
best_istg = file_best_istg;
best_ist = NULL;
}
}
if (file_best_ist) {
@@ -1633,9 +1691,19 @@ static int map_auto_video(Muxer *mux, const OptionsContext *o)
if (file_best_score > best_score) {
best_score = file_best_score;
best_ist = file_best_ist;
best_istg = NULL;
}
}
}
if (best_istg) {
FilterGraph *fg = best_istg->fg;
OutputFilter *ofilter = fg->outputs[0];
av_assert0(fg->nb_outputs == 1);
av_log(mux, AV_LOG_VERBOSE, "Creating output stream from stream group derived complex filtergraph %d.\n", fg->index);
return ost_add(mux, o, AVMEDIA_TYPE_VIDEO, NULL, ofilter, NULL, NULL);
}
if (best_ist)
return ost_add(mux, o, AVMEDIA_TYPE_VIDEO, best_ist, NULL, NULL, NULL);
@@ -2061,7 +2129,8 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc,
nb_interleaved += IS_INTERLEAVED(type);
nb_av_enc += IS_AV_ENC(ost, type);
nb_audio_fs += (ost->enc && type == AVMEDIA_TYPE_AUDIO &&
!(ost->enc->enc_ctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE));
(!(ost->enc->enc_ctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) ||
(ost->enc->enc_ctx->flags2 & AV_CODEC_FLAG2_FIXED_FRAME_SIZE)));
limit_frames |= ms->max_frames < INT64_MAX;
limit_frames_av_enc |= (ms->max_frames < INT64_MAX) && IS_AV_ENC(ost, type);
@@ -2486,6 +2555,8 @@ static int of_map_group(Muxer *mux, AVDictionary **dict, AVBPrint *bp, const cha
}
break;
}
case AV_STREAM_GROUP_PARAMS_LCEVC:
break;
default:
av_log(mux, AV_LOG_ERROR, "Unsupported mapped group type %d.\n", stg->type);
ret = AVERROR(EINVAL);
@@ -2508,6 +2579,8 @@ static int of_parse_group_token(Muxer *mux, const char *token, char *ptr)
{ .i64 = AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT }, .unit = "type" },
{ "iamf_mix_presentation", NULL, 0, AV_OPT_TYPE_CONST,
{ .i64 = AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION }, .unit = "type" },
{ "lcevc", NULL, 0, AV_OPT_TYPE_CONST,
{ .i64 = AV_STREAM_GROUP_PARAMS_LCEVC }, .unit = "type" },
{ NULL },
};
const AVClass class = {
@@ -2582,6 +2655,10 @@ static int of_parse_group_token(Muxer *mux, const char *token, char *ptr)
ret = avformat_stream_group_add_stream(stg, oc->streams[idx]);
if (ret < 0)
goto end;
OutputStream *ost = mux->of.streams[idx];
if (ost->enc && (type == AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT ||
type == AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION))
ost->enc->enc_ctx->flags2 |= AV_CODEC_FLAG2_FIXED_FRAME_SIZE;
}
while (e = av_dict_get(dict, "stg", e, 0)) {
char *endptr;
@@ -2606,8 +2683,6 @@ static int of_parse_group_token(Muxer *mux, const char *token, char *ptr)
ret = of_parse_iamf_submixes(mux, stg, ptr);
break;
default:
av_log(mux, AV_LOG_FATAL, "Unknown group type %d.\n", type);
ret = AVERROR(EINVAL);
break;
}
@@ -3220,6 +3295,8 @@ static int process_forced_keyframes(Muxer *mux, const OptionsContext *o)
"-force_key_frames is deprecated, use just 'source'\n");
ost->kf.type = KF_FORCE_SOURCE;
#endif
} else if (!strcmp(forced_keyframes, "scd_metadata")) {
ost->kf.type = KF_FORCE_SCD_METADATA;
} else {
int ret = parse_forced_key_frames(ost, &ost->kf, mux, forced_keyframes);
if (ret < 0)
+111 -4
View File
@@ -242,6 +242,70 @@ OPT_MATCH_PER_STREAM(int, int, OPT_TYPE_INT, i);
OPT_MATCH_PER_STREAM(int64, int64_t, OPT_TYPE_INT64, i64);
OPT_MATCH_PER_STREAM(dbl, double, OPT_TYPE_DOUBLE, dbl);
static unsigned opt_match_per_stream_group(void *logctx, enum OptionType type,
const SpecifierOptList *sol,
AVFormatContext *fc, AVStreamGroup *stg)
{
int matches = 0, match_idx = -1;
av_assert0((type == sol->type) || !sol->nb_opt);
for (int i = 0; i < sol->nb_opt; i++) {
const StreamSpecifier *ss = &sol->opt[i].stream_spec;
if (stream_group_specifier_match(ss, fc, stg, logctx)) {
match_idx = i;
matches++;
}
}
if (matches > 1 && sol->opt_canon) {
const SpecifierOpt *so = &sol->opt[match_idx];
const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";
char namestr[128] = "";
char optval_buf[32];
const char *optval = optval_buf;
snprintf(namestr, sizeof(namestr), "-%s", sol->opt_canon->name);
if (sol->opt_canon->flags & OPT_HAS_ALT) {
const char * const *names_alt = sol->opt_canon->u1.names_alt;
for (int i = 0; names_alt[i]; i++)
av_strlcatf(namestr, sizeof(namestr), "/-%s", names_alt[i]);
}
switch (sol->type) {
case OPT_TYPE_STRING: optval = so->u.str; break;
case OPT_TYPE_INT: snprintf(optval_buf, sizeof(optval_buf), "%d", so->u.i); break;
case OPT_TYPE_INT64: snprintf(optval_buf, sizeof(optval_buf), "%"PRId64, so->u.i64); break;
case OPT_TYPE_FLOAT: snprintf(optval_buf, sizeof(optval_buf), "%f", so->u.f); break;
case OPT_TYPE_DOUBLE: snprintf(optval_buf, sizeof(optval_buf), "%f", so->u.dbl); break;
default: av_assert0(0);
}
av_log(logctx, AV_LOG_WARNING, "Multiple %s options specified for "
"stream group %d, only the last option '-%s%s%s %s' will be used.\n",
namestr, stg->index, sol->opt_canon->name, spec[0] ? ":" : "",
spec, optval);
}
return match_idx + 1;
}
#define OPT_MATCH_PER_STREAM_GROUP(name, type, opt_type, m) \
void opt_match_per_stream_group_ ## name(void *logctx, const SpecifierOptList *sol, \
AVFormatContext *fc, AVStreamGroup *stg, type *out) \
{ \
unsigned ret = opt_match_per_stream_group(logctx, opt_type, sol, fc, stg); \
if (ret > 0) \
*out = sol->opt[ret - 1].u.m; \
}
OPT_MATCH_PER_STREAM_GROUP(str, const char *, OPT_TYPE_STRING, str);
OPT_MATCH_PER_STREAM_GROUP(int, int, OPT_TYPE_INT, i);
OPT_MATCH_PER_STREAM_GROUP(int64, int64_t, OPT_TYPE_INT64, i64);
OPT_MATCH_PER_STREAM_GROUP(dbl, double, OPT_TYPE_DOUBLE, dbl);
int view_specifier_parse(const char **pspec, ViewSpecifier *vs)
{
const char *spec = *pspec;
@@ -295,7 +359,7 @@ int view_specifier_parse(const char **pspec, ViewSpecifier *vs)
return 0;
}
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global)
int parse_and_set_vsync(const char *arg, enum VideoSyncMethod *vsync_var, int file_idx, int st_idx, int is_global)
{
if (!av_strcasecmp(arg, "cfr")) *vsync_var = VSYNC_CFR;
else if (!av_strcasecmp(arg, "vfr")) *vsync_var = VSYNC_VFR;
@@ -504,8 +568,10 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
}
if (arg[0] == '[') {
ViewSpecifier vs;
/* this mapping refers to lavfi output */
const char *c = arg + 1;
char *endptr;
ret = GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
if (ret < 0)
@@ -518,6 +584,27 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
ret = AVERROR(EINVAL);
goto fail;
}
arg++;
m->group_index = -1;
file_idx = strtol(arg, &endptr, 0);
if (file_idx >= nb_input_files || file_idx < 0)
goto end;
arg = endptr;
ret = stream_specifier_parse(&ss, *arg == ':' ? arg + 1 : arg, 1, NULL);
if (ret < 0)
goto end;
arg = ss.remainder ? ss.remainder : "";
ret = view_specifier_parse(&arg, &vs);
if (ret < 0 || (*arg && strcmp(arg, "]")))
goto end;
m->file_index = file_idx;
m->stream_index = ss.idx;
m->group_index = ss.stream_list == STREAM_LIST_GROUP_IDX ? ss.list_id : -1;
} else {
ViewSpecifier vs;
char *endptr;
@@ -558,6 +645,9 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
for (i = 0; i < o->nb_stream_maps; i++) {
m = &o->stream_maps[i];
if (file_idx == m->file_index &&
!m->linklabel &&
m->stream_index >= 0 &&
m->stream_index < input_files[m->file_index]->nb_streams &&
stream_specifier_match(&ss,
input_files[m->file_index]->ctx,
input_files[m->file_index]->ctx->streams[m->stream_index],
@@ -583,6 +673,7 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
m->file_index = file_idx;
m->stream_index = i;
m->group_index = ss.stream_list == STREAM_LIST_GROUP_IDX ? ss.list_id : -1;
m->vs = vs;
}
}
@@ -602,6 +693,7 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
goto fail;
}
}
end:
ret = 0;
fail:
stream_specifier_uninit(&ss);
@@ -1021,6 +1113,12 @@ static int opt_preset(void *optctx, const char *opt, const char *arg)
char filename[1000], line[1000], tmp_line[1000];
const char *codec_name = NULL;
int ret = 0;
int depth = o->depth;
if (depth > 2) {
av_log(NULL, AV_LOG_ERROR, "too deep recursion\n");
return AVERROR(EINVAL);
}
codec_name = opt_match_per_type_str(&o->codec_names, *opt);
@@ -1032,6 +1130,7 @@ static int opt_preset(void *optctx, const char *opt, const char *arg)
return AVERROR(ENOENT);
}
o->depth ++;
while (fgets(line, sizeof(line), f)) {
char *key = tmp_line, *value, *endptr;
@@ -1050,7 +1149,8 @@ static int opt_preset(void *optctx, const char *opt, const char *arg)
else if (!strcmp(key, "vcodec")) opt_video_codec (o, key, value);
else if (!strcmp(key, "scodec")) opt_subtitle_codec(o, key, value);
else if (!strcmp(key, "dcodec")) opt_data_codec (o, key, value);
else if (opt_default_new(o, key, value) < 0) {
else if ((parse_option(o, key, value, options) < 0) &&
(opt_default_new(o, key, value) < 0)) {
av_log(NULL, AV_LOG_FATAL, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
filename, line, key, value);
ret = AVERROR(EINVAL);
@@ -1059,6 +1159,7 @@ static int opt_preset(void *optctx, const char *opt, const char *arg)
}
fail:
o->depth = depth;
fclose(f);
return ret;
@@ -1188,7 +1289,7 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char *
char *graph_desc;
int ret;
graph_desc = file_read(arg);
graph_desc = read_file_to_string(arg);
if (!graph_desc)
return AVERROR(EINVAL);
@@ -1406,7 +1507,7 @@ int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
/* create complex filtergraphs */
for (int i = 0; i < go.nb_filtergraphs; i++) {
ret = fg_create(NULL, go.filtergraphs[i], sch);
ret = fg_create(NULL, &go.filtergraphs[i], sch, NULL);
go.filtergraphs[i] = NULL;
if (ret < 0)
goto fail;
@@ -1842,6 +1943,12 @@ const OptionDef options[] = {
{ .off = OFFSET(display_vflips) },
"set display vertical flip for stream(s) "
"(overrides any display rotation if it is not set)"},
{ "mastering_display", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
{ .off = OFFSET(mastering_displays) },
"set SMPTE2084 mastering display color volume info" },
{ "content_light", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
{ .off = OFFSET(content_lights) },
"set SMPTE2084 Max CLL and Max FALL values" },
{ "vn", OPT_TYPE_BOOL, OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
{ .off = OFFSET(video_disable) },
"disable video" },
+230 -65
View File
@@ -189,7 +189,6 @@ typedef struct PreMuxQueue {
typedef struct SchMuxStream {
SchedulerNode src;
SchedulerNode src_sched;
unsigned *sub_heartbeat_dst;
unsigned nb_sub_heartbeat_dst;
@@ -235,7 +234,6 @@ typedef struct SchMux {
typedef struct SchFilterIn {
SchedulerNode src;
SchedulerNode src_sched;
int send_finished;
int receive_finished;
} SchFilterIn;
@@ -249,7 +247,7 @@ typedef struct SchFilterGraph {
SchFilterIn *inputs;
unsigned nb_inputs;
atomic_uint nb_inputs_finished_send;
unsigned nb_inputs_finished_send;
unsigned nb_inputs_finished_receive;
SchFilterOut *outputs;
@@ -389,7 +387,7 @@ static int queue_alloc(ThreadQueue **ptq, unsigned nb_streams, unsigned queue_si
// for frames held in queues inside the ffmpeg utility. If this
// can ever dynamically change then the corresponding decode
// code needs to be updated as well.
av_assert0(queue_size == DEFAULT_FRAME_THREAD_QUEUE_SIZE);
av_assert0(queue_size <= DEFAULT_FRAME_THREAD_QUEUE_SIZE);
}
tq = tq_alloc(nb_streams, queue_size,
@@ -407,6 +405,9 @@ static int task_start(SchTask *task)
{
int ret;
if (!task->parent)
return 0;
av_log(task->func_arg, AV_LOG_VERBOSE, "Starting thread...\n");
av_assert0(!task->thread_running);
@@ -434,7 +435,7 @@ static void task_init(Scheduler *sch, SchTask *task, enum SchedulerNodeType type
task->func_arg = func_arg;
}
static int64_t trailing_dts(const Scheduler *sch, int count_finished)
static int64_t trailing_dts(const Scheduler *sch)
{
int64_t min_dts = INT64_MAX;
@@ -444,7 +445,7 @@ static int64_t trailing_dts(const Scheduler *sch, int count_finished)
for (unsigned j = 0; j < mux->nb_streams; j++) {
const SchMuxStream *ms = &mux->streams[j];
if (ms->source_finished && !count_finished)
if (ms->source_finished)
continue;
if (ms->last_dts == AV_NOPTS_VALUE)
return AV_NOPTS_VALUE;
@@ -456,6 +457,43 @@ static int64_t trailing_dts(const Scheduler *sch, int count_finished)
return min_dts == INT64_MAX ? AV_NOPTS_VALUE : min_dts;
}
static int64_t progressing_dts(const Scheduler *sch, int count_finished)
{
int64_t max_dts = INT64_MIN;
for (unsigned i = 0; i < sch->nb_mux; i++) {
const SchMux *mux = &sch->mux[i];
for (unsigned j = 0; j < mux->nb_streams; j++) {
const SchMuxStream *ms = &mux->streams[j];
if (ms->source_finished && !count_finished)
continue;
if (ms->last_dts != AV_NOPTS_VALUE)
max_dts = FFMAX(max_dts, ms->last_dts);
}
}
return max_dts == INT64_MIN ? AV_NOPTS_VALUE : max_dts;
}
void sch_remove_filtergraph(Scheduler *sch, int idx)
{
SchFilterGraph *fg = &sch->filters[idx];
av_assert0(!fg->task.thread_running);
memset(&fg->task, 0, sizeof(fg->task));
tq_free(&fg->queue);
av_freep(&fg->inputs);
fg->nb_inputs = 0;
av_freep(&fg->outputs);
fg->nb_outputs = 0;
fg->task_exited = 1;
}
void sch_free(Scheduler **psch)
{
Scheduler *sch = *psch;
@@ -1264,28 +1302,110 @@ int sch_mux_sub_heartbeat_add(Scheduler *sch, unsigned mux_idx, unsigned stream_
return 0;
}
static void unchoke_for_stream(Scheduler *sch, SchedulerNode src);
// Unchoke any filter graphs that are downstream of this node, to prevent it
// from getting stuck trying to push data to a full queue
static void unchoke_downstream(Scheduler *sch, SchedulerNode *dst)
{
SchFilterGraph *fg;
SchDec *dec;
SchEnc *enc;
switch (dst->type) {
case SCH_NODE_TYPE_DEC:
dec = &sch->dec[dst->idx];
for (int i = 0; i < dec->nb_outputs; i++)
unchoke_downstream(sch, dec->outputs[i].dst);
break;
case SCH_NODE_TYPE_ENC:
enc = &sch->enc[dst->idx];
for (int i = 0; i < enc->nb_dst; i++)
unchoke_downstream(sch, &enc->dst[i]);
break;
case SCH_NODE_TYPE_MUX:
// muxers are never choked
break;
case SCH_NODE_TYPE_FILTER_IN:
fg = &sch->filters[dst->idx];
if (fg->best_input == fg->nb_inputs) {
fg->waiter.choked_next = 0;
} else {
// ensure that this filter graph is not stuck waiting for
// input from a different upstream demuxer
unchoke_for_stream(sch, fg->inputs[fg->best_input].src);
}
break;
default:
av_unreachable("Invalid destination node type?");
break;
}
}
static void unchoke_for_stream(Scheduler *sch, SchedulerNode src)
{
while (1) {
SchFilterGraph *fg;
// fed directly by a demuxer (i.e. not through a filtergraph)
if (src.type == SCH_NODE_TYPE_DEMUX) {
sch->demux[src.idx].waiter.choked_next = 0;
SchDemux *demux;
switch (src.type) {
case SCH_NODE_TYPE_DEMUX:
// fed directly by a demuxer (i.e. not through a filtergraph)
demux = &sch->demux[src.idx];
if (demux->waiter.choked_next == 0)
return; // prevent infinite loop
demux->waiter.choked_next = 0;
for (int i = 0; i < demux->nb_streams; i++)
unchoke_downstream(sch, demux->streams[i].dst);
return;
case SCH_NODE_TYPE_DEC:
src = sch->dec[src.idx].src;
continue;
case SCH_NODE_TYPE_ENC:
src = sch->enc[src.idx].src;
continue;
case SCH_NODE_TYPE_FILTER_OUT:
fg = &sch->filters[src.idx];
// the filtergraph contains internal sources and
// requested to be scheduled directly
if (fg->best_input == fg->nb_inputs) {
fg->waiter.choked_next = 0;
return;
}
src = fg->inputs[fg->best_input].src;
continue;
default:
av_unreachable("Invalid source node type?");
return;
}
}
}
av_assert0(src.type == SCH_NODE_TYPE_FILTER_OUT);
fg = &sch->filters[src.idx];
static void choke_demux(const Scheduler *sch, int demux_id, int choked)
{
av_assert1(demux_id < sch->nb_demux);
SchDemux *demux = &sch->demux[demux_id];
// the filtergraph contains internal sources and
// requested to be scheduled directly
if (fg->best_input == fg->nb_inputs) {
fg->waiter.choked_next = 0;
return;
for (int i = 0; i < demux->nb_streams; i++) {
SchedulerNode *dst = demux->streams[i].dst;
SchFilterGraph *fg;
switch (dst->type) {
case SCH_NODE_TYPE_DEC:
tq_choke(sch->dec[dst->idx].queue, choked);
break;
case SCH_NODE_TYPE_ENC:
tq_choke(sch->enc[dst->idx].queue, choked);
break;
case SCH_NODE_TYPE_MUX:
break;
case SCH_NODE_TYPE_FILTER_IN:
fg = &sch->filters[dst->idx];
if (fg->nb_inputs == 1)
tq_choke(fg->queue, choked);
break;
default:
av_unreachable("Invalid destination node type?");
break;
}
src = fg->inputs[fg->best_input].src_sched;
}
}
@@ -1299,9 +1419,9 @@ static void schedule_update_locked(Scheduler *sch)
if (atomic_load(&sch->terminate))
return;
dts = trailing_dts(sch, 0);
dts = trailing_dts(sch);
atomic_store(&sch->last_dts, dts);
atomic_store(&sch->last_dts, progressing_dts(sch, 0));
// initialize our internal state
for (unsigned type = 0; type < 2; type++)
@@ -1328,11 +1448,23 @@ static void schedule_update_locked(Scheduler *sch)
continue;
// resolve the source to unchoke
unchoke_for_stream(sch, ms->src_sched);
unchoke_for_stream(sch, ms->src);
have_unchoked = 1;
}
}
// also unchoke any sources feeding into closed filter graph inputs, so
// that they can observe the downstream EOF
for (unsigned i = 0; i < sch->nb_filters; i++) {
SchFilterGraph *fg = &sch->filters[i];
for (unsigned j = 0; j < fg->nb_inputs; j++) {
SchFilterIn *fi = &fg->inputs[j];
if (fi->receive_finished && !fi->send_finished)
unchoke_for_stream(sch, fi->src);
}
}
// make sure to unchoke at least one source, if still available
for (unsigned type = 0; !have_unchoked && type < 2; type++)
for (unsigned i = 0; i < (type ? sch->nb_filters : sch->nb_demux); i++) {
@@ -1345,13 +1477,16 @@ static void schedule_update_locked(Scheduler *sch)
}
}
for (unsigned type = 0; type < 2; type++)
for (unsigned type = 0; type < 2; type++) {
for (unsigned i = 0; i < (type ? sch->nb_filters : sch->nb_demux); i++) {
SchWaiter *w = type ? &sch->filters[i].waiter : &sch->demux[i].waiter;
if (w->choked_prev != w->choked_next)
if (w->choked_prev != w->choked_next) {
waiter_set(w, w->choked_next);
if (!type)
choke_demux(sch, i, w->choked_next);
}
}
}
}
@@ -1361,6 +1496,27 @@ enum {
CYCLE_NODE_DONE,
};
// Finds the filtergraph or muxer upstream of a scheduler node
static SchedulerNode src_filtergraph(const Scheduler *sch, SchedulerNode src)
{
while (1) {
switch (src.type) {
case SCH_NODE_TYPE_DEMUX:
case SCH_NODE_TYPE_FILTER_OUT:
return src;
case SCH_NODE_TYPE_DEC:
src = sch->dec[src.idx].src;
continue;
case SCH_NODE_TYPE_ENC:
src = sch->enc[src.idx].src;
continue;
default:
av_unreachable("Invalid source node type?");
return (SchedulerNode) {0};
}
}
}
static int
check_acyclic_for_output(const Scheduler *sch, SchedulerNode src,
uint8_t *filters_visited, SchedulerNode *filters_stack)
@@ -1377,22 +1533,23 @@ check_acyclic_for_output(const Scheduler *sch, SchedulerNode src,
// descend into every input, depth first
if (src.idx_stream < fg->nb_inputs) {
const SchFilterIn *fi = &fg->inputs[src.idx_stream++];
SchedulerNode node = src_filtergraph(sch, fi->src);
// connected to demuxer, no cycles possible
if (fi->src_sched.type == SCH_NODE_TYPE_DEMUX)
if (node.type == SCH_NODE_TYPE_DEMUX)
continue;
// otherwise connected to another filtergraph
av_assert0(fi->src_sched.type == SCH_NODE_TYPE_FILTER_OUT);
av_assert0(node.type == SCH_NODE_TYPE_FILTER_OUT);
// found a cycle
if (filters_visited[fi->src_sched.idx] == CYCLE_NODE_STARTED)
if (filters_visited[node.idx] == CYCLE_NODE_STARTED)
return AVERROR(EINVAL);
// place current position on stack and descend
av_assert0(nb_filters_stack < sch->nb_filters);
filters_stack[nb_filters_stack++] = src;
src = (SchedulerNode){ .idx = fi->src_sched.idx, .idx_stream = 0 };
src = (SchedulerNode){ .idx = node.idx, .idx_stream = 0 };
continue;
}
@@ -1514,22 +1671,7 @@ static int start_prepare(Scheduler *sch)
for (unsigned j = 0; j < mux->nb_streams; j++) {
SchMuxStream *ms = &mux->streams[j];
switch (ms->src.type) {
case SCH_NODE_TYPE_ENC: {
SchEnc *enc = &sch->enc[ms->src.idx];
if (enc->src.type == SCH_NODE_TYPE_DEC) {
ms->src_sched = sch->dec[enc->src.idx].src;
av_assert0(ms->src_sched.type == SCH_NODE_TYPE_DEMUX);
} else {
ms->src_sched = enc->src;
av_assert0(ms->src_sched.type == SCH_NODE_TYPE_FILTER_OUT);
}
break;
}
case SCH_NODE_TYPE_DEMUX:
ms->src_sched = ms->src;
break;
default:
if (!ms->src.type) {
av_log(mux, AV_LOG_ERROR,
"Muxer stream #%u not connected to a source\n", j);
return AVERROR(EINVAL);
@@ -1547,26 +1689,12 @@ static int start_prepare(Scheduler *sch)
for (unsigned j = 0; j < fg->nb_inputs; j++) {
SchFilterIn *fi = &fg->inputs[j];
SchDec *dec;
if (!fi->src.type) {
av_log(fg, AV_LOG_ERROR,
"Filtergraph input %u not connected to a source\n", j);
return AVERROR(EINVAL);
}
if (fi->src.type == SCH_NODE_TYPE_FILTER_OUT)
fi->src_sched = fi->src;
else {
av_assert0(fi->src.type == SCH_NODE_TYPE_DEC);
dec = &sch->dec[fi->src.idx];
switch (dec->src.type) {
case SCH_NODE_TYPE_DEMUX: fi->src_sched = dec->src; break;
case SCH_NODE_TYPE_ENC: fi->src_sched = sch->enc[dec->src.idx].src; break;
default: av_assert0(0);
}
}
}
for (unsigned j = 0; j < fg->nb_outputs; j++) {
@@ -2189,14 +2317,20 @@ static int send_to_filter(Scheduler *sch, SchFilterGraph *fg,
if (frame)
return tq_send(fg->queue, in_idx, frame);
pthread_mutex_lock(&sch->schedule_lock);
if (!fg->inputs[in_idx].send_finished) {
fg->inputs[in_idx].send_finished = 1;
tq_send_finish(fg->queue, in_idx);
// close the control stream when all actual inputs are done
if (atomic_fetch_add(&fg->nb_inputs_finished_send, 1) == fg->nb_inputs - 1)
if (++fg->nb_inputs_finished_send == fg->nb_inputs)
tq_send_finish(fg->queue, fg->nb_inputs);
schedule_update_locked(sch);
}
pthread_mutex_unlock(&sch->schedule_lock);
return 0;
}
@@ -2447,6 +2581,8 @@ void sch_filter_receive_finish(Scheduler *sch, unsigned fg_idx, unsigned in_idx)
av_assert0(in_idx < fg->nb_inputs);
fi = &fg->inputs[in_idx];
pthread_mutex_lock(&sch->schedule_lock);
if (!fi->receive_finished) {
fi->receive_finished = 1;
tq_receive_finish(fg->queue, in_idx);
@@ -2454,13 +2590,18 @@ void sch_filter_receive_finish(Scheduler *sch, unsigned fg_idx, unsigned in_idx)
// close the control stream when all actual inputs are done
if (++fg->nb_inputs_finished_receive == fg->nb_inputs)
tq_receive_finish(fg->queue, fg->nb_inputs);
schedule_update_locked(sch);
}
pthread_mutex_unlock(&sch->schedule_lock);
}
int sch_filter_send(Scheduler *sch, unsigned fg_idx, unsigned out_idx, AVFrame *frame)
{
SchFilterGraph *fg;
SchedulerNode dst;
int ret;
av_assert0(fg_idx < sch->nb_filters);
fg = &sch->filters[fg_idx];
@@ -2468,9 +2609,16 @@ int sch_filter_send(Scheduler *sch, unsigned fg_idx, unsigned out_idx, AVFrame *
av_assert0(out_idx < fg->nb_outputs);
dst = fg->outputs[out_idx].dst;
return (dst.type == SCH_NODE_TYPE_ENC) ?
send_to_enc (sch, &sch->enc[dst.idx], frame) :
send_to_filter(sch, &sch->filters[dst.idx], dst.idx_stream, frame);
if (dst.type == SCH_NODE_TYPE_ENC) {
ret = send_to_enc(sch, &sch->enc[dst.idx], frame);
if (ret == AVERROR_EOF)
send_to_enc(sch, &sch->enc[dst.idx], NULL);
} else {
ret = send_to_filter(sch, &sch->filters[dst.idx], dst.idx_stream, frame);
if (ret == AVERROR_EOF)
send_to_filter(sch, &sch->filters[dst.idx], dst.idx_stream, NULL);
}
return ret;
}
static int filter_done(Scheduler *sch, unsigned fg_idx)
@@ -2512,6 +2660,18 @@ int sch_filter_command(Scheduler *sch, unsigned fg_idx, AVFrame *frame)
return send_to_filter(sch, fg, fg->nb_inputs, frame);
}
void sch_filter_choke_inputs(Scheduler *sch, unsigned fg_idx)
{
SchFilterGraph *fg;
av_assert0(fg_idx < sch->nb_filters);
fg = &sch->filters[fg_idx];
pthread_mutex_lock(&sch->schedule_lock);
fg->best_input = fg->nb_inputs;
schedule_update_locked(sch);
pthread_mutex_unlock(&sch->schedule_lock);
}
static int task_cleanup(Scheduler *sch, SchedulerNode node)
{
switch (node.type) {
@@ -2520,7 +2680,7 @@ static int task_cleanup(Scheduler *sch, SchedulerNode node)
case SCH_NODE_TYPE_DEC: return dec_done (sch, node.idx);
case SCH_NODE_TYPE_ENC: return enc_done (sch, node.idx);
case SCH_NODE_TYPE_FILTER_IN: return filter_done(sch, node.idx);
default: av_assert0(0);
default: av_unreachable("Invalid node type?");
}
}
@@ -2561,6 +2721,9 @@ static int task_stop(Scheduler *sch, SchTask *task)
int ret;
void *thread_ret;
if (!task->parent)
return 0;
if (!task->thread_running)
return task_cleanup(sch, task->node);
@@ -2585,6 +2748,8 @@ int sch_stop(Scheduler *sch, int64_t *finish_ts)
for (unsigned i = 0; i < (type ? sch->nb_demux : sch->nb_filters); i++) {
SchWaiter *w = type ? &sch->demux[i].waiter : &sch->filters[i].waiter;
waiter_set(w, 1);
if (type)
choke_demux(sch, i, 0); // unfreeze to allow draining
}
for (unsigned i = 0; i < sch->nb_demux; i++) {
@@ -2623,7 +2788,7 @@ int sch_stop(Scheduler *sch, int64_t *finish_ts)
}
if (finish_ts)
*finish_ts = trailing_dts(sch, 1);
*finish_ts = progressing_dts(sch, 1);
sch->state = SCH_STATE_STOPPED;
+10 -1
View File
@@ -205,6 +205,8 @@ int sch_add_dec_output(Scheduler *sch, unsigned dec_idx);
int sch_add_filtergraph(Scheduler *sch, unsigned nb_inputs, unsigned nb_outputs,
SchThreadFunc func, void *ctx);
void sch_remove_filtergraph(Scheduler *sch, int idx);
/**
* Add a muxer to the scheduler.
*
@@ -257,7 +259,7 @@ int sch_add_mux(Scheduler *sch, SchThreadFunc func, int (*init)(void *),
/**
* Default size of a frame thread queue.
*/
#define DEFAULT_FRAME_THREAD_QUEUE_SIZE 8
#define DEFAULT_FRAME_THREAD_QUEUE_SIZE 2
/**
* Add a muxed stream for a previously added muxer.
@@ -443,6 +445,13 @@ int sch_filter_send(Scheduler *sch, unsigned fg_idx, unsigned out_idx,
int sch_filter_command(Scheduler *sch, unsigned fg_idx, struct AVFrame *frame);
/**
* Called by filtergraph tasks to choke all filter inputs, preventing them from
* receiving more frames until woken up again by the scheduler. Used during
* initial graph configuration to avoid unnecessary buffering.
*/
void sch_filter_choke_inputs(Scheduler *sch, unsigned fg_idx);
/**
* Called by encoder tasks to obtain frames for encoding. Will wait for a frame
* to become available and return it in frame.
+100 -10
View File
@@ -37,6 +37,7 @@
#include "libavutil/pixdesc.h"
#include "libavutil/dict.h"
#include "libavutil/fifo.h"
#include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/time.h"
#include "libavutil/bprint.h"
@@ -267,6 +268,7 @@ typedef struct VideoState {
AVComplexFloat *rdft_data;
int xpos;
double last_vis_time;
RenderParams render_params;
SDL_Texture *vis_texture;
SDL_Texture *sub_texture;
SDL_Texture *vid_texture;
@@ -350,6 +352,7 @@ static int find_stream_info = 1;
static int filter_nbthreads = 0;
static int enable_vulkan = 0;
static char *vulkan_params = NULL;
static char *video_background = NULL;
static const char *hwaccel = NULL;
/* current context */
@@ -942,6 +945,11 @@ static enum AVColorSpace sdl_supported_color_spaces[] = {
AVCOL_SPC_SMPTE170M,
};
static enum AVAlphaMode sdl_supported_alpha_modes[] = {
AVALPHA_MODE_UNSPECIFIED,
AVALPHA_MODE_STRAIGHT,
};
static void set_sdl_yuv_conversion_mode(AVFrame *frame)
{
#if SDL_VERSION_ATLEAST(2,0,8)
@@ -958,15 +966,52 @@ static void set_sdl_yuv_conversion_mode(AVFrame *frame)
#endif
}
static void draw_video_background(VideoState *is)
{
const int tile_size = VIDEO_BACKGROUND_TILE_SIZE;
SDL_Rect *rect = &is->render_params.target_rect;
SDL_BlendMode blendMode;
if (!SDL_GetTextureBlendMode(is->vid_texture, &blendMode) && blendMode == SDL_BLENDMODE_BLEND) {
switch (is->render_params.video_background_type) {
case VIDEO_BACKGROUND_TILES:
SDL_SetRenderDrawColor(renderer, 237, 237, 237, 255);
fill_rectangle(rect->x, rect->y, rect->w, rect->h);
SDL_SetRenderDrawColor(renderer, 222, 222, 222, 255);
for (int x = 0; x < rect->w; x += tile_size * 2)
fill_rectangle(rect->x + x, rect->y, FFMIN(tile_size, rect->w - x), rect->h);
for (int y = 0; y < rect->h; y += tile_size * 2)
fill_rectangle(rect->x, rect->y + y, rect->w, FFMIN(tile_size, rect->h - y));
SDL_SetRenderDrawColor(renderer, 237, 237, 237, 255);
for (int y = 0; y < rect->h; y += tile_size * 2) {
int h = FFMIN(tile_size, rect->h - y);
for (int x = 0; x < rect->w; x += tile_size * 2)
fill_rectangle(x + rect->x, y + rect->y, FFMIN(tile_size, rect->w - x), h);
}
break;
case VIDEO_BACKGROUND_COLOR: {
const uint8_t *c = is->render_params.video_background_color;
SDL_SetRenderDrawColor(renderer, c[0], c[1], c[2], c[3]);
fill_rectangle(rect->x, rect->y, rect->w, rect->h);
break;
}
case VIDEO_BACKGROUND_NONE:
SDL_SetTextureBlendMode(is->vid_texture, SDL_BLENDMODE_NONE);
break;
}
}
}
static void video_image_display(VideoState *is)
{
Frame *vp;
Frame *sp = NULL;
SDL_Rect rect;
SDL_Rect *rect = &is->render_params.target_rect;
vp = frame_queue_peek_last(&is->pictq);
calculate_display_rect(rect, is->xleft, is->ytop, is->width, is->height, vp->width, vp->height, vp->sar);
if (vk_renderer) {
vk_renderer_display(vk_renderer, vp->frame);
vk_renderer_display(vk_renderer, vp->frame, &is->render_params);
return;
}
@@ -1015,7 +1060,6 @@ static void video_image_display(VideoState *is)
}
}
calculate_display_rect(&rect, is->xleft, is->ytop, is->width, is->height, vp->width, vp->height, vp->sar);
set_sdl_yuv_conversion_mode(vp->frame);
if (!vp->uploaded) {
@@ -1027,15 +1071,16 @@ static void video_image_display(VideoState *is)
vp->flip_v = vp->frame->linesize[0] < 0;
}
SDL_RenderCopyEx(renderer, is->vid_texture, NULL, &rect, 0, NULL, vp->flip_v ? SDL_FLIP_VERTICAL : 0);
draw_video_background(is);
SDL_RenderCopyEx(renderer, is->vid_texture, NULL, rect, 0, NULL, vp->flip_v ? SDL_FLIP_VERTICAL : 0);
set_sdl_yuv_conversion_mode(NULL);
if (sp) {
#if USE_ONEPASS_SUBTITLE_RENDER
SDL_RenderCopy(renderer, is->sub_texture, NULL, &rect);
SDL_RenderCopy(renderer, is->sub_texture, NULL, rect);
#else
int i;
double xratio = (double)rect.w / (double)sp->width;
double yratio = (double)rect.h / (double)sp->height;
double xratio = (double)rect->w / (double)sp->width;
double yratio = (double)rect->h / (double)sp->height;
for (i = 0; i < sp->sub.num_rects; i++) {
SDL_Rect *sub_rect = (SDL_Rect*)sp->sub.rects[i];
SDL_Rect target = {.x = rect.x + sub_rect->x * xratio,
@@ -1906,6 +1951,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
par->sample_aspect_ratio = codecpar->sample_aspect_ratio;
par->color_space = frame->colorspace;
par->color_range = frame->color_range;
par->alpha_mode = frame->alpha_mode;
par->frame_rate = fr;
par->hw_frames_ctx = frame->hw_frames_ctx;
ret = av_buffersrc_parameters_set(filt_src, par);
@@ -1932,6 +1978,11 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
AV_OPT_TYPE_INT, sdl_supported_color_spaces)) < 0)
goto fail;
if ((ret = av_opt_set_array(filt_out, "alphamodes", AV_OPT_SEARCH_CHILDREN,
0, FF_ARRAY_ELEMS(sdl_supported_alpha_modes),
AV_OPT_TYPE_INT, sdl_supported_alpha_modes)) < 0)
goto fail;
ret = avfilter_init_dict(filt_out, NULL);
if (ret < 0)
goto fail;
@@ -2832,6 +2883,7 @@ static int read_thread(void *arg)
int st_index[AVMEDIA_TYPE_NB];
AVPacket *pkt = NULL;
int64_t stream_start_time;
char metadata_description[96];
int pkt_in_play_range = 0;
const AVDictionaryEntry *t;
SDL_mutex *wait_mutex = SDL_CreateMutex();
@@ -2939,8 +2991,10 @@ static int read_thread(void *arg)
is->realtime = is_realtime(ic);
if (show_status)
if (show_status) {
fprintf(stderr, "\x1b[2K\r");
av_dump_format(ic, 0, is->filename, 0);
}
for (i = 0; i < ic->nb_streams; i++) {
AVStream *st = ic->streams[i];
@@ -2949,7 +3003,11 @@ static int read_thread(void *arg)
if (type >= 0 && wanted_stream_spec[type] && st_index[type] == -1)
if (avformat_match_stream_specifier(ic, st, wanted_stream_spec[type]) > 0)
st_index[type] = i;
// Clear all pre-existing metadata update flags to avoid printing
// initial metadata as update.
st->event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
}
ic->event_flags &= ~AVFMT_EVENT_FLAG_METADATA_UPDATED;
for (i = 0; i < AVMEDIA_TYPE_NB; i++) {
if (wanted_stream_spec[i] && st_index[i] == -1) {
av_log(NULL, AV_LOG_ERROR, "Stream specifier %s does not match any %s stream\n", wanted_stream_spec[i], av_get_media_type_string(i));
@@ -3117,6 +3175,27 @@ static int read_thread(void *arg)
} else {
is->eof = 0;
}
if (show_status) {
if (ic->event_flags & AVFMT_EVENT_FLAG_METADATA_UPDATED) {
fprintf(stderr, "\x1b[2K\r");
dump_dictionary(NULL, ic->metadata,
"\r New metadata", " ", AV_LOG_INFO);
}
if (ic->streams[pkt->stream_index]->event_flags &
AVSTREAM_EVENT_FLAG_METADATA_UPDATED) {
fprintf(stderr, "\x1b[2K\r");
snprintf(metadata_description,
sizeof(metadata_description),
"\r New metadata for stream %d",
pkt->stream_index);
dump_dictionary(NULL, ic->streams[pkt->stream_index]->metadata,
metadata_description, " ", AV_LOG_INFO);
}
}
ic->event_flags &= ~AVFMT_EVENT_FLAG_METADATA_UPDATED;
ic->streams[pkt->stream_index]->event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
/* check if packet is in play range specified by user, then queue, otherwise discard */
stream_start_time = ic->streams[pkt->stream_index]->start_time;
pkt_ts = pkt->pts == AV_NOPTS_VALUE ? pkt->dts : pkt->pts;
@@ -3198,6 +3277,16 @@ static VideoState *stream_open(const char *filename,
av_log(NULL, AV_LOG_WARNING, "-volume=%d < 0, setting to 0\n", startup_volume);
if (startup_volume > 100)
av_log(NULL, AV_LOG_WARNING, "-volume=%d > 100, setting to 100\n", startup_volume);
if (video_background) {
if (!strcmp(video_background, "none")) {
is->render_params.video_background_type = VIDEO_BACKGROUND_NONE;
} else if (strcmp(video_background, "tiles")) {
if (av_parse_color(is->render_params.video_background_color, video_background, -1, NULL) >= 0)
is->render_params.video_background_type = VIDEO_BACKGROUND_COLOR;
else
goto fail;
}
}
startup_volume = av_clip(startup_volume, 0, 100);
startup_volume = av_clip(SDL_MIX_MAXVOLUME * startup_volume / 100, 0, SDL_MIX_MAXVOLUME);
is->audio_volume = startup_volume;
@@ -3711,6 +3800,7 @@ static const OptionDef options[] = {
{ "filter_threads", OPT_TYPE_INT, OPT_EXPERT, { &filter_nbthreads }, "number of filter threads per graph" },
{ "enable_vulkan", OPT_TYPE_BOOL, 0, { &enable_vulkan }, "enable vulkan renderer" },
{ "vulkan_params", OPT_TYPE_STRING, OPT_EXPERT, { &vulkan_params }, "vulkan configuration using a list of key=value pairs separated by ':'" },
{ "video_bg", OPT_TYPE_STRING, OPT_EXPERT, { &video_background }, "set video background for transparent videos" },
{ "hwaccel", OPT_TYPE_STRING, OPT_EXPERT, { &hwaccel }, "use HW accelerated decoding" },
{ NULL, },
};
@@ -3745,9 +3835,9 @@ void show_help_default(const char *opt, const char *arg)
"c cycle program\n"
"w cycle video filters or show modes\n"
"s activate frame-step mode\n"
"left/right seek backward/forward 10 seconds or to custom interval if -seek_interval is set\n"
"left/right seek backward/forward by 10 seconds or a custom interval if -seek_interval is set\n"
"down/up seek backward/forward 1 minute\n"
"page down/page up seek backward/forward 10 minutes\n"
"page down/page up seek to previous/next chapter or backward/forward 10 minutes if no chapters\n"
"right mouse click seek to percentage in file corresponding to fraction of width\n"
"left double-click toggle full screen\n"
);
+56 -38
View File
@@ -43,6 +43,7 @@
#include "libavutil/bprint.h"
#include "libavutil/mem.h"
#include "libavutil/internal.h"
#endif
@@ -53,7 +54,7 @@ struct VkRenderer {
int (*get_hw_dev)(VkRenderer *renderer, AVBufferRef **dev);
int (*display)(VkRenderer *renderer, AVFrame *frame);
int (*display)(VkRenderer *renderer, AVFrame *frame, RenderParams *params);
int (*resize)(VkRenderer *renderer, int width, int height);
@@ -104,36 +105,6 @@ static void vk_log_cb(void *log_priv, enum pl_log_level level,
av_log(log_priv, level_map[level], "%s\n", msg);
}
// Should keep sync with optional_device_exts inside hwcontext_vulkan.c
static const char *optional_device_exts[] = {
/* Misc or required by other extensions */
VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME,
VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME,
VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME,
VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME,
VK_EXT_PHYSICAL_DEVICE_DRM_EXTENSION_NAME,
VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME,
VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME,
/* Imports/exports */
VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME,
VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME,
VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME,
VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME,
VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME,
#ifdef _WIN32
VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME,
VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME,
#endif
/* Video encoding/decoding */
VK_KHR_VIDEO_QUEUE_EXTENSION_NAME,
VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME,
VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME,
VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME,
"VK_MESA_video_decode_av1",
};
static inline int enable_debug(const AVDictionary *opt)
{
AVDictionaryEntry *entry = av_dict_get(opt, "debug", NULL, 0);
@@ -145,14 +116,22 @@ static void hwctx_lock_queue(void *priv, uint32_t qf, uint32_t qidx)
{
AVHWDeviceContext *avhwctx = priv;
const AVVulkanDeviceContext *hwctx = avhwctx->hwctx;
#if FF_API_VULKAN_SYNC_QUEUES
FF_DISABLE_DEPRECATION_WARNINGS
hwctx->lock_queue(avhwctx, qf, qidx);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
static void hwctx_unlock_queue(void *priv, uint32_t qf, uint32_t qidx)
{
AVHWDeviceContext *avhwctx = priv;
const AVVulkanDeviceContext *hwctx = avhwctx->hwctx;
#if FF_API_VULKAN_SYNC_QUEUES
FF_DISABLE_DEPRECATION_WARNINGS
hwctx->unlock_queue(avhwctx, qf, qidx);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
static int add_instance_extension(const char **ext, unsigned num_ext,
@@ -313,7 +292,11 @@ static void placebo_lock_queue(struct AVHWDeviceContext *dev_ctx,
{
RendererContext *ctx = dev_ctx->user_opaque;
pl_vulkan vk = ctx->placebo_vulkan;
#if FF_API_VULKAN_SYNC_QUEUES
FF_DISABLE_DEPRECATION_WARNINGS
vk->lock_queue(vk, queue_family, index);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
static void placebo_unlock_queue(struct AVHWDeviceContext *dev_ctx,
@@ -322,7 +305,11 @@ static void placebo_unlock_queue(struct AVHWDeviceContext *dev_ctx,
{
RendererContext *ctx = dev_ctx->user_opaque;
pl_vulkan vk = ctx->placebo_vulkan;
#if FF_API_VULKAN_SYNC_QUEUES
FF_DISABLE_DEPRECATION_WARNINGS
vk->unlock_queue(vk, queue_family, index);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
static int get_decode_queue(VkRenderer *renderer, int *index, int *count)
@@ -374,6 +361,8 @@ static int create_vk_by_placebo(VkRenderer *renderer,
int decode_index;
int decode_count;
int ret;
const char **dev_exts;
int num_dev_exts;
ctx->get_proc_addr = SDL_Vulkan_GetVkGetInstanceProcAddr();
@@ -388,16 +377,21 @@ static int create_vk_by_placebo(VkRenderer *renderer,
}
ctx->inst = ctx->placebo_instance->instance;
dev_exts = av_vk_get_optional_device_extensions(&num_dev_exts);
if (!dev_exts)
return AVERROR(ENOMEM);
ctx->placebo_vulkan = pl_vulkan_create(ctx->vk_log, pl_vulkan_params(
.instance = ctx->placebo_instance->instance,
.get_proc_addr = ctx->placebo_instance->get_proc_addr,
.surface = ctx->vk_surface,
.allow_software = false,
.opt_extensions = optional_device_exts,
.num_opt_extensions = FF_ARRAY_ELEMS(optional_device_exts),
.opt_extensions = dev_exts,
.num_opt_extensions = num_dev_exts,
.extra_queues = VK_QUEUE_VIDEO_DECODE_BIT_KHR,
.device_name = select_device(opt),
));
av_free(dev_exts);
if (!ctx->placebo_vulkan)
return AVERROR_EXTERNAL;
ctx->hw_device_ref = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VULKAN);
@@ -409,8 +403,12 @@ static int create_vk_by_placebo(VkRenderer *renderer,
device_ctx->user_opaque = ctx;
vk_dev_ctx = device_ctx->hwctx;
#if FF_API_VULKAN_SYNC_QUEUES
FF_DISABLE_DEPRECATION_WARNINGS
vk_dev_ctx->lock_queue = placebo_lock_queue;
vk_dev_ctx->unlock_queue = placebo_unlock_queue;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
vk_dev_ctx->get_proc_addr = ctx->placebo_instance->get_proc_addr;
@@ -725,11 +723,13 @@ static int convert_frame(VkRenderer *renderer, AVFrame *frame)
return ret;
}
static int display(VkRenderer *renderer, AVFrame *frame)
static int display(VkRenderer *renderer, AVFrame *frame, RenderParams *params)
{
SDL_Rect *rect = &params->target_rect;
struct pl_swapchain_frame swap_frame = {0};
struct pl_frame pl_frame = {0};
struct pl_frame target = {0};
struct pl_render_params pl_params = pl_render_default_params;
RendererContext *ctx = (RendererContext *) renderer;
int ret = 0;
struct pl_color_space hint = {0};
@@ -754,8 +754,26 @@ static int display(VkRenderer *renderer, AVFrame *frame)
}
pl_frame_from_swapchain(&target, &swap_frame);
if (!pl_render_image(ctx->renderer, &pl_frame, &target,
&pl_render_default_params)) {
target.crop = (pl_rect2df){.x0 = rect->x, .x1 = rect->x + rect->w,
.y0 = rect->y, .y1 = rect->y + rect->h};
switch (params->video_background_type) {
case VIDEO_BACKGROUND_TILES:
pl_params.background = PL_CLEAR_TILES;
pl_params.tile_size = VIDEO_BACKGROUND_TILE_SIZE * 2;
break;
case VIDEO_BACKGROUND_COLOR:
pl_params.background = PL_CLEAR_COLOR;
for (int i = 0; i < 3; i++)
pl_params.background_color[i] = params->video_background_color[i] / 255.0;
pl_params.background_transparency = (255 - params->video_background_color[3]) / 255.0;
break;
case VIDEO_BACKGROUND_NONE:
pl_frame.repr.alpha = PL_ALPHA_NONE;
break;
}
if (!pl_render_image(ctx->renderer, &pl_frame, &target, &pl_params)) {
av_log(NULL, AV_LOG_ERROR, "pl_render_image failed\n");
ret = AVERROR_EXTERNAL;
goto out;
@@ -858,9 +876,9 @@ int vk_renderer_get_hw_dev(VkRenderer *renderer, AVBufferRef **dev)
return renderer->get_hw_dev(renderer, dev);
}
int vk_renderer_display(VkRenderer *renderer, AVFrame *frame)
int vk_renderer_display(VkRenderer *renderer, AVFrame *frame, RenderParams *render_params)
{
return renderer->display(renderer, frame);
return renderer->display(renderer, frame, render_params);
}
int vk_renderer_resize(VkRenderer *renderer, int width, int height)
+15 -1
View File
@@ -25,6 +25,20 @@
typedef struct VkRenderer VkRenderer;
#define VIDEO_BACKGROUND_TILE_SIZE 64
enum VideoBackgroundType {
VIDEO_BACKGROUND_TILES,
VIDEO_BACKGROUND_COLOR,
VIDEO_BACKGROUND_NONE,
};
typedef struct RenderParams {
SDL_Rect target_rect;
uint8_t video_background_color[4];
enum VideoBackgroundType video_background_type;
} RenderParams;
VkRenderer *vk_get_renderer(void);
int vk_renderer_create(VkRenderer *renderer, SDL_Window *window,
@@ -32,7 +46,7 @@ int vk_renderer_create(VkRenderer *renderer, SDL_Window *window,
int vk_renderer_get_hw_dev(VkRenderer *renderer, AVBufferRef **dev);
int vk_renderer_display(VkRenderer *renderer, AVFrame *frame);
int vk_renderer_display(VkRenderer *renderer, AVFrame *frame, RenderParams *params);
int vk_renderer_resize(VkRenderer *renderer, int width, int height);
+364 -72
View File
@@ -36,6 +36,7 @@
#include "libavutil/ambient_viewing_environment.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/avutil.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/display.h"
@@ -130,6 +131,11 @@ static int use_byte_value_binary_prefix = 0;
static int use_value_sexagesimal_format = 0;
static int show_private_data = 1;
static const char *audio_codec_name = NULL;
static const char *data_codec_name = NULL;
static const char *subtitle_codec_name = NULL;
static const char *video_codec_name = NULL;
#define SHOW_OPTIONAL_FIELDS_AUTO -1
#define SHOW_OPTIONAL_FIELDS_NEVER 0
#define SHOW_OPTIONAL_FIELDS_ALWAYS 1
@@ -138,6 +144,7 @@ static int show_optional_fields = SHOW_OPTIONAL_FIELDS_AUTO;
static char *output_format;
static char *stream_specifier;
static char *show_data_hash;
static char *data_dump_format;
typedef struct ReadInterval {
int id; ///< identifier
@@ -208,6 +215,8 @@ typedef enum {
SECTION_ID_STREAM_GROUP_SUBPIECE,
SECTION_ID_STREAM_GROUP_BLOCKS,
SECTION_ID_STREAM_GROUP_BLOCK,
SECTION_ID_STREAM_GROUP_SIDE_DATA_LIST,
SECTION_ID_STREAM_GROUP_SIDE_DATA,
SECTION_ID_STREAM_GROUP_STREAMS,
SECTION_ID_STREAM_GROUP_STREAM,
SECTION_ID_STREAM_GROUP_DISPOSITION,
@@ -246,7 +255,7 @@ static const char *get_stream_group_type(const void *data)
return av_x_if_null(avformat_stream_group_name(stg->type), "unknown");
}
static struct AVTextFormatSection sections[] = {
static const AVTextFormatSection sections[] = {
[SECTION_ID_CHAPTERS] = { SECTION_ID_CHAPTERS, "chapters", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_CHAPTER, -1 } },
[SECTION_ID_CHAPTER] = { SECTION_ID_CHAPTER, "chapter", 0, { SECTION_ID_CHAPTER_TAGS, -1 } },
[SECTION_ID_CHAPTER_TAGS] = { SECTION_ID_CHAPTER_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "chapter_tags" },
@@ -291,7 +300,7 @@ static struct AVTextFormatSection sections[] = {
[SECTION_ID_STREAM_GROUP_STREAM_TAGS] = { SECTION_ID_STREAM_GROUP_STREAM_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "stream_group_stream_tags" },
[SECTION_ID_STREAM_GROUP] = { SECTION_ID_STREAM_GROUP, "stream_group", 0, { SECTION_ID_STREAM_GROUP_TAGS, SECTION_ID_STREAM_GROUP_DISPOSITION, SECTION_ID_STREAM_GROUP_COMPONENTS, SECTION_ID_STREAM_GROUP_STREAMS, -1 } },
[SECTION_ID_STREAM_GROUP_COMPONENTS] = { SECTION_ID_STREAM_GROUP_COMPONENTS, "components", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_COMPONENT, -1 }, .element_name = "component", .unique_name = "stream_group_components" },
[SECTION_ID_STREAM_GROUP_COMPONENT] = { SECTION_ID_STREAM_GROUP_COMPONENT, "component", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { SECTION_ID_STREAM_GROUP_SUBCOMPONENTS, -1 }, .unique_name = "stream_group_component", .element_name = "component_entry", .get_type = get_stream_group_type },
[SECTION_ID_STREAM_GROUP_COMPONENT] = { SECTION_ID_STREAM_GROUP_COMPONENT, "component", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { SECTION_ID_STREAM_GROUP_SIDE_DATA_LIST, SECTION_ID_STREAM_GROUP_SUBCOMPONENTS, -1 }, .unique_name = "stream_group_component", .element_name = "component_entry", .get_type = get_stream_group_type },
[SECTION_ID_STREAM_GROUP_SUBCOMPONENTS] = { SECTION_ID_STREAM_GROUP_SUBCOMPONENTS, "subcomponents", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_SUBCOMPONENT, -1 }, .element_name = "component" },
[SECTION_ID_STREAM_GROUP_SUBCOMPONENT] = { SECTION_ID_STREAM_GROUP_SUBCOMPONENT, "subcomponent", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { SECTION_ID_STREAM_GROUP_PIECES, -1 }, .element_name = "subcomponent_entry", .get_type = get_raw_string_type },
[SECTION_ID_STREAM_GROUP_PIECES] = { SECTION_ID_STREAM_GROUP_PIECES, "pieces", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_PIECE, -1 }, .element_name = "piece", .unique_name = "stream_group_pieces" },
@@ -300,6 +309,8 @@ static struct AVTextFormatSection sections[] = {
[SECTION_ID_STREAM_GROUP_SUBPIECE] = { SECTION_ID_STREAM_GROUP_SUBPIECE, "subpiece", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { SECTION_ID_STREAM_GROUP_BLOCKS, -1 }, .element_name = "subpiece_entry", .get_type = get_raw_string_type },
[SECTION_ID_STREAM_GROUP_BLOCKS] = { SECTION_ID_STREAM_GROUP_BLOCKS, "blocks", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_BLOCK, -1 }, .element_name = "block" },
[SECTION_ID_STREAM_GROUP_BLOCK] = { SECTION_ID_STREAM_GROUP_BLOCK, "block", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { -1 }, .element_name = "block_entry", .get_type = get_raw_string_type },
[SECTION_ID_STREAM_GROUP_SIDE_DATA_LIST] = { SECTION_ID_STREAM_GROUP_SIDE_DATA_LIST, "side_data_list", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_SIDE_DATA, -1 }, .element_name = "side_data", .unique_name = "stream_group_side_data_list" },
[SECTION_ID_STREAM_GROUP_SIDE_DATA] = { SECTION_ID_STREAM_GROUP_SIDE_DATA, "side_data", AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE|AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .unique_name = "stream_group_side_data", .element_name = "side_datum", .get_type = get_packet_side_data_type },
[SECTION_ID_STREAM_GROUP_STREAMS] = { SECTION_ID_STREAM_GROUP_STREAMS, "streams", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_STREAM, -1 }, .unique_name = "stream_group_streams" },
[SECTION_ID_STREAM_GROUP_STREAM] = { SECTION_ID_STREAM_GROUP_STREAM, "stream", 0, { SECTION_ID_STREAM_GROUP_STREAM_DISPOSITION, SECTION_ID_STREAM_GROUP_STREAM_TAGS, -1 }, .unique_name = "stream_group_stream" },
[SECTION_ID_STREAM_GROUP_DISPOSITION] = { SECTION_ID_STREAM_GROUP_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "stream_group_disposition" },
@@ -318,6 +329,13 @@ static struct AVTextFormatSection sections[] = {
[SECTION_ID_SUBTITLE] = { SECTION_ID_SUBTITLE, "subtitle", 0, { -1 } },
};
typedef struct EntrySelection {
int show_all_entries;
AVDictionary *entries_to_show;
} EntrySelection;
static EntrySelection selected_entries[FF_ARRAY_ELEMS(sections)] = { 0 };
static const OptionDef *options;
/* FFprobe context */
@@ -331,7 +349,7 @@ static const char unit_hertz_str[] = "Hz" ;
static const char unit_byte_str[] = "byte" ;
static const char unit_bit_per_second_str[] = "bit/s";
static int nb_streams;
static unsigned int nb_streams;
static uint64_t *nb_streams_packets;
static uint64_t *nb_streams_frames;
static int *selected_streams;
@@ -352,6 +370,14 @@ typedef struct LogBuffer {
static LogBuffer *log_buffer;
static int log_buffer_size;
static int is_key_selected_callback(AVTextFormatContext *tctx, const char *key)
{
const AVTextFormatSection *section = tctx->section[tctx->level];
const EntrySelection *selection = &selected_entries[section - sections];
return selection->show_all_entries || av_dict_get(selection->entries_to_show, key, NULL, 0);
}
static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
{
AVClass* avc = ptr ? *(AVClass **) ptr : NULL;
@@ -410,8 +436,8 @@ static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
#define print_list_fmt(k, f, n, m, ...) do { \
av_bprint_clear(&pbuf); \
for (int idx = 0; idx < n; idx++) { \
for (int idx2 = 0; idx2 < m; idx2++) { \
for (unsigned int idx = 0; idx < n; idx++) { \
for (unsigned int idx2 = 0; idx2 < m; idx2++) { \
if (idx > 0 || idx2 > 0) \
av_bprint_chars(&pbuf, ' ', 1); \
av_bprintf(&pbuf, f, __VA_ARGS__); \
@@ -431,6 +457,30 @@ static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
#define print_duration_ts(k, v) avtext_print_ts(tfc, k, v, 1)
#define print_val(k, v, u) avtext_print_unit_integer(tfc, k, v, u)
static void print_integers(AVTextFormatContext *tfc, const char *key,
const void *data, int size, const char *format,
int columns, int bytes, int offset_add)
{
AVBPrint bp;
unsigned offset = 0;
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
av_bprint_chars(&bp, '\n', 1);
while (size) {
av_bprintf(&bp, "%08x: ", offset);
for (int i = 0, l = FFMIN(size, columns); i < l; i++) {
if (bytes == 1) av_bprintf(&bp, format, *(const uint8_t*)data);
else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data));
else if (bytes == 4) av_bprintf(&bp, format, AV_RN32(data));
data = (const char*)data + bytes;
size--;
}
av_bprint_chars(&bp, '\n', 1);
offset += offset_add;
}
avtext_print_string(tfc, key, bp.str, 0);
}
#define REALLOCZ_ARRAY_STREAM(ptr, cur_n, new_n) \
{ \
ret = av_reallocp_array(&(ptr), (new_n), sizeof(*(ptr))); \
@@ -462,7 +512,7 @@ static void print_displaymatrix(AVTextFormatContext *tfc, const int32_t matrix[9
double rotation = av_display_rotation_get(matrix);
if (isnan(rotation))
rotation = 0;
avtext_print_integers(tfc, "displaymatrix", (void*)matrix, 9, " %11d", 3, 4, 1);
print_integers(tfc, "displaymatrix", matrix, 9, " %11d", 3, 4, 1);
print_int("rotation", rotation);
}
@@ -755,6 +805,62 @@ static void print_dynamic_hdr10_plus(AVTextFormatContext *tfc, const AVDynamicHD
}
}
static void print_dynamic_hdr_smpte2094_app5(AVTextFormatContext *tfc, const AVDynamicHDRSmpte2094App5 *metadata)
{
if (!metadata)
return;
print_int("application_version", metadata->application_version);
print_int("minimum_application_version", metadata->minimum_application_version);
print_int("has_custom_hdr_reference_white_flag", metadata->has_custom_hdr_reference_white_flag);
print_int("has_adaptive_tone_map_flag", metadata->has_adaptive_tone_map_flag);
if (metadata->has_custom_hdr_reference_white_flag)
print_int("hdr_reference_white", metadata->hdr_reference_white);
if (!metadata->has_adaptive_tone_map_flag)
return;
print_int("baseline_hdr_headroom", metadata->baseline_hdr_headroom);
print_int("use_reference_white_tone_mapping_flag", metadata->use_reference_white_tone_mapping_flag);
if (metadata->use_reference_white_tone_mapping_flag)
return;
print_int("num_alternate_images", metadata->num_alternate_images);
print_int("gain_application_space_chromaticities_flag", metadata->gain_application_space_chromaticities_flag);
print_int("has_common_component_mix_params_flag", metadata->has_common_component_mix_params_flag);
print_int("has_common_curve_params_flag", metadata->has_common_curve_params_flag);
if (metadata->gain_application_space_chromaticities_flag == 3) {
for (int i = 0; i < 8; i++)
print_int("gain_application_space_chromaticities", metadata->gain_application_space_chromaticities[i]);
}
for (int a = 0; a < metadata->num_alternate_images; a++) {
print_int("alternate_hdr_headroom", metadata->alternate_hdr_headrooms[a]);
print_int("component_mixing_type", metadata->component_mixing_type[a]);
if (metadata->component_mixing_type[a] == 3) {
for (int k = 0; k < 6; k++) {
print_int("has_component_mixing_coefficient_flag", metadata->has_component_mixing_coefficient_flag[a][k]);
if (metadata->has_component_mixing_coefficient_flag[a][k])
print_int("component_mixing_coefficient", metadata->component_mixing_coefficient[a][k]);
}
}
print_int("gain_curve_num_control_points_minus_1", metadata->gain_curve_num_control_points_minus_1[a]);
print_int("gain_curve_use_pchip_slope_flag", metadata->gain_curve_use_pchip_slope_flag[a]);
for (int c = 0; c <= metadata->gain_curve_num_control_points_minus_1[a]; c++)
print_int("gain_curve_control_point_x", metadata->gain_curve_control_points_x[a][c]);
for (int c = 0; c <= metadata->gain_curve_num_control_points_minus_1[a]; c++)
print_int("gain_curve_control_point_y", metadata->gain_curve_control_points_y[a][c]);
if (!metadata->gain_curve_use_pchip_slope_flag[a]) {
for (int c = 0; c <= metadata->gain_curve_num_control_points_minus_1[a]; c++)
print_int("gain_curve_control_point_theta", metadata->gain_curve_control_points_theta[a][c]);
}
}
}
static void print_dynamic_hdr_vivid(AVTextFormatContext *tfc, const AVDynamicHDRVivid *metadata)
{
if (!metadata)
@@ -896,7 +1002,7 @@ static void print_film_grain_params(AVTextFormatContext *tfc,
avtext_print_section_footer(tfc);
}
for (int uv = 0; uv < 2; uv++) {
for (unsigned uv = 0; uv < 2; uv++) {
if (!aom->num_uv_points[uv] && !aom->chroma_scaling_from_luma)
continue;
@@ -962,7 +1068,8 @@ static void print_film_grain_params(AVTextFormatContext *tfc,
}
static void print_pkt_side_data(AVTextFormatContext *tfc,
AVCodecParameters *par,
int width,
int height,
const AVPacketSideData *sd,
SectionID id_data)
{
@@ -988,7 +1095,7 @@ static void print_pkt_side_data(AVTextFormatContext *tfc,
print_int("padding", spherical->padding);
} else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
size_t l, t, r, b;
av_spherical_tile_bounds(spherical, par->width, par->height,
av_spherical_tile_bounds(spherical, width, height,
&l, &t, &r, &b);
print_int("bound_left", l);
print_int("bound_top", t);
@@ -1057,6 +1164,12 @@ static void print_pkt_side_data(AVTextFormatContext *tfc,
print_int("crop_right", AV_RL32(sd->data + 12));
} else if (sd->type == AV_PKT_DATA_AFD && sd->size > 0) {
print_int("active_format", *sd->data);
} else if (sd->type == AV_PKT_DATA_EXIF) {
print_int("size", sd->size);
} else if (sd->type == AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL && sd->size >= 8) {
print_int("block_additional_id", AV_RB64(sd->data));
if (do_show_data)
avtext_print_data(tfc, "block_additional_data", sd->data + 8, sd->size - 8);
}
}
@@ -1148,6 +1261,16 @@ static void print_chroma_location(AVTextFormatContext *tfc, enum AVChromaLocatio
}
}
static void print_alpha_mode(AVTextFormatContext *tfc, enum AVAlphaMode alpha_mode)
{
const char *val = av_alpha_mode_name(alpha_mode);
if (!val || alpha_mode == AVALPHA_MODE_UNSPECIFIED) {
print_str_opt("alpha_mode", "unspecified");
} else {
print_str("alpha_mode", val);
}
}
static void clear_log(int need_lock)
{
int i;
@@ -1243,7 +1366,7 @@ static void show_packet(AVTextFormatContext *tfc, InputFile *ifile, AVPacket *pk
avtext_print_section_header(tfc, NULL, SECTION_ID_PACKET_SIDE_DATA_LIST);
for (int i = 0; i < pkt->side_data_elems; i++) {
print_pkt_side_data(tfc, st->codecpar, &pkt->side_data[i],
print_pkt_side_data(tfc, st->codecpar->width, st->codecpar->height, &pkt->side_data[i],
SECTION_ID_PACKET_SIDE_DATA);
avtext_print_section_footer(tfc);
}
@@ -1279,6 +1402,9 @@ static void show_subtitle(AVTextFormatContext *tfc, AVSubtitle *sub, AVStream *s
fflush(stdout);
}
static void print_iamf_param_definition(AVTextFormatContext *tfc, const char *name,
const AVIAMFParamDefinition *param, SectionID section_id);
static void print_frame_side_data(AVTextFormatContext *tfc,
const AVFrame *frame,
const AVStream *stream)
@@ -1317,6 +1443,9 @@ static void print_frame_side_data(AVTextFormatContext *tfc,
} else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_PLUS) {
AVDynamicHDRPlus *metadata = (AVDynamicHDRPlus *)sd->data;
print_dynamic_hdr10_plus(tfc, metadata);
} else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_SMPTE_2094_APP5) {
AVDynamicHDRSmpte2094App5 *metadata = (AVDynamicHDRSmpte2094App5 *)sd->data;
print_dynamic_hdr_smpte2094_app5(tfc, metadata);
} else if (sd->type == AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) {
print_context_light_level(tfc, (AVContentLightMetadata *)sd->data);
} else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {
@@ -1336,6 +1465,13 @@ static void print_frame_side_data(AVTextFormatContext *tfc,
print_film_grain_params(tfc, fgp);
} else if (sd->type == AV_FRAME_DATA_VIEW_ID) {
print_int("view_id", *(int*)sd->data);
} else if (sd->type == AV_FRAME_DATA_EXIF) {
print_int("size", sd->size);
} else if (sd->type == AV_FRAME_DATA_IAMF_MIX_GAIN_PARAM ||
sd->type == AV_FRAME_DATA_IAMF_DEMIXING_INFO_PARAM ||
sd->type == AV_FRAME_DATA_IAMF_RECON_GAIN_INFO_PARAM) {
const AVIAMFParamDefinition *param = (AVIAMFParamDefinition *)sd->data;
print_iamf_param_definition(tfc, NULL, param, SECTION_ID_FRAME_SIDE_DATA);
}
avtext_print_section_footer(tfc);
}
@@ -1400,6 +1536,7 @@ static void show_frame(AVTextFormatContext *tfc, AVFrame *frame, AVStream *strea
print_primaries(tfc, frame->color_primaries);
print_color_trc(tfc, frame->color_trc);
print_chroma_location(tfc, frame->chroma_location);
print_alpha_mode(tfc, frame->alpha_mode);
break;
case AVMEDIA_TYPE_AUDIO:
@@ -1631,12 +1768,10 @@ static int read_interval_packets(AVTextFormatContext *tfc, InputFile *ifile,
}
av_packet_unref(pkt);
//Flush remaining frames that are cached in the decoder
for (i = 0; i < ifile->nb_streams; i++) {
for (int i = 0; i < ifile->nb_streams; i++) {
pkt->stream_index = i;
if (do_read_frames) {
while (process_frame(tfc, ifile, frame, pkt, &(int){1}) > 0);
if (ifile->streams[i].dec_ctx)
avcodec_flush_buffers(ifile->streams[i].dec_ctx);
}
}
@@ -1650,17 +1785,33 @@ end:
return ret;
}
static void flush_buffers(InputFile *ifile)
{
int i;
if (!do_read_frames)
return;
for (i = 0; i < ifile->nb_streams; i++) {
if (ifile->streams[i].dec_ctx)
avcodec_flush_buffers(ifile->streams[i].dec_ctx);
}
}
static int read_packets(AVTextFormatContext *tfc, InputFile *ifile)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
int i, ret = 0;
int ret = 0;
int64_t cur_ts = fmt_ctx->start_time;
if (read_intervals_nb == 0) {
ReadInterval interval = (ReadInterval) { .has_start = 0, .has_end = 0 };
ret = read_interval_packets(tfc, ifile, &interval, &cur_ts);
} else {
for (i = 0; i < read_intervals_nb; i++) {
for (int i = 0; i < read_intervals_nb; i++) {
/* flushing buffers can reset parts of the private context which may be
* read by show_streams(), so only flush between each read_interval */
if (i)
flush_buffers(ifile);
ret = read_interval_packets(tfc, ifile, &read_intervals[i], &cur_ts);
if (ret < 0)
break;
@@ -1673,7 +1824,7 @@ static int read_packets(AVTextFormatContext *tfc, InputFile *ifile)
static void print_dispositions(AVTextFormatContext *tfc, uint32_t disposition, SectionID section_id)
{
avtext_print_section_header(tfc, NULL, section_id);
for (int i = 0; i < sizeof(disposition) * CHAR_BIT; i++) {
for (unsigned i = 0; i < sizeof(disposition) * CHAR_BIT; i++) {
const char *disposition_str = av_disposition_to_string(1U << i);
if (disposition_str)
@@ -1755,6 +1906,10 @@ static int show_stream(AVTextFormatContext *tfc, AVFormatContext *fmt_ctx, int s
print_str("codec_tag_string", av_fourcc2str(par->codec_tag));
print_fmt("codec_tag", "0x%04"PRIx32, par->codec_tag);
av_bprint_clear(&pbuf);
if (!av_mime_codec_str(par, stream->avg_frame_rate, &pbuf))
print_str("mime_codec_string", pbuf.str);
switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
print_int("width", par->width);
@@ -1803,7 +1958,7 @@ static int show_stream(AVTextFormatContext *tfc, AVFormatContext *fmt_ctx, int s
else
print_str_opt("field_order", "unknown");
if (dec_ctx)
if (dec_ctx && do_read_frames)
print_int("refs", dec_ctx->refs);
break;
@@ -1892,7 +2047,7 @@ static int show_stream(AVTextFormatContext *tfc, AVFormatContext *fmt_ctx, int s
if (stream->codecpar->nb_coded_side_data) {
avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_SIDE_DATA_LIST);
for (int i = 0; i < stream->codecpar->nb_coded_side_data; i++) {
print_pkt_side_data(tfc, stream->codecpar, &stream->codecpar->coded_side_data[i],
print_pkt_side_data(tfc, stream->codecpar->width, stream->codecpar->height, &stream->codecpar->coded_side_data[i],
SECTION_ID_STREAM_SIDE_DATA);
avtext_print_section_footer(tfc);
}
@@ -1909,10 +2064,10 @@ static int show_stream(AVTextFormatContext *tfc, AVFormatContext *fmt_ctx, int s
static int show_streams(AVTextFormatContext *tfc, InputFile *ifile)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
int i, ret = 0;
int ret = 0;
avtext_print_section_header(tfc, NULL, SECTION_ID_STREAMS);
for (i = 0; i < ifile->nb_streams; i++)
for (int i = 0; i < ifile->nb_streams; i++)
if (selected_streams[i]) {
ret = show_stream(tfc, fmt_ctx, i, &ifile->streams[i], 0);
if (ret < 0)
@@ -1926,7 +2081,7 @@ static int show_streams(AVTextFormatContext *tfc, InputFile *ifile)
static int show_program(AVTextFormatContext *tfc, InputFile *ifile, AVProgram *program)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
int i, ret = 0;
int ret = 0;
avtext_print_section_header(tfc, NULL, SECTION_ID_PROGRAM);
print_int("program_id", program->id);
@@ -1940,7 +2095,7 @@ static int show_program(AVTextFormatContext *tfc, InputFile *ifile, AVProgram *p
goto end;
avtext_print_section_header(tfc, NULL, SECTION_ID_PROGRAM_STREAMS);
for (i = 0; i < program->nb_stream_indexes; i++) {
for (unsigned i = 0; i < program->nb_stream_indexes; i++) {
if (selected_streams[program->stream_index[i]]) {
ret = show_stream(tfc, fmt_ctx, program->stream_index[i], &ifile->streams[program->stream_index[i]], IN_PROGRAM);
if (ret < 0)
@@ -1957,10 +2112,10 @@ end:
static int show_programs(AVTextFormatContext *tfc, InputFile *ifile)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
int i, ret = 0;
int ret = 0;
avtext_print_section_header(tfc, NULL, SECTION_ID_PROGRAMS);
for (i = 0; i < fmt_ctx->nb_programs; i++) {
for (unsigned i = 0; i < fmt_ctx->nb_programs; i++) {
AVProgram *program = fmt_ctx->programs[i];
if (!program)
continue;
@@ -1984,7 +2139,7 @@ static void print_tile_grid_params(AVTextFormatContext *tfc, const AVStreamGroup
print_int("width", tile_grid->width);
print_int("height", tile_grid->height);
avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SUBCOMPONENTS);
for (int i = 0; i < tile_grid->nb_tiles; i++) {
for (unsigned i = 0; i < tile_grid->nb_tiles; i++) {
avtext_print_section_header(tfc, "tile_offset", SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
print_int("stream_index", tile_grid->offsets[i].idx);
print_int("tile_horizontal_offset", tile_grid->offsets[i].horizontal);
@@ -1992,6 +2147,15 @@ static void print_tile_grid_params(AVTextFormatContext *tfc, const AVStreamGroup
avtext_print_section_footer(tfc);
}
avtext_print_section_footer(tfc);
if (tile_grid->nb_coded_side_data) {
avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SIDE_DATA_LIST);
for (int i = 0; i < tile_grid->nb_coded_side_data; i++) {
print_pkt_side_data(tfc, tile_grid->width, tile_grid->height, &tile_grid->coded_side_data[i],
SECTION_ID_STREAM_GROUP_SIDE_DATA);
avtext_print_section_footer(tfc);
}
avtext_print_section_footer(tfc);
}
avtext_print_section_footer(tfc);
}
@@ -1999,12 +2163,21 @@ static void print_iamf_param_definition(AVTextFormatContext *tfc, const char *na
const AVIAMFParamDefinition *param, SectionID section_id)
{
SectionID subsection_id, parameter_section_id;
subsection_id = sections[section_id].children_ids[0];
av_assert0(subsection_id != -1);
if (section_id == SECTION_ID_FRAME_SIDE_DATA)
subsection_id = SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST;
else {
av_assert0(sections[section_id].children_ids[0] != -1);
subsection_id = sections[section_id].children_ids[0];
}
av_assert0(sections[subsection_id].children_ids[0] != -1);
parameter_section_id = sections[subsection_id].children_ids[0];
av_assert0(parameter_section_id != -1);
avtext_print_section_header(tfc, "IAMF Param Definition", section_id);
print_str("name", name);
// When printing as part of side-data, skip opening a section
if (section_id != SECTION_ID_FRAME_SIDE_DATA)
avtext_print_section_header(tfc, "IAMF Param Definition", section_id);
if (name)
print_str("name", name);
print_int("nb_subblocks", param->nb_subblocks);
print_int("type", param->type);
print_int("parameter_id", param->parameter_id);
@@ -2013,7 +2186,7 @@ static void print_iamf_param_definition(AVTextFormatContext *tfc, const char *na
print_int("constant_subblock_duration", param->constant_subblock_duration);
if (param->nb_subblocks > 0)
avtext_print_section_header(tfc, NULL, subsection_id);
for (int i = 0; i < param->nb_subblocks; i++) {
for (unsigned i = 0; i < param->nb_subblocks; i++) {
const void *subblock = av_iamf_param_definition_get_subblock(param, i);
switch(param->type) {
case AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN: {
@@ -2047,18 +2220,24 @@ static void print_iamf_param_definition(AVTextFormatContext *tfc, const char *na
}
if (param->nb_subblocks > 0)
avtext_print_section_footer(tfc); // subsection_id
avtext_print_section_footer(tfc); // section_id
if (section_id != SECTION_ID_FRAME_SIDE_DATA)
avtext_print_section_footer(tfc); // section_id
}
static void print_iamf_audio_element_params(AVTextFormatContext *tfc, const AVStreamGroup *stg,
const AVIAMFAudioElement *audio_element)
{
AVBPrint pbuf;
av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
avtext_print_section_header(tfc, stg, SECTION_ID_STREAM_GROUP_COMPONENT);
print_int("nb_layers", audio_element->nb_layers);
print_int("audio_element_type", audio_element->audio_element_type);
print_int("default_w", audio_element->default_w);
avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SUBCOMPONENTS);
for (int i = 0; i < audio_element->nb_layers; i++) {
for (unsigned i = 0; i < audio_element->nb_layers; i++) {
const AVIAMFLayer *layer = audio_element->layers[i];
char val_str[128];
avtext_print_section_header(tfc, "IAMF Audio Layer", SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
@@ -2067,8 +2246,12 @@ static void print_iamf_audio_element_params(AVTextFormatContext *tfc, const AVSt
if (audio_element->audio_element_type == AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL) {
print_int("output_gain_flags", layer->output_gain_flags);
print_q("output_gain", layer->output_gain, '/');
} else if (audio_element->audio_element_type == AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE)
} else if (audio_element->audio_element_type == AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE) {
print_int("ambisonics_mode", layer->ambisonics_mode);
if (layer->ambisonics_mode == AV_IAMF_AMBISONICS_MODE_PROJECTION)
print_list_fmt("demixing_matrix", "%d/%d", layer->nb_demixing_matrix, 1, layer->demixing_matrix[idx].num,
layer->demixing_matrix[idx].den);
}
avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENT
}
if (audio_element->demixing_info)
@@ -2079,6 +2262,8 @@ static void print_iamf_audio_element_params(AVTextFormatContext *tfc, const AVSt
SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENTS
avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_COMPONENT
av_bprint_finalize(&pbuf, NULL);
}
static void print_iamf_submix_params(AVTextFormatContext *tfc, const AVIAMFSubmix *submix)
@@ -2088,7 +2273,7 @@ static void print_iamf_submix_params(AVTextFormatContext *tfc, const AVIAMFSubmi
print_int("nb_layouts", submix->nb_layouts);
print_q("default_mix_gain", submix->default_mix_gain, '/');
avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_PIECES);
for (int i = 0; i < submix->nb_elements; i++) {
for (unsigned i = 0; i < submix->nb_elements; i++) {
const AVIAMFSubmixElement *element = submix->elements[i];
avtext_print_section_header(tfc, "IAMF Submix Element", SECTION_ID_STREAM_GROUP_PIECE);
print_int("stream_id", element->audio_element_id);
@@ -2111,7 +2296,7 @@ static void print_iamf_submix_params(AVTextFormatContext *tfc, const AVIAMFSubmi
if (submix->output_mix_config)
print_iamf_param_definition(tfc, "output_mix_config", submix->output_mix_config,
SECTION_ID_STREAM_GROUP_PIECE);
for (int i = 0; i < submix->nb_layouts; i++) {
for (unsigned i = 0; i < submix->nb_layouts; i++) {
const AVIAMFSubmixLayout *layout = submix->layouts[i];
char val_str[128];
avtext_print_section_header(tfc, "IAMF Submix Layout", SECTION_ID_STREAM_GROUP_PIECE);
@@ -2141,7 +2326,7 @@ static void print_iamf_mix_presentation_params(AVTextFormatContext *tfc, const A
print_str(annotation->key, annotation->value);
avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENT
}
for (int i = 0; i < mix_presentation->nb_submixes; i++)
for (unsigned i = 0; i < mix_presentation->nb_submixes; i++)
print_iamf_submix_params(tfc, mix_presentation->submixes[i]);
avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENTS
avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_COMPONENT
@@ -2163,7 +2348,7 @@ static int show_stream_group(AVTextFormatContext *tfc, InputFile *ifile, AVStrea
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
AVBPrint pbuf;
int i, ret = 0;
int ret = 0;
av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP);
@@ -2188,7 +2373,7 @@ static int show_stream_group(AVTextFormatContext *tfc, InputFile *ifile, AVStrea
goto end;
avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_STREAMS);
for (i = 0; i < stg->nb_streams; i++) {
for (unsigned i = 0; i < stg->nb_streams; i++) {
if (selected_streams[stg->streams[i]->index]) {
ret = show_stream(tfc, fmt_ctx, stg->streams[i]->index, &ifile->streams[stg->streams[i]->index], IN_STREAM_GROUP);
if (ret < 0)
@@ -2206,10 +2391,10 @@ end:
static int show_stream_groups(AVTextFormatContext *tfc, InputFile *ifile)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
int i, ret = 0;
int ret = 0;
avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUPS);
for (i = 0; i < fmt_ctx->nb_stream_groups; i++) {
for (unsigned i = 0; i < fmt_ctx->nb_stream_groups; i++) {
AVStreamGroup *stg = fmt_ctx->stream_groups[i];
ret = show_stream_group(tfc, ifile, stg);
@@ -2223,10 +2408,10 @@ static int show_stream_groups(AVTextFormatContext *tfc, InputFile *ifile)
static int show_chapters(AVTextFormatContext *tfc, InputFile *ifile)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
int i, ret = 0;
int ret = 0;
avtext_print_section_header(tfc, NULL, SECTION_ID_CHAPTERS);
for (i = 0; i < fmt_ctx->nb_chapters; i++) {
for (unsigned i = 0; i < fmt_ctx->nb_chapters; i++) {
AVChapter *chapter = fmt_ctx->chapters[i];
avtext_print_section_header(tfc, NULL, SECTION_ID_CHAPTER);
@@ -2284,10 +2469,69 @@ static void show_error(AVTextFormatContext *tfc, int err)
avtext_print_section_footer(tfc);
}
static int get_decoder_by_name(const char *codec_name, const AVCodec **codec)
{
if (codec_name == NULL)
return 0;
*codec = avcodec_find_decoder_by_name(codec_name);
if (*codec == NULL) {
av_log(NULL, AV_LOG_ERROR,
"No codec could be found with name '%s'\n", codec_name);
return AVERROR(EINVAL);
}
return 0;
}
static int set_decoders(AVFormatContext *fmt_ctx)
{
int ret;
#define GET_DECODER(type_) \
ret = get_decoder_by_name(type_##_codec_name, &fmt_ctx->type_##_codec); \
if (ret < 0) return ret;
GET_DECODER(audio);
GET_DECODER(data);
GET_DECODER(subtitle);
GET_DECODER(video);
return 0;
}
static const AVCodec *get_decoder_for_stream(AVFormatContext *fmt_ctx, AVStream *stream)
{
const AVCodec *codec = NULL;
switch (stream->codecpar->codec_type) {
case AVMEDIA_TYPE_VIDEO: codec = fmt_ctx->video_codec; break;
case AVMEDIA_TYPE_AUDIO: codec = fmt_ctx->audio_codec; break;
case AVMEDIA_TYPE_SUBTITLE: codec = fmt_ctx->subtitle_codec; break;
case AVMEDIA_TYPE_DATA: codec = fmt_ctx->data_codec; break;
}
if (codec != NULL)
return codec;
if (stream->codecpar->codec_id == AV_CODEC_ID_PROBE) {
av_log(NULL, AV_LOG_WARNING,
"Failed to probe codec for input stream %d\n", stream->index);
return NULL;
}
codec = avcodec_find_decoder(stream->codecpar->codec_id);
if (codec == NULL) {
av_log(NULL, AV_LOG_WARNING,
"Unsupported codec with id %d for input stream %d\n",
stream->codecpar->codec_id, stream->index);
return NULL;
}
return codec;
}
static int open_input_file(InputFile *ifile, const char *filename,
const char *print_filename)
{
int err, i;
int err;
AVFormatContext *fmt_ctx = NULL;
const AVDictionaryEntry *t = NULL;
int scan_all_pmts_set = 0;
@@ -2296,6 +2540,9 @@ static int open_input_file(InputFile *ifile, const char *filename,
if (!fmt_ctx)
return AVERROR(ENOMEM);
err = set_decoders(fmt_ctx);
if (err < 0)
return err;
if (!av_dict_get(format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
av_dict_set(&format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE);
scan_all_pmts_set = 1;
@@ -2325,7 +2572,7 @@ static int open_input_file(InputFile *ifile, const char *filename,
err = avformat_find_stream_info(fmt_ctx, opts);
for (i = 0; i < orig_nb_streams; i++)
for (int i = 0; i < orig_nb_streams; i++)
av_dict_free(&opts[i]);
av_freep(&opts);
@@ -2343,27 +2590,17 @@ static int open_input_file(InputFile *ifile, const char *filename,
ifile->nb_streams = fmt_ctx->nb_streams;
/* bind a decoder to each input stream */
for (i = 0; i < fmt_ctx->nb_streams; i++) {
for (unsigned i = 0; i < fmt_ctx->nb_streams; i++) {
InputStream *ist = &ifile->streams[i];
AVStream *stream = fmt_ctx->streams[i];
const AVCodec *codec;
ist->st = stream;
if (stream->codecpar->codec_id == AV_CODEC_ID_PROBE) {
av_log(NULL, AV_LOG_WARNING,
"Failed to probe codec for input stream %d\n",
stream->index);
codec = get_decoder_for_stream(fmt_ctx, stream);
if (!codec)
continue;
}
codec = avcodec_find_decoder(stream->codecpar->codec_id);
if (!codec) {
av_log(NULL, AV_LOG_WARNING,
"Unsupported codec with id %d for input stream %d\n",
stream->codecpar->codec_id, stream->index);
continue;
}
{
AVDictionary *opts;
@@ -2411,10 +2648,9 @@ static int open_input_file(InputFile *ifile, const char *filename,
static void close_input_file(InputFile *ifile)
{
int i;
/* close decoder for each stream */
for (i = 0; i < ifile->nb_streams; i++)
for (int i = 0; i < ifile->nb_streams; i++)
avcodec_free_context(&ifile->streams[i].dec_ctx);
av_freep(&ifile->streams);
@@ -2427,7 +2663,7 @@ static int probe_file(AVTextFormatContext *tfc, const char *filename,
const char *print_filename)
{
InputFile ifile = { 0 };
int ret, i;
int ret;
int section_id;
do_analyze_frames = do_analyze_frames && do_show_streams;
@@ -2447,7 +2683,7 @@ static int probe_file(AVTextFormatContext *tfc, const char *filename,
REALLOCZ_ARRAY_STREAM(streams_with_closed_captions,0,ifile.fmt_ctx->nb_streams);
REALLOCZ_ARRAY_STREAM(streams_with_film_grain,0,ifile.fmt_ctx->nb_streams);
for (i = 0; i < ifile.fmt_ctx->nb_streams; i++) {
for (unsigned i = 0; i < ifile.fmt_ctx->nb_streams; i++) {
if (stream_specifier) {
ret = avformat_match_stream_specifier(ifile.fmt_ctx,
ifile.fmt_ctx->streams[i],
@@ -2510,6 +2746,10 @@ end:
av_freep(&selected_streams);
av_freep(&streams_with_closed_captions);
av_freep(&streams_with_film_grain);
av_freep(&audio_codec_name);
av_freep(&data_codec_name);
av_freep(&subtitle_codec_name);
av_freep(&video_codec_name);
return ret;
}
@@ -2646,23 +2886,24 @@ static int opt_format(void *optctx, const char *opt, const char *arg)
static inline void mark_section_show_entries(SectionID section_id,
int show_all_entries, AVDictionary *entries)
{
struct AVTextFormatSection *section = &sections[section_id];
EntrySelection *selection = &selected_entries[section_id];
section->show_all_entries = show_all_entries;
selection->show_all_entries = show_all_entries;
if (show_all_entries) {
const AVTextFormatSection *section = &sections[section_id];
for (const int *id = section->children_ids; *id != -1; id++)
mark_section_show_entries(*id, show_all_entries, entries);
} else {
av_dict_copy(&section->entries_to_show, entries, 0);
av_dict_copy(&selection->entries_to_show, entries, 0);
}
}
static int match_section(const char *section_name,
int show_all_entries, AVDictionary *entries)
{
int i, ret = 0;
int ret = 0;
for (i = 0; i < FF_ARRAY_ELEMS(sections); i++) {
for (unsigned i = 0; i < FF_ARRAY_ELEMS(sections); i++) {
const struct AVTextFormatSection *section = &sections[i];
if (!strcmp(section_name, section->name) ||
(section->unique_name && !strcmp(section_name, section->unique_name))) {
@@ -2964,6 +3205,36 @@ static int opt_sections(void *optctx, const char *opt, const char *arg)
return 0;
}
static int opt_codec(void *optctx, const char *opt, const char *arg)
{
const char *spec = strchr(opt, ':');
const char **name;
if (!spec) {
av_log(NULL, AV_LOG_ERROR,
"No media specifier was specified for '%s' in option '%s'. Use -%s:<media_spec> "
"where <media_spec> can be one of: 'a' (audio), 'v' (video), 's' (subtitle), 'd' (data)\n",
arg, opt, opt);
return AVERROR(EINVAL);
}
spec++;
switch (spec[0]) {
case 'a' : name = &audio_codec_name; break;
case 'd' : name = &data_codec_name; break;
case 's' : name = &subtitle_codec_name; break;
case 'v' : name = &video_codec_name; break;
default:
av_log(NULL, AV_LOG_ERROR,
"Invalid media specifier '%s' in option '%s'. "
"Must be one of: 'a' (audio), 'v' (video), 's' (subtitle), 'd' (data)\n", spec, opt);
return AVERROR(EINVAL);
}
av_freep(name);
*name = av_strdup(arg);
return *name ? 0 : AVERROR(ENOMEM);
}
static int opt_show_versions(void *optctx, const char *opt, const char *arg)
{
mark_section_show_entries(SECTION_ID_PROGRAM_VERSION, 1, NULL);
@@ -3007,6 +3278,7 @@ static const OptionDef real_options[] = {
{ "of", OPT_TYPE_STRING, 0, { &output_format }, "alias for -output_format", "format" },
{ "select_streams", OPT_TYPE_STRING, 0, { &stream_specifier }, "select the specified streams", "stream_specifier" },
{ "sections", OPT_TYPE_FUNC, OPT_EXIT, {.func_arg = opt_sections}, "print sections structure and section information, and exit" },
{ "data_dump_format", OPT_TYPE_STRING, 0, { &data_dump_format }, "set data dump format (available formats are: xxd, base64)" },
{ "show_data", OPT_TYPE_BOOL, 0, { &do_show_data }, "show packets data" },
{ "show_data_hash", OPT_TYPE_STRING, 0, { &show_data_hash }, "show packets data hash" },
{ "show_error", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_error }, "show probing error" },
@@ -3039,14 +3311,19 @@ static const OptionDef real_options[] = {
{ "print_filename", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_print_filename}, "override the printed input filename", "print_file"},
{ "find_stream_info", OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT, { &find_stream_info },
"read and decode the streams to fill missing information with heuristics" },
{ "c", OPT_TYPE_FUNC, OPT_FUNC_ARG, { .func_arg = opt_codec}, "force decoder", "decoder_name" },
{ "codec", OPT_TYPE_FUNC, OPT_FUNC_ARG, { .func_arg = opt_codec}, "alias for -c (force decoder)", "decoder_name" },
{ NULL, },
};
static inline int check_section_show_entries(int section_id)
{
struct AVTextFormatSection *section = &sections[section_id];
if (sections[section_id].show_all_entries || sections[section_id].entries_to_show)
const EntrySelection *selection = &selected_entries[section_id];
if (selection->show_all_entries || selection->entries_to_show)
return 1;
const AVTextFormatSection *section = &sections[section_id];
for (const int *id = section->children_ids; *id != -1; id++)
if (check_section_show_entries(*id))
return 1;
@@ -3065,7 +3342,8 @@ int main(int argc, char **argv)
AVTextWriterContext *wctx;
char *buf;
char *f_name = NULL, *f_args = NULL;
int ret, input_ret, i;
int ret, input_ret;
AVTextFormatDataDump data_dump_format_id = AV_TEXTFORMAT_DATADUMP_XXD;
init_dynload();
@@ -3150,6 +3428,18 @@ int main(int argc, char **argv)
goto end;
}
if (data_dump_format) {
if (!strcmp(data_dump_format, "xxd")) {
data_dump_format_id = AV_TEXTFORMAT_DATADUMP_XXD;
} else if (!strcmp(data_dump_format, "base64")) {
data_dump_format_id = AV_TEXTFORMAT_DATADUMP_BASE64;
} else {
av_log(NULL, AV_LOG_ERROR, "Unknown data dump format with name '%s'\n", data_dump_format);
ret = AVERROR(EINVAL);
goto end;
}
}
if (output_filename) {
ret = avtextwriter_create_file(&wctx, output_filename);
} else
@@ -3159,11 +3449,13 @@ int main(int argc, char **argv)
goto end;
AVTextFormatOptions tf_options = {
.is_key_selected = is_key_selected_callback,
.show_optional_fields = show_optional_fields,
.show_value_unit = show_value_unit,
.use_value_prefix = use_value_prefix,
.use_byte_value_binary_prefix = use_byte_value_binary_prefix,
.use_value_sexagesimal_format = use_value_sexagesimal_format,
.data_dump_format = data_dump_format_id,
};
if ((ret = avtext_context_open(&tctx, f, wctx, f_args, sections, FF_ARRAY_ELEMS(sections), tf_options, show_data_hash)) >= 0) {
@@ -3215,8 +3507,8 @@ end:
av_freep(&read_intervals);
uninit_opts();
for (i = 0; i < FF_ARRAY_ELEMS(sections); i++)
av_dict_free(&(sections[i].entries_to_show));
for (size_t i = 0; i < FF_ARRAY_ELEMS(selected_entries); ++i)
av_dict_free(&selected_entries[i].entries_to_show);
avformat_network_deinit();
+9 -28
View File
@@ -33,6 +33,7 @@
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
#include "libavutil/dict.h"
#include "libavutil/common.h"
@@ -74,7 +75,7 @@ typedef enum {
SECTION_ID_ENCODER,
} SectionID;
static struct AVTextFormatSection sections[] = {
static const AVTextFormatSection sections[] = {
[SECTION_ID_ROOT] = { SECTION_ID_ROOT, "root", AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER, { SECTION_ID_FILTERGRAPHS, SECTION_ID_INPUTFILES, SECTION_ID_OUTPUTFILES, SECTION_ID_DECODERS, SECTION_ID_ENCODERS, SECTION_ID_STREAMLINKS, -1 } },
[SECTION_ID_FILTERGRAPHS] = { SECTION_ID_FILTERGRAPHS, "graphs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FILTERGRAPH, -1 } },
@@ -271,7 +272,7 @@ static void print_link(GraphPrintContext *gpc, AVFilterLink *link)
}
if (link->w && link->h) {
if (tfc->show_value_unit) {
if (tfc->opts.show_value_unit) {
print_fmt("size", "%dx%d", link->w, link->h);
} else {
print_int("width", link->w);
@@ -292,7 +293,7 @@ static void print_link(GraphPrintContext *gpc, AVFilterLink *link)
////print_str("format", av_x_if_null(av_get_subtitle_fmt_name(link->format), "?"));
if (link->w && link->h) {
if (tfc->show_value_unit) {
if (tfc->opts.show_value_unit) {
print_fmt("size", "%dx%d", link->w, link->h);
} else {
print_int("width", link->w);
@@ -306,7 +307,7 @@ static void print_link(GraphPrintContext *gpc, AVFilterLink *link)
av_channel_layout_describe(&link->ch_layout, layout_string, sizeof(layout_string));
print_str("channel_layout", layout_string);
print_val("channels", link->ch_layout.nb_channels, "ch");
if (tfc->show_value_unit)
if (tfc->opts.show_value_unit)
print_fmt("sample_rate", "%d.1 kHz", link->sample_rate / 1000);
else
print_val("sample_rate", link->sample_rate, "Hz");
@@ -470,12 +471,6 @@ static void print_filter(GraphPrintContext *gpc, const AVFilterContext *filter,
avtext_print_section_footer(tfc); // SECTION_ID_FILTER
}
static void init_sections(void)
{
for (unsigned i = 0; i < FF_ARRAY_ELEMS(sections); i++)
sections[i].show_all_entries = 1;
}
static void print_filtergraph_single(GraphPrintContext *gpc, FilterGraph *fg, AVFilterGraph *graph)
{
AVTextFormatContext *tfc = gpc->tfc;
@@ -876,7 +871,6 @@ static int init_graphprint(GraphPrintContext **pgpc, AVBPrint *target_buf)
GraphPrintContext *gpc = NULL;
int ret;
init_sections();
*pgpc = NULL;
av_bprint_init(target_buf, 0, AV_BPRINT_SIZE_UNLIMITED);
@@ -919,8 +913,8 @@ static int init_graphprint(GraphPrintContext **pgpc, AVBPrint *target_buf)
gpc->id_prefix_num = atomic_fetch_add(&prefix_num, 1);
gpc->is_diagram = !!(tfc->formatter->flags & AV_TEXTFORMAT_FLAG_IS_DIAGRAM_FORMATTER);
if (gpc->is_diagram) {
tfc->show_value_unit = 1;
tfc->show_optional_fields = -1;
tfc->opts.show_value_unit = 1;
tfc->opts.show_optional_fields = -1;
gpc->opt_flags = AV_TEXTFORMAT_PRINT_STRING_OPTIONAL;
gpc->skip_buffer_filters = 1;
////} else {
@@ -953,16 +947,13 @@ fail:
int print_filtergraph(FilterGraph *fg, AVFilterGraph *graph)
{
av_assert2(fg);
GraphPrintContext *gpc = NULL;
AVTextFormatContext *tfc;
AVBPrint *target_buf = &fg->graph_print_buf;
int ret;
if (!fg) {
av_log(NULL, AV_LOG_ERROR, "Invalid filter graph provided\n");
return AVERROR(EINVAL);
}
if (target_buf->len)
av_bprint_finalize(target_buf, NULL);
@@ -970,11 +961,6 @@ int print_filtergraph(FilterGraph *fg, AVFilterGraph *graph)
if (ret)
return ret;
if (!gpc) {
av_log(NULL, AV_LOG_ERROR, "Failed to initialize graph print context\n");
return AVERROR(ENOMEM);
}
tfc = gpc->tfc;
// Due to the threading model each graph needs to print itself into a buffer
@@ -1011,11 +997,6 @@ static int print_filtergraphs_priv(FilterGraph **graphs, int nb_graphs, InputFil
if (ret)
goto cleanup;
if (!gpc) {
ret = AVERROR(ENOMEM);
goto cleanup;
}
tfc = gpc->tfc;
avtext_print_section_header(tfc, NULL, SECTION_ID_ROOT);
+19 -12
View File
@@ -23,6 +23,7 @@
#include <stdio.h>
#include "cmdutils.h"
#include "fopen_utf8.h"
#include "opt_common.h"
#include "libavutil/avassert.h"
@@ -67,6 +68,11 @@ enum show_muxdemuxers {
SHOW_MUXERS,
};
enum show_codec {
SHOW_DECODER,
SHOW_ENCODER,
};
static FILE *report_file;
static int report_file_level = AV_LOG_DEBUG;
@@ -590,9 +596,9 @@ int show_help(void *optctx, const char *opt, const char *arg)
if (!*topic) {
show_help_default(topic, par);
} else if (!strcmp(topic, "decoder")) {
show_help_codec(par, 0);
show_help_codec(par, SHOW_DECODER);
} else if (!strcmp(topic, "encoder")) {
show_help_codec(par, 1);
show_help_codec(par, SHOW_ENCODER);
} else if (!strcmp(topic, "demuxer")) {
show_help_demuxer(par);
} else if (!strcmp(topic, "muxer")) {
@@ -707,16 +713,16 @@ int show_codecs(void *optctx, const char *opt, const char *arg)
/* print decoders/encoders when there's more than one or their
* names are different from codec name */
while ((codec = next_codec_for_id(desc->id, &iter, 0))) {
while ((codec = next_codec_for_id(desc->id, &iter, SHOW_DECODER))) {
if (strcmp(codec->name, desc->name)) {
print_codecs_for_id(desc->id, 0);
print_codecs_for_id(desc->id, SHOW_DECODER);
break;
}
}
iter = NULL;
while ((codec = next_codec_for_id(desc->id, &iter, 1))) {
while ((codec = next_codec_for_id(desc->id, &iter, SHOW_ENCODER))) {
if (strcmp(codec->name, desc->name)) {
print_codecs_for_id(desc->id, 1);
print_codecs_for_id(desc->id, SHOW_ENCODER);
break;
}
}
@@ -773,12 +779,12 @@ static int print_codecs(int encoder)
int show_decoders(void *optctx, const char *opt, const char *arg)
{
return print_codecs(0);
return print_codecs(SHOW_DECODER);
}
int show_encoders(void *optctx, const char *opt, const char *arg)
{
return print_codecs(1);
return print_codecs(SHOW_ENCODER);
}
int show_bsfs(void *optctx, const char *opt, const char *arg)
@@ -808,7 +814,8 @@ int show_filters(void *optctx, const char *opt, const char *arg)
" A = Audio input/output\n"
" V = Video input/output\n"
" N = Dynamic number and/or type of input/output\n"
" | = Source or sink filter\n");
" | = Source or sink filter\n"
" ------\n");
while ((filter = av_filter_iterate(&opaque))) {
descr_cur = descr;
for (i = 0; i < 2; i++) {
@@ -874,7 +881,7 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
const char *name = NULL;
const char *long_name = NULL;
if (muxdemuxers !=SHOW_DEMUXERS) {
if (muxdemuxers != SHOW_DEMUXERS) {
ofmt_opaque = NULL;
while ((ofmt = av_muxer_iterate(&ofmt_opaque))) {
is_dev = is_device(ofmt->priv_class);
@@ -990,7 +997,7 @@ int show_pix_fmts(void *optctx, const char *opt, const char *arg)
#endif
while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
enum AVPixelFormat av_unused pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
av_unused enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
printf("%c%c%c%c%c %-16s %d %3d %d",
sws_isSupportedInput (pix_fmt) ? 'I' : '.',
sws_isSupportedOutput(pix_fmt) ? 'O' : '.',
@@ -1204,7 +1211,7 @@ int init_report(const char *env, FILE **file)
if (!envlevel)
report_file_level = FFMAX(report_file_level, prog_loglevel);
report_file = fopen(filename.str, "w");
report_file = fopen_utf8(filename.str, "w");
if (!report_file) {
int ret = AVERROR(errno);
av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n",
+3 -2
View File
@@ -41,9 +41,9 @@ int show_sources(void *optctx, const char *opt, const char *arg);
#if CONFIG_AVDEVICE
#define CMDUTILS_COMMON_OPTIONS_AVDEVICE \
{ "sources" , OPT_TYPE_FUNC, OPT_EXIT | OPT_FUNC_ARG | OPT_EXPERT, { .func_arg = show_sources }, \
{ "sources" , OPT_TYPE_FUNC, OPT_EXIT | OPT_EXPERT, { .func_arg = show_sources }, \
"list sources of the input device", "device" }, \
{ "sinks" , OPT_TYPE_FUNC, OPT_EXIT | OPT_FUNC_ARG | OPT_EXPERT, { .func_arg = show_sinks }, \
{ "sinks" , OPT_TYPE_FUNC, OPT_EXIT | OPT_EXPERT, { .func_arg = show_sinks }, \
"list sinks of the output device", "device" }, \
#else
@@ -198,6 +198,7 @@ int opt_cpucount(void *optctx, const char *opt, const char *arg);
#define CMDUTILS_COMMON_OPTIONS \
{ "L", OPT_TYPE_FUNC, OPT_EXIT, { .func_arg = show_license }, "show license" }, \
{ "license", OPT_TYPE_FUNC, OPT_EXIT, { .func_arg = show_license }, "show license" }, \
{ "h", OPT_TYPE_FUNC, OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
{ "?", OPT_TYPE_FUNC, OPT_EXIT | OPT_EXPERT, { .func_arg = show_help }, "show help", "topic" }, \
{ "help", OPT_TYPE_FUNC, OPT_EXIT | OPT_EXPERT, { .func_arg = show_help }, "show help", "topic" }, \
+2 -3
View File
@@ -1,6 +1,5 @@
*.html.c
*.css.c
*.html.gz
*.css.gz
*.min
*.min.gz
*.css.min
*.css.min.gz
+9 -3
View File
@@ -4,10 +4,16 @@ clean::
vpath %.html $(SRC_PATH)
vpath %.css $(SRC_PATH)
# Uncomment to prevent deletion during build
#.PRECIOUS: %.css.c %.css.min %.css.gz %.css.min.gz %.html.gz %.html.c
OBJS-resman += \
fftools/resources/resman.o \
RESOBJS += \
fftools/resources/graph.html.o \
fftools/resources/graph.css.o \
$(RESOBJS): CCDEP =
$(RESOBJS): CC_DEPFLAGS =
.SECONDARY: $(RESOBJS:.o=.gz) $(RESOBJS:.o=.c) $(RESOBJS:%.css.o=%.css.min) $(RESOBJS:%.css.o=%.css.min.gz) $(RESOBJS:%.html.o=%.html.gz) $(RESOBJS:.o=)
+60 -68
View File
@@ -26,6 +26,7 @@
#include "libavutil/mem.h"
#include "libavutil/avassert.h"
#include "libavutil/base64.h"
#include "libavutil/bprint.h"
#include "libavutil/error.h"
#include "libavutil/hash.h"
@@ -147,11 +148,7 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form
goto fail;
}
tctx->show_value_unit = options.show_value_unit;
tctx->use_value_prefix = options.use_value_prefix;
tctx->use_byte_value_binary_prefix = options.use_byte_value_binary_prefix;
tctx->use_value_sexagesimal_format = options.use_value_sexagesimal_format;
tctx->show_optional_fields = options.show_optional_fields;
tctx->opts = options;
if (nb_sections > SECTION_MAX_NB_SECTIONS) {
av_log(tctx, AV_LOG_ERROR, "The number of section definitions (%d) is larger than the maximum allowed (%d)\n", nb_sections, SECTION_MAX_NB_SECTIONS);
@@ -289,23 +286,19 @@ void avtext_print_section_footer(AVTextFormatContext *tctx)
void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags)
{
const AVTextFormatSection *section;
av_assert0(tctx);
if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
if (tctx->opts.show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
return;
if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
if (tctx->opts.show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
&& (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
&& !(tctx->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS))
return;
av_assert0(key && tctx->level >= 0 && tctx->level < SECTION_MAX_NB_LEVELS);
section = tctx->section[tctx->level];
if (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) {
if (!tctx->opts.is_key_selected || tctx->opts.is_key_selected(tctx, key)) {
tctx->formatter->print_integer(tctx, key, val);
tctx->nb_item[tctx->level]++;
}
@@ -391,7 +384,7 @@ static char *value_string(const AVTextFormatContext *tctx, char *buf, int buf_si
vali = uv.val.i;
}
if (uv.unit == unit_second_str && tctx->use_value_sexagesimal_format) {
if (uv.unit == unit_second_str && tctx->opts.use_value_sexagesimal_format) {
double secs;
int hours, mins;
secs = vald;
@@ -403,10 +396,10 @@ static char *value_string(const AVTextFormatContext *tctx, char *buf, int buf_si
} else {
const char *prefix_string = "";
if (tctx->use_value_prefix && vald > 1) {
if (tctx->opts.use_value_prefix && vald > 1) {
int64_t index;
if (uv.unit == unit_byte_str && tctx->use_byte_value_binary_prefix) {
if (uv.unit == unit_byte_str && tctx->opts.use_byte_value_binary_prefix) {
index = (int64_t)(log2(vald) / 10);
index = av_clip64(index, 0, FF_ARRAY_ELEMS(si_prefixes) - 1);
vald /= si_prefixes[index].bin_val;
@@ -420,13 +413,13 @@ static char *value_string(const AVTextFormatContext *tctx, char *buf, int buf_si
vali = (int64_t)vald;
}
if (show_float || (tctx->use_value_prefix && vald != (int64_t)vald))
if (show_float || (tctx->opts.use_value_prefix && vald != (int64_t)vald))
snprintf(buf, buf_size, "%f", vald);
else
snprintf(buf, buf_size, "%"PRId64, vali);
av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || tctx->show_value_unit ? " " : "",
prefix_string, tctx->show_value_unit ? uv.unit : "");
av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || tctx->opts.show_value_unit ? " " : "",
prefix_string, tctx->opts.show_value_unit ? uv.unit : "");
}
return buf;
@@ -452,15 +445,15 @@ int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *
section = tctx->section[tctx->level];
if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
if (tctx->opts.show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
return 0;
if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
if (tctx->opts.show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
&& (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
&& !(tctx->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS))
return 0;
if (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) {
if (!tctx->opts.is_key_selected || tctx->opts.is_key_selected(tctx, key)) {
if (flags & AV_TEXTFORMAT_PRINT_STRING_VALIDATE) {
char *key1 = NULL, *val1 = NULL;
ret = validate_string(tctx, &key1, key);
@@ -516,30 +509,57 @@ void avtext_print_ts(AVTextFormatContext *tctx, const char *key, int64_t ts, int
avtext_print_integer(tctx, key, ts, 0);
}
static void print_data_xxd(AVBPrint *bp, const uint8_t *data, int size)
{
unsigned offset = 0;
int i;
av_bprintf(bp, "\n");
while (size) {
av_bprintf(bp, "%08x: ", offset);
int l = FFMIN(size, 16);
for (i = 0; i < l; i++) {
av_bprintf(bp, "%02x", data[i]);
if (i & 1)
av_bprintf(bp, " ");
}
av_bprint_chars(bp, ' ', 41 - 2 * i - i / 2);
for (i = 0; i < l; i++)
av_bprint_chars(bp, data[i] - 32U < 95 ? data[i] : '.', 1);
av_bprintf(bp, "\n");
offset += l;
data += l;
size -= l;
}
}
static void print_data_base64(AVBPrint *bp, const uint8_t *data, int size)
{
char buf[AV_BASE64_SIZE(60)];
av_bprintf(bp, "\n");
while (size) {
int l = FFMIN(size, 60);
av_base64_encode(buf, sizeof(buf), data, l);
av_bprintf(bp, "%s\n", buf);
data += l;
size -= l;
}
}
void avtext_print_data(AVTextFormatContext *tctx, const char *key,
const uint8_t *data, int size)
{
AVBPrint bp;
unsigned offset = 0;
int i;
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
av_bprintf(&bp, "\n");
while (size) {
av_bprintf(&bp, "%08x: ", offset);
int l = FFMIN(size, 16);
for (i = 0; i < l; i++) {
av_bprintf(&bp, "%02x", data[i]);
if (i & 1)
av_bprintf(&bp, " ");
}
av_bprint_chars(&bp, ' ', 41 - 2 * i - i / 2);
for (i = 0; i < l; i++)
av_bprint_chars(&bp, data[i] - 32U < 95 ? data[i] : '.', 1);
av_bprintf(&bp, "\n");
offset += l;
data += l;
size -= l;
switch (tctx->opts.data_dump_format) {
case AV_TEXTFORMAT_DATADUMP_XXD:
print_data_xxd(&bp, data, size);
break;
case AV_TEXTFORMAT_DATADUMP_BASE64:
print_data_base64(&bp, data, size);
break;
default:
av_unreachable("Invalid data dump type");
}
avtext_print_string(tctx, key, bp.str, 0);
av_bprint_finalize(&bp, NULL);
@@ -561,34 +581,6 @@ void avtext_print_data_hash(AVTextFormatContext *tctx, const char *key,
avtext_print_string(tctx, key, buf, 0);
}
void avtext_print_integers(AVTextFormatContext *tctx, const char *key,
uint8_t *data, int size, const char *format,
int columns, int bytes, int offset_add)
{
AVBPrint bp;
unsigned offset = 0;
if (!key || !data || !format || columns <= 0 || bytes <= 0)
return;
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
av_bprintf(&bp, "\n");
while (size) {
av_bprintf(&bp, "%08x: ", offset);
for (int i = 0, l = FFMIN(size, columns); i < l; i++) {
if (bytes == 1) av_bprintf(&bp, format, *data);
else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data));
else if (bytes == 4) av_bprintf(&bp, format, AV_RN32(data));
data += bytes;
size--;
}
av_bprintf(&bp, "\n");
offset += offset_add;
}
avtext_print_string(tctx, key, bp.str, 0);
av_bprint_finalize(&bp, NULL);
}
static const char *writercontext_get_writer_name(void *p)
{
AVTextWriterContext *wctx = p;
+24 -18
View File
@@ -57,9 +57,7 @@ typedef struct AVTextFormatSection {
const int children_ids[SECTION_MAX_NB_CHILDREN + 1]; ///< list of children section IDS, terminated by -1
const char *element_name; ///< name of the contained element, if provided
const char *unique_name; ///< unique section name, in case the name is ambiguous
AVDictionary *entries_to_show;
const char *(*get_type)(const void *data); ///< function returning a type if defined, must be defined when SECTION_FLAG_HAS_TYPE is defined
int show_all_entries;
const char *id_key; ///< name of the key to be used as the id
const char *src_id_key; ///< name of the key to be used as the source id for diagram connections
const char *dest_id_key; ///< name of the key to be used as the target id for diagram connections
@@ -91,6 +89,11 @@ typedef enum {
AV_TEXTFORMAT_LINKTYPE_MANYTOMANY = AV_TEXTFORMAT_LINKTYPE_NONDIR,
} AVTextFormatLinkType;
typedef enum {
AV_TEXTFORMAT_DATADUMP_XXD,
AV_TEXTFORMAT_DATADUMP_BASE64,
} AVTextFormatDataDump;
typedef struct AVTextFormatter {
const AVClass *priv_class; ///< private class of the formatter, if any
int priv_size; ///< private size for the formatter context
@@ -109,6 +112,24 @@ typedef struct AVTextFormatter {
#define SECTION_MAX_NB_LEVELS 12
#define SECTION_MAX_NB_SECTIONS 100
typedef struct AVTextFormatOptions {
/**
* Callback to discard certain elements based upon the key used.
* It is called before any element with a key is printed.
* If this callback is unset, all elements are printed.
*
* @retval 1 if the element is supposed to be printed
* @retval 0 if the element is supposed to be discarded
*/
int (*is_key_selected)(struct AVTextFormatContext *tctx, const char *key);
int show_optional_fields;
int show_value_unit;
int use_value_prefix;
int use_byte_value_binary_prefix;
int use_value_sexagesimal_format;
AVTextFormatDataDump data_dump_format;
} AVTextFormatOptions;
struct AVTextFormatContext {
const AVClass *class; ///< class of the formatter
const AVTextFormatter *formatter; ///< the AVTextFormatter of which this is an instance
@@ -131,11 +152,7 @@ struct AVTextFormatContext {
AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]; ///< generic print buffer dedicated to each section,
/// used by various formatters
int show_optional_fields;
int show_value_unit;
int use_value_prefix;
int use_byte_value_binary_prefix;
int use_value_sexagesimal_format;
AVTextFormatOptions opts;
struct AVHashContext *hash;
@@ -144,14 +161,6 @@ struct AVTextFormatContext {
unsigned int string_validation_utf8_flags;
};
typedef struct AVTextFormatOptions {
int show_optional_fields;
int show_value_unit;
int use_value_prefix;
int use_byte_value_binary_prefix;
int use_value_sexagesimal_format;
} AVTextFormatOptions;
#define AV_TEXTFORMAT_PRINT_STRING_OPTIONAL 1
#define AV_TEXTFORMAT_PRINT_STRING_VALIDATE 2
@@ -181,9 +190,6 @@ void avtext_print_data(AVTextFormatContext *tctx, const char *key, const uint8_t
void avtext_print_data_hash(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size);
void avtext_print_integers(AVTextFormatContext *tctx, const char *key, uint8_t *data, int size,
const char *format, int columns, int bytes, int offset_add);
const AVTextFormatter *avtext_get_formatter_by_name(const char *name);
extern const AVTextFormatter avtextformatter_default;
+2 -1
View File
@@ -26,6 +26,7 @@
#include "avtextformat.h"
#include "libavutil/attributes.h"
#include "libavutil/bprint.h"
#include "libavutil/opt.h"
#include "tf_internal.h"
@@ -74,7 +75,7 @@ static char *ini_escape_str(AVBPrint *dst, const char *src)
case '=':
case ':':
av_bprint_chars(dst, '\\', 1);
/* fallthrough */
av_fallthrough;
default:
if ((unsigned char)c < 32)
av_bprintf(dst, "\\x00%02x", (unsigned char)c);
+20 -17
View File
@@ -27,10 +27,9 @@
#include "avtextformat.h"
#include "tf_internal.h"
#include "tf_mermaid.h"
#include <libavutil/mem.h>
#include <libavutil/avassert.h>
#include <libavutil/bprint.h>
#include <libavutil/opt.h>
#include "libavutil/bprint.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
static const char *init_directive = ""
@@ -241,6 +240,20 @@ static void set_str(const char **dst, const char *src)
*dst = av_strdup(src);
}
static void mermaid_subgraph_complete_start(MermaidContext *mmc, AVTextFormatContext *tfc, int level) {
struct section_data parent_sec_data = mmc->section_data[level];
AVBPrint *parent_buf = &tfc->section_pbuf[level];
if (parent_sec_data.subgraph_start_incomplete) {
if (parent_buf->len > 0)
writer_printf(tfc, "%s", parent_buf->str);
writer_put_str(tfc, "</div>\"]\n");
mmc->section_data[level].subgraph_start_incomplete = 0;
}
}
#define MM_INDENT() writer_printf(tfc, "%*c", mmc->indent_level * 2, ' ')
static void mermaid_print_section_header(AVTextFormatContext *tfc, const void *data)
@@ -297,19 +310,7 @@ static void mermaid_print_section_header(AVTextFormatContext *tfc, const void *d
}
if (parent_section && parent_section->flags & AV_TEXTFORMAT_SECTION_FLAG_IS_SUBGRAPH) {
struct section_data parent_sec_data = mmc->section_data[tfc->level - 1];
AVBPrint *parent_buf = &tfc->section_pbuf[tfc->level - 1];
if (parent_sec_data.subgraph_start_incomplete) {
if (parent_buf->len > 0)
writer_printf(tfc, "%s", parent_buf->str);
writer_put_str(tfc, "</div>\"]\n");
mmc->section_data[tfc->level - 1].subgraph_start_incomplete = 0;
}
mermaid_subgraph_complete_start(mmc, tfc, tfc->level - 1);
}
av_freep(&mmc->section_data[tfc->level].section_id);
@@ -455,6 +456,8 @@ static void mermaid_print_section_footer(AVTextFormatContext *tfc)
} else if ((section->flags & AV_TEXTFORMAT_SECTION_FLAG_IS_SUBGRAPH)) {
mermaid_subgraph_complete_start(mmc, tfc, tfc->level);
MM_INDENT();
writer_put_str(tfc, "end\n");
+2 -2
View File
@@ -64,8 +64,8 @@ static av_cold int xml_init(AVTextFormatContext *wctx)
return AVERROR(EINVAL); \
}
////CHECK_COMPLIANCE(show_private_data, "private");
CHECK_COMPLIANCE(wctx->show_value_unit, "unit");
CHECK_COMPLIANCE(wctx->use_value_prefix, "prefix");
CHECK_COMPLIANCE(wctx->opts.show_value_unit, "unit");
CHECK_COMPLIANCE(wctx->opts.use_value_prefix, "prefix");
}
return 0;
+17
View File
@@ -38,6 +38,7 @@ enum {
};
struct ThreadQueue {
int choked;
int *finished;
unsigned int nb_streams;
@@ -157,6 +158,9 @@ static int receive_locked(ThreadQueue *tq, int *stream_idx,
{
unsigned int nb_finished = 0;
if (tq->choked)
return AVERROR(EAGAIN);
while (av_container_fifo_read(tq->fifo, data, 0) >= 0) {
unsigned idx;
int ret;
@@ -230,6 +234,7 @@ void tq_send_finish(ThreadQueue *tq, unsigned int stream_idx)
* next time the consumer thread tries to read this stream it will get
* an EOF and recv-finished flag will be set */
tq->finished[stream_idx] |= FINISHED_SEND;
tq->choked = 0;
pthread_cond_broadcast(&tq->cond);
pthread_mutex_unlock(&tq->lock);
@@ -249,3 +254,15 @@ void tq_receive_finish(ThreadQueue *tq, unsigned int stream_idx)
pthread_mutex_unlock(&tq->lock);
}
void tq_choke(ThreadQueue *tq, int choked)
{
pthread_mutex_lock(&tq->lock);
int prev_choked = tq->choked;
tq->choked = choked;
if (choked != prev_choked)
pthread_cond_broadcast(&tq->cond);
pthread_mutex_unlock(&tq->lock);
}

Some files were not shown because too many files have changed in this diff Show More