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

119684 Commits

Author SHA1 Message Date
a18b2c2696 lavc/vvc: Detect subpic overlaps at CTU level
In d5dbcc00d8, it was hoped that detection
of subpicture overlaps could be performed at the tile level, so as to
avoid introducing per-CTU checks. Unfortunately since that patch,
fuzzing has indicated there are some structures involving
pps_subpic_one_or_more_tiles_slice where tile-level checking is not
sufficient.  Performing the check at the CTU level should (touch wood)
be the be-all and and-all of this, as CTUs are the lowest common
denominator of the picture partitioning.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2025-05-24 10:57:20 +08:00
363a7a34f6 lavc/vvc/plt: validate run and signalled_entries
Fixes a crash triggered by a fuzzed clip:
https://github.com/ffvvc/tests/tree/main/fuzz/passed/000256.bit

Reproduce with:
ffmpeg -i 000256.bit -f null -
2025-05-24 10:36:19 +08:00
cbdb5e2477 ffv1enc_vulkan: fix array overflow 2025-05-24 02:28:13 +09:00
56b85b689d aacdec_ac: fix signed overflow in ff_aac_ac_update_context()
The issue is that state->cur[] is 8-bits, but a+b+1 can overflow
before being clipped to 0xF in the following line, causing an incorrect
state to be saved for the next symbol.

This solves numerous bitstream desyncs, particularly when coefficients
with magnitude greater than 127 are sent.
2025-05-24 02:19:18 +09:00
8c509ba491 tests/fate/ac3: Make ac3-fixed-encode-2 bitexact across arches
Don't use a 7.1 EAC3 input file for which our decoder is not
bitexact; instead just use the asynth-44100-8.wav file
which (as a 7.1 file) exhibits the same issue fixed by
1b3f4842c1.
(Either the encoder or the resampler are still not completely
bitexact, so we limit the number of frames output.)

Also switch to a framecrc test so that the output channel layout
is directly contained in the ref file.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-23 14:06:26 +02:00
559317cc13 avfilter/vf_libplacebo: add shader_cache option
Useful to speed up shader compilation. May significantly lower startup
times, in particular with large or complex shaders.

Sponsored-by: nxtedition
2025-05-23 14:05:16 +02:00
4f623b4c59 avfilter/vf_libplacebo: implement rotation option
Flipping can already be accomplished by setting the crop_w/h expressions to
their negative values, so together these options can implement any of the
common frame orientations.
2025-05-23 14:02:45 +02:00
a79720e10f avformat/matroskadec: Accept WebVTT subtitles with empty cues
Fixes: #11493
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-05-23 00:43:33 +02:00
9c6c653a46 avformat/imfdec: inherit opaque from parent AVFormatContext
io_open and io_close2 callbacks may use opaque pointer stored in the
context. They are already inherited, so opaque should also be passed
through.

Fixes IMF playback in mpv.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Reviewed-by: Pierre-Anthony Lemieux <pal@sandflow.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-05-23 00:43:32 +02:00
622a72b5ea tests/fate/ac3: add a second ac3_fixed encoder test
Exercising the lavfi filtergraph codepath to choose the best output layout.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-05-22 19:38:26 -03:00
1b3f4842c1 avfilter/avfiltergraph: fix regression in picking channel layout
Signed-off-by: James Almer <jamrial@gmail.com>
2025-05-22 19:38:11 -03:00
8eae65dc5c avcodec/lcevcdec: don't try to write to output frames directly
The buffer references may not be writable at this point, as the decoder
calls get_buffer2() with the AV_GET_BUFFER_FLAG_REF flag.

Fixes races as reported by tsan, producing correct output regardless of
threading choices.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-05-22 19:28:35 -03:00
d028cf03b8 swscale/swscale_unscaled: fix planarRgbToplanarRgbWrapper() for formats with bpc between 9-14 bits
Currently, planarRgbToplanarRgbWrapper() always sets the alpha value to 255,
without taking the bit depth into consideration.

This commit restricts the alpha value to the bit depth.
2025-05-23 00:07:56 +02:00
748e960e04 swscale/swscale_unscaled: fix packed16togbra16() for formats with bpc between 9-14 bits
Currently, packed16togbra16() always sets the alpha value to 0xFFFF,
without taking the bit depth into consideration.

This causes a bug on x86, which can be reproduced with:
./libswscale/tests/swscale -unscaled 1 -src xyz12le -dst gbrap12be

The problem arises in ff_hscale14to15_4_ssse3(), in the conversion
from gbrap12be to yuva444p, which comes after the conversion from
xyz12le to gbrap12be.

It has something to do with pmaddwd not working on unsigned values.
There is some code to deal with 0xFFFF if the input has a bit depth of
16, but not for bit depths < 16.
We could fix ff_hscale14to15_4_ssse3() to also work correctly with
0xFFFF on bit depths < 16, or we could just not write 0xFFFF there in
the first place, which is what this commit does.
2025-05-23 00:01:04 +02:00
0c1d87d1e6 swscale/swscale_unscaled: fix packed30togbra10() for formats with bpc between 9-14 bits
Currently, packed30togbra10() always sets the alpha value to 0xFFFF,
without taking the bit depth into consideration.

This commit restricts the alpha value to the bit depth.
2025-05-23 00:00:05 +02:00
a16c053a33 swscale/swscale_unscaled: fix planarCopyWrapper() for yuv444p => yuva444p
Currently, planarCopyWrapper() assumes that src[3] must be NULL when
the source format has no alpha plane.

This commit updates the condition for filling the alpha plane based on
the number of components available in the source format as well.
2025-05-22 23:59:39 +02:00
db5e0e2ef9 build: remove unused SLIBOBJS variable
The SLIBOBJS variable was introduced in 56572787ae but is no longer used.
Another variable, SHLIBOBJS, was introduced after SLIBOBJS, in 20b0d24c2f.
The functionality from SLIBOBJS was effectively migrated to SHLIBOBJS in b77fff47d0.

No code has used SLIBOBJS since.

This commit removes all remaining references to SLIBOBJS from the build system.
2025-05-22 23:59:03 +02:00
9b9a287872 doc/examples/qsv_decode: use av_err2str
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2025-05-22 22:26:30 +02:00
e93a43b511 doc/examples/filter_audio: use av_err2str
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2025-05-22 22:26:30 +02:00
977d1a24bc vulkan/ffv1: fix sync issue in cached bitstream reader/writer
The issue is that there is an explicit lack of synchronization as only the very
first invocation writes symbols and updates the state, which other invocations
then store.
2025-05-23 05:23:44 +09:00
b9b44e15b5 rtpdec: Set bitrate for pcm-mulaw audio
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
Co-authored-by: Marvin Scholz <epirat07@gmail.com>
2025-05-22 22:11:37 +02:00
f566392f66 libavformat/rtpdec_opus: add fmtp parsing of sprop-maxcapturerate
Co-authored-by: Marvin Scholz <epirat07@gmail.com>
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2025-05-22 22:11:37 +02:00
2a180c7150 libavformat/rtpdec_opus: Set duration field on Opus AVPacket
This commit will properly set the duration field of Opus AVPackets.
Currently, duration is set to 0 on Opus packets from the RTP demuxer.

The Ogg muxer depends on the duration field to properly compute the page granule
value. Without a proper duration, the granule will be wrong, and result in
negative pts values in ogg files.

See oggenc.c:657 (ogg_write_packet_internal)

This commit calculates using the opus_duration function, which was copied
from oggparseopus.c

I moved this functionality and the existing opus extradata functionality
(added by me in 6c24f2b) into a new rtpdec_opus.c file.

Reviewed-by: Tristan Matthews <tmatth@videolan.org>
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2025-05-22 22:10:46 +02:00
36ec9217e6 avformat/dhav: fix backward scanning for get_duration and optimize seeking
The backwards scanning done for incomplete final packets should not
assume a specific alignment at the end of the file. Truncated files
result in hundreds of thousands of seeks if the final packet does not
fall on a specific byte boundary, which can be extremely slow.
For example, with HTTP, each backwards seek results in a separate
HTTP request.

This changes the scanning to check for the end tag 1 byte at a time
and buffers the last 1 MiB to avoid additional seek operations.

Co-authored-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Justin Ruggles <justinr@vimeo.com>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2025-05-22 16:11:16 +01:00
c8b09fb0ac avutil/refstruct: Remove redundant check
We now require C11.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-22 15:12:54 +02:00
4099d53759 avfilter/vf_interlace_vulkan: fix FPS and PTS calculation
ol->frame_rate is 0/0, so we need to calcalute the correct value based on
the il->frame_rate instead. Also adjust the time base, PTS and frame_duration
values accordingly. (Logic taken from vf_tinterlace.c)
2025-05-21 16:10:55 +02:00
f1b3e51950 avcodec/amfenc_h264: improve B-frame usability and simplify options
- Query GPU caps for B-frame support and warn if unsupported.
- Make `-max_b_frames` optional
- Drop explicit `-pa_lookahead_buffer_depth` requirement in
adaptive mode.
2025-05-21 15:42:30 +02:00
2a5ee83442 avcodec/atrac3: Use av_unreachable() instead of av_assert1(0)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:52 +02:00
328ba54efa avcodec/4xm: Use av_unreachable() instead of av_assert0(0)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:52 +02:00
5653e0b1fa avcodec/mjpegenc_common: Use av_unreachable() instead of av_assert0(0)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:52 +02:00
85fb3453f8 avcodec/adpcm: Use av_unreachable() instead of av_assert0()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:52 +02:00
0bdb69119a avcodec/vp9: Replace av_assert(0) by av_unreachable()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:52 +02:00
2282a3740b avcodec/rv20enc: Use av_assert1() instead of av_assert0()
There is really no good reason to perform these checks in
release builds.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:52 +02:00
a35917268d avcodec/mpegvideo encs: Add put_bits_assume_flushed() to encode_header
This allows the compiler to remove the implicit "Do I need to output
the PutBitContext buffer here?" checks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:52 +02:00
5d0e8fa4bb avcodec/vlc: Make assert check more strict
The earlier code allowed callers to use arbitrary values as
symbols_size as long as no symbols were present.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:52 +02:00
ef58de7fdc avcodec/mpegvideo_{dec,motion}: Mark unreachable code as unreachable
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:52 +02:00
57696f7c2b avcodec/wmaenc: Use av_unreachable() instead of av_assert0(0)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:52 +02:00
831a0d0c6b avcodec/speedhqenc: Use av_unreachable() for unreachable condition
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:46 +02:00
2df9c8da72 avcodec/e?ac3enc: Inform compiler about PutBitContext being blank
This turned out to be very beneficial: For GCC 13, the codesize
of ac3_output_frame_header went down from 4522B to 1247B and
from 10762B to 9298B for eac3_output_frame_header. For Clang 17,
the numbers went down from 3923B to 2477B and from 8338B to 6548B
(always with -O3).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:25 +02:00
4484e9b373 avcodec/put_bits: Allow to mark places where PutBitContext is flushed
This will allow the compiler to optimize the "is the cache full?"
branches away from some put_bits().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:25 +02:00
988e319b40 avcodec/dolby_e_parse: Use av_unreachable instead of av_assert0(0)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:25 +02:00
22e6e4e914 avcodec/utvideoenc: Remove always-false pixel format check
Mark it as unreachable instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:02:10 +02:00
d7d1379d06 avcodec/vlc: Make code more readable with av_unreachable()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:01:43 +02:00
fc520ccb07 avcodec/pcm-dvdenc: Mark unreachable default cases as unreachable
Fixes a Clang warning when asserts are disabled:
"variable 'quant' is used uninitialized whenever switch default is taken
[-Wsometimes-uninitialized]"

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 12:01:30 +02:00
7a27357636 avcodec/mpeg4videodec: Mark impossible switch case as unreachable
Alternative to 8fc649b931.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 11:36:09 +02:00
b5824a6dab avcodec/proresenc_anatoliy: Mark impossible case as unreachable
Alternative fix for fix Coverity issue 1440385 (instead of
6106177ad6).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 11:35:31 +02:00
fc9e2a92c1 avcodec/amrwbdec: Mark default switch as unreachable
Alternative fix for Coverity issue #1473499
instead of a3bb269db9.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 11:16:25 +02:00
004cc60f0e avutil/avassert: Add av_unreachable() and av_assume() macros
Useful to let the compiler and static analyzers know that
something is unreachable without adding an av_assert
(which would be either dead for the compiler or add runtime
overhead) for this.
The implementation used here enforces the use of a message
to provide a reason why a particular code is supposed to be
unreachable.

Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 10:45:23 +02:00
b6f84cd72a avcodec/svq3: Improve returning last picture
Use av_frame_move_ref() instead of av_frame_ref().
This allows to remove the separate variable for whether
we have already returned the delayed last pic. It also
makes stream looping work when looping multiple times;
previously the delayed pic was only output the first time,
because last_frame_output was never reset.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 03:10:52 +02:00
b98128898a tests/fate/qt: Use passthrough fps_mode for svq3-watermark
The file has buggy timestamps (it uses B-frames, yet pts==dts)
and therefore the last frame is currently discarded by FFmpeg cli.
Using -fps_mode passthrough avoids this and provides coverage
of the SVQ3 draining logic.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-21 03:10:52 +02:00