1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2026-06-19 19:03:00 +02:00
Commit Graph

125102 Commits

Author SHA1 Message Date
James Almer 62731e05ab avformat/mov: don't assume a sample to be the last in fragmented input
Both the seek index and the stream duration are constantly being updated as
trun boxes are read.

Fixes mpv issue 18149.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-18 13:46:54 -03:00
Ramiro Polla 10e9f273ee swscale/uops: relax detection of exact computations in linear
The first computation in a linear row doesn't have anything to
accumulate to, so a multiply-accumulate instruction won't be used
either way. This led to identical functions being instantiated for
different params.
2026-06-18 14:50:45 +00:00
Ramiro Polla 80cd1a4361 swscale/uops: skip offset from unity detection for linear
There is no easy optimization that can be triggered by knowing that the
offset is exactly 1. This led to identical functions being instantiated
for different params.
2026-06-18 14:50:45 +00:00
Ramiro Polla 3c6c6388b0 swscale/aarch64/ops: skip filtering ops lists when generating ops_entries.c
sws_ops_aarch64 would still register operations that came before the
filtering ops (which are unsupported).
2026-06-18 14:50:13 +00:00
Ramiro Polla d0313ea2c2 swscale/aarch64/ops: convert single-component packed read/write to planar
b488ee55 relaxed the check and stopped taking the number of components
into account. This led to the generation of duplicate read/write
functions for single component packed/planar.

ops_entries.c wasn't regenerated to take this into account; instead
some conversions were no longer being supported for the neon backend.
2026-06-18 14:50:13 +00:00
Andreas Rheinhardt ea9c361a7b avcodec/snow: Don't override fpel hdsp function
The functions do the same, yet the dedicated functions
from hpeldsp are more optimized.
(Notice that the motion estimation code only uses
aligned scratchpad buffers as destination when using
hdsp functions, so Snow-specific functions with relaxed
alignment like for the me-cmp API are not necessary.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-18 16:05:30 +02:00
James Almer 364d309af8 avcodec/liboapvenc: fix compilation
Rebase conflict gone wrong.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-18 11:00:40 -03:00
Dawid Kozinski 5942e4e900 avcodec/liboapvenc: Added support for mastering display color volume and content light level metadata 2026-06-18 09:54:51 -03:00
James Almer d2d371d10d Reapply "fate/aac: add xHE-AAC decode and loudness normalization tests"
This reverts commit ee39fe499f.

The failing test is a duplicate test looking for a sample in the wrong folder.
2026-06-18 09:23:16 -03:00
Michael Niedermayer c098b07035 avformat/movenc: initialize all tracks
Fixes: NULL pointer dereference

As a sideeffect this also sets the timescale correctly if an
intermediate matches MOV_TIMESCALE_Q, the previous code stoped
in that case as it could not distinguish it from the overflow detection

Regression since: 51f5f60443

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-18 12:04:39 +00:00
Jun Zhao dd6ae3e024 .forgejo/pre-commit: add local commit-msg hook
Register check_commit_msg.sh as a commit-msg stage hook in the
pre-commit configuration so developers get immediate feedback
on commit message format during `git commit`.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-18 10:35:27 +00:00
Jun Zhao 4394a36c6b tools/check_commit_msg: add commit message validation script
Add a shell script that validates commit messages against FFmpeg
conventions.  Based on the lint_commit_msg.py checker from mpv
(Kacper Michajłow, Timo Rothenpieler).

Supports three entry points: stdin (for CI pipelines), file
argument (for pre-commit commit-msg hook), and revision range
(for manual batch checking).

Checks enforced (errors block):
  - Subject matches "component[/module]: description" pattern
  - No conventional-commits style (feat:/fix:/chore:/refactor:)
  - Blank line between subject and body
  - No duplicate Signed-off-by from same person
  - No multiple subject-like lines in body (squash-mess detection)

Checks that only warn:
  - Subject line > 120 characters
  - Trailing whitespace on subject line
  - Subject should not end with a period
  - Prefix should not contain file extension (.c, .h, etc.)

Merge, Revert and Reapply subjects are exempted from format checks.

Usage:
  echo "avcodec/vvc: fix pred" | sh tools/check_commit_msg.sh
  sh tools/check_commit_msg.sh .git/COMMIT_EDITMSG
  sh tools/check_commit_msg.sh HEAD~5..HEAD

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-18 10:35:27 +00:00
Andreas Rheinhardt f760b2fb67 avcodec/x86/cavsdsp: Combine #if blocks, avoid av_unused
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-17 23:05:23 +02:00
Andreas Rheinhardt 087f25c2ab avcodec/x86/rv40dsp_init: Remove pointless av_unused
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-17 23:05:23 +02:00
Andreas Rheinhardt 2a46d30855 avcodec/x86/hpeldsp: Remove declaration of non-existing func
Forgotten in a51279bbde.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-17 23:05:23 +02:00
Romain Beauxis e8cfe912f4 avformat/hls: Also report stream-level metadata update. 2026-06-17 15:39:33 -05:00
Steve Lhomme b441d97486 configure: use -ldl with AMF if necessary
It uses dlopen(). On some systems that requires to link with libdl.so.

Co-authored-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-17 14:39:56 +00:00
Andreas Rheinhardt eb7f4b4e79 avcodec/x86/h264_intrapred: Add AVX2 horizontal pred versions
pred8x8_horizontal_8_c:                   6.9
pred8x8_horizontal_8_sse2:                9.9 ( 0.70x)
pred8x8_horizontal_8_ssse3:               9.5 ( 0.73x)
pred8x8_horizontal_8_avx2:                5.1 ( 1.35x)

pred16x16_horizontal_8_c:                10.9
pred16x16_horizontal_8_sse2:             15.0 ( 0.72x)
pred16x16_horizontal_8_ssse3:            11.7 ( 0.93x)
pred16x16_horizontal_8_avx2:              9.6 ( 1.13x)

The new functions are cheap and only occupy 2*48B.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-17 14:33:28 +02:00
Andreas Rheinhardt 93412ff602 avcodec/x86/h264_intrapred: Avoid reg-reg moves
Possible if src of the PRED4x4_LOWPASS macro is not used lateron.
Saves 195B of .text here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-17 14:33:28 +02:00
Dmitrii Gershenkop 485f195690 avutil/hwcontext_amf: Implement AMF hardware memory mapping support. 2026-06-17 12:30:56 +00:00
Zhao Zhili 5c2f9899df avformat/matroskaenc: fix error code on LCEVC payload allocation failure
The branch returned the ret variable when av_malloc() failed, but ret
is uninitialized at that point unless an earlier branch happened to
set it.
2026-06-17 11:11:18 +00:00
Lynne ee39fe499f Revert "fate/aac: add xHE-AAC decode and loudness normalization tests"
This reverts commit dae76b2cb1.
2026-06-17 18:01:18 +09:00
Lynne dae76b2cb1 fate/aac: add xHE-AAC decode and loudness normalization tests
Frequency-domain mono/stereo decoding at several sampling rates, M/S,
TNS, and target_level-based loudness normalization, compared against
the reference decoder output of the ISO/IEC 23003-3 conformance
sequences (at -16, -24 and -31 dB targets driven by loudnessInfoV1
metadata), plus an exhale-encoded stream carrying v0 loudnessInfo().
2026-06-17 17:34:27 +09:00
Lynne a51ec04adf aacdec_usac: parse loudnessInfoV1
Real-world xHE-AAC streams and the ISO/IEC 23003-3 conformance
sequences carry their loudness metadata exclusively as loudnessInfoV1()
inside loudnessInfoSetExtension(), which was previously rejected with
AVERROR_PATCHWELCOME, making such streams undecodable and loudness
normalization inoperative on them.

loudnessInfoV1() is identical to loudnessInfo() apart from an added
eqSetId field. Parse it, restrict measurement selection to
eqSetId == 0 (in line with the downmixId/drcSetId restrictions), and
skip unknown loudnessInfoSetExtension() payloads using their explicitly
coded size instead of erroring out.
2026-06-17 17:34:24 +09:00
Hunter Kvalevog 8f970a24d5 configure: add pkg-config check for libtheora
This allows libtheora to be found via pkg-config in addition to the
existing approach.

Signed-off-by: Hunter Kvalevog <hunter@kvog.sh>
2026-06-17 02:31:43 +00:00
Michael Niedermayer a554d0aa8a swscale/aarch64: fix uyvy/yuyv to yuv420p/yuv422p on odd width
interleaved_yuv_to_planar, shared by uyvytoyuv422, uyvytoyuv420,
yuyvtoyuv422 and yuyvtoyuv420, only handled even widths. The packed
UYVY/YUYV macroblocks are pixel pairs and the trailing half macroblock of
an odd width was mishandled:

- the slow path (width <= 31) decrements its pixel counter by two from an
  odd value, so it never reaches zero and the loop runs far past the line,
  overwriting the destination (observed as a crash in checkasm);
- the fast path (width >= 32) shifts the tail pointers back by width-32 and
  reprocesses an overlapping, misaligned tuple, producing wrong samples and
  dropping the last chroma column.

Process only whole pixel pairs and emit the trailing odd column from a
per-line epilogue that matches the C reference: for yuv422 one Y, U and V
sample; for yuv420 the Y of both lines of the pair with the chroma averaged
across them, and luma only for the final line when the height is odd. The
empty even part (width 0 or 1) is guarded so the slow path no longer enters
its run-past loop.

All four variants are now bit-exact with the C reference for even and odd
widths. Verified with checkasm under qemu-aarch64.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 02:40:59 +02:00
Michael Niedermayer 21782b7b31 swscale/x86/rgb_2_rgb: fix uyvytoyuv422 overwrite on odd width
uyvytoyuv422 converts packed UYVY, whose macroblocks are pixel pairs, and
the SIMD code only handled even widths. On an odd width the trailing half
macroblock made the kernel write past the end of the Y/U/V destinations:
the AVX512ICL masked tail dropped the odd pixel and the fall-through
re-entered the SIMD loop, writing a full mmsize*2 chunk past the planes
(127 bytes of Y, 63 of U and 63 of V); the sse2/avx/avx2 scalar tail
wrote one byte past the Y plane.

Process only whole pairs and emit the trailing odd column from a small
per-row epilogue that matches uyvytoyuv422_c (ydst[w-1] = src[2w-1],
udst[cw-1] = src[2w-2], vdst[cw-1] = src[2w]).

All four SIMD variants are now bit-exact with the C reference for even and
odd widths and no longer overwrite the destination. Verified on AVX512ICL
hardware (Ryzen 9 9950X) with checkasm.

Found-by: Claude (Anthropic). Human-verified and reported by Omkhar Arasaratnam <omkhar@linkedin.com>.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 02:40:59 +02:00
Michael Niedermayer d67a6d27c2 avcodec/snowenc: fix chroma reference edge extension for odd width
When extending the edges of the reconstructed reference frame, the chroma
plane width and height were passed to draw_edges() as w >> chroma_h_shift
(floor) instead of AV_CEIL_RSHIFT(). For an odd width with subsampled chroma
(e.g. 4:2:0) the chroma plane is one column wider than the floor, and
draw_edges() replicates the edge columns, so it overwrote the last real
chroma column with the previous one. The decoder does not draw_edges() its
reference, so its copy kept the correct value: the encoder and decoder
references diverged and every following inter frame was reconstructed
differently by the two, breaking bit-exact (lossless) round-tripping and
drifting lossy inter coding, for any odd-width 4:2:0 snow stream.

Use AV_CEIL_RSHIFT(), matching the input_picture edge extension just above.

Found-by: Claude
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 02:27:33 +02:00
Bogdan Lisman a62d996927 avcodec/snowenc: fix SIGFPE in get_dc() when a block lies outside the plane
get_dc() divides the accumulated, OBMC-weighted DC by aa, the sum of the
squared OBMC weights taken over the in-plane pixels.  When an OBMC block
falls entirely outside the plane - e.g. a tiny chroma plane after mcdeint
splits a frame into fields - no pixel contributes, aa stays 0 and the
ROUNDED_DIV() divides by zero (SIGFPE).  ab is 0 in exactly the same case,
so the result degenerates to 0; return it directly.

Reproducible with the GPL mcdeint filter in slow/extra_slow mode, e.g.

    ffmpeg -f lavfi -i testsrc=s=128x2 -vf mcdeint=mode=slow -f null -

Add a self-contained lavfi-based FATE regression test for the slow mode,
which previously crashed and is therefore not covered by the existing
sample-based fast/medium tests.

Fixes trac ticket #7779.

Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
2026-06-17 02:27:33 +02:00
Michael Niedermayer 30c6667dad avcodec/snowenc: fix out-of-bounds OBMC read in get_dc() for narrow planes
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 02:26:14 +02:00
Marvin Scholz bfa67bafad lavfi: af_showinfo: add support for IAMF side-data 2026-06-17 00:03:14 +00:00
Bogdan Lisman d69e8d0a95 avcodec/decode: reset PTS correction counters in ff_decode_flush_buffers
pts_correction_num_faulty_pts and pts_correction_num_faulty_dts were not
cleared by ff_decode_flush_buffers(), so they survived avcodec_flush_buffers().
After a seek, guess_correct_pts() therefore kept biasing its reordered-pts vs
dts choice on pre-seek history instead of starting fresh as it does after
ff_decode_preinit(), which already zeroes both counters. This could yield an
incorrect AVFrame.best_effort_timestamp on the frames following a seek.

Reset both counters on flush, next to the existing last_pts/last_dts reset, so
the decoder's timestamp-correction state is fully reinitialized.

Fixes: ticket #11645
Reported-by: keks51
Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
2026-06-16 15:59:52 +00:00
James Almer 491e0d1cfb avformat/matroskaenc: write LCEVC payloads as ITU-T T35 block additional
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 10:20:33 -03:00
James Almer 140d708d65 avcodec/codec_par: copy AVCodecContext sw_pix_fmt instead of pix_fmt to AVCodecParameters if set
In case of an encoding scenario using a hardware encoder, AVCodecContext->pix_fmt may be a
hwaccel format that conveys no information muxers can use when looking at its descriptor,
as is the case of bitdepth.
As such, if sw_pix_fmt is set, copy that value instead.

Fixes issue #23420

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 10:11:32 -03:00
Zhao Zhili 7338d08bcf avutil: zero size output parameter on allocation failure
Several _alloc() functions taking a size_t *size output parameter
either left it uninitialized or unconditionally set it to sizeof(...)
when the underlying av_mallocz() failed. Callers that check the
returned pointer first are unaffected, but the stale value is a trap
for any code path that inspects size without a NULL check.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-06-16 12:41:53 +00:00
James Almer 44d7755f7e avformat/mov: export initial padding
Some muxers, like Matroska, use it to write priming samples.

fate-segment-adts-to-mkv no longer uses the ref file from
fate-segment-adts-to-mkv-header-all as it's demuxed through the hls demuxer
and this commit exposed a bug where initial padding is not being propagated.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 09:18:24 -03:00
James Almer f18bc95323 tests/fate/aac: use mp4 instead of adts for encoding tests
It properly signals primming and padding samples, which lets us remove all the
comparison offsets.
But leave one test using adts, to not reduce coverage.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 09:18:24 -03:00
James Almer 60d50e2f29 tests/fate/gapless: print packet side data
Only a hinting "|" delimiter character was being printed.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 09:18:24 -03:00
James Almer da04251772 avformat/mov: export information about the last actual sample in a stream
This way the generic demux code can calculate how many trimming samples should
be discarded.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 09:18:24 -03:00
James Almer 298e5f810c tests/audiomatch: don't attempt to print floating point values
Instead check that the result is sane

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 09:18:24 -03:00
James Almer 51f5f60443 avformat/movenc: use a common denominator across all tracks as movie timescale
The default of 1000 may result in off by 1 errors when rescaling certain
durations, as is the case of fate-gaplessenc-itunes-to-ipod-aac, so lets
try to prevent that by using a global timescale every track can agree
with whenever possible.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 09:18:24 -03:00
James Almer 2153c6795c avcodec/decode: don't discard the existing skip_samples value if a new side data doesn't report any
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 09:18:23 -03:00
James Almer 68b53a8dbf avformat/demux: discard trimming samples in codecs with fixed frame size
When a demuxer reports the last packet with a duration smaller than the real coded duration,
this information is not relayed to the decoder, which will happily output all the trimming
samples anyway.
Fix that by ensuring we export a discard padding information as side data.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 09:18:23 -03:00
James Almer 47b4be8865 avformat/isom: export codecpar frame_size
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 09:18:23 -03:00
James Almer 0c29837dac avcodec/mpeg4audio: add a frame_length field to MPEG4AudioConfig
Will be useful to get fixed frame sizes outside decoders.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 09:18:23 -03:00
Bogdan Lisman 07ae44a607 doc/muxers: document the lrc precision option
The lrc muxer has a precision option controlling the number of
fractional digits written in each timestamp, but it was not documented.
Add it to the lrc section, including its range and default.

Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
2026-06-16 00:23:38 +00:00
Bogdan Lisman 1168447626 avcodec/snowenc: fix out-of-bounds memcpy in get_block_rd() for narrow planes
For an edge block, get_block_rd() copies the full-OBMC-weight central
region directly from cur[] into the reconstruction.  It moved one
boundary to block_w/block_h but overwrote the in-plane clip (x0/x1/y0/y1
computed earlier from the plane size) instead of intersecting with it.
When a plane is narrower than block_w - e.g. a tiny field/chroma plane
produced by the mcdeint filter - the right-edge case left x0 = block_w
while x1 stayed clipped to w - sx < block_w, so x1 - x0 became negative
and was passed to memcpy() as a huge size_t, crashing with SIGSEGV.

Intersect the moved boundaries with the existing clip so the copy region
stays inside the plane and the memcpy length can never be negative.

Reproducible with the GPL mcdeint filter in slow/extra_slow mode, e.g.

    ffmpeg -f lavfi -i testsrc=s=5x32 -vf mcdeint=mode=slow -f null -

This is a separate crash from the get_dc() SIGFPE (ticket #7779) reached
through the same iterative_me() path.  Add a lavfi-based FATE regression
test.

Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
2026-06-15 19:33:25 +00:00
Bogdan Lisman 3d1d546f70 avutil/eval: apply unary sign to print, squish, gauss and lerp
The leading sign of a (sub)expression is stored as +-1 in each node's
value field (parse_factor) and every other function multiplies its
result by it. print, squish, gauss and lerp ignored it, so e.g.
-print(1) evaluated to 1 instead of -1 and -gauss(0) to 0.398942
instead of -0.398942, while -1*print(1) was correct.

Fixes: ticket #9833
Reported-by: Player701
Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
2026-06-15 19:11:59 +00:00
Michael Niedermayer fd290e2fcd avcodec/cbs_av1_syntax_template: reset seen_frame_header on sequence
headers

With this change CBS and the decoder appear to be in sync.

Fixes: division by 0

Fixes: 501794431/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-4792576644546560
Fixes: 501898692/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-4772278394224640
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 17:10:52 +00:00
Diego de Souza a1801e06ae avcodec/nvenc: add AV1 hierarchical B-frame reference mode support
- Check B-frame ref mode capabilities via bitmask (EACH/MIDDLE/HIERARCHICAL)
- Expose b_ref_mode hierarchical option in AV1 encoder when supported

Signed-off-by: Eshed Ram <eram@nvidia.com>
Signed-off-by: Sergey Struzh <sstruzh@nvidia.com>
Signed-off-by: Nathan Sala <nsala@nvidia.com>
Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-15 18:14:39 +02:00