Commit Graph

122133 Commits

Author SHA1 Message Date
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] ff3f3a54e2
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