Commit graph

6766 commits

Author SHA1 Message Date
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
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
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
a0d4c07b86 tests/checkasm: add test for png
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-04 12:05:35 +08: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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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