Compare commits

..

2047 Commits

Author SHA1 Message Date
nyanmisaka a508495cd7 avutil/hwcontext_cuda: fix yuv420p V/U plane overlap in cuda_get_buffer()
Odd-height yuv420p result in incorrect calculations of the U-plane
address offset. The last row of the V-plane overlapped with and was
overwritten by the first row of the U-plane, leading to chroma artifacts.

```
ffmpeg -init_hw_device cuda=cu -filter_hw_device cu -f lavfi -i \
testsrc=s=1920x1081,format=yuv420p -vf hwupload -c:v hevc_nvenc \
-vframes 1 -y <OUTPUT>
```

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
(cherry picked from commit 3f6bf150cb)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:11:20 +02:00
Niklas Haas 901a25e0d1 avfilter/vf_scale_cuda: fix inverted downscaling check
Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 6baf561303)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:10:59 +02:00
Niklas Haas 74c735ab10 avfilter/vf_scale_cuda: allocate inter buffer with correct subsampling
Since the input and output format can differ (e.g. 444 -> 420), we need to
reference the correct subsampling for the partially applied filter.

Keep track of this in the CUDATex itself.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 01972b4f85)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:10:47 +02:00
Niklas Haas 316651a9ae avfilter/vf_scale_cuda: allocate intermediate buffer directly
Instead of going via an AVFrame at all. This will allow us to fix the
intermediate chroma plane size for split downscaling.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 420a9e90b8)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:10:37 +02:00
Niklas Haas 3a7097cfa7 avfilter/vf_scale_cuda: use persistent intermediate CUDATex
Instead of re-creating this object every frame.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit e79e9f06ba)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:10:26 +02:00
Niklas Haas f3f292929e avfilter/vf_scale_cuda: defer buffer allocation to setup_filters()
At this point, s->hwctx and CudaFunctions * are available.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 4289a29bb0)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:10:16 +02:00
Niklas Haas c5caacd845 avfilter/vf_scale_cuda: introduce CUDATex and mapping helper
I want to disentangle the internal logic from AVFrame, because some
intermediate states (e.g. for partially subsampled chroma with simultaneous
scaling) may not directly map to a valid AVPixelFormat.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit fef976b197)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:10:05 +02:00
Niklas Haas 480bf29af3 avfilter/vf_scale_cuda: add fail: label (cosmetic)
Make the next commit a bit easier to review.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 61750318db)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:09:51 +02:00
Niklas Haas 9573519b01 avfilter/vf_scale_cuda: eliminate redundant context push/pop
This is already done by cudascale_filter_frame().

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 0c3f04a97c)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:09:37 +02:00
Niklas Haas d9402f5d71 fftools/ffmpeg_demux: only throttle readrate on the slowest stream
If streams are badly interleaved, then the readrate logic can end up
accumulating an ever-growing lag. Rather than looping over each stream
and sleeping for each stream individually based on the local DTS and lag
logic, pull the sleep out of the loop and only sleep once based on the
furthest-behind stream (i.e. the stream contributing the lowest sleep
duration).

To reproduce:

$ ./ffmpeg -re -i fallbeatcaptiontest.mp4 -c copy -f null -t 10 -

Before this commit, this would run at ~0.7x and accumulate an infinitely
growing lag in one stream. After this commit, both streams run at ~1x as
expected, after an initial burst period due to the bad (1s granularity)
interleaving.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit de6bcf5c05)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 12:26:51 +02:00
Niklas Haas b9a83fda41 fftools/ffmpeg_demux: remove unused variable
This is a dead assignment except on a single branch, so just define it
locally.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit e7be06c8bd)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 12:26:51 +02:00
Niklas Haas 5a4b9c5976 fftools/ffmpeg_demux: skip finished/unstarted streams in readrate_sleep()
This shouldn't affect the actual behavior, as the initialization of ds->dts
(implicitly zero'd) and the previous calculation of stream_ts_offset
guarantees that the `if (pts <= stream_ts_offset) continue;` branch fires.

Mainly a minor clarification of the code for the upcoming refactor.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 5c877416a5)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 12:26:51 +02:00
Timo Rothenpieler 16e59dfabf forgejo/workflows: change to targeting 9.0 release branch 2026-06-27 00:03:34 +02:00
Michael Niedermayer 08d06a7a8a Update for release/9.0 branch start
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 03:06:39 +02:00
Michael Niedermayer 47e9d68e20 Bump minor for release/9.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 02:43:34 +02:00
Michael Niedermayer b140509940 pre branch Update
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 02:26:01 +02:00
Diego de Souza 41d8d12cc2 avcodec/nvenc: accept P012/P212/YUV444P12MSB input (truncated to 10-bit)
NVDEC and CUVID now output AV_PIX_FMT_P012 (12-bit 4:2:0),
AV_PIX_FMT_P212 (12-bit 4:2:2) and AV_PIX_FMT_YUV444P12MSB (12-bit 4:4:4)
for high-bit-depth content, but nvenc rejected them: nvenc_map_buffer_format()
returned NV_ENC_BUFFER_FORMAT_UNDEFINED, so a pipeline such as
"-hwaccel cuda -i 12bit.mp4 -c:v hevc_nvenc" failed with EINVAL.

NVENC has no native 12-bit encode format. As is already done for the
16-bit inputs (P016, YUV444P16, GBRP16), accept the 12-bit formats and
map them to the 10-bit NVENC buffer formats, truncating the two least
significant bits: P012 -> YUV420_10BIT, P212 -> P210, YUV444P12MSB ->
YUV444_10BIT. They are added to the supported input format list and to
the IS_10BIT / IS_YUV444 / IS_YUV422 helpers accordingly.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-25 21:45:06 +00:00
Bogdan Lisman b5ef72c16b tests/fate/filter-video: gate mcdeint testsrc tests on scale filter
fate-filter-mcdeint-slow and -slow-edge feed testsrc (RGB24 only) into
mcdeint (YUV420P/YUV444P only), so ffmpeg auto-inserts a scale filter to
convert the pixel format.  That conversion needs swscale, so both tests
fail to configure the filter graph under --disable-swscale:

    Error configuring filter graph: Invalid argument
    Conversion failed!

Reported by the x86_64-archlinux-gcc-disableswscale FATE slot.  Add
SCALE_FILTER to their dependency list so they are skipped when the scale
filter (and thus swscale) is unavailable, matching the existing
convention for conversion-dependent FATE tests.

Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
2026-06-25 16:39:27 +00:00
Niklas Haas e5a3c5e409 avformat/http: accept case-insensitive Connection header value
RFC 9110 defines this as case-insensitive, and some servers (e.g. MythTV)
send it as "Close" instead of "close".

See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/23222
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 15:50:43 +00:00
Niklas Haas bd51105806 avformat/http: infer default s->willclose based on request header
If we send `Connection: close` but don't get any response Connection header
back from the HTTP server, we should still assume the server will close our
connection.

There is a minor bit of ambiguity about what state to assume if the user
overrode the "Connection:" header, but I'm optimistically leaning in
favor of keep-alive as the more likely value for a user to set.

Not updating our internal state tracking as a result of user-provided
headers overriding our own headers is a prior problem with http.c that is
outside the scope of this PR to fix.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 15:50:43 +00:00
Martin Storsjö 1499c4ac6d avformat/tls_openssl: Add a missing <string.h> include
This is needed when building with OpenSSL enabled on macOS after
c32a719cb2.

The tls_openssl.c contains a number of explicit calls to strlen(),
which require including <string.h>.
2026-06-25 15:34:04 +03:00
Martin Storsjö b2b37802a9 configure: Check for division of __int128
This fixes detection on toolchains where the compiler is able to
compile code with __int128, but the toolchain doesn't automatically
link in suitable helper functions needed for handling division.
(In practice, clang targeting MSVC environments.)
2026-06-25 11:15:10 +00:00
Martin Storsjö 93ebde18e1 checkasm: Trim out unused upstream files
We only need the source files themselves; keep them and the
LICENSE file.
2026-06-25 12:47:17 +03:00
Martin Storsjö d5d62e04b9 tools: Add a script for updating the checkasm subtree
Trim out any files we don't need downstream.

Automate doing the subtree merges, and automate resolving the
conflicts for updates for files that we want to have removed.
If updates end up with other conflicts, the script (or in practice,
git) exits without creating the intended merge commit - but
regular updates should run automatically.
2026-06-25 12:46:50 +03:00
Niklas Haas f947bc9c15 tests/fate/swscale: skip fate-sws-uops-macros without int128
This is very slow otherwise (10x slower than with native int128). Developers
can still manually run it if they need to, but we should exclude it from
the default FATE target.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:48 +02:00
Niklas Haas fe3e67556b swscale/ops_optimizer: remove unneeded 32-bit overflow check
No longer needed with AVRational64. Now we can just apply_op_q(), on
everything except floating point types (which are still not representable
in AVRational64 and likely never will be, though this is mostly a moot
point as the uops layer can still optimize this further).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:48 +02:00
Niklas Haas 1257f26120 swscale/ops: make ff_sws_apply_op_q slightly more robust
Switch on the exact pixel type and add a range assertion.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:48 +02:00
Niklas Haas b9481ae3c2 swscale/format: remove no longer needed overflow check
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:48 +02:00
Niklas Haas d04f7b17c7 tests/checkasm/sw_ops: eliminate unneeded overflow check
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:48 +02:00
Niklas Haas 3743d2851d swscale/ops: switch from AVRational to AVRational64
This has two immediate consequences:

1. Fixes overflow in the range tracker for some 32-bit packed formats:

 rgb24 -> v30xbe:
   [ 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: {64 64 64 _}, max: {940 960 960 _}
   [f32 ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 -1}
     min: {64.001953 64.001953 64.001953 _}, max: {940.998047 960.998047 960.998047 _}
   [f32 +++X] SWS_OP_CONVERT      : f32 -> u32
     min: {64 64 64 _}, max: {940 960 960 _}
   [u32 +++X] SWS_OP_SWIZZLE      : 2013
     min: {64 64 64 _}, max: {960 940 960 _}
   [u32 ++++] SWS_OP_CLEAR        : {_ _ _ 1}
     min: {64 64 64 1}, max: {960 940 960 1}
   [u32 +XXX] SWS_OP_PACK         : {10 10 10 2}
-    min: {268697857 _ _ _}, max: {-264581375 _ _ _}
+    min: {268697857 _ _ _}, max: {4030385921 _ _ _}
   [u32 zXXX] SWS_OP_SWAP_BYTES
-    min: {268697857 _ _ _}, max: {-264581375 _ _ _}
+    min: {268697857 _ _ _}, max: {4030385921 _ _ _}

2. Slightly increases the accuracy of intermediate values for some linear ops:

 yuv444p10be -> rgb48be:
   [u16 zzzX] SWS_OP_READ         : 3 elem(s) planar >> 0
     min: {0 0 0 _}, max: {1023 1023 1023 _}
   [u16 +++X] SWS_OP_SWAP_BYTES
     min: {0 0 0 _}, max: {1023 1023 1023 _}
   [u16 +++X] SWS_OP_CONVERT      : u16 -> f32
     min: {0 0 0 _}, max: {1023 1023 1023 _}
   [f32 ...X] SWS_OP_LINEAR       : matrix3+off3 [...]
46.813777] [0 0 0 1 0]]
-    min: {-57290.842348 -44341.337325 -71146.813777 _}, max: {124144.718860 111375.162457 137973.627845 _}
+    min: {-57290.842348 -44341.337326 -71146.813777 _}, max: {124144.718860 111375.162457 137973.627845 _}
   [f32 ...X] SWS_OP_MAX          : {0 0 0 _} <= x
     min: {0 0 0 _}, max: {124144.718860 111375.162457 137973.627845 _}
   [f32 ...X] SWS_OP_MIN          : x <= {65535 65535 65535 _}
     min: {0 0 0 _}, max: {65535 65535 65535 _}
   [f32 +++X] SWS_OP_CONVERT      : f32 -> u16
     min: {0 0 0 _}, max: {65535 65535 65535 _}
   [u16 zzzX] SWS_OP_SWAP_BYTES
     min: {0 0 0 _}, max: {65535 65535 65535 _}
   [u16 XXXX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Importantly, none of the changes affect the actual operation list, just the
range tracking metadata.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:44 +02:00
Niklas Haas aff6d64ecd swscale/ops_optimizer: omit overflow check on SWS_OP_SCALE
1. This is currently impossible to trigger
2. We're about to switch to AVRational64, eliminating this concern
3. The AVRational64 API intentionally doesn't expose av_reduce64()

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:15 +02:00
Niklas Haas 845a3bfcec swscale/format: factor out intmax_q() and make more robust
This formulation is generally preferred as it avoids the risk of (1 << depth)
overflowing when depth is 32/64/etc.

I also wanted to have these in a common place to make the upcoming changes
easier.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:15 +02:00
Niklas Haas eda15846b2 swscale/format: avoid Q0/Q1 macros
These come with some challenging ambiguity in the following patch to switch
from AVRational to AVRational64, so best just avoid them and have individual
usage sites define them locally with the correct type.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:15 +02:00
Niklas Haas 82a73428e1 swscale/ops: don't re-define Q() macro
It's already in ops_internal.h

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:15 +02:00
Niklas Haas b568f20f32 swscale/rational64: add 64-bit rational type
This is needed by the ops code, to represent intermediate values for 32-bit
formats, which can exceed the value range of int32_t (especially for
intermediate products).

I copied the math almost 1:1 from rational.c, but adapted to use the 128-bit
integer wrappers defined by int128.h. I added a generous amount of tests in
any case.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:15 +02:00
Niklas Haas 6a853ce327 avutil/rational: avoid signed integer overflow
Passing -INT_MIN to av_sub_q() overflows due to the negation. Writing out
the formula explicitly avoids this.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:15 +02:00
Niklas Haas 33e5fca2ee avutil/tests/rational: add explicit unit tests for edge cases
The existing tests don't really stress test the edge-case behavior when adding
or multiplying values that over/underflow.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:15 +02:00
Niklas Haas 9e3343a94d avutil/int128: add header for 128-bit integers
These can be implemented efficiently on most modern 64-bit compilers. Fallback
is only needed for 32-bit, which we do using the existing generic "integer.h"
header (currently also hard-coded as 128 bits).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:15 +02:00
Ramiro Polla 46997547a6 swscale/uops: reduce size of uop_names[] array
Uses an offset into the full name to get the macro name. Also spells
out the names of the types to make the code easier to grep.
2026-06-24 22:39:31 +00:00
Marton Balint 18d164a573 avformat/asfdec_f: do not truncate get_value result
Also change the function to return 0 on error, this is a more sensible error
value for aspect ratios anyway.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:54 +02:00
Marton Balint 99aab32380 avformat/asfdec_f: simplify get_tag/get_value usage
get_tag() only behaves differently for the BOOLs of Extended Content
Description Object, so lets adjust the type there instead of passing BOOL width
for all calls. Similar to what asfdec_o does.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:54 +02:00
Marton Balint cfb76bc38c tests/fate/id3v2: add ID3 test with alternate asf demuxer
This tests the previously untested alternative ASF demuxer, plus the metadata
is actually a bit different from what is returned by the historical ASF
demuxer.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:54 +02:00
Marton Balint dab1ac3e6e avformat/utils: fix ff_dict_set_timestamp() with negative timestamps
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint c434d0a160 avformat/asfdec_f: set creation time as metadata
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint 2bbf0da31a avformat/asfdec_o: use common function for setting creation time
This also increases precision.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint 83c6534d5a avformat/asfenc: use common function for timestamp conversion
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint 2d2a810294 avformat/wtvdec: use ISO timestamps with timezone and higher precision
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint 2b1cf52dbe avformat/asf: add helper functions to convert between filetime and avtime
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint ce104d1054 avformat/asfdec_o: fix EOF check in read_header
Since d1ac645636 ff_get_guid() never returns
EOF. This change completely broke the asfdec_o demuxer returning failure on
every file.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint 3e4acff3aa avformat/asfdec_o: remove constants already defined in asf.h
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Jonathan Harris 7587e1224a libavcodec/dxv.c: handle widths not a multiple of 16
The Resolume DXV codec is based on 4x4 pixel DXT1/DXT5/BC4/BC5 blocks, so
it's natural to assume that files would be padded to multiples of 4 in width
and height. But in practice .mov files produced by the Resolume software are
always padded to multiples of 16 in width and height, so FFmpeg currently
decodes them incorrectly.

When encoding FFmpeg already pads both width and height to 16 so no change
is required - see libavcodec/dxvenc.c:37-40 (commit
d4556c98f0):

/*
 * Resolume will refuse to display frames that are not padded to 16x16 pixels.
 */
#define DXV_ALIGN(x) FFALIGN(x, 16)

Signed-off-by: Jonathan Harris <ffmpeg@marginal.org.uk>
2026-06-24 13:49:42 -07:00
Timo Rothenpieler 23881eef2b Changelog: document cleanup of nvenc 2026-06-24 18:51:12 +00:00
Timo Rothenpieler 677c61b8fe avcodec/nvenc: reject deprecated global_quality instead of -qp 2026-06-24 18:51:12 +00:00
Timo Rothenpieler 64e6d750f9 avcodec/nvenc: remove legacy option aliases 2026-06-24 18:51:12 +00:00
Timo Rothenpieler a66a022332 avcodec/nvenc: remove deprecated preset aliases 2026-06-24 18:51:12 +00:00
Timo Rothenpieler 2b054bc9e6 avcodec/nvenc: remove legacy cbr and 2pass AVOptions 2026-06-24 18:51:12 +00:00
Timo Rothenpieler dcf339c413 avcodec/nvenc: remove old and long deprecated rc modes 2026-06-24 18:51:12 +00:00
Timo Rothenpieler 6495133363 avcodec/nvenc: remove support for SDK versions older than 11.1 2026-06-24 18:51:12 +00:00
Kacper Michajłow c3ca443969 tests/fate/seek: exclude hls-seek test without aresample
Fixes build with --disable-swresample.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-24 16:04:38 +00:00
Michael Niedermayer e0a012d129 doc/developer: bug fixes intended for backporting should stay minimal.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-24 14:15:26 +00:00
Ramiro Polla 49e73395b7 swscale/uops: move SWS_MASK* from ops.h to uops.h
These helpers are also needed for uops.
2026-06-24 13:14:35 +00:00
Ramiro Polla fde02c904c swscale/ops: remove friendly linear mask names
These names are not really useful and the uops list already shows the
shape of the mask.
2026-06-24 13:14:35 +00:00
Diego de Souza df94900c98 avfilter/cuda: support P012/P212 and MSB 4:4:4 in scale/transpose/thumbnail
NVDEC and CUVID now output AV_PIX_FMT_P012 (12-bit 4:2:0), AV_PIX_FMT_P212
(12-bit 4:2:2) and AV_PIX_FMT_YUV444P10MSB / AV_PIX_FMT_YUV444P12MSB
(10/12-bit 4:4:4) for high-bit-depth content, but these CUDA filters
rejected the formats in their supported-format lists, breaking pipelines
such as "-hwaccel cuda ... -vf scale_cuda" on 12-bit input.

These formats use 16-bit sample storage, and the filters select their CUDA
kernel by byte-storage size and plane layout, not by the number of valid
bits, so they can reuse the existing 16-bit kernels:

- scale_cuda: P012/P212 -> "semiplanar16", YUV444P10MSB/YUV444P12MSB ->
  "planar16".
- transpose_cuda: the ushort/ushort2 kernels are chosen from the pixel
  descriptor (byte size + channel count); just allow the new formats.
- thumbnail_cuda: P012 reuses the P010/P016 path and the MSB 4:4:4 formats
  reuse the YUV444P16 path; P012 is added to the 4:2:0 chroma-histogram
  scaling as well. (thumbnail has no 4:2:2 path, so P212 is not added.)

The CUDA deinterlacers (bwdif_cuda, yadif_cuda) already accept any format
with <= 2 bytes per sample and <= 2 channels, so they need no change. The
8-bit-only filters (overlay_cuda, pad_cuda, bilateral_cuda, chromakey_cuda,
colorspace_cuda) do not support high bit depths and are left untouched.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-24 12:18:15 +00:00
crueter 4ba56d8ab7 build: Use Make builtin for .objs response files when possible
Since 9e857e1f8a, library.mak generates a
response file containing the list of input object files. This was done
to avoid hitting the 8192 character command line limit on Windows
shells.

However, that particular solution still relies on emitting a
very long `echo` command that gets delegated to a subshell. This means
that, for example, running `make` within problematic shells like Git
Bash could still hit the command line length limit when this `echo` step
is ran. Other MSYS2 shells are not affected, meaning the previous
workaround only helped when running in an MSYS2 environment, but broke
when using Git Bash, e.g. for MSVC. This primarily affected `libavcodec`
due to the sheer volume of files contained within.

To avoid this problem, this commit changes the object emission step to
use GNU make's `file` builtin to write the list of object files. `file`
itself was introduced in GNU Make 4.0, but FFmpeg still supports old
versions--notably Apple's ancient Make 3.81--so for older make versions
that don't support this, the old echo subshell is used. This tradeoff
should be fine since it's trivial to grab a new-enough Make on Windows,
and other platforms that may be stuck with ancient Make versions
shouldn't have nearly as restrictive command line limits.

Signed-off-by: crueter <crueter@eden-emu.dev>
2026-06-24 08:27:10 +00:00
Kacper Michajłow dc953a19e6 avformat/hlsenc: initialize avg_bandwidth
Fixes use of uninitialized value and dumping it into AVERAGE-BANDWIDTH
in playlist. Note this will be correctly set when we are at final
segment, otherwise it's optional.

Fixes: fate-hls-seek test on MSAN build

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-24 02:04:02 +00:00
Diego de Souza a02dfb1262 avcodec/cuviddec: map new NVDEC 4:2:0/4:2:2/4:4:4 output formats
The switch to the new NVDEC pixel formats made cuvid_derive_output_format()
and the format probe select AV_PIX_FMT_P012 for 12-bit 4:2:0,
AV_PIX_FMT_P210/P212 for 10/12-bit 4:2:2 and AV_PIX_FMT_YUV444P10MSB/
YUV444P12MSB for 10/12-bit 4:4:4, but cuvid_handle_video_sequence() still
only mapped the older formats to a CUVID surface format. Decoding such
streams therefore failed with "Unsupported output format" (AVERROR(EINVAL));
because every packet then errored without producing a frame, the failure
could also manifest as a hang rather than a clean error exit. The
system-memory copy path in cuvid_output_frame() rejected the same formats
with AVERROR_BUG.

Map P012 to cudaVideoSurfaceFormat_P016 (mirroring P010), P210/P212 to
cudaVideoSurfaceFormat_P216 (mirroring P216) and YUV444P10MSB/YUV444P12MSB
to cudaVideoSurfaceFormat_YUV444_16Bit (mirroring YUV444P16); the hardware
surface is physically 16-bit and the pixel format only records the number
of valid bits. Add the same formats to the system-memory copy path, whose
per-plane geometry is already derived generically from the pixel descriptor.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-23 23:58:45 +00:00
Diego de Souza 74db061f0a avutil/hwcontext_cuda: add P012 and P212 to supported formats
NVDEC and CUVID decode 12-bit 4:2:0 content to AV_PIX_FMT_P012 and
12-bit 4:2:2 to AV_PIX_FMT_P212, but these formats were missing from
the CUDA frames context supported format list. As a result
av_hwframe_ctx_init() rejected them ("Pixel format not supported",
AVERROR(ENOSYS)), so decoding 12-bit content to CUDA frames and
hwdownload of such frames both failed.

Add P012 and P212 next to the existing P010/P016 and P210/P216 entries.
The per-plane device transfer is derived generically from the pixel
descriptor, so no other changes are required.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-23 23:58:45 +00:00
marcos ashton 2985d42978 libavutil/pixdesc: fix prefix matching in *_from_name() functions
The seven *_from_name() functions in pixdesc.c (color_range,
color_primaries, color_transfer, color_space, chroma_location,
alpha_mode) used av_strstart() for prefix matching, which returns
incorrect results when one name is a prefix of another.

av_color_space_from_name("ycgco-re") matched "ycgco" at index
AVCOL_SPC_YCGCO and returned 8 instead of AVCOL_SPC_YCGCO_RE.
av_color_space_from_name("ycgco-ro") had the same issue. The
*_ext name lookups inside av_color_primaries_from_name and
av_color_transfer_from_name had the same flaw.

Switch all eight call sites 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-06-23 23:42:38 +00:00
James Almer b0919b271b tests/fate/mov: add a test for remainder sample calculation
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-23 20:07:25 -03:00
James Almer 579edeabec avformat/movenc: look for remainder samples in packet side data
Sometimes the duration itself reflects the remainder samples by being set to a
value lower than the frame size, but in other cases it's done only through
a discard padding value in side data.
Take the latter into account when calculating durations.

Fixes issue #23532.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-23 20:07:25 -03:00
James Almer 661dd0ffd5 avformat/movenc: use track timescale when making up a tmcd track pts
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-23 20:07:25 -03:00
James Almer 0559f92adc avformat/movenc: don't derive tmcd track durations if they were copied
This behavior only applies to tracks created by the muxer.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-23 20:07:25 -03:00
James Almer 92386ba213 tests/fate: print checksum and output file size for stream_remux() tests
This puts the tests in line with transcode(), making it easier to detect affecting changes.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-23 23:05:57 +00:00
Andreas Rheinhardt 2f59339479 avfilter/buffersink: Fix indentation
Necessary after 509c1f99a7.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 22:38:55 +00:00
Niklas Haas 9420146e6d avfilter/vf_scale_cuda: re-indent after previous change
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Niklas Haas 5d0748243f avfilter/vf_scale_cuda: add use_filters option
This may be faster or slower than the existing specialized kernels,
so I opted not to prefer it by default. I also deliberately didn't expose
additional filter function capabilites yet.

The main motivating reason here is to get correct anti-aliasing behavior
when downscaling, which is currently completely broken.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Niklas Haas 469281fa50 avfilter/vf_scale_cuda: add generic 1D filter kernel
This can be useful for any sort of separable filtering with arbitrary
weights.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Niklas Haas d98cc462f6 avfilter/vf_scale_cuda: generalize kernel signature to accept weights
Ignored for now by the existing fixed function kernels.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Niklas Haas b400791442 avfilter/scale_filters: add internal copy of libswscale/filters.c
Useful for GPU-based filters, which may also need to compute filter weights.
Since we cannot cross-link to internal functions, we need to recompile this
helper inside libavfilter.c.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Kacper Michajłow 50209cd0c0 avformat/hls: advance first_timestamp once per live window slide
Anchor c->first_timestamp to the playlist that established it and only let
that playlist's expiring segments advance it, so it slides exactly once
per window slide.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-23 20:40:28 +02:00
Kacper Michajłow e27ad5760c avformat/hls: rebase seek discard threshold to each playlist's DTS baseline
After a seek, hls_read_packet drops packets until each playlist reaches
seek_timestamp. That threshold lives on c->first_timestamp's baseline,
i.e. the DTS of whichever stream produced the very first packet. Streams
can have different DTS baselines though. So comparing one stream's
threshold against another stream's DTS is wrong. A stream whose first
keyframe precedes the global baseline gets its segment keyframe dropped
and resumes a segment (or more) late.

Track the first DTS per playlist and rebase the threshold onto each
playlist's own baseline. Since HLS segments are presentation-aligned
across renditions, every stream then resumes at the same presentation
time. seek_timestamp keeps its meaning on the global timeline, only the
per-playlist comparison value is translated.

This fixes playlists that would be unable to play from the start, and
instead skip one or more segments, before data is output.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-23 20:40:28 +02:00
Kacper Michajłow caa3fa6af0 avformat/hls: fix seeking to before the first timestamp
find_timestamp_in_playlist() already selects the first segment when the
target is below the playlist's first timestamp, but returns 0.
hls_read_seek() treats that as a failure, and all seek operation is
failed.

This breaks seeking to the very start whenever the requested timestamp
is slightly below the first one. Clamp such targets to the first segment
and report success instead.

Fixes: https://github.com/mpv-player/mpv/issues/14840#issuecomment-4703186169
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-23 20:40:28 +02:00
Kacper Michajłow 0616685b1e avformat/hls: reuse the open connection for contiguous byte-range segments
CMAF and other EXT-X-BYTERANGE playlists address consecutive segments as
contiguous byte ranges of a single resource. Each segment was fetched with
a separate bounded request, paying a request/response round-trip per
segment even though the connection was kept alive.

Keep the AVIOContext open across segments of the same resource and seek to
the next segment instead of reopening, for contiguous ranges the seek
targets the current position and issues no request in practice.

Non-contiguous, encrypted and non-seekable cases fall back to the
previous reopen behaviour.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-23 20:40:28 +02:00
Kacper Michajłow 54f0296dfe avformat/hls: deduplicate playlists shared by multiple variants
Master playlists can reference the same media playlist URI from several
rendition group. new_playlist() allocated a separate playlist struct for
each reference, this is unndeded work and we can fold duplicates into
single probe.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-23 20:40:28 +02:00
Kacper Michajłow f699b3a8f5 tests/fate/seek: add HLS multi-playlist seek test
Add a seek test for an HLS master playlist with separate audio and video
media playlists with different DTS baselines.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-23 20:40:27 +02:00
Niklas Haas f87323a359 avformat/http: properly fall back on soft seek failure
If the HTTP server still has stale bytes in the TCP receive buffer, but
the underlying conection was already closed, then the http_open_cnx()
call might fail even though we successfully drained the previous request.

In this case, there is no proper fallback to a new connection, leading to
sudden truncation.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 20:33:00 +02:00
Niklas Haas 0d0f9a06ab avformat/http: only re-use old connection if valid
Otherwise, this might leak stale bytes that were already drained by the
HTTP soft-seek attempt.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 20:33:00 +02:00
Niklas Haas 62006041cc avformat/http: don't return EOF unless we actually read all bytes
Otherwise, this masquerades failure due to I/O as legitimate EOFs.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 20:33:00 +02:00
Niklas Haas 557ab6f2ab avformat/http: make short-seek logic more robust
This avoids an underflow if short_seek is negative (which can happen if e.g.
ffurl_get_short_seek() returns AVERROR(ENOSYS)), as well as a possible
underflow if the read position is somehow past `range_end` (e.g. if the HTTP
server malicously lied about the content range but gave us more bytes anyway)

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 20:33:00 +02:00
Niklas Haas 8712114200 avformat/http: properly re-set s->range_end before requests
Otherwise this could leak stale values from a previous response.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 20:33:00 +02:00
Andreas Rheinhardt 927ffd0930 fftools/ffmpeg: Remove deprecated -vsync option
Deprecated in commit 09c53a04c5
on 2022-06-11.

Thanks to Michael Niedermayer for pointing out that
the documentation needs to be updated, too.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:58 +02:00
Andreas Rheinhardt 07407fff61 fftools/ffmpeg: Remove deprecated -filter_complex_script option
Deprecated in commit c316c4c77b
on 2024-01-20.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:58 +02:00
Andreas Rheinhardt 7a6c1b19ab fftools/ffmpeg: Remove deprecated -top option
Deprecated in commit 5d58a35f98
on 2023-09-18.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:58 +02:00
Andreas Rheinhardt 687e061cb2 fftools/ffmpeg: Remove deprecated -vsync/fps_mode drop
Deprecated in commit 3dc319587f
on 2023-12-18.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:58 +02:00
Andreas Rheinhardt 1c99ba791b fftools/ffmpeg_mux_init: Remove deprecated source_no_drop
Deprecated in commit d2c416fdf1
on 2023-10-10.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:58 +02:00
Andreas Rheinhardt 985ebb1749 fftools/ffmpeg_mux_init: Remove deprecated FFMPEG_OPT_ENC_TIME_BASE_NUM
Deprecated in commit dff3a283cd
on 2023-07-23.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt d09f5815d7 fftools/ffmpeg_opt: Remove disabled and deprecated adrift_threshold
Deprecated in commit 5a04aae821
on 2023-05-02.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt d77b5234b5 fftools/ffmpeg_opt: Remove deprecated no-op -qphist option
Deprecated and disabled in commit 2f24290c8e
on 2023-04-13.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt 762b94e672 libs: Bump major version of all libraries
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Michael Niedermayer 54849fe663 avcodec/avformat: Unavpriv avpriv_packet_list_*()
The avpriv_packet_list_put/get/free() functions and the PacketList type
were implemented in libavcodec and exported via the avpriv_ mechanism
solely so that libavformat (and decklink in libavdevice) could use them;
libavcodec itself has no users of them. Exporting them across the library
boundary has the usual drawbacks for shared builds (export/import overhead
and having to keep them around for ABI stability even once unneeded).

Move the implementation and the PacketList/PacketListEntry types to
libavformat and rename the functions to ff_packet_list_*(). libavformat is
the primary user and compiles the new packet_list.c directly; decklink,
the only libavdevice user, gets a private copy for shared builds via the
SHLIBOBJS scheme already used for reverse.o and ccfifo.o (static builds
resolve the symbols from libavformat).

AVPACKET_IS_EMPTY() and ff_side_data_set_prft() remain in
libavcodec/packet_internal.h as they are libavcodec-internal.
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt 2d3776b8cc avutil/x86/emms: Unavpriv avpriv_emms_asm()
This fallback function is used if external MMX is available,
while inline MMX and intrinsics for emitting emms are unavailable.
It is implemented as an avpriv function, which has several
drawbacks for shared builds:
1. The function is so small (3 bytes; 16 with padding)
that the overhead of exporting and importing it dwarfs
the gains from code deduplication.
2. A call to an external library has more overhead than
a library-internal one.
3. It may cause linking failures when a libavutil not exporting
avpriv_emms_asm() is paired with a library needing it
(if inline assembly and intrinsics were unavailable when building
the dependent library). I am not aware of this ever happening.
4. We would be forced to keep avpriv_emms_asm() around for ABI stability
even after it is no longer needed.

This commit therefore uses the STLIBOBJS, SHLIBOBJS approach
to duplicating it into each library on its own if needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt fff992a5bc avutil/xga_font_data: Stop exporting font data directly
Commit c6c8063186 added getters for them.
Also remove av_export_avutil and the BUILDING_foo macro.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt da0ea43984 avutil/hwcontext_vulkan: Move AVVkFrame.internal to the end
This allows us to remove it by allocating AVVkFrameInternal
jointly with AVVkFrame.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Lynne 61693f6c35 hwcontext_vulkan: switch to VkAccessFlagBits2 2026-06-23 19:15:57 +02:00
Andreas Rheinhardt 1c36aa8e33 avutil/opt: Remove FF_API_OPT_PTR
Deprecated on 2024-10-16.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt c32a719cb2 avutil: Remove FF_API_OPT_INT_LIST
Deprecated on 2024-09-30.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt 38990c59d7 avutil/hwcontext_vulkan: Remove FF_API_VULKAN_FIXED_QUEUES
Deprecated on 2024-08-11.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt 46d52299f5 avutil/cpu: Remove FF_API_RISCV_FD_ZBA
Deprecated on 2024-08-05.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt 51231c5588 avutil/common: Remove FF_API_MOD_UINTP2
Deprecated on 2024-06-13.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt 191be14fb6 avcodec/packet: Accept const dictionaries in av_packet_pack_dictionary()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt c03d6ba2eb avcodec/packet: Remove AVPacketList
Deprecated in f7db77bd87
on 2021-03-17.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt e930e2e60a avcodec/exif: Remove avpriv_exif_decode_ifd()
Superseded by the public exif API.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt 38221d0ec9 avcodec/codec: Remove deprecated AVCodec arrays
They were deprecated in 3305767560
on 2024-09-08. Removing them allows to constify all FFCodecs;
furthermore, it allows to use a union of a video-only and a audio-only
structure to reduce sizeof(FFCodec).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt 1c2e630456 avcodec/nvenc_h264: Remove FF_API_NVENC_H264_MAIN
I.e. switch to high profile by default.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt 861d17e0f0 avcodec/exr: Remove FF_API_EXR_GAMMA
Deprecated on 2025-03-28.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt c85b83f8df avcodec: Remove FF_API_CODEC_PROPS
Deprecated since 2025-01-05.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt 0438966d84 avcodec: Remove FF_API_V408_CODECID
Deprecated on 2024-10-12.
The output of the v410enc test changes because padding bits
are now filled with 1s instead of zeroes and because
bits_per_coded_sample changes to 30 (from 32), see
https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22455#issuecomment-46213.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:13:06 +02:00
Andreas Rheinhardt 7fd9780ab2 avcodec: Remove FF_API_NVDEC_OLD_PIX_FMTS
The switch to the new pixel formats was announced
on 2025-07-11.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt e967ae98f4 avcodec: Remove FF_API_PARSER_PRIVATE
Deprecated on 2025-11-01. It is removed right now despite
this being fairly recently, because users never had
a legitimate reason to touch these fields at all:
After all, their meaning was entirely undocumented.

Furthermore, the split callback is unset for any parser
since commit e5af920309 from 2021.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt e7858bb3bb avcodec: Remove FF_API_PARSER_CODECID
The parser API was scheduled to use enum AVCodecID
in commit 8a322c956f
on 2025-11-01. The switch is made now despite this
being fairly recently because it involves no deprecation
and therefore no change from our downstreams at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt f31675400b avcodec: Remove FF_CODEC_OMX
The omx encoders were deprecated on 2024-11-09.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt ca1d253621 avcodec/sonic: Remove sonic codecs
The original plan from commit d89fbfd4df
(merged on 2024-11-25) was to remove the encoders on the then next
major version bump (i.e. the bump to lavc 62, the current version)
and to disable the decoders by default on said bump. Both did not
happen; one deadline has already passed and the other is right upon us,
so just remove all sonic codecs now.

Note: Codec IDs and descriptors are kept.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt 6d2d1f3f32 avformat/oggenc: Remove deprecated pagesize option
Deprecated in commit 59220d559b.
on 2013-01-08.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt 9549c9ad79 avformat/tls: Remove FF_API_NO_DEFAULT_TLS_VERIFY
The decision to switch to checking peer certificates by default
at the next major version bump was announced on 2025-08-09
in commit 5621eee672.

Thanks to Michael Niedermayer for pointing out that the documentation
needs to be updated, too.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt 5aba289032 avformat: Remove FF_API_INTERNAL_TIMING
Deprecated since 2024-07-09.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt 9f58e3014c avfilter: Remove FF_API_LIBNPP_SUPPORT
libnpp and the corresponding filters have been deprecated
in commit 994a368451
on 2025-09-26. By the time of our next release,
a year will have passed, so they are removed immediately.

Note: Passing --enable-libnpp to configure results in
a warning about the deprecation and is otherwise a no-op.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt 7116138857 avfilter/avfilter: Remove FF_API_CONTEXT_PUBLIC
Deprecated on 2024-10-07.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt 509c1f99a7 avfilter: Remove deprecated FF_API_BUFFERSINK_OPTS
Deprecated since 2024-09-30.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt d333beb8b5 avdevice: Remove deprecated FF_API_ALSA_CHANNELS
Deprecated since 2025-02-01.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt 1d92e85fcd tests/fate/hlsenc: Make hls-iframes-single-fmp4 bitexact
The mp4 file contained LIBAVFORMAT_IDENT and when it's
length changes (as during a major version bump)
the test output changes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:14:42 +02:00
Andreas Rheinhardt c78350af98 avformat/hlsenc: Forward AVFormatContext.flags
Needed for AVFMT_FLAG_BITEXACT.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:05:02 +02:00
James Almer 8f3c62cb6a tests/fate/hlsenc: don't write the segment output to /dev/null
Fixes fate-hls-iframes-single-fmp4 on msys2, where #EXT-X-MAP:URI would print
"nul" instead of "null".

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-23 12:01:23 -03:00
Jack Lau a9e27e2e0c avformat/tls_{openssl,mbedtls}: parse host when external_sock is true
See 28b92b9b2e

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-06-23 22:44:20 +08:00
Jack Lau e2eee22f16 avformat/tls_openssl: refactor dtls_start() to use common code
Removing the dtls_start() and create a simple dtls_open()
wrapper that just set s->is_dtls and call tls_open() to
use common code.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-06-23 22:44:20 +08:00
Jack Lau b7db2538f6 avformat/tls_openssl: copy the dtls code into tls_open()
This is first step for moving dtls related code
into tls_open() to make sure they can use common
code in one function.

Next patch should be removing dtls_start() and create
a simple dtls_open() wrapper (set is_dtls and then call
tls_open()) just like GnuTLS.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-06-23 22:44:20 +08:00
Niklas Haas 30155f9c3a swscale/uops: split planes when generating ops lists
This updates uops_macros.h and the graph.c implementation in lockstep,
otherwise we'd have an intermediate commit with a bunch of broken formats.

Overall speedup=1.008x faster, min=0.144x max=5.550x

The min/max numbers are mostly measurement noise, but the real speedup for
affected formats is anywhere from 0.9x to around 2x-3x.

It's worth noting that the speedup for the formats which currently regress
is because we don't yet refcopy the planes, but I have another series in the
works which will take care of this soon.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas 09c0cd6837 swscale/tests/sws_ops: split passes when printing ops lists
This affects a large number of conversions across the board, either:

1. Lifting a constant alpha/chroma clear out from the conversion pass:

 rgb24 16x16 -> yuva444p 16x16:
+  [ u8 $XXX] SWS_OP_CLEAR        : {255 _ _ _}
+  [ u8 XXXX] SWS_OP_WRITE        : 1 elem(s) planar >> 0, via {3}
+    ('X' unused, 'z' byteswapped, '=' copied, '$' const, '+' integer, '0' zero)
+ translated micro-ops:
+    u8_clear_x_1
+    u8_write_planar_x
+ Sub-pass #1:
   [ u8 +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 +++X] SWS_OP_CONVERT      : u8 -> f32
   [f32 ...X] SWS_OP_LINEAR       : matrix3+off3 [...]
   [f32 ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 -1}
   [f32 +++X] SWS_OP_CONVERT      : f32 -> u8
-  [ u8 +++$] SWS_OP_CLEAR        : {_ _ _ 255}
-  [ u8 XXXX] SWS_OP_WRITE        : 4 elem(s) planar >> 0
+  [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
     ('X' unused, 'z' byteswapped, '=' copied, '$' const, '+' integer, '0' zero)

 gray 16x16 -> yuv444p 16x16:
+  [ u8 $$XX] SWS_OP_CLEAR        : {128 128 _ _}
+  [ u8 XXXX] SWS_OP_WRITE        : 2 elem(s) planar >> 0, via {2, 1}
+    ('X' unused, 'z' byteswapped, '=' copied, '$' const, '+' integer, '0' zero)
+ translated micro-ops:
+    u8_clear_xy_xx
+    u8_write_planar_xy
+ Sub-pass #1:
   [ u8 =XXX] SWS_OP_READ         : 1 elem(s) planar >> 0
   [ u8 =XXX] SWS_OP_CONVERT      : u8 -> f32
   [f32 .XXX] SWS_OP_LINEAR       : luma [...]
   [f32 .XXX] SWS_OP_DITHER       : 16x16 matrix + {0 -1 -1 -1}
   [f32 +XXX] SWS_OP_CONVERT      : f32 -> u8
-  [ u8 +$$X] SWS_OP_CLEAR        : {_ 128 128 _}
-  [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+  [ u8 XXXX] SWS_OP_WRITE        : 1 elem(s) planar >> 0
     ('X' unused, 'z' byteswapped, '=' copied, '$' const, '+' integer, '0' zero)
  translated micro-ops:
     u8_read_planar_x
     u8_to_f32_x
     f32_linear_x_x000x
     f32_dither_x_0_16x16
     f32_to_u8_x
-    u8_clear_yz_xx
-    u8_write_planar_xyz
+    u8_write_planar_x

or

2. Passing through a plane that was previously unmodified by an ops chain:

 gbrap 16x16 -> yuva444p 16x16:
-  [ u8 ====] SWS_OP_READ         : 4 elem(s) planar >> 0, via {2, 0, 1, 3}
-  [ u8 ====] SWS_OP_CONVERT      : u8 -> f32
-  [f32 ...=] SWS_OP_LINEAR       : matrix3+off3 [...]
-  [f32 ...=] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 -1}
-  [f32 +++=] SWS_OP_CONVERT      : f32 -> u8
-  [ u8 XXXX] SWS_OP_WRITE        : 4 elem(s) planar >> 0
+  [ u8 =XXX] SWS_OP_READ         : 1 elem(s) planar >> 0, via {3}
+  [ u8 XXXX] SWS_OP_WRITE        : 1 elem(s) planar >> 0, via {3}
     ('X' unused, 'z' byteswapped, '=' copied, '$' const, '+' integer, '0' zero)
  translated micro-ops:
-    u8_read_planar_xyzw
-    u8_to_f32_xyzw
+    u8_read_planar_x
+    u8_write_planar_x
+ Sub-pass #1:
+  [ u8 ===X] SWS_OP_READ         : 3 elem(s) planar >> 0, via {2, 0, 1}
+  [ u8 ===X] SWS_OP_CONVERT      : u8 -> f32
+  [f32 ...X] SWS_OP_LINEAR       : matrix3+off3 [...]
+  [f32 ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 -1}
+  [f32 +++X] SWS_OP_CONVERT      : f32 -> u8
+  [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+    ('X' unused, 'z' byteswapped, '=' copied, '$' const, '+' integer, '0' zero)
+ translated micro-ops:
+    u8_read_planar_xyz
+    u8_to_f32_xyz
     f32_linear_xyz_xxx0x_xxx0x_xxx0x
     f32_dither_xyz_0_3_2_16x16
-    f32_to_u8_xyzw
-    u8_write_planar_xyzw
+    f32_to_u8_xyz
+    u8_write_planar_xyz

(Op lists are abridged slightly for brevity)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas 0901ca4108 swscale/ops_dispatch: add option to split const/copied subpasses
This already helps performance as-is, but will help performance massively
once we add the ability for the memcpy backend to do a refcopy instead of
an actual copy.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas 65197f67ff swscale/ops_dispatch: add option to link subpass outputs together
Not needed currently but will be used for parallel splits.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas 291e849ee3 swscale/ops_optimizer: add ff_sws_op_list_split_planes()
Can be used to extract a reduced subset of operations affecting only certain
output planes, e.g. splitting an op list into a "memcpy" and a "non-memcpy"
part, or splitting apart op lists for independent or subsampled planes.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas ed12cf7515 swscale/uops: simplify uop mask printing slightly
We can re-use the helper we just added.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas 4f6d5c1794 swscale/uops: add a helper to print a comp mask as a string
For debugging/logging purposes exclusively.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas b494a82321 swscale/ops: remove now-unneeded function
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas 2eb254c5fd swscale/ops_dispatch: avoid possible infinite recursion
If the filter cannot actually be optimized into the read (for whatever
reason), this code would previously loop infinitely. Bail out cleanly
instead.

The FFSWAP is there to make the error message print the remainder (the one
containing unsplittable ops), rather than the noop list.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas 848753352d swscale/ops_dispatch: substantially refactor subpass compilation
Instead of a loop with fixed structure, this function now recursively calls
itself as many times as needed to satisfy all criteria.

This is absolutely needed for the upcoming refactor which will allow for
also splitting apart ops lists as needed to e.g. handle partially subsampled
ops lists, which may need a complex sequence of filtering and merge steps
to be fully satisfied.

This does modify the way in which subpasses are compiled slightly, in that
each new subpass first tried again un-split, rather than a single split
resulting in all subsequent passes being split as well. This is mostly a
benign change, though it might matter one day.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas 2509eb3e8c swscale/ops_optimizer: extract subpass splitting logic to helper
I will also delete the old name in an upcoming commit.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas 409b870bd6 swscale/tests/sws_ops: only print actually compiled ops lists
We already have the unoptimized reference ops; printing each intermediate
stage here is just noise that makes this file harder to scroll through IMO.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas 17154619e5 swscale/ops_dispatch: group compilation args into struct
This will make it easier to keep passing around these parameters in helper
functions in the upcoming refactor.

Take the opportunity to also rename the plain `compile` function to
`compile_single`.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas 27ff50f6ab swscale/ops_dispatch: add SWS_OP_FLAG_DRY_RUN
Avoids us having to write awkward code like `output ? &pass : NULL`.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas e3d15d4606 swscale/ops_dispatch: move compile flags from ops.h
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas 07e6ee54e7 swscale/ops_dispatch: move no-op check after optimization pass
Otherwise, this will false negative if the redundant operations haven't
been optimized away yet, resulting in unnecessary memcpy operations.

Fixes: a534156083
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas d86f0ae534 swscale/ops_dispatch: don't assume first operation is a read
Makes ff_sws_compile_pass() more robust; will be needed for plane splitting.
Besides, it's perfectly valid to have an operation list that starts with
e.g. SWS_OP_CLEAR.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas c1eee3d4d8 swscale/graph: add a function to allow reusing output buffers
Used for plane splitting, among other things. (e.g. plane passthrough)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas aecca98488 swscale/ops: fix noop check ignoring read/write filters
Fixes a few cases where we previously didn't actually scale:

 gbrpf32le 16x16 -> gbrpf32le 16x32:
-  (no-op)
+  [f32 ...X] SWS_OP_READ         : 3 elem(s) planar >> 0 + 2 tap bilinear filter (V)
+    min: {nan nan nan _}, max: {nan nan nan _}
+  [f32 XXXX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+    ('X' unused, 'z' byteswapped, '=' copied, '$' const, '+' integer, '0' zero)
+ translated micro-ops:
+    f32_read_planar_fv_xyz_f32
+    u32_write_planar_xyz

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas cd2109b3a6 swscale/ops: fix stale comment
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Niklas Haas b992479539 swscale/ops: keep track of copied/cleared components
These represent components which have not (yet) been modified from their
input values (i.e. after a read, or clear). Such components can be
basically passed through via a refcopy (where applicable), as well as helping
to distinguish dissimilar types of plane for (plane splitting).

Generates benign diffs like:

 gray 16x16 -> yuv444p 16x16:
-  [ u8 +XXX] SWS_OP_READ         : 1 elem(s) planar >> 0
+  [ u8 =XXX] SWS_OP_READ         : 1 elem(s) planar >> 0
     min: {0 _ _ _}, max: {255 _ _ _}
-  [ u8 +XXX] SWS_OP_CONVERT      : u8 -> f32
+  [ u8 =XXX] SWS_OP_CONVERT      : u8 -> f32
     min: {0 _ _ _}, max: {255 _ _ _}
   [f32 .XXX] SWS_OP_LINEAR       : luma [[73/85 0 0 0 16] [0 1 0 0 0] [0 0 1 0 0] [0 0 0 1 0]]
     min: {16 _ _ _}, max: {235 _ _ _}
   [f32 .XXX] SWS_OP_DITHER       : 16x16 matrix + {0 -1 -1 -1}
     min: {16.001953 _ _ _}, max: {235.998047 _ _ _}
   [f32 +XXX] SWS_OP_CONVERT      : f32 -> u8
     min: {16 _ _ _}, max: {235 _ _ _}
-  [ u8 +++X] SWS_OP_CLEAR        : {_ 128 128 _}
+  [ u8 +$$X] SWS_OP_CLEAR        : {_ 128 128 _}
     min: {16 128 128 _}, max: {235 128 128 _}
   [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
-    (X = unused, z = byteswapped, + = exact, 0 = zero)
+    ('X' unused, 'z' byteswapped, '=' copied, '$' const, '+' integer, '0' zero)
  translated micro-ops:
     u8_read_planar_x
     u8_to_f32_x
     f32_linear_x_x000x
     f32_dither_x_0_16x16
     f32_to_u8_x
     u8_clear_yz_xx
     u8_write_planar_xyz

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 11:48:13 +00:00
Kacper Michajłow cbbbe4a862 configure: bump AMF requirement to 1.5.2
485f195690 requires AMFSurface1, which is
available since 1.5.2.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-23 08:39:44 +00:00
Jun Zhao 7c176c068d doc/filters: document subtitles filter's shaping option
The shaping option is now exposed by both the ass and subtitles filters.
Document it under subtitles, update the ass filter description to refer
to the shared option set, and note that complex shaping is required for
Arabic, Hebrew, Devanagari and Thai and depends on a HarfBuzz-enabled
libass build.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-23 03:57:25 +00:00
Jun Zhao b08c9c5f53 lavfi/vf_subtitles: expose shaping option
The ass filter exposes libass' shaping mode selection so callers can
request complex shaping for scripts such as Arabic. The subtitles filter
uses the same renderer path but did not expose the option.

This left the zero-initialized shaping field to select
ASS_SHAPING_SIMPLE implicitly.

Expose the same shaping option for subtitles and default it to auto,
matching the ass filter. This allows subtitles=...:shaping=complex to
render Arabic lam-alef correctly when libass is built with HarfBuzz
support.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-23 03:57:25 +00:00
Stefan Breunig 80a4f96c7d fate/hls: add byterange tests for iframe_only+single_file playlists 2026-06-23 00:04:42 +00:00
Stefan Breunig de4cfe98b6 avformat/hlsenc: clean up unused keyframe tracking variables 2026-06-23 00:04:42 +00:00
Stefan Breunig ea3d417d90 avformat/hlsplaylist: fix byte offsets for single_file+iframes_only
fix ticket: 8636

video_keyframe_size and video_keyframe_pos tracked the end of the
previous P/B frame. In the case of I-frame only videos, this would
result in byteoffsets always being 0@0 in the case of fmp4. For
mpegts, the size would be correct but the pos still always be @0.

Since size and pos already correctly track the start of a segment,
we can re-use them even in I-frame only mode.
2026-06-23 00:04:42 +00:00
Kacper Michajłow e999ea73bc configure: keep -march=native for --cpu=host
--cpu=host resolved =native to the concrete CPU name and passed that to
the compiler. The name is a strict superset of the actual machine: it
discards the per-feature adjustments the compiler makes for =native
(e.g. AVX-512 left disabled by the OS or a VM), so the build could emit
instructions that fault at runtime.

Keep the resolved name for per-arch feature gating, but feed
-march/-mcpu=native for the codegen so that information is preserved.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-22 21:02:17 +00:00
Kacper Michajłow efa8b20987 vf_libplacebo: remove compatibility code with not supported versions 2026-06-22 16:18:59 +00:00
Kacper Michajłow 5041a6ac90 fftools/ffplay_renderer: remove PL_API_VER check 2026-06-22 16:18:59 +00:00
Kacper Michajłow 045016de21 configure: bump libplacebo requirement to 7.351.0
Since commit ec8e796b4, older libplacebo wouldn't built.

The support for 8.0 has been fixed in libplacebo commits 7cbbc764e and
563ea4a1a.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-22 16:18:59 +00:00
stevxiao a2856b3c30 avfilter/dnn: add ONNX Runtime backend with GPU execution provider support
This patch adds ONNX Runtime as a new DNN backend for FFmpeg's dnn_processing
filter, enabling hardware-accelerated neural network inference on multiple
GPU and NPU platforms.

Execution Providers Supported:
- CPU execution provider (default)
- CUDA execution provider (NVIDIA GPUs)
- DirectML execution provider (AMD/Intel/NVIDIA GPUs on Windows)
- VitisAI execution provider (AMD Ryzen AI NPU)

The options for dnn_processing with dnn_backend=onnx:
- device: execution provider — cpu, cuda, dml, or vitisai (default: cpu)
- device_id: GPU device index (default: 0)
- threads_per_operation: inference thread count for CPU EP (default: 0, auto)
- input: input tensor name. When omitted the backend resolves it from loaded session
- output: output tensor name. When omitted the backend resolves it from loaded session

Example usage:
  # CPU inference
  ffmpeg -i input.mp4 -vf "format=rgb24,dnn_processing=dnn_backend=onnx:model=model.onnx:input=image_in:output=image_out" output.mp4

  # CUDA GPU inference
  ffmpeg -i input.mp4 -vf "dnn_processing=dnn_backend=onnx:model=model.onnx:device=cuda:device_id=0" output.mp4

  # DirectML GPU inference (Windows)
  ffmpeg -i input.mp4 -vf "dnn_processing=dnn_backend=onnx:model=model.onnx:device=dml:device_id=0" output.mp4

  # VitisAI NPU inference
  ffmpeg -i input.mp4 -vf "dnn_processing=dnn_backend=onnx:model=model.onnx:device=vitisai" output.mp4

  Note: depending on the model, you may need a format filter (e.g. format=rgb24 or format=grayf32) before dnn_processing to convert the frames to the pixel format the model's input tensor expects.

Signed-off-by: younengxiao <steven.xiao@amd.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2026-06-22 20:06:40 +08:00
Ramiro Polla d09330e578 swscale/aarch64/ops: mark more operations as type-invariant
This prevents the generation of a few more duplicate functions (where
there would be both f32 and u32 functions).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-22 13:56:31 +02:00
Ramiro Polla a016f34d17 swscale/aarch64/ops: remove redundant linear combinations
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.

Also simplified the AVRational comparisons a bit.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-22 13:56:31 +02:00
Ramiro Polla 7fc637fc0c swscale/aarch64/ops: fix mask for swizzle ops
The mask for swizzle ops assumed that merely having a component assigned
to itself was enough to detect whether the swizzle was needed for that
component, but that wasn't correct. We should also take into account
whether the component is needed for the next operation or not.

Additionally, prevent duplicate functions from being generated by
clearing the swizzle index for unused components.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-22 13:56:31 +02:00
Ramiro Polla 083089e047 swscale/aarch64/ops: remove redundant single-component packed read/write
These functions are essentially the same as single-component planar
read/write, and are actually never instantiated. This was left over
from the initial implementation.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-22 13:56:31 +02:00
Zhao Zhili 07b9158994 avfilter/avf_showcwt: drop redundant outer av_clip
av_clipd() already bounds the result to [1, 65536]. The surrounding
av_clip() can never alter it.
2026-06-22 11:43:51 +00:00
Kacper Michajłow 64ce854ef5 avutil/hwcontext_d3d11va: support native P016 format
Map DXGI_FORMAT_P016 to AV_PIX_FMT_P016 and keep the 12-bit P012 as a
compatibility entry, matching how Y216 and Y416 already expose both their
native 16-bit and 12-bit variants.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-22 11:06:13 +00:00
James Almer ff1e1b5b72 tests/fate/gapless: add tests for Opus and aac in m4a with edit lists
None of the existing aac tests use edit lists to signal priming and remainder samples.
Also, no test exists for the Ogg or Matroska demuxers implementations either, so add
some using Opus.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-21 21:41:02 -03:00
James Almer c6bb22dea0 avcodec/cbs_av1: check that a Frame Header was seen before parsing a Tile Group
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-20 21:19:56 -03:00
Niklas Haas 9cbd889670 swscale/x86/ops: add AVX2/SSE4 path for SWS_UOP_READ_PALETTE
The AVX2 is a fairly straightforward vpgatherdd + 4x4 transpose. The SSE4
fallback is an unrolled scalar loop, for lack of anything better to do.

checkasm:
 - CPU: AMD Ryzen 9 9950X3D 16-Core Processor (00B40F40)
 - Timing source: x86 (rdtsc)
 - Bench duration: 10000 µs per function (45898205 cycles)
 - Random seed: 2518020648

Benchmark results:
  name                             cycles (vs ref)
  u8_read_palette_xyzw_c:          2877.5
  u8_read_palette_xyzw_x86_sse4:   1951.9 ( 1.47x)
  u8_read_palette_xyzw_x86_avx2:   1051.6 ( 2.74x)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 14:08:49 +00:00
Niklas Haas 310df19fcd tests/checkasm/sw_ops: add check for SWS_UOP_READ_PALETTE
We just need to ensure the palette contains valid data, which will happen
automatically as long as the plane 1 is large enough.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 14:08:49 +00:00
Niklas Haas d4b9b94ccb swscale/format: add support for AV_PIX_FMT_PAL8
This is handled using the new SWS_RW_PALETTE read op mode. We need to be a bit
careful to use the correct pixfmt descriptor downstream, because the descriptor
for PAL8 itself merely describes the *index*, rather than the actual data
values.

Accomplish this by introducing a new function to map the palette format to the
resulting pixel format after applying the palette (explicitly documented as
AV_PIX_FMT_RGB32).

+pal8 16x16 -> rgb24 16x16:
+  [ u8 +++X] SWS_OP_READ         : 4 elem(s) palette >> 0
+    min: {0 0 0 _}, max: {255 255 255 _}
+  [ u8 +++X] SWS_OP_SWIZZLE      : 2103
+    min: {0 0 0 _}, max: {255 255 255 _}
+  [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
+    (X = unused, z = byteswapped, + = exact, 0 = zero)
+ translated micro-ops:
+    u8_read_palette_xyzw
+    u8_permute_xz_zx
+    u8_write_packed_xyz
...

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 14:08:49 +00:00
Niklas Haas ffd6855a50 swscale/vulkan/ops: properly error out for unsupported read modes
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 14:08:49 +00:00
Niklas Haas 6217350269 swscale/uops_backend: add SWS_UOP_READ_PALETTE reference implementation
This does not actually generate any code yet as the macro is still empty,
but that will change once I add support for generated palette reads to
the format handling code. This logic merely needs to be in place first
to avoid introducing broken intermediate states where palette uops are
generated but not implemented by the reference backend.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 14:08:49 +00:00
Niklas Haas 5163b05552 swscale/uops: add SWS_UOP_READ_PALETTE
This commit only adds the uop itself; it does not yet add any implementations.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 14:08:49 +00:00
Niklas Haas efbfd75434 swscale/ops_dispatch: add support for dispatching palette reads
This requires some tiny bit of extra setup work from the dispatch layer.
Specifically, we need to arrange for the palette data pointer to end up in
exec.in[1], and to disable the pointer advancement logic for this plane (this
can be accomplished by just setting the stride and bump to 0).

We also want to disable the tail buffer / overflow pixel copying logic for
the palette, which can be accomplished by ensuring that p->planes_in only
contains the number of *data* planes, excluding the fixed palette.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 14:08:49 +00:00
Niklas Haas d26994d35f swscale/format: exclude palette formats for output
In theory, we could learn to handle them internally, using the same
systematic palette trick, but I'll defer this for now, as vf_scale already
handles this internally.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 14:08:49 +00:00
Niklas Haas 168dfcb557 swscale/ops: add SWS_RW_PALETTE for PAL8 read type
I decided to model this as a separate read/write type, rather than as a
separate operation (e.g. SWS_OP_PALETTE), because it makes the semantics
surrounding the read value range, plane pointer setup, etc. much cleaner.

(This will become evident in the upcoming changes to the dispatch layer)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 14:08:49 +00:00
Kirill A. Korinsky b57ff00bcf configure/x86: split 7-register check from EBP availability
LLVM commit
https://github.com/llvm/llvm-project/commit/0d471b3f64d3116bd57c79d872f7384fff80daa5
made Clang save and restore EBP around inline asm that only
clobbers it. This can make the existing EBP crash probe pass even
when the compiler still cannot allocate the 7-register i386 inline
asm used behind HAVE_7REGS.

Keep ebp_available for HAVE_6REGS and add a separate
x86_32_7regs probe for HAVE_7REGS.

Discussion:
https://marc.info/?t=178015389900001&r=1&w=2
2026-06-20 11:46:49 +00:00
Niklas Haas b3689e792f swscale/uops: simplify permute naming scheme
We also drop the useless/unused mask from the permute ops.

Avoids a bunch of otherwise duplicate permute ops. Now that this is
handled by SWS_UOP_MOVE for x86, there is no downside to this.

The FATE change is a pure rename of the uops dumps.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:10:22 +02:00
Niklas Haas 8cc6b2ddaf swscale/tests/swscale: fix unscaled subsampled chroma format check
This should be matching against the *chroma* scaler, not the main scaler.
Of course, under normal circumstances, scaler_sub matches scaler, but this
allows users to explicitly override this defaulting by setting e.g.

-scaler none -scaler_sub bicubic

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:08:33 +02:00
Niklas Haas fa1ca69a8b swscale/filters: add ability to set a virtual output size
Odd-size luma planes are not exact multiples of the chroma plane; but the
sample grid is still matched as though it were. We need to account for this
when translating a luma sample to the corresponding chroma sample coordinates.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:08:21 +02:00
Niklas Haas 8215e9bbea swscale/filters: add option for adding an input pixel offset
This is needed for chroma subsampling, which requires a different filter
offset for chroma subsamples (according to the frame's chroma location).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:08:07 +02:00
Niklas Haas 1f6dc79c80 swscale/format: factor out ff_sws_chroma_pos() helper
Moved here from graph.c, as it's needed for the new chroma scaling code.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:07:35 +02:00
Niklas Haas 4653e68aab swscale/graph: nuke SwsGraph.field
No longer needed after the previous commit.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:07:20 +02:00
Niklas Haas aedede0cee swscale/format: add SwsFormat.field
This metadata is needed to compute the correct chroma sampling offsets.
We previously stored this in graph->field, but that's a bad place for it,
because it doesn't survive the translation to the ops abstraction layer.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:06:21 +02:00
Niklas Haas 7e7c1c0d94 swscale/format: nuke ff_props_equal()
And merge it with the more clear ff_fmt_equal().

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:05:36 +02:00
Niklas Haas 3a2c5050c6 swscale: fix format equality check
I can't say I remember why this logic was written this way, but I can't
think of any good reason why we should exclude comparing the image
dimensions here - the intent is obviously to allow passthrough / noop.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:05:08 +02:00
Niklas Haas ba1c1d9eee swscale/graph: separate pass dispatch size from buffer size
This allows adding passes which will be dispatched over a reduced number of
lines, without affecting the allocated buffer dimensions - e.g. for passes
which purely write to subsampled chroma planes.

A few hard-coded references to pass->width/height need to be replaced by
the corresponding output frame references, but it's not a huge deal.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:04:27 +02:00
Niklas Haas cb8a006f8a swscale/graph: don't over-allocate pass buffer lines
This is not only wasteful but also serves no real purpose. Looping over
the correct number of lines is trivial; there is far less point in vertical
padding than horizontal padding.

Furthermore, this might actually introduce issues when linking output buffers;
since the extra padding depends on the pass's alignment and threading
requirements, which may differ from pass to pass.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:04:01 +02:00
Niklas Haas d474b408f2 swscale/ops_optimizer: simplify unused op check (cosmetic)
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:03:38 +02:00
Niklas Haas b120505ce2 swscale/ops: apply ff_sws_comp_mask_swizzle() in-place
More convenient at every use site.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 03:02:41 +02:00
Niklas Haas faac9fa705 swscale/ops_optimizer: set correct range metadata after split pass
Replaces a few "nan" value ranges by real values, and drops a bunch of
redundant non-FMA variants that resulted from this bug.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 02:52:02 +02:00
Niklas Haas e52459195c swscale/ops: simplify SWS_OP_READ default comps handling
We can still pre-fill the prev array here; ff_sws_apply_op_q() is a no-op.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 02:50:26 +02:00
Niklas Haas 127efb7072 swscale/format: pass SwsFormat to ff_sws_decode_colors()
Needed to set initial plane size metadata. I decided to update
ff_sws_encode_colors() as well for symmetry.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-20 02:49:48 +02:00
Andreas Rheinhardt 4bbb7d9b99 avutil/x86/x86util: Force VEX encoding when using -mavx
This avoids reg-reg moves and saves 90112B of .text here.
It also makes the code less reliant on a clean upper ymm state.

Not all functions use VEX encoding yet; besides inline assembly
functions which are not influenced by x86inc.asm there are also
functions using a mixture of xmm and mmx registers (e.g.
h264_intrapred.asm) using INIT_MMX where the automatic VEX translation
is not active. This means that some parts of the code still rely
on a clean upper ymm state.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-19 20:39:56 +02:00
Ramiro Polla f523577512 swscale/aarch64: convert generation of ops_entries.c to a fate test
This serves two purposes:
- there is a test to check that the file is always up-to-date
- it can easily be regenerated using fate's own infrastructure
2026-06-19 14:33:28 +00:00
Ramiro Polla c00b5be5de swscale/format: modify SwsSwizzleOp in-place in swizzle_inv() 2026-06-19 14:32:44 +00:00
Ramiro Polla d90645c4db swscale/cms: pass SwsColor by pointer instead of value in gamut_from_colorspace() 2026-06-19 14:32:44 +00:00
Ramiro Polla 6f52c88f45 swscale/graph: pass SwsFormat by pointer instead of value in adapt_colors() 2026-06-19 14:32:44 +00:00
Ramiro Polla 12750ed512 swscale/lut3d: pass SwsFormat by pointer instead of value in ff_sws_lut3d_pick_pixfmt() 2026-06-19 14:32:44 +00:00
Ramiro Polla a9cd93c917 swscale/ops: pass SwsSwizzleOp by pointer instead of value in ff_sws_comp_mask_swizzle() 2026-06-19 14:32:44 +00:00
Ramiro Polla 7599173512 swscale/ops: pass SwsComps by pointer instead of value in extract_{constant_rows,scalar,swizzle}() 2026-06-19 14:32:44 +00:00
Ramiro Polla 176493e4c4 swscale/ops: pass SwsLinearOp by pointer instead of value in ff_sws_linear_mask() 2026-06-19 14:32:44 +00:00
Ramiro Polla 59cba3147f swscale/uops: rename SwsOpTable/SwsOpEntry to SwsUOpTable/SwsUOpEntry
These structs are only used through ff_sws_uop_lookup() and are not part
of the SwsOp dispatch path, so rename them to reflect their actual scope.
2026-06-19 14:32:02 +00:00
Ramiro Polla b532f4a6ce swscale/tests/sws_ops_aarch64: remove on-stack copy of const data
It doesn't get modified, so there's no need to create a copy.
2026-06-19 14:31:27 +00:00
Andreas Rheinhardt 9ea36321f9 avcodec/liboapvenc: Use av_freep() where appropriate
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-19 15:18:54 +02:00
Azat Nurgaliev bccaf86a89 avcodec/amfdec: propagate color and HDR metadata from AMF surfaces
The AMF hardware decoder exposes color information and HDR side data on
output surfaces, but the decoder previously copied only static avctx
values onto output frames. Read primaries, transfer, range, and profile
from each surface, keep avctx updated, and fall back to cached values
when a field is not signalled on a given frame.

On resolution change, re-create the hw frames context instead of
trying to re-init an already initialized pool.

Attach HDR10 mastering/display metadata when PQ transfer is detected.
Release the AMF HDR metadata buffer after attaching side data.
2026-06-19 09:48:56 +00:00
Araz Iusubov 431ceceac7 avcodec/amfenc: add high_quality quality preset 2026-06-19 08:44:30 +00:00
Jun Zhao a4317c4ff8 avcodec/webvttdec: map WebVTT cue timestamps to ASS {\kf} tags
Split each cue at its inline timestamps and emit every segment as
"{\kf<cs>}<text>", the duration being the segment's own span (next
timestamp minus current); the tag precedes the text so the karaoke fill
runs during the segment.  Boundaries are rounded to centiseconds against
the cue start and differenced, so durations telescope to the cue length
without drift.  Packet timing uses pkt_timebase rather than assuming a
1/1000 time base.  Out-of-range, non-monotonic and malformed timestamps
are ignored; cues without timestamps are emitted unchanged.

ASS {\kf} only approximates WebVTT timed text (no ::cue(:past/:future)).

Fixes: ticket #23289
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-19 04:33:18 +00:00
marcos ashton 8a863106de avcodec/x86/me_cmp: add SSSE3 median_sad8
Same approach as median_sad16, processing one 8 pixel row per XMM
register.

median_sad_1_c:     141.4 ( 1.00x)
median_sad_1_ssse3:  29.1 ( 4.86x)

Benchmarks and tests run with checkasm on an Intel Core Ultra 7 155H.

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-06-18 22:08:02 +00:00
marcos ashton b8a44a7f76 avcodec/x86/me_cmp: add SSSE3 median_sad16
The median_sad functions have NEON implementations but no x86 ones,
so x86 always used the C code. x86_64 only due to register pressure.

median_sad_0_c:     314.5 ( 1.00x)
median_sad_0_ssse3:  51.1 ( 6.16x)

Benchmarks and tests run with checkasm on an Intel Core Ultra 7 155H.

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-06-18 22:08:02 +00:00
James Almer dedb75a810 avcodec/encode: take into account priming samples in the last packet duration
The generic code was setting the last packet duration based on the input frame
while ignoring the fact the encoder may have output an initial padding amount
of samples in the first (e.g. 481 for mp2, 256 for AC3, etc).

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-18 21:17:23 +00:00
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
Zhao Zhili 6489456452 avcodec/itut35: free HDR metadata on failure 2026-06-15 15:35:07 +00:00
Zhao Zhili 974a75798a avformat/mov_chan: free temporary layout on error paths 2026-06-15 15:13:53 +00:00
Zhao Zhili 4acfab044d checkasm/sw_ops: fix typo in write operations
check_write() matched against SWS_UOP_READ_PACKED/PLANAR, copied from
check_read(), instead of SWS_UOP_WRITE_PACKED/PLANAR.
2026-06-15 14:36:05 +00:00
James Almer cd199a7d69 avcodec/aacenc: fix some layouts with FLC/FRC channels
Said channels always come before FL/FR.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-15 11:19:58 -03:00
Zhao Zhili cdafceabf8 avcodec/aacenc: fix config_map for 6.1(front) 2026-06-15 13:31:36 +00:00
Zhao Zhili 1659781894 avcodec/aacdec: fix double-increment of height_tags in loop
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-06-15 17:45:16 +08:00
Michael Niedermayer 44d082edc8 avfilter/convolution: compute user matrix products in unsigned
Fixes: integer overflow

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 03:15:19 +00:00
Steven Liu 7e1cec8e0a avformat/dashdec: fix unsigned integer overflow in segment number calculation
fix issue: issues/23238
Several time-related fields in DASHContext were declared as uint64_t,
causing the arithmetic in calc_cur_seg_no(), calc_min_seg_no(), and
calc_max_seg_no() to be performed with unsigned semantics.

The expression:
  (get_current_time_in_sec() - availability_start_time) * fragment_timescale
is uint64_t throughout. When presentationTimeOffset is large (e.g. an
absolute epoch-based timestamp common in DVB-DASH live streams), the
subsequent subtraction:
  uint64_t_result - presentation_timeoffset
wraps around to a value near 2^64, because the elapsed wall-clock time
in timescale ticks is far smaller than the absolute presentation time
offset.  The enormous quotient ends up truncated to int32_t when passed
to ff_dash_fill_tmpl_params(), producing a negative $Number$ value in
the segment URL and causing repeated HTTP 403 errors.

Fix this by changing the affected fields and the two helper functions
(get_current_time_in_sec, get_utc_date_time_insec) from uint64_t to
int64_t.  All values involved are well within the int64_t range (Unix
timestamps in seconds and ISO 8601 durations), and the arithmetic
naturally needs signed semantics because intermediate sub-expressions
like (elapsed - time_shift_buffer_depth) can be negative at stream
start.

    Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2026-06-15 02:22:05 +00:00
Michael Niedermayer f7e6a8ade5 avformat/mpegts: use av_fast_realloc() for prg
Fixes: Timeout
Fixes: 514855073/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGTS_fuzzer-5074757044469760
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 00:25:34 +00:00
Michael Niedermayer 5f13df1b51 avfilter/avf_showcwt: fix DIRECTION_RL EOF fill clearing the wrong columns
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 21:08:21 +00:00
Michael Niedermayer b276ac07e8 avfilter/avf_showcwt: avoid undefined float to int conversion of nb_consumed_samples
Reproduced with:
ffmpeg -f lavfi -i "sine=frequency=440" -filter_complex \
 "[0:a]showcwt=size=32x32:deviation=0[v]" -map "[v]" -f null -

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 21:08:21 +00:00
Michael Niedermayer d133b4a231 avfilter/avf_showcwt: fix out of array read in compute_kernel
Reproduced with a small output (e.g. size=2x2) under ASan.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 21:08:21 +00:00
jiale yao 0d0eadd8ed avfilter/avf_showcwt: fix DIRECTION_DU EOF fill clearing the wrong rows
Fixes: out of array read

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 21:08:21 +00:00
Michael Niedermayer a55a8c9a68 avfilter/v360: compute remap table offsets in 64bit
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 21:01:41 +00:00
Michael Niedermayer fd6b3fa423 avfilter/v360: reject out-of-range dimensions
Fixes: integer overflow

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 21:01:41 +00:00
Andreas Rheinhardt 19e377b4b9 avcodec/x86/hpeldsp: Port mmxext functions to SSE2
The only noticable changes in benchmarks are for
the x2 horizontal no_rnd case where SSE2 and movhps
are beneficial:

Old benchmarks:
avg_pixels_tab[1][1]_c:                                 42.2 ( 1.00x)
avg_pixels_tab[1][1]_mmxext:                            10.8 ( 3.89x)
avg_pixels_tab[1][2]_c:                                 18.0 ( 1.00x)
avg_pixels_tab[1][2]_mmxext:                             6.1 ( 2.96x)
put_no_rnd_pixels_tab[1][1]_c:                          29.7 ( 1.00x)
put_no_rnd_pixels_tab[1][1]_mmxext:                     12.3 ( 2.41x)
put_no_rnd_pixels_tab[1][2]_c:                          20.4 ( 1.00x)
put_no_rnd_pixels_tab[1][2]_mmxext:                     12.2 ( 1.67x)
put_pixels_tab[1][1]_c:                                 29.9 ( 1.00x)
put_pixels_tab[1][1]_mmxext:                             7.6 ( 3.92x)
put_pixels_tab[1][2]_c:                                 16.8 ( 1.00x)
put_pixels_tab[1][2]_mmxext:                             6.4 ( 2.63x)

New benchmarks:
avg_pixels_tab[1][1]_c:                                 42.3 ( 1.00x)
avg_pixels_tab[1][1]_sse2:                              10.7 ( 3.95x)
avg_pixels_tab[1][2]_c:                                 17.8 ( 1.00x)
avg_pixels_tab[1][2]_sse2:                               6.3 ( 2.83x)
put_no_rnd_pixels_tab[1][1]_c:                          29.6 ( 1.00x)
put_no_rnd_pixels_tab[1][1]_sse2:                       10.5 ( 2.81x)
put_no_rnd_pixels_tab[1][2]_c:                          20.4 ( 1.00x)
put_no_rnd_pixels_tab[1][2]_sse2:                       12.3 ( 1.67x)
put_pixels_tab[1][1]_c:                                 30.1 ( 1.00x)
put_pixels_tab[1][1]_sse2:                               7.6 ( 3.93x)
put_pixels_tab[1][2]_c:                                 16.8 ( 1.00x)
put_pixels_tab[1][2]_sse2:                               6.4 ( 2.64x)

Switching to SSE2 unfortunately increased codesize of the relevant
functions by 160B.

This makes these functions ABI compatible, i.e. they no longer
rely on others calling emms_c to fix the fpu state. It also
implies that many mpegvideo decoders (the exceptions are MPEG-4,
RV30, RV40 and the VC-1 family) now no longer use any mmx registers
at all. So one can remove the emms_c from the MPEG-1/2 decoder.
The same is true for VP3.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-14 22:04:42 +02:00
Andreas Rheinhardt c35f57f3c4 avcodec/x86/fpel: Use SSE2 in avg_pixels8
No change in benchmarks here; this already allows
to remove an emms_c from cavsdec.c.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-14 22:04:42 +02:00
Andreas Rheinhardt 77dbbdcac2 avcodec/x86/hpeldsp: Avoid loading constants
No change in benchmarks here.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-14 22:04:42 +02:00
Andreas Rheinhardt 00ece261b8 avcodec/x86/hpeldsp: Avoid offsetting unnecessarily
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-14 22:04:42 +02:00
Andreas Rheinhardt 0ff6f28437 avcodec/x86/hpeldsp: Deduplicate {avg,put}_pixels{8,16}_y2 macros
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-14 22:04:42 +02:00
Andreas Rheinhardt 65a87545a9 avcodec/x86/hpeldsp: Add _approx to non-bitexact functions' names
Right now, their exact counterparts have a "_exact" in their names;
switch this around.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-14 22:04:42 +02:00
Andreas Rheinhardt 5d277e8c7c avcodec/x86/hpeldsp: Avoid constant in {avg,put}_pixels16_xy2_ssse3
No difference in benchmarks here.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-14 22:04:42 +02:00
Andreas Rheinhardt f5c26ccf93 avcodec/x86/hpeldsp: Deduplicate {avg,put}_pixels{8,16}_x2 macros
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-14 22:04:42 +02:00
Romain Beauxis 8851de74e8 tests/fate/wav.mak: gate tests that need swresample 2026-06-14 15:03:28 -05:00
Kacper Michajłow 60d868527b fate/probe: test mpeg-ts with a png prefix and tiff from ticket #5565
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-14 21:59:14 +02:00
Kacper Michajłow 0eb2d1f64a avformat/mpegts: return SCORE_MAX for fully sync-aligned boundary buffers
At check_count == CHECK_COUNT the existing branch caps the score at
SCORE_MAX/2 even when every analyzed packet is sync-aligned and when
analyze() already has full confidence. This loses probe to
signature-only image demuxers (e.g. png_pipe at SCORE_MAX - 1) for
streams with a small leading non-TS prefix. Some CDNs prepend a 1x1 PNG
to MPEG-TS payloads to bypass image-only Content-Type filtering, and the
PNG signature otherwise wins the first probe iteration.

Fixes: https://github.com/mpv-player/mpv/issues/11365

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-14 20:51:07 +02:00
Michael Niedermayer 4171581953 swresample/x86/resample: write only int16 in the int16 resampler
The resample asm code as it is currently handles 1 sample at a time

The asm code should be redesigned and handle more than 1 sample at a
time. That is the whole purpose of SIMD. There is also multiple samples
available that need identical handling like from several channels or
similar handling from other points in time.

Such redesign would make the resampler faster and would change the
requirements of padding and maybe memory layout. So it seems simpler
to just avoid overwriting in the asm as it is today than to have
the allocation handle specific overallocation for asm code that
ideally should be redesigned

Fixes writing 16bits over the end of the array

This is an alternative fix for https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23053

Found-by: Ivan Grigorev <ivangrigoriev@meta.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 15:34:43 +00:00
Ivan Grigorev bdbb580d9c swresample/tests: add resample realloc regression test
Add a regression test exercising the swr_convert(N) -> swr_convert(2N)
edge case: the second call reuses the internal preout buffer at full
capacity, with no trailing slack from swri_realloc_audio()'s amortized
doubling. internal_sample_fmt is forced to S16P to reach the int16 SIMD
resample path, where ff_resample_common_int16_sse2 overruns its
destination by 2 bytes on the last iteration.

Without a resampler fix this test fails under valgrind/ASAN with a
heap-buffer-overflow (Invalid write of size 4, 2 bytes past the end).

Signed-off-by: Ivan Grigorev <ivangrigoriev@meta.com>
2026-06-14 15:34:43 +00:00
jiale yao 71478d1165 avformat/rtpenc_amr: Check input size
Fixes: heap buffer overflow

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 15:32:48 +00:00
WyattBlue b1d2190f5f avutil/riscv: Include unistd.h for musl Linux
Before, glibc appears to transitively pull in the syscall number
definitions, but musl does not do this. Thus, `__NR_riscv_hwprobe`
is undeclared and an error is emitted.

Fix this by including `<asm/unistd.h>`, which makes the macro
visible on musl.
2026-06-14 13:51:25 +00:00
Scott Boudreaux dddc703cc1 swscale/ppc: fix LOAD_FILTER overread in VSX path
Part of the yuv2planeX ASAN fix - replace vec_vsx_ld with vec_splats
to avoid reading past the filter array.

Signed-off-by: Scott Boudreaux <scott@elyanlabs.com>
2026-06-14 13:47:14 +00:00
Scott Boudreaux d4673a97ac swscale/ppc: fix ASAN stack-buffer-overflow in yuv2planeX
Fix two buffer overreads in the PowerPC yuv2planeX SIMD paths
that cause daily FATE checkasm-sw_scale ASAN failures on both
ppc64 (G5, altivec) and ppc64le (POWER9, VSX):

1. VSX LOAD_FILTER: vec_vsx_ld(joffset, filter) reads 16 bytes
   at the given byte offset.  When joffset >= filterSize*2 - 14
   (e.g. joffset=30 for filterSize=16), this reads up to 14 bytes
   past the 32-byte filter array.  Fix by replacing the vector
   load with vec_splats(f[j]) which only reads the single int16_t
   element needed (the result is splatted to all lanes anyway).

2. GET_LS look-ahead overread: yuv2planeX_8_16 calls
   yuv2planeX_8 twice per filter tap.  Each call's GET_LS macro
   speculatively loads the next 16-byte vector for pipelining.
   On the second call, this look-ahead reads 16 bytes past the
   last valid source element.  Fix by tightening the SIMD loop
   bound from (dstW - 15) to (dstW - 23), ensuring the farthest
   speculative load stays within src[j][0..dstW-1].  The scalar
   fallback handles the remaining 16-23 trailing pixels.

The ASAN reports from FATE:
  ppc64 (altivec): stack-buffer-overflow in yuv2planeX_8_16_altivec
                   at swscale_ppc_template.c:56
  ppc64le (VSX):   unknown-crash in yuv2planeX_8_16_vsx
                   at swscale_ppc_template.c:52

Signed-off-by: Scott Boudreaux <scott@elyanlabs.com>
2026-06-14 13:47:14 +00:00
Niklas Haas 6698195dc4 avformat/shared: propagate correct short seek size on failure
This might be AVERROR(ENOSYS), which we shouldn't propagate.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas fa6a5807c2 avformat/shared: allow AVERROR_EXIT/EAGAIN as transient failures
These shouldn't really permanently invalidate the block.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas f87923765d avformat/shared: robustness fix for seek-past-end
If the filesize is known as a result of AVERROR_EOF on a block that ends
before the current seek position, this might end up negative. Error
out cleanly instead of aborting.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas a22037858e avformat/shared: use flock() instead of fcntl()
flock() also locks against accesses by other threads of the same
process, unlike fcntl().

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas 9140cbe583 avformat/shared: don't read directly into cache file when racing writes
Instead, read to the output/temporary buffer (write_back path). This is to
lessen the impact of racing the write against other clients trying to race
the same pending block.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas 58e5ec8a5a avformat/shared: allocate fallback buffer unconditionally
Needed for the upcoming commit, but also more robust in general. The memory
waste is negligible.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas c97a2328c0 avformat/shared: set default cache timeout to 10 ms
This value is matched to the typical seek latency in a reasonably capable
7200 rpm disk device, as well as the typical latency of an on-premise HTTP
request.

Note that this change should rarely have a significant effect, because
it only matters when using multiple concurrent processes, and one process
is somehow stuck in I/O (or died). Since we sleep in a loop for 1/16th of
the requested timeout value, this should only increase the effective read
latency by up to ~500 us on top of the actual underlying latency.

The alternative is hammering the same underlying resource with the exact
same requests at the exact same time (e.g. during init).

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas 5dd020faff avformat/shared: error out if filesize does not match expected
If this happens, something is almost surely wrong with the cache file
(e.g. mismatched source file), so it's much better to error out rather than
hit silent data corruption.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas a37c00c4e9 avformat/shared: add missing ret = 0
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
deng.zewen f704dd77b7 libavcodec/riscv: add RVV optimized hevc_add_res 2026-06-14 03:10:29 +00:00
James Almer e772f50a65 fftools/ffmpeg_demux: ensure tile grid stream groups are sane
This is already checked in libavformat, at least in the only demuxer that
creates them, but best not risk an out-of-bounds access in case a new demuxer
doesn't take the proper measures.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-13 21:52:32 -03:00
James Almer 3d2c02f1dd avcodec/bsf/h264_mp4toannexb: don't overwrite output codecpar extradata after init()
It's against the documented behavior of bitstream filters.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-13 21:32:07 -03:00
Michael Niedermayer ab5043f055 avcodec/sanm: reject codec37 frames taller than the allocated buffer
No testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 22:03:59 +00:00
Michael Niedermayer b2695bcbb3 avcodec/sanm: reject codec47 frames taller than the allocated buffer
Fixes: 513469519/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5024854725427200
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-13 22:03:59 +00:00
Michael Niedermayer f7368f97b9 avfilter: use ff_slice_pos() for per-slice boundary computation
This is a behavior preserving change for all non-overflowing cases.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 21:41:05 +00:00
Michael Niedermayer 218b4771a3 avfilter: add ff_slice_pos() helper for slice boundaries
Slice based filter workers compute their per-thread row/sample/channel
boundaries as total * jobnr / nb_jobs. The total * jobnr product is
evaluated in int and overflows signed int for large dimensions and many
slice threads, before the division by nb_jobs brings it back in range.
2026-06-13 21:41:05 +00:00
Michael Niedermayer 200e0cba67 avfilter/estdif: avoid signed overflow in slice boundary calculation
deinterlace_slice() computed per-thread row boundaries with int
multiplication height * (jobnr + 1). With a tall frame and many filter
threads the product overflows signed int before the division by nb_jobs.

Use int64_t for the intermediate product before converting back to int
row indices.

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 21:41:05 +00:00
Michael Niedermayer 2ff28aca4b avcodec/jpeglsdec: bound cumulative decoded JPEG-LS height per packet
Fixes: Timeout
Fixes: 509211998/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-5098892286033920
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-13 21:40:40 +00:00
Michael Niedermayer 10f2abc41f swscale: support sliced input with cascaded scaling contexts
Previously scale_cascaded() assumed the whole source frame arrived in a
single sws_scale() call, and the dispatcher only routed full-frame calls
to it. A partial input slice fell through to ff_swscale() on the parent
dispatcher context, whose scaler state (c->desc) is never initialized in
cascade mode, causing a NULL dereference / crash.

Top-down sliced output is bit-exact with full-frame scaling; bottom-up
matches swscale's pre-existing (non-cascade) slice behaviour for
subsampled intermediate formats.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 21:32:37 +00:00
Michael Niedermayer 6049b4d7bc avformat/rtspdec: bound Content-Length in the ANNOUNCE handler to SDP_MAX_SIZE
Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-06-13 21:31:18 +00:00
James Almer 0cf9169c85 avcodec/cbs_h266_syntax_template: reject subpic info with res_change_in_clvs
Found-by: Anthony Hurtado
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 15:57:19 +00:00
Michael Niedermayer 7b717fe50d avcodec/misc4: Check nb channels
Found-by: Forgejo Fairy
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 15:55:40 +00:00
Michael Niedermayer 0c662529f6 avcodec/rv10, rv34: check init_get_bits8() before RealVideo bit access
Found-by: Samarth Kumbla <samarthk@cantina.security>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 15:54:44 +00:00
Ling, Edison 3773831c21 avcodec/d3d12va_encode: Add H264/HEVC constrained intra prediction parameter support
Add parameter `constrained_intra_pred` for users to enable constrained intra prediction (as opposed to default unconstrained) in D3D12 H264 and HEVC encoding.

Usage:
  false (default): `-constrained_intra_pred false`  or  `-constrained_intra_pred 0`
  true:            `-constrained_intra_pred true`   or  `-constrained_intra_pred 1`

Sample command line:
```
ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v h264_d3d12va -constrained_intra_pred true -y output.mp4
ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v hevc_d3d12va -constrained_intra_pred true -y output.mp4
```
2026-06-13 11:21:14 +00:00
Kacper Michajłow bb6de744cc avcodec/opus/enc_psy: init intensity_stereo for silent frames
Silent frames return early from ff_opus_psy_celt_frame_init before
intensity_stereo is set, but postencode_update reads it into
avg_is_band, causing a use-of-uninitialized-value. Set it to end_band
like the non-silent path does.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-13 12:08:10 +02:00
Niklas Haas f71c30ef9e swscale/x86/ops: fix CPU flags checks
This should be using EXTERNAL_*() as the code lives in separately assembled
files. Also, the FMA4 check should have been FMA3.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-13 08:26:19 +00:00
Andrew Kelley 2797dad735 hevc: qualify libavcodec include paths
Removes the special -I flag specified in the avcodec/hevc/ subdirectory.

This makes code copy-pastable to other parts of the ffmpeg codebase, as
well as simplifying the build script.

It also reduces ambiguity, since there are many instances of same-named
header files existing in both libavformat/ and libavcodec/
subdirectories.

Follows: b29bdd3715
2026-06-13 05:48:44 +00:00
Daniel Verkamp 4a7cc39c63 doc/muxers: Document wav muxer
Signed-off-by: Daniel Verkamp <daniel@drv.nu>
2026-06-13 04:10:48 +00:00
Daniel Verkamp 7d416470c7 doc/demuxers: Document wav ignore_length option
Signed-off-by: Daniel Verkamp <daniel@drv.nu>
2026-06-13 04:10:48 +00:00
Romain Beauxis bf8f1550f0 tests/fate: move fate-wav-bad-avg-byterate to
fate-seek-bad-avg-byterate, fix build dependency on libavformat/tests/seek
2026-06-12 14:45:42 -05:00
haoyuLiu dd9083cb89 avformat/http: reject request-line tokens not terminated by whitespace
Fixes out of array access

Found-by: Cloud-LHY (@Clouditera-lhy) / VulnForge Security Research Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 16:47:05 +00:00
James Almer b817e19259 avformat/dump: support printing Dolby Vision stream group information
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-12 15:10:12 +00:00
Andreas Rheinhardt 9dd0fe0225 avcodec/allcodecs: Move AV_CODEC_PROP_ENHANCEMENT check to test tool
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-12 15:11:53 +02:00
James Almer 631ac6d055 fftools/ffmpeg_filter: propagate display matrix side data through the filterchain
But only if autorotating is disabled.

Fixes issue #23383.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-12 09:28:20 -03:00
Michael Niedermayer 2cc7b87bdb avformat/mov: reject out of range ispe dimensions, avoid overflow summing HEIF tile dimensions
ispe width/height are read as uint32 but stored in int HEIFItem fields;
values above INT_MAX became negative, and read_image_grid() summing such
widths into coded_width overflowed int:
libavformat/mov.c:10404:33: runtime error: signed integer overflow: -2147483647 + -2147483647 cannot be represented in type 'int'

Also accumulate the grid tile dimensions and running offsets in 64bit
and validate the totals, as up to 256 tile columns of individually
valid widths can still overflow int.

Found-by: 51511
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 02:00:36 +00:00
Michael Niedermayer c82196b299 avformat/hlsenc: reject out-of-range EXT-X-PROGRAM-DATE-TIME
Parse the timestamp with av_small_strptime() instead of sscanf(): it
range-checks each field (year 0-9999, month, day, hour, minute, second)
and limits the number of digits consumed, so an oversized field can no
longer overflow during parsing. The mktime() result is additionally
checked for EOVERFLOW.

Fixes: integer overflow

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 01:57:06 +00:00
Michael Niedermayer 369a50fe75 tools/target_dec_fuzzer: Bound cumulative get_buffer allocation
Fixes: Timeout
Fixes: 509366072/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-4588961581563904
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-12 01:56:23 +00:00
Lynne 03be563053 hwcontext_vulkan: fix BGRA/BGR0 images
The fix was a lot simpler than I thought it was.
2026-06-12 10:14:33 +09:00
Andrew Kelley 8a10a8a03e opus: qualify libavcodec include paths
Removes the special -I flag specified in the avcodec/opus/ subdirectory.

This makes code copy-pastable to other parts of the ffmpeg codebase, as
well as simplifying the build script.

It also reduces ambiguity, since there are many instances of same-named
header files existing in both libavformat/ and libavcodec/
subdirectories.

Follows: b29bdd3715
2026-06-12 00:49:14 +00:00
David Korczynski 4527854281 avcodec/agm: validate actual src_y against prev plane in decode_inter_plane
Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 00:47:12 +00:00
David Korczynski 50e65074f5 avformat/dhav: Fix second integer overflow in get_duration()
Fixes: ada-2-poc.dhav

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.
2026-06-12 00:46:32 +00:00
Zhen Yan fa391e90fb fftools/ffmpeg_dec: deep-copy subtitle_header to fix use-after-free
Found-by: Zhen Yan
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 00:45:29 +00:00
Michael Niedermayer d2dd0a0a8f avcodec/cbs_h265: allocate VPS hrd_parameters dynamically
H265RawVPS embedded hrd_parameters as an inline array of
HEVC_MAX_LAYER_SETS (1024) H265RawHRDParameters, making the structure
roughly 7.9 MB. CBS allocates the whole content structure for every VPS
NAL unit before parsing it, so a packet consisting of many tiny VPS NALs
forces gigabytes of allocations and triggers an out-of-memory condition.

Allocate hrd_parameters separately, sized to vps_num_hrd_parameters,
backed by an AVBufferRef registered as a second internal reference
offset on the VPS unit type. This shrinks the resident structure to tens
of kilobytes and bounds the hrd_parameters allocation by the amount that
is actually parsed.

Fixes: 472754452/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-6379024978083840
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-12 00:43:44 +00:00
Michael Niedermayer 82f097c825 avcodec/hevc/ps: Check window parameters
Fixes: signed integer overflow: -1094995529 * 2 cannot be represented in type 'int'
Fixes: 484567435/clusterfuzz-testcase-minimized-ffmpeg_dem_HXVS_fuzzer-5628836988649472

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-12 01:44:34 +02:00
Michael Niedermayer 8c868a1fd2 avcodec/hevc/ps: Factor window reading out
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 01:44:34 +02:00
James Almer e4c631731e avformat/mov: allow outputting potentially truncated APV packets
The size field could be wrong while the actual payload is valid.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-11 21:09:24 +00:00
James Almer 4b23a90935 avcodec/lcevcdec: respect log level from the external library
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-11 17:28:14 -03:00
James Almer d024831750 avcodec/lcevcdec: don't inherit the parent decoder logging context
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-11 17:27:19 -03:00
Niklas Haas 625ab011f4 swscale/uops: add default fallback for translate_op()
Makes it a bit easier to add ops and uops in separate commits.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas b488ee5553 swscale/ops: generalize SwsReadWriteOp.packed to enum
I want to start adding more data layouts, like semiplanar formats (nv12), or
palette formats. I made an effort to distinguish existing checks for rw.packed
into "mode != PLANAR" and "mode == PACKED", based on the intent of the
surrounding code, in anticipation of these new layouts.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas 01c007ec4d swscale/ops_memcpy: simplify plane count check
Instead of testing for this condition indirectly via packed and rw.elems,
we can now express the relevant condition directly. The memcpy backend works
if and only if each component lives on a separate plane.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas 84c8f55398 swscale/ops_optimizer: simplify shuffle solver plane checks
Using ff_sws_rw_op_planes(), to directly encode the relevant condition (i.e.
physical access to multiple planes).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas 5f43d0cd46 swscale/ops: add and use ff_sws_rw_op_planes()
This is rw_planes() from ops_dispatch.c, but exposed internally.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas ef79a57b75 swscale/ops_dispatch: move some code from setup() to compile()
This won't change from frame to frame, so there's no reason to redundantly
re-setup these fields. Paves the way for the next change as well.

The one minor annoyance is that this relies on SwsOpList.src/dst being
populated, to gain access to the sub_x/sub_y fields. However, that's not
a big ask, given that e.g. the dispatch layer already relies on the
pixel dimensions from this field being accurate for sizing intermediate
buffers during filter splitting.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas 7c5d45b843 swscale/ops_dispatch: reword misleading error
The block size is given in units of pixels, so this message as written
does not even make sense.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas addee69955 swscale/ops_dispatch: generalize block_size_in/out to array
See previous commit for justification. I decided to split these
refactors up into several independent commits to make it easier
to review and bisect, since they are all independent atomic changes.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas 2d01687fd0 swscale/ops_dispatch: generalize over_read/over_read to array
I want to introduce operations like semiplanar reads, which would
possibly require a different number of over_read bytes per plane.

That aside, this is just a general cleanliness improvement.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas 11900e4e12 swscale/ops: generalize SWS_OP_FILTER_* result type
Instead of hard-coding SWS_PIXEL_F32 here. This is not really useful
yet, but I wanted to clean up the semantics here regardless.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas 57d7bf5194 swscale/ops_optimizer: fix broken convert->filter commute check
This one failed to adjust prev->type to the result of filtering,
leading to basically broken intermediate op lists. Fortunately, the
optimizer usually ended up eliminating these cases altogether.

Replace it by a fixed check to merge filters with any prior conversion
op that satisfies the criteria (and is deemed beneficial).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas 091149b187 swscale/ops: group filtered rw metadata into struct
This is a minor cosmetic improvement that allows me to use more
convenient names for a filter-related metadata fields, without
confusion.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Romain Beauxis f35a082ecc libavformat/{riffenc, adpcmenc}.c: export correct bitrate 2026-06-11 14:06:20 +00:00
Romain Beauxis 80b2dcc991 libavformat/riffdec.c: correct invalid bit_rate when possible. 2026-06-11 14:06:20 +00:00
Romain Beauxis cffc83f50d tests/fate/wav.mak: Add bitrate regression tests. 2026-06-11 14:06:20 +00:00
Romain Beauxis 8d01e55e1b tests/fate-run.sh: add run_with_patched_temp 2026-06-11 14:06:20 +00:00
Romain Beauxis e02b4e5d62 libavformat/tests/seek.c: add optional stream id CLI param. 2026-06-11 14:06:20 +00:00
Romain Beauxis 12dddab095 libavcodec/tests/encinfo.c: add encoder info test utility 2026-06-11 14:06:20 +00:00
David Korczynski d30dead35e avcodec/truespeech: reject iterations count whose * 240 product overflows 32-bit
Found-by: Anthropic agents; validated and reported by Ada Logics.
Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-11 13:58:45 +00:00
Andrew Kelley b29bdd3715 bsf: qualify libavcodec include paths
Removes the special -I flag specified in the avcodec/bsf/ subdirectory.

This makes code copy-pastable to other parts of the ffmpeg codebase, as
well as simplifying the build script.

It also reduces ambiguity, since there are many instances of same-named
header files existing in both libavformat/ and libavcodec/
subdirectories.

Reverts: 0e4dfa4709
Reapplies: 41b73ae883
2026-06-10 18:52:32 -07:00
Timo Rothenpieler 5f998e304d avcodec/nvenc: fix b_ref_mode capability check
Turns out it's a bitfield, not straight values.

Fixes #23061
2026-06-10 20:17:44 +02:00
James Almer cf0244aa38 avformat/movenc: avoid negative cts offsets when using an edit list with CMAF output
Fixes issue #23417.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-10 18:14:42 +00:00
Martin Storsjö d05786cf23 aarch64: vp9lpf: Fix GCS violations
The aarch64 VP9 loopfilters actually violate aarch64 GCS
(Guarded Control Stack), even though we marked the code as GCS
compliant in 846746be4b.

This means that builds with GCS enabled, after that commit,
will crash when decoding VP9, on future hardware (or current
QEMU) that supports GCS. This also goes for ffmpeg version 8.1.1
where the GCS enabling was backported.

This matches the fix that was done for hevcdsp in
1f7ed8a78d.

This issue wasn't observed if running checkasm in QEMU - therefore,
I thought all GCS issues had been fixed by
846746be4b. (If I would have
tested the full "make fate" with QEMU, the issue would
have appeared though.)

However with the new checkasm, some of the GCS violations
do appear even in checkasm.

The reason is that the checkasm vp9 test intentionally craft
input pixels that attempt to trigger all the individual
separate cases in each input buffer (in
randomize_loopfilter_buffers). This means that the checkasm
tests actually never test or exercise the early exit cases,
which are the ones that violate GCS.

With the new checkasm, the call to "bench_new" always test
running the code at least once, even if not benchmarking.

As the input buffers weren't reinitialized between the test
and "bench_new", the pixel differences now differ from the
initial setup, so that the code now some times (often) would
end up hitting the early exit cases.

Ideally, the vp9 checkasm test would be repeated to cover all
cases of input buffers that allow early exits, in addition to
covering the case with all different cases in one block.
2026-06-10 18:03:01 +00:00
DROOdotFOO cc7c567920 swscale/aarch64/yuv2rgb_neon: add BE 16bpp output formats
BE counterparts to the LE paths in 2e142e52ae; pack adds rev16 before
store. nv12/nv21 paths are added but bench-only (no C ref, same as
2e142e52ae).

Test Name                              A55-gcc           M1-clang             A76-gcc
-------------------------------------------------------------------------------------
yuv420p_rgb565be_1920_neon    15086.1 ( 3.91x)    5507.0 ( 4.34x)    19229.1 ( 2.02x)
yuv420p_bgr565be_1920_neon    15291.7 ( 3.84x)    5476.9 ( 4.37x)    19229.4 ( 2.02x)
yuv420p_rgb555be_1920_neon    15091.5 ( 3.67x)    5569.0 ( 3.97x)    19229.3 ( 1.90x)
yuv420p_bgr555be_1920_neon    15298.6 ( 3.62x)    5600.6 ( 3.98x)    19228.8 ( 1.90x)
yuv422p_rgb565be_1920_neon    16862.3 ( 4.00x)    6378.8 ( 4.64x)    22110.3 ( 2.07x)
yuv422p_bgr565be_1920_neon    17139.3 ( 3.93x)    6448.1 ( 4.50x)    22104.1 ( 2.07x)
yuv422p_rgb555be_1920_neon    16853.3 ( 3.98x)    6468.8 ( 4.12x)    22106.4 ( 1.98x)
yuv422p_bgr555be_1920_neon    17202.2 ( 3.89x)    6467.0 ( 4.12x)    22110.2 ( 1.98x)
yuva420p_rgb565be_1920_neon   15050.2 ( 3.92x)    5452.5 ( 4.39x)    19229.5 ( 2.02x)
yuva420p_bgr565be_1920_neon   15346.6 ( 3.84x)    5462.4 ( 4.36x)    19228.9 ( 2.02x)
yuva420p_rgb555be_1920_neon   15050.8 ( 3.69x)    5463.3 ( 3.95x)    19228.6 ( 1.90x)
yuva420p_bgr555be_1920_neon   15352.8 ( 3.61x)    5543.6 ( 3.89x)    19228.6 ( 1.90x)

Co-authored-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: DROOdotFOO <drew@axol.io>
2026-06-10 17:54:20 +00:00
DROOdotFOO 7ab5aebc08 swscale/yuv2rgb: add explicit BE/LE 565/555 cases
ff_yuv2rgb_get_func_ptr() now returns the C reference for explicit
BE/LE 16bpp formats, not only the NE alias.

Signed-off-by: DROOdotFOO <drew@axol.io>
2026-06-10 17:54:20 +00:00
Romain Beauxis 590d775a66 avcodec/codec_id: add .props to AV_CODEC_ID_APPLE_APAC
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-06-10 10:08:39 -05:00
wangbin c73476e107 avfilter/vf_scale_d3d11: ensure guids are defined
fix vf_scale_d3d11.o : error LNK2001: unresolved external symbol IID_ID3D11VideoContext
2026-06-10 15:08:12 +00:00
Niklas Haas 976e18fdef swscale/x86: use correct HOSTCC_E flag instead of CC_E
HOSTCC and CC might be completely different compilers.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-10 15:04:50 +00:00
Niklas Haas 7b59a86633 swscale/uops_tmpl: move attributes before static keyword
This fails to compile with C23 standard attributes otherwise.

Technically only av_unused requires this, but move the other attributes
as well for consistency / future proofing.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-10 16:27:58 +02:00
Frank Plowman b899f7e8b5 lavc/vvc: Fix num_entry_points derivation when using RPR
Context:
1. In the case sps_subpic_info_present=0, there is a single subpicture
   which includes the entire picture.
2. When sps_subpic_info_present=0, we might be using Reference Picture
   Resampling (RPR), in which picture sizes might differ in the PPS,
   rather than in the SPS.

Because of 2., we can't rely on the sequence-level variables
sps_subpic_width_minus1 and sps_subpic_height_minus1 to derive the
picture-level variable num_entry_points, as the picture might have a
different size to the picture used when deriving those sequence-level
variables.
2026-06-10 14:02:29 +00:00
Hunter Kvalevog 54749da98a avdevice/gdigrab: make overlay window layered
WS_EX_LAYERED allows input events to pass through to windows beneath.

WS_EX_NOACTIVATE prevents the window from stealing focus when created.
2026-06-10 12:56:20 +00:00
Hunter Kvalevog dc1128e475 avdevice/gdigrab: process window in a separate thread
Move window creation and event processing to a dedicated thread.

GetMessage only processes events from the calling thread's message
queue. Because gdigrab_read_header and gdigrab_read_packet don't run on
the same thread, the message queue was not being drained.

Fixes: #11539
2026-06-10 12:56:20 +00:00
Robert Nagy 97491ce0d5 libavfilter/libplacebo: gamma22 and gamma28 aliases 2026-06-10 12:34:38 +00:00
Robert Nagy 06e11c87c6 libavcodec/options_table: gamma22 and gamma28 aliases 2026-06-10 12:34:38 +00:00
Romain Beauxis c19949ae0f avformat/isom_tags: Add support for detecting apple_apac
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-06-10 11:59:35 +00:00
Romain Beauxis f98eaa3ea9 avcodec/codec_id: Add Apple Positional Audio Codec.
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-06-10 11:59:35 +00:00
Lynne f1b4b5b5f6 aacdec_usac: apply volume normalization settings 2026-06-10 18:04:22 +09:00
Lynne 71b59582e2 aacdec_usac: implement basic DRC parameter decoding 2026-06-10 18:04:22 +09:00
Michael Niedermayer d3a56ed37b swscale/tests/sws_ops: fix uops leak on translate success path
Fall through to the existing cleanup so uops is freed on both the success
and failure paths.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-10 07:48:37 +00:00
Bejoy a5ee6ff720 docs: refine issue tracker transition references 2026-06-10 06:35:21 +00:00
David Korczynski 331b3e9dea avcodec/on2avc: reject subframe count whose * SUBFRAME_SIZE product overflows 32-bit
Found-by: Anthropic agents; validated and reported by Ada Logics.
Signed-off-by: David Korczynski <david@adalogics.com>
2026-06-10 02:15:53 +00:00
Ramiro Polla 2576e09434 swscale/aarch64/ops: simplify process function generation
There was no good reason to have it as an SwsAArch64OpType.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-10 01:47:11 +02:00
Ramiro Polla 19250a1846 swscale/aarch64/ops: use plain ret instruction
Use a call/ret pair instead of awkwardly exporting and then jumping
back to the return label.

This is similar to c29465bcb6, but for aarch64.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-10 01:47:10 +02:00
Ramiro Polla 061dc9ab6d swscale/aarch64/rasm: add blr instruction
And a64op_lr() helper for LR register.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-10 01:46:29 +02:00
Ramiro Polla ecba7e1d42 swscale/aarch64/rasm: split conditional and unconditional branch instructions
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-10 01:46:29 +02:00
Ramiro Polla 692951d1c2 swscale/tests/sws_ops_aarch64: fix skipping of scaling ops
Scaling ops were add to ff_sws_enum_op_lists() in 1d841635. But the
code that skipped scaling ops in convert_to_aarch64_impl() wasn't
taking into consideration that, in sws_ops_aarch64, the scaling ops
aren't folded into read ops.

Also updates libswscale/aarch64/ops_entries.c with the new entries.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-10 01:46:29 +02:00
Diego de Souza 0a7c5e507b avcodec/nvenc: fix compatibility with Video Codec SDK 13.1
NV_ENC_CLOCK_TIMESTAMP_SET was changed in SDK 13.1: countingType was
replaced by countingTypeLSB and countingTypeMSB.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2026-06-10 01:28:40 +02:00
Frank Plowman 6bfc7214d1 configure: Declare MPEG decoder/SEI dependencies on ITU-T35
Forgotten in 070bd112be
2026-06-09 19:07:14 +00:00
James Almer 9eb6f2f450 avcodec/aacenc: fix PCE layouts for 7.1 and 7.1(wide)
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-09 15:33:20 -03:00
Martin Storsjö b20c4c6f98 checkasm: Update to the latest upstream version
This update was done by running this command:

    $ git subtree pull --squash --prefix=tests/checkasm/ext \
      https://code.ffmpeg.org/FFmpeg/checkasm.git master

This includes fixes for a couple regressions noted after integrating
the new external checkasm into ffmpeg:

- Fixes spurious errors about missing vzeroupper in C code generated
  by MSVC, fixing https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/23360
- Fixes building for WINAPI_FAMILY_PHONE_APP, and for UWP with older
  Windows SDKs, https://code.videolan.org/videolan/checkasm/-/work_items/37
- Fixes building in x86_32 mode for Windows with --disable-asm,
  https://code.videolan.org/videolan/checkasm/-/work_items/36
2026-06-09 20:57:59 +03:00
Martin Storsjö b3bcd320f5 Squashed 'tests/checkasm/ext/' changes from 0df02535c7..e13b0bb3ff
e13b0bb3ff x86: Skip the vzeroupper checks when built with MSVC
3cbf066c51 longjmp: Use raw arch defines for checking for x86_32
54817bd68f include: Fix a mismatched include guard comment
162f15c861 github: Build the UWP job as WINAPI_FAMILY_PHONE_APP
34d920e8bb arm/cpu: Avoid the Windows registry API in UWP builds
9a0cb83b69 utils: Avoid the GetStdHandle and GetConsoleScreenBufferInfo APIs in UWP builds
8d1609d583 ci: Test building ffmpeg with the latest checkasm
d93232845f ci: Test building latest dav1d and dav2d with the current checkasm
e15a8efbfc readme: Add me to the list of maintainers
01b4334a95 meson: Bump version to v1.3.0

git-subtree-dir: tests/checkasm/ext
git-subtree-split: e13b0bb3ff0935b7d2a1c2cc91163370f2cc8f40
2026-06-09 20:57:50 +03:00
Kacper Michajłow f43f609bb8 avutil/x86/tx_float: add missing vzeroupper to 15xM PFA FFT
The AVX2 15xM PFA FFT calls its second-dimension subtransform with dirty
YMM. That subtransform may be a legacy-SSE codelet (fft4 is SSE2 only),
causing AVX<->SSE transition penalties. Clear them after the first
dimension, before the calls.

Detected with `sde64 -ast` FATE job.

Fixes: ace42cf581
2026-06-09 17:54:21 +00:00
Lynne 4406f5ba5b prores_raw: document vendor-specific metadata location 2026-06-10 02:38:36 +09:00
Lynne 4cf96187e4 prores_raw: set frame crop fields
Some sensors or cameras put junk in the frame boundaries. We should
crop them out.
2026-06-10 02:38:35 +09:00
Lynne 0def4ceb18 prores_raw: export raw camera color data values 2026-06-10 02:38:35 +09:00
Lynne 12dc67b6fe lavu/frame: add camera raw codec side data
Required to correctly present raw video.
Codec-specific since I'd like to support ARRIRAW in the future, which
has a different format.
2026-06-10 02:38:35 +09:00
Niklas Haas 941a35149b swscale/x86/ops_int: switch to SWS_UOP_MOVE
Instead of SWS_UOP_PERMUTE/SWS_UOP_COPY.

No real measurable difference in performance (it just eliminates a few
practically free register renames), but definitely simpler.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 36004d681f swscale/uops: add SWS_UOP_MOVE for optimal register-register swizzles
This decomposes a swizzle mask into a series of optimal register-register
moves, using at most two temporary scratch registers.

This is a better match for ASM-style backends than the existing PERMUTE/COPY
uops that are designed for the needs of the C backend (or other backends which
either apply the swizzle mask directly or permute pointers).

I originally had logic equivalent to this written in NASM macros, but it was
just such a complicated mess that I think it's better to rewrite it in C and
have the resulting metadata be an explicit part of the uop definition.

This commit only adds the uop, I'll update the x86 implementation in the
next step.

Co-authored-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 228ef8d97b swscale/ops: make compile() take const SwsOpList *
The old x86 backend was the only backend that actually mutated the ops list.
With this gone, we can constify this parameter.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas a7c6a5f74e swscale/ops_chain: remove dead code
This is no longer needed now that both C and x86 are ported to uops.
The other ff_sws_setup_*() functions are still used by the aarch64 backend.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 43a8e2da01 swscale/x86/ops: rewrite based on uops_macros.h
This is a ground-up refactor of the existing x86 ops code, using the new
uops macros to auto-generate every single kernel instance without guesswork.

While I was at it, I also cleaned up the file a bit and made sure we have only
a single, consistent way of writing/defining the kernels. This also gets rid
of some of the old boilerplate like decl_pattern.

Most kernels are trivial ports, but a few deserve attention or note:

- SWS_UOP_LINEAR is now generated more efficiently, thanks to the distinction
  between 0/1/arbitrary components. I also rewrote the code to keep track of
  whether the output was initialized yet or not, which lets us skip the
  initial `xorps` and `addps` for the first component.

- SWS_UOP_PERMUTE is generated automatically by using some NASM logic to
  detect permutation cycles and emit the minimal sequence of `mova`
  instructions. SWS_UOP_COPY, on the other hand, is implemented naively. I
  originally had a more complex implementation that could handle both, but
  I decided it really isn't worth the complication just to save 2-3 cycles.

- SWS_UOP_SCALE now has a native 8-bit implementation, which is faster than
  falling back to C code.

- SWS_UOP_SWAP_BYTES is no longer compiled as a type-agnostic pshufb, instead
  we hard-code the shuffle mask

- SWS_UOP_DITHER is now much simpler and avoids branching etc. entirely

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 257f1438a5 swscale/x86/ops: simplify mmsize determination
No reason for this to be a separate function also, it just obscures
the error path for no reason.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 2a09d0346e swscale/x86/ops_include: clarify/fix some comments
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 6deae052a2 swscale/x86/uops: generate NASM macros using uops_macros.h
Rather than hard-coding a separate set of NASM macros, or generating them
with a separate function, we can just leverage the C preprocessor to generate
a NASM source file *from* the existing ops macros.

This is maybe a bit unorthodox, but it avoids unnecessary overhead from
re-generating the macros twice, avoids manual updating of the NASM macros,
and generally does not come with any real downside except being a bit ugly.

The main source of ugliness is the fact that the C preprocessor expands
everything into a single line, whereas NASM expects separate statements to
be on separate lines. Very fortunately, we can work around this by writing a
another NASM macro to take its arguments and dump them onto multiple lines.

It may seem premature, but I went ahead and defined all the macros, since
it was easy enough to do.

I added the %include in this commit to trigger build errors that occur only
as a result of introducing this file in the same commit that introduces it.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 6057759ffc swscale/uops: parametrize filter op result type
The ops.h infrastructure currently hard-codes this as SWS_PIXEL_F32,
but I want to at least properly parametrize this in case we ever
decide to revisit this decision in the future. In particular, it
may become relevant for trivial kernels or kernels whose intermediates
are bounded, exact integers (which could possibly be output directly
as e.g. U16 or U32).

The FATE change is just because the filter op names gained a suffix.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 4a8a1f5b8b swscale/uops: add SWS_UOP_READ_PLANAR_FV_FMA
Analog of SWS_UOP_READ_PLANAR_FV for FMA-enabled backends.
The logic for determining when we can safely use FMA is maybe a bit
obtuse, given that a `return type == SWS_PIXEL_U8` would have just done
the trick as well, but better to be safe than sorry, if we ever decide to
tune this constant in the future.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas dbe961b4cd swscale/uops: add SWS_UOP_LINEAR_FMA and SWS_UOP_FLAG_FMA
This is like SWS_UOP_LINEAR but parametrized by which matrix entries can use
FMA instead of bitexact IEEE mul/add instructions.

I decided to make these a separate uop to avoid bogging down the reference
backend with arch-specific details like FMA. However, I think FMA ops are quite
common/universal so I pre-emptively split it into its own separate flag rather
than defining something like SWS_UOP_FLAG_X86.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 4e18068165 swscale/uops: also generate macros under SWS_BITEXACT
And SWS_BITEXACT|SWS_ACCURATE_RND, for completeness. This roughly doubles
the runtime of the uops macros generation. Let's hope it doesn't explode
further.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 157f586e5c swscale/uops: thread SwsContext through ff_sws_ops_translate()
Needed to access ctx->flags, in particular SWS_BITEXACT.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas f97ba8cbe7 swscale/uops: loop over all flags when generating macros
This list is currently empty but will be expanded by the following commit.

I briefly tested whether it would be worth avoiding the free/realloc on
the uops array, but found the performance difference to be negligible.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 02a168a576 swscale/uops: keep track of input range during op translation
Needed for the FMA decision logic.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 3f9219d605 swscale/uops: add SwsUOpFlags to ff_sws_ops_translate()
These will be used to e.g. enable extra uops during translation.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas b7a80a9f0d swscale/ops_backend: delete ops-based C backend
And make uops_backend.c the new reference.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 100ce4ac41 tests/checkasm/sw_ops: rewrite using uops_macros.h
This ensures 100% coverage of all uop primitives by generating the set of
tests exactly from the list of seen primitives, using the uops macros.

There are some annoying quirks still because of the fact that we have to
essentially "untranslate" the UOPs back to SwsOps that result back in the
intended uop after the translation, but overall it's not too bad and still
much better than the status quo of hand-rolling the list of test cases.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 636b9eda75 swscale/ops_tmpl_float: allow arbitrary values for 1x1 dither
Removes the 1x1 dither fast path, mirroring the previous commit.

This is not really needed nor useful but it will make the transition to
the uops architecture slightly easier, as 1x1 dither gets reinterpreted
as SWS_UOP_ADD there.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas ca8774b9d6 swscale/x86: remove broken and unnecessary 1x1 dither fast path
This is broken because it fails to check dither.y_offset[] to determine if
dithering for a channel is requested or not.

This is unnecessary because the generic dither code already jumps over unused
components, which is cheap enough not to worry about this special case for
now.

This code will, in any case, soon be replaced by a uops_macros.h-derived
approach. This commit is only needed as a stopgap to make checkasm continue
working after the sws_uops refactor.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 19652a83a2 swscale/x86/ops_include: use %assign instead of %xdefine
For numeric 1/0 constants. As an aside, fix the broken comment.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas b328e152a4 swscale/x86: move entry points to ops_common.asm
As well as the packed shuffle solver. These don't really interact with
the rest of the code in ops_int.asm, which is, by name at least, intended for
integer op kernels.

More importantly, these functions will be shared with the uops rewrite.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas c5c9c6d996 swscale/x86: rename ops_common.asm to ops_include.asm
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 8118e964bb swscale/uops: auto-generate reference C backend from uops_macros.h
Instead of choosing by hand which kernels to implement, this rewrite focuses
on leveraging the power of uops_macros.h to auto-generate all needed kernels.
This not only simplifies maintenance, but also improves performance.

I have decided to develop the replacement backend as a separate file, under
a separate prefix, for the explicit purpose of being able to verify the
correctness of the rewrite using the current backend as a checkasm reference.

The code for the kernels themselves has been largely copied from the old
C backend, modified slightly to conform to the uop template style. This does
result in some code duplication, but a following commit will clean it up.
I nonetheless want to preserve this commit for bisection purposes, to ensure
we have one commit that contains both backends side-by-side.

Overall speedup=1.182x faster, min=0.197x max=3.450x

The big slowdowns are flukes caused by tiny deviations in the runtime of
a noop memcpy conversion.

As a nice side benefit, the compiled binary is now also ~10% smaller, and
the code ~50% smaller.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 1e268fbedf swscale/ops_chain: add uop-based helpers to assemble SwsOpChain
This will eventually replace the existing op_match() and
ff_sws_op_compile_tables(), but I've decided to introduce it separately first
so that I can incrementally update the backends to use the new API, at the
cost of some temporary code duplication.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas adaf142647 swscale/uops: generate uop helper macros
This follows the same approach as is used currently by ops_entries_aarch64,
except I decided to have the generation logic live directly in uops.c
to allow re-using internal helpers and move it closer to the other helpers
that depend on the exact set of uops and their fields.

Unlike libswscale/tests/sws_ops.c, we make an effort to actually test all
relevant flag combinations, since these can affect the generated op lists.

I will use these macros to auto-generate both the C template-based kernels,
as well as the entire x86 backend, in the near future, hence their excessive
flexibility.

Re-use the libswscale/tests/sws_ops.c that we already compile. We could put it
in its own file but this is just as convenient, and it's easily moved anyways.
Having it be a FATE test ensures that it is always up-to-date.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 18:27:20 +02:00
Niklas Haas 8ad7cc6ccd swscale/tests/sws_ops: also print/test micro-op list
Tests for changes or regressions in the generated micro-ops. This will be
instrumental in my development of the micro-ops optimizer, and my plans to
phase out some of the macro-op optimization passes in favor of doing those
optimizations on the uop level instead.

 rgb24 16x16 -> rgb24 16x32:
   [ u8 +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 ...X] SWS_OP_FILTER_V     : 16 -> 32 bilinear (2 taps)
     min: {0 0 0 _}, max: {255 255 255 _}
   [f32 ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 -1}
     min: {1/512 1/512 1/512 _}, max: {255.998047 255.998047 255.998047 _}
   [f32 ...X] SWS_OP_MIN          : x <= {255 255 255 _}
     min: {1/512 1/512 1/512 _}, max: {255 255 255 _}
   [f32 +++X] SWS_OP_CONVERT      : f32 -> u8
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)
  Retrying with split passes:
   [ u8 +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)
+ translated micro-ops:
+    u8_read_packed_xyz
+    u8_write_planar_xyz
  Sub-pass #1:
   [ u8 ...X] SWS_OP_READ         : 3 elem(s) planar >> 0 + 2 tap bilinear filter (V)
     min: {0 0 0 _}, max: {255 255 255 _}
   [f32 ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 -1}
     min: {1/512 1/512 1/512 _}, max: {255.998047 255.998047 255.998047 _}
   [f32 ...X] SWS_OP_MIN          : x <= {255 255 255 _}
     min: {1/512 1/512 1/512 _}, max: {255 255 255 _}
   [f32 +++X] SWS_OP_CONVERT      : f32 -> u8
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)
+ translated micro-ops:
+    u8_read_planar_fv_xyz
+    f32_dither_xyz_0_3_2_16x16
+    f32_min_xyz
+    f32_to_u8_xyz
+    u8_write_packed_xyz
...

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 01:11:01 +02:00
Niklas Haas 3a7331d311 swscale/ops: remove unused function ff_sws_enum_ops()
Users can trivially recreate this logic anyways.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 01:10:57 +02:00
Niklas Haas 6b75166758 swscale/tests/sws_ops: minor cleanup / consistency
Clean up after the previous revert.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 01:10:54 +02:00
Niklas Haas dcfe3d3b90 Revert "swscale/tests/sws_ops: add option for summarizing all operation patterns"
This reverts commit f76aa4e408.

This is no longer needed once we switch to uops_macros.h, which will do the
same thing except better.
2026-06-09 01:10:49 +02:00
Niklas Haas aaf6a52fe6 swscale/uops: add uop translation logic
This will replace the fuzzy matching logic in op_match() that is used by the
C and x86 implementations, as well as the translation to AARCH64_OP_* that is
used by the NEON asmgen backend.

Down the line, this function will also take a set of flags to enable
backend-specific kernels like FMA variants, but I also decided to keep it
initially simple to ease the transition.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 01:10:39 +02:00
Niklas Haas dc88bcdf8c swscale/uops: add uop definitions
Taken from AARCH64_OP_*, but generalized/simplified a bit and updated to add
missing op types, especially for special cases that already have dedicated
implementations on x86.

This initial definition is kept intentionally simple and close to SwsOp, to
make it easier to port the existing ops backends to the new infrastructure.
However, in the future, this will be refactored dramatically - distinctions
like convert vs expand will cease to exist on the SwsOp level, and will
instead be introduced by separate optimization passes on the uops level.

SWS_UOP_LINEAR in particular will most likely be broken up into multiple
uops. I also took this opportunity to redefine the mask in a more useful way.

I decided to split up SWS_OP_CONVERT as well, because it was making x86
codegen unnecessarily difficult due to the strong interaction between exact
pixel sizes.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-09 01:09:34 +02:00
Niklas Haas ae6f3ce02c swscale/uops: split off from ops.h
Forming what will be the start of a larger helper file for backend-internal
translation of higher-level ops into lower level kernels. This header file
needs to be includable from independent source files, as it will be used to
provide definitions for build-time code generation (e.g. ops_asmgen.c), so
it must be self-contained.

Pulling in all of ops.h from uops.h would be too large dependency, since
ops.h pulls in graph.h, refstruct, bprint, etc. It's easier to start from a
fresh file that is documented as being usable at compile time.

For now, just declare the common types that will be needed by the uops layer.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-08 18:29:02 +02:00
Niklas Haas 48a42b5f21 configure: add -P to $CC_E flag
This suppresses the addition of #line directives in the preprocessed output,
which is what we want when we're invoking the hostcc just to preprocess some
files. (Currently, this variable is only used for configure-internal checks
anyways, but I want to use it to preprocess a NASM file)

On MSVC/Intel, /EP is the equivalent syntax, though we use -EP instead for
consistency.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-08 18:24:45 +02:00
haoyuLiu 6028720d70 avfilter/zmq: initialize send_buf before shared cleanup on parse failure
Found-by: VulnForge Security Research Team
Reported-by: Cloud-LHY <haoyuliu@clouditera.com>
2026-06-08 02:20:53 +00:00
Jun Zhao c75701a62f lavf/mov: read multi-valued metadata tags
When a metadata tag (e.g. ©ART) contains multiple values, either as
multiple 'data' child atoms within one tag or as multiple sibling tag
atoms with the same key, only the first value was read.

Fix by joining multiple values with semicolons using AV_DICT_APPEND,
consistent with Ogg Vorbis Comment handling in oggparsevorbis.c, and
reusing the existing 'goto retry' loop that covr already uses.
Also add the missing atom.size -= str_size to correctly track remaining
bytes in the tag atom, matching the covr path.

Limitation: on remux the joined string is written back as a single
value, same lossy behavior as Ogg Vorbis. Lossless round-trip would
require AV_DICT_MULTIKEY support throughout the metadata pipeline.

Fix #22367
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-08 02:18:32 +00:00
Michael Niedermayer 5622d515e8 tools/target_dec_fuzzer: reduce 4XM max pixels to avoid timeout
Fixes: Timeout
Fixes: 511356573/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FOURXM_fuzzer-5010010110492672
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-08 01:21:12 +00:00
Jun Zhao cfa3ceac7a lavc/hevc: add aarch64 NEON for angular modes 10 and 26
Add NEON-optimized implementations for HEVC angular intra prediction
modes 10 (pure horizontal) and 26 (pure vertical) at 8-bit depth.

Mode 10 (Horizontal):
- Broadcasts left[y] to fill each row using ld2r/ld4r for efficiency
- Applies edge smoothing for luma blocks smaller than 32x32

Mode 26 (Vertical):
- Copies top reference row to all output rows
- Applies edge smoothing for luma blocks smaller than 32x32

Edge smoothing uses uhsub+usqadd to compute the filtered result
directly in 8-bit, avoiding widening to 16-bit intermediates.

The C pred_angular wrappers are made non-static with ff_ prefix to
allow the NEON dispatch to fall back to C for modes not yet optimized.
This will be reverted once all angular modes are implemented.

Note: since pred_angular[] is a per-size function pointer (not
per-mode), checkasm benchmarks will show '_neon' for all 33 modes
even though only modes 10/26 are truly accelerated; unoptimized
modes show ~1.0x speedup as they pass through the NEON wrapper to
the C fallback with negligible overhead.

Speedup over C on Apple M4 (checkasm --bench, 15-run average):

  Mode 10 (Horizontal):
    4x4: 4.66x    8x8: 5.80x    16x16: 16.86x    32x32: 24.89x

  Mode 26 (Vertical):
    4x4: 1.16x    8x8: 1.83x    16x16: 2.45x    32x32: 4.50x

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-07 23:29:33 +00:00
Jun Zhao 3d71b9ec93 tests/checkasm: hevc_pred: use pixel helpers for diagnostic output
Replace plain memcmp+fail() with checkasm_check_pixel_padded() for
DC, planar, and angular prediction tests. Use PIXEL_RECT for output
buffers instead of flat arrays.

This enables:
- Detailed per-pixel difference output when run with 'checkasm -v'
- Detection of out-of-bounds writes beyond the NxN block area
- Padding violation reporting (writes past block boundary)

Previously, a test failure would only report "FAILED" with no
information about which pixels were wrong, making assembly debugging
difficult. Follows the pattern established in 4d4b301e4a (checkasm:
hevc_pel: Use helpers for checking for writes out of bounds).

Suggested-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-07 23:29:33 +00:00
Jun Zhao 3ec0f14f7d avcodec/h264_ps: set default SAR, remove stale workaround
Set sps->vui.sar to {0,1} (unspecified) before the VUI parsing
block, matching the HEVC pattern at hevc_ps.c.  The old
zero-init-to-1 workaround is now unreachable and is removed.

Suggested-by: James Almer <jamrial@gmail.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-07 18:55:16 +00:00
Jun Zhao e598463b3d avcodec/h2645_vui: interpret a degenerate SAR as unspecified
Per ITU-T H.264 (ISO/IEC 14496-10) Annex E.2.1 and ITU-T H.265
(ISO/IEC 23008-2) Annex E.3.1, when sar_width or sar_height is zero
the sample aspect ratio shall be considered unspecified. Internally
ffmpeg represents an unspecified SAR as 0/1, while fractions with a
zero denominator are not handled properly (den=0 is silently changed
to den=1 in h264_ps.c, turning an invalid 20480/0 into a "valid" but
impossibly extreme 20480/1); so we bridge the gap by replacing x/0
with 0/1 at the VUI parsing layer.

An av_log warning is added so an invalid SAR in the bitstream is
diagnosed rather than silently overwritten.

This fixes a problem with some video files provided by game
OddBallers when executed with Wine/Proton, which report SAR 20480/0.

Based on patch by Giovanni Mascellani <gmascellani@codeweavers.com>.
Fixes: ticket #23321

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-07 18:55:16 +00:00
Andreas Rheinhardt bb49197ede avcodec/liboapvenc: Remove dimension change check
If this were to be checked, it should be checked generically,
not in every single encoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-07 17:53:44 +02:00
Andreas Rheinhardt 0faa43ae6c avcodec/liboapvenc: Use av_image_copy2() to avoid cast
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-07 17:53:44 +02:00
Andreas Rheinhardt bf47563bd8 avcodec/liboapvenc: Remove always-false checks
Already checked in encode_preinit_video().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-07 17:53:44 +02:00
Andreas Rheinhardt 80ea2d1487 avcodec/liboapvenc: Return directly when possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-07 17:53:44 +02:00
Andreas Rheinhardt 67855a7234 avcodec/liboapvenc: Use av_unreachable for unreachable default cases
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-07 17:53:44 +02:00
Andreas Rheinhardt 9791c4d183 avcodec/liboapvenc: Don't set AVCodec.pix_fmts directly
Instead use CODEC_PIXFMTS. Avoids deprecation warnings
from Clang and simplifies the removal of AVCodec.pix_fmts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-07 17:53:44 +02:00
James Almer d1faab734d avcodec/dcadec: map Lw/Rw to FLC/FRC
Some 7.1 DTS files seem to signal Lw/Rw channels that the decoder has been
mapping to SL/SR, despite the macro for the mask being called 7_1_WIDE.
This resulted in said samples reporting the same native layout as actual 7.1
samples with Lsr/Rsr/Lss/Rss (mapped to BL/BR/SL/SR).

If we were to be strict, Lw/Rw would map to WR/WL, but that would result in an
unusual native layout. Instead, lets map them to FLC/FRC, which will result in
the more common 7.1(wide) native layout.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-07 10:24:42 -03:00
Niklas Haas 3137d337fe tests/checkasm/sw_ops: use new checkasm_set_func_variant()
The current approach of re-testing the C reference for every backend
separately leads to both confusing output (e.g. having an extra redundant
`memcpy_c` line for every op, even those not implemented by the memcpy
backend), as well as a lot of unnecessary wasted time re-testing and
re-benching the same C variant for every backend.

This new API function lets us test the C function only a single time, while
simultaneously having all of the other backends implicitly compare themselves
against the C reference.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-07 09:24:23 +00:00
Michael Niedermayer 04e2341056 avcodec/adpcm: fix signed integer overflow in get_nb_samples()
Fixes: signed integer overflow: 314572800 * 8 cannot be represented in type 'int'

Tighten the guard to INT_MAX/14, which covers the largest expansion
factor used in the function currently.

Found-by: Jiale Yao <19888972804@163.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-07 02:57:25 +00:00
Michael Niedermayer 0a8d961388 avformat/matroskadec: avoid signed overflow in DASH cue time differences
Fixes: 493466409/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6150181551931392
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-07 02:56:44 +00:00
Ramiro Polla f8af47b640 build: remove checkasm_header_config_generated.h on distclean
Forgotten in 4569ab7eaa.
2026-06-06 23:58:13 +02:00
David Korczynski 1e9984772b avcodec/fastaudio: reject subframes count whose * 256 product overflows 32-bit
fastaudio_decode() computes
    subframes = pkt->size / (40 * channels);
    frame->nb_samples = subframes * 256;
both as 32-bit signed multiplications. When pkt->size is large enough
to make subframes >= 2^24, the second multiplication overflows the
signed int range and frame->nb_samples wraps to a small value.
ff_get_buffer() then sizes the audio plane for that wrapped sample
count, while the decoder loop at line 152 still iterates the full
(unwrapped) subframes count, performing a 1024-byte memcpy per
subframe per channel. The 27th iteration (or first iteration with
nb_samples=0) writes one byte past the per-plane allocation,
yielding the ASan heap-buffer-overflow WRITE at libavcodec/fastaudio
.c:171 reported as ANT-2026-03891.

Reject the subframes value whose *256 product would overflow before
performing the multiplication. The bound INT_MAX / 256 (= 8388607)
keeps the existing two's-complement semantics of every reachable
input and rejects only the configurations that would have wrapped.

Reproducer: a crafted AVI declaring one mono audio chunk of
671_088_680 bytes (sparse) with the decoder forced via
'ffmpeg -c:a fastaudio -i evil.avi'.

Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-06 21:32:08 +00:00
Michael Niedermayer 7c7ca349bc avcodec/vc2enc_dwt: avoid signed overflow in the 5/3 and Haar DWT
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-06 19:07:39 +00:00
Michael Niedermayer 5f91556215 avcodec/vc2enc_dwt: avoid signed overflow in the 9/7 DWT lifting
Fixes: 490488944/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC2_fuzzer-5310290362433536
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-06 19:07:39 +00:00
DROOdotFOO d9e2239f3c swscale/aarch64/yuv2rgb_neon: 2 lines at a time, yuva420p
Alpha is full resolution, so each row loads its own 16 alpha bytes
via process_row's \rsrcA arg.

Test Name                                A55-gcc            M1-clang             A76-gcc
----------------------------------------------------------------------------------------
yuva420p_to_argb_neon            22607.6 (1.16x)        39.2 (1.24x)     13631.6 (1.12x)
yuva420p_to_rgba_neon            22608.2 (1.16x)        38.3 (1.21x)     13912.8 (1.12x)
yuva420p_to_abgr_neon            23074.6 (1.16x)        38.8 (1.22x)     14492.1 (1.08x)
yuva420p_to_bgra_neon            23079.7 (1.16x)        39.9 (1.19x)     14472.6 (1.08x)

Co-authored-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: DROOdotFOO <drew@axol.io>
2026-06-06 19:38:40 +02:00
DROOdotFOO 4b6f7c2a05 swscale/aarch64/yuv2rgb_neon: 2 lines at a time, rgb16
pack_rgb16_2l uses v26-v29 as scratch (luma temps, dead by then)
instead of v20-v23, so v20-v25 chroma survives the pack step. A
.error trips if yuva420p hits rgb16 (v28/v29 would clobber alpha);
the dispatcher routes that combination through yuv420p anyway.

Test Name                                A55-gcc            M1-clang             A76-gcc
----------------------------------------------------------------------------------------
nv12_to_rgb565le_neon            28531.9 (1.12x)        46.8 (1.28x)     19252.9 (1.09x)
nv12_to_bgr565le_neon            29018.1 (1.12x)        48.1 (1.17x)     19252.0 (1.09x)
nv12_to_rgb555le_neon            28531.3 (1.12x)        47.2 (1.24x)     19253.6 (1.09x)
nv12_to_bgr555le_neon            29012.1 (1.12x)        45.8 (1.22x)     19252.5 (1.09x)
nv21_to_rgb565le_neon            28532.3 (1.12x)        48.4 (1.15x)     19430.0 (1.09x)
nv21_to_bgr565le_neon            29013.8 (1.12x)        47.2 (1.21x)     19428.8 (1.09x)
nv21_to_rgb555le_neon            28533.3 (1.12x)        49.7 (1.16x)     19430.5 (1.09x)
nv21_to_bgr555le_neon            29011.4 (1.12x)        48.5 (1.18x)     19428.7 (1.09x)
yuv420p_to_rgb565le_neon         28351.9 (1.11x)        46.4 (1.18x)     19635.3 (1.08x)
yuv420p_to_bgr565le_neon         28831.8 (1.11x)        50.8 (1.09x)     19634.5 (1.08x)
yuv420p_to_rgb555le_neon         28351.3 (1.11x)        46.3 (1.23x)     19634.2 (1.08x)
yuv420p_to_bgr555le_neon         28829.1 (1.11x)        46.5 (1.21x)     19634.3 (1.08x)
yuva420p_to_rgb565le_neon        28349.5 (1.11x)        51.2 (1.06x)     19634.7 (1.08x)
yuva420p_to_bgr565le_neon        28833.1 (1.11x)        48.6 (1.17x)     19633.9 (1.08x)
yuva420p_to_rgb555le_neon        28351.6 (1.11x)        47.8 (1.16x)     19635.2 (1.08x)
yuva420p_to_bgr555le_neon        28831.5 (1.11x)        46.4 (1.14x)     19634.8 (1.08x)

Co-authored-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: DROOdotFOO <drew@axol.io>
2026-06-06 19:38:40 +02:00
DROOdotFOO dad212060c swscale/aarch64/yuv2rgb_neon: 2 lines at a time, gbrp
Six dst pointers exhaust the caller-saved registers; spill x19/x20.
yuva420p_to_gbrp_neon is routed through the yuv420p path by the
dispatcher (gbrp has no alpha channel).

Test Name                                A55-gcc            M1-clang             A76-gcc
----------------------------------------------------------------------------------------
nv12_to_gbrp_neon                20017.8 (1.15x)        32.8 (1.34x)     10658.0 (1.27x)
nv21_to_gbrp_neon                20020.9 (1.15x)        32.5 (1.36x)     10691.1 (1.26x)
yuv420p_to_gbrp_neon             19856.3 (1.14x)        31.4 (1.34x)     10348.0 (1.37x)
yuva420p_to_gbrp_neon            19859.8 (1.14x)        30.9 (1.27x)     10350.9 (1.37x)

Co-authored-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: DROOdotFOO <drew@axol.io>
2026-06-06 19:38:40 +02:00
DROOdotFOO 4bfe7efd0c swscale/aarch64/yuv2rgb_neon: 2 lines at a time, packed RGB
Vertically-subsampled inputs (nv12, nv21, yuv420p) share a chroma
row across two output rows; compute the chroma -> RGB offsets once
and apply to both luma rows. Covers argb/rgba/abgr/bgra/rgb24/bgr24.

Test Name                                A55-gcc            M1-clang             A76-gcc
----------------------------------------------------------------------------------------
nv12_to_argb_neon                21647.2 (1.16x)        40.1 (1.24x)     13813.3 (1.16x)
nv12_to_rgba_neon                21653.7 (1.16x)        40.8 (1.32x)     14105.0 (1.13x)
nv12_to_abgr_neon                22122.2 (1.15x)        40.3 (1.27x)     14100.2 (1.16x)
nv12_to_bgra_neon                22121.6 (1.15x)        39.6 (1.24x)     14125.9 (1.16x)
nv12_to_rgb24_neon               19842.0 (1.18x)        33.4 (1.28x)     12868.9 (1.17x)
nv12_to_bgr24_neon               20318.0 (1.18x)        34.6 (1.23x)     12868.8 (1.17x)
nv21_to_argb_neon                21648.5 (1.16x)        41.0 (1.29x)     13978.5 (1.14x)
nv21_to_rgba_neon                21653.0 (1.16x)        41.3 (1.21x)     14173.5 (1.11x)
nv21_to_abgr_neon                22120.6 (1.15x)        41.1 (1.20x)     14505.4 (1.14x)
nv21_to_bgra_neon                22120.8 (1.15x)        41.0 (1.22x)     14520.1 (1.14x)
nv21_to_rgb24_neon               19830.5 (1.19x)        35.1 (1.28x)     12832.4 (1.17x)
nv21_to_bgr24_neon               20317.1 (1.18x)        34.6 (1.27x)     12833.1 (1.17x)
yuv420p_to_argb_neon             21450.2 (1.15x)        39.2 (1.19x)     14118.3 (1.12x)
yuv420p_to_rgba_neon             21447.2 (1.15x)        38.8 (1.24x)     14326.0 (1.14x)
yuv420p_to_abgr_neon             21927.0 (1.15x)        38.9 (1.25x)     14826.6 (1.13x)
yuv420p_to_bgra_neon             21930.8 (1.15x)        41.4 (1.18x)     14822.9 (1.13x)
yuv420p_to_rgb24_neon            19365.5 (1.17x)        33.5 (1.25x)     13291.8 (1.16x)
yuv420p_to_bgr24_neon            19848.8 (1.16x)        34.1 (1.35x)     13292.8 (1.16x)

Co-authored-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: DROOdotFOO <drew@axol.io>
2026-06-06 19:38:40 +02:00
DROOdotFOO 11b1721b11 swscale/aarch64/yuv2rgb_neon: reorder params, unify signature
Pass src[]/srcStride[] as arrays (x5/x6), move y_offset/y_coeff into
register args (w2/w3). Only int-after-pointer stack args remain, so
Apple and AAPCS64 lay them out identically; every __APPLE__ is gone.
nv12/nv21/yuv420p/yuv422p/yuva420p share one signature.

Co-authored-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: DROOdotFOO <drew@axol.io>
2026-06-06 19:38:40 +02:00
DROOdotFOO 8dbc729950 swscale/aarch64/yuv2rgb_neon: name registers
the loop body. .text byte-identical.

Co-authored-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: DROOdotFOO <drew@axol.io>
2026-06-06 19:38:40 +02:00
DROOdotFOO e0fa641240 swscale/aarch64/yuv2rgb_neon: chroma-preserve compute_rgb
Macro writes per-luma sums into the destination registers, leaving
v20-v25 (chroma -> RGB offsets) intact for the 2-line callers. Takes
bare register names. compute_rgba and compute_rgba_alpha follow suit.

Single-row callers reload v20-v25 each iteration via
chroma_to_rgb_offsets, so the change is a no-op for them: Apple M1
width=1920 mean -0.54% across 55 paths, within bench noise.

Co-authored-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: DROOdotFOO <drew@axol.io>
2026-06-06 19:38:40 +02:00
Michael Niedermayer b99c6fc8c3 avformat/dashdec: Fail with any inner stream count being 0
Fixes: ada-3-poc.mpd

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-06-06 17:29:17 +00:00
Ramiro Polla 025d6330a5 swscale/aarch64/ops_asmgen: fold impl pointer increment into loading of continuation address
This commit reduces every kernel by one instruction, for example:
 function ff_sws_clear_8_u16_0001_neon, export=1, jumpable=1
-        ldr             x0, [x1]                        // SwsFuncPtr cont = impl->cont;
         ldr             q16, [x1, #16]                  // v128 clear_vec = impl->priv.v128;
+        ldr             x0, [x1], #32                   // SwsFuncPtr cont = (impl++)->cont;
         dup             v0.8h, v16.h[0]                 // vl[0] = broadcast(clear_vec[0])
-        add             x1, x1, #32                     // impl += 1;
         br              x0                              // jump to cont
 endfunc

A55: Overall speedup=1.066x faster, min=0.881x max=1.288x
A76: Overall speedup=1.012x faster, min=0.570x max=1.546x

The large min/max differences are due to pathological branch miss cases
that happen either before of after this commit.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-06 11:54:14 +00:00
Ramiro Polla 20b0a4faaa tests/fate: add fate-sws-unstable test
The fate test for unscaled conversions (fate-sws-unscaled) does not
test the filtering (scaling) paths.

This commit adds a test for all the scaling paths for the new swscale
code, but only runs 2% of the tests (otherwise this test alone would
take about two and a half minutes on a modern x86_64 machine).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-05 22:37:18 +02:00
Niklas Haas 7fc7aaf265 swscale/graph: prefer ops backend for floating point formats
These have horrible support in legacy swscale; in particular, they break the
pixel range (limited vs full) when converting to yuva444p, resulting in SSIM
errors like:

uyva 96x96 -> grayf32le 96x96, SSIM={Y=0.997654 U=1.000000 V=1.000000 A=1.000000} loss=1.876414e-03
  loss 1.876414e-03 is worse by 1.864254e-03, expected loss 1.215935e-05

(The ops-based backend gets a 100% bit-exact roundtrip here)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-05 22:37:18 +02:00
Ramiro Polla 016cee7a02 tests/fate/sws-unscaled: constrain to -backends unstable
This is more explicit than -flags unstable, because it also excludes
any pixel formats that are only handled by the legacy code.

Sponsored-by: Sovereign Tech Fund
Co-authored-by: Niklas Haas <git@haasn.dev>
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-05 22:35:55 +02:00
Ramiro Polla 59166b4131 swscale/input: fix rgbf32 input (add half input functions)
The rgbf32 input code was missing the subsampled input functions.

This fixes:
$ ./libswscale/tests/swscale -scaler none -src rgbf32be -dst rgb565be
rgbf32be 96x96 -> rgb565be 96x96, flags=0x0 dither=1 scaler=0/0, SSIM={Y=0.999820 U=0.932819 V=0.924956 A=1.000000} loss=1.436615e-02
rgbf32be 96x96 -> rgb565be 96x96, flags=0x0 dither=1 scaler=0/0
  loss 1.436615e-02 is WORSE by 1.413935e-02, expected loss 2.267957e-04

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-05 22:33:58 +02:00
Ramiro Polla 6b7fd40e25 swscale/swscale_unscaled: disable unscaled copy from yaf32be to grayf32be
yaf32be input wasn't being properly filtered out of the simple copy
condition when converting to grayf32be, which caused half the luma
plane to be interleaved with half the alpha plane, instead of just
copying the luma plane.

This fixes:
$ ./libswscale/tests/swscale -scaler none -src yaf32be -dst grayf32be
yaf32be 96x96 -> grayf32be 96x96, flags=0x0 dither=1 scaler=0/0, SSIM={Y=0.866842 U=1.000000 V=1.000000 A=1.000000} loss=1.065262e-01
yaf32be 96x96 -> grayf32be 96x96, flags=0x0 dither=1 scaler=0/0
  loss 1.065262e-01 is WORSE by 1.065202e-01, expected loss 6.020069e-06

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-05 22:33:37 +02:00
Niklas Haas 5a6bf8d4f4 swscale/tests/swscale: allow all backends for auxiliary conversions
This enables testing all internally supported pixel formats.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-05 22:32:51 +02:00
Ramiro Polla 3977bca9f4 swscale/utils: improve check for float formats that will be converted to uint16_t
This was triggering an assertion in x86:
$ ./libswscale/tests/swscale -scaler none -backends unstable -src rgb24 -dst yaf32be
Assertion c->srcBpc == 16 failed at src/libswscale/x86/swscale.c:637
Aborted

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-05 22:31:09 +02:00
Ramiro Polla c7046f0ab3 swscale/ops_backend: add missing float clear pattern
This fixes:
$ ./libswscale/tests/swscale -scaler none -backends unstable -src rgb24 -dst yaf32be

... and exposes another bug in x86 when -cpuflags 0 is not passed,
which will be fixed in next commit.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-05 22:29:24 +02:00
Niklas Haas 8366d5f8d6 swscale/tests/swscale: refactor format testing logic
Uses the internal ff_sws_test_pixfmt_backend() to test for format support
on the concrete backend that's in-use for the auxiliary/main conversions,
respectively, while taking into account the -backends and -api options.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-05 22:22:27 +02:00
Niklas Haas 517c3d5fc1 swscale/graph: re-check pixel format support in add_legacy_sws_pass()
When the user passes multiple backends (e.g. SWS_BACKEND_ALL), the
static check in sws_setup_frame() might have succeeded for the ops
backend but not the legacy backend, so we need to properly restrict
the legacy backend implementation function as well. Otherwise, this
may trigger internal errors / AVERROR(EINVAL) inside sws_init_context().

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-05 21:55:27 +02:00
Michael Niedermayer b355200263 avcodec/mjpegdec: require progress in AVRn interlaced field loop
Fixes: Timeout
Fixes: 500554625/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MEDIA100_fuzzer-5094103347167232
Fixes: 511253447/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-5780722463080448
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-05 11:49:42 +00:00
Martin Storsjö 96470d1e8c checkasm: Fix defining CHECKASM_HAVE_GENERATED_H
Commit 4569ab7eaa tried to set this
only on the object files for the checkasm library itself, but
missed that EXT_CHECKASMOBJS lacks the path prefix, thus this
wasn't set at all.

Alternatively, for simplicity, we could keep passing this for
all checkasm object files, not only the checkasm library objects;
the other object files don't use it in any case.
2026-06-05 11:46:38 +00:00
Martin Storsjö 17c25ee550 configure: Include stdbit_h in the checkasm config header 2026-06-05 11:46:38 +00:00
Michael Niedermayer 0aa316ec2c tools/target_dec_fuzzer: reduce BMP max pixels to avoid RLE timeout
a valid RLE bitmap can decompress to far more than its input size, an early end-of-picture code
leaves the rest of the canvas blank, thus we cannot add a check in bmp decode

Fixes: Timeout
Fixes: 510821718/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BMP_DEC_fuzzer-5011979420106752
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-05 11:46:17 +00:00
Hendrik Leppkes 4eec440e36 configure: filter out -D options from msvc link
The linker does not understand or require -D (define) options, and
unknown options are treated as errors.

Fixes building with MSVC and SChannel, which regressed after
1e031d4af7
2026-06-05 07:39:40 +00:00
Hendrik Leppkes ab07382dc5 build: ignore checkasm_header_config_generated.h 2026-06-05 07:35:46 +00:00
Kacper Michajłow 2a54b181c0 tests/checkasm/vvc_mc: prevent function inline to avoid stack overflow
Fixes stack overflow on Windows when by default we have 1 MB.
Individually those functions fit, but when they are all inlined, it's
too much.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-05 08:22:40 +02:00
Kacper Michajłow 7d2a629ccf tests/checkasm/rv34dsp: pass correct buffer to bench function
The test can negate stride, in which case we have to use adjusted
`dst_newp`.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-05 08:22:37 +02:00
Andreas Rheinhardt 56124f1e68 avcodec/exif: Remove version_major.h inclusion
Forgotten in d151d3aecb.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-05 03:02:04 +00:00
Andreas Rheinhardt 447a07fc12 avcodec/decode: Move exif declarations to exif_internal.h
It is (arguably) a slightly better place for them and avoids
a forward declaration of enum AVExifHeaderMode which is not possible
in ISO C before C23 (and requires specifying the underlying type
with C23).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-05 03:02:04 +00:00
Michael Niedermayer ba825ce85f avcodec/mwsc: do not dereference a missing reference frame
Fixes: 493841393/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MWSC_fuzzer-5079884677578752
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-05 01:27:39 +00:00
Kacper Michajłow 65ae944d34 configure: set -mpreferred-stack-boundary=4 for Windows 32-bit targets
Win32 ABI only mandates 4 bytes stack alignment. GCC 16 changed default
align and no longer works with ffmpeg expectations.

Fixes crashes on aligned memory access in mingw32 gcc 16 build.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-05 03:17:43 +02:00
Michael Niedermayer 32eb07bb83 avcodec/misc4: reject invalid sample rate
Fixes: AVERROR_BUG

Fixes: 493055111/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MISC4_fuzzer-5752676962074624
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-05 01:16:31 +00:00
Michael Niedermayer 0ab097fb34 swscale/output: avoid signed overflow in yuv2rgba64_1 alpha
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-05 01:15:22 +00:00
Michael Niedermayer ad84fc9b7d swscale/output: avoid signed overflow in yuv2rgba64_full_1 alpha
Fixes: 493055112/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5823995319746560
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-05 01:15:22 +00:00
Michael Niedermayer 2cce6ad030 tools/target_dem_fuzzer: do not exit on io_buffer allocation failure
Failure to allocate a randomly sized buffer should not count as a anomaly in the fuzzer
there is nothing to fix in that case

Fixes: 490112574/clusterfuzz-testcase-minimized-ffmpeg_dem_TMV_fuzzer-6600485921685504
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-05 01:14:43 +00:00
Michael Niedermayer 0ea090e09f avformat/gxfenc: Check timecode and propagate error
Fixes: ./ffmpeg   -f lavfi -i testsrc=duration=0.1:size=720x480:rate=30   -c:v mpeg2video -frames:v 1   -metadata timecode="999999999:00:00:00"   -f gxf output.gxf

Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-05 01:14:02 +00:00
Michael Niedermayer dbe78ffdb8 swscale/rgb2rgb_template: use unsigned for <<24
Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-05 01:14:02 +00:00
Michael Niedermayer fe2dabbbf4 avformat/iamf_parse: bound substream count by remaining OBU size
also check for nb_substreams == 0

Fixes: 472641765/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6390897173659648
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-05 01:11:58 +00:00
Michael Niedermayer c7e0bac050 avformat/matroskadec: bound TRACKENTRY parsing by max_streams
After the fix the reproducer finishes in 43 ms instead of OOM-ing at the
2 GB limit. Legitimate .mkv/.webm fate samples still parse cleanly.

Fixes: 471604245/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6662979358883840
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-05 01:11:11 +00:00
Hendrik Leppkes 89bdd9e1a5 avcodec/hevc: look for the DOVI RPU in all NALs, not just the last one
Some encoders seem to place the SEI suffix NAL at the very end, with the
RPU before it.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-05 01:08:08 +00:00
Ramiro Polla fcaafd2c11 swscale/tests/swscale: add -scaler/-scaler_sub parameters to set scaler algorithm
The -unscaled parameter has been removed in favour of "-scaler none".

Some legacy scalers cannot be selected with these options (i.e.: SWS_X
and SWS_FAST_BILINEAR). To test these, the -flags parameter shoule be
used instead.

This option sets the scaler/scaler_sub fields in SwsContext. There is a
comment about these fields in struct SwsContext:

  Note: Does not affect the legacy (stateful) API.

This comment is not entirely correct, since scaler/scaler_sub are taken
into consideration to select the algorithm, but that doesn't update the
flags field, which is still used to select implementations:

libswscale/x86/swscale.c:574:            if (c->opts.flags & SWS_FAST_BILINEAR && c->canMMXEXTBeUsed) {
libswscale/ppc/swscale_vsx.c:2033:            if (c->opts.flags & SWS_FAST_BILINEAR && c->opts.dst_w >= c->opts.src_w && c->chrDstW >= c->chrSrcW) {
libswscale/swscale_unscaled.c:2465:        && (!needsDither || (c->opts.flags&(SWS_FAST_BILINEAR|SWS_POINT))))
libswscale/swscale_unscaled.c:2650:    if (c->opts.flags&(SWS_FAST_BILINEAR|SWS_POINT)) {
libswscale/utils.c:1279:            && !(sws->flags & SWS_FAST_BILINEAR)
libswscale/utils.c:1388:         (flags & SWS_FAST_BILINEAR)))
libswscale/utils.c:1417:            && (flags & SWS_FAST_BILINEAR)) {
libswscale/utils.c:1437:    if (flags & SWS_FAST_BILINEAR) {
libswscale/utils.c:1648:        if (c->canMMXEXTBeUsed && (flags & SWS_FAST_BILINEAR)) {
libswscale/swscale.c:678:            if (c->opts.flags & SWS_FAST_BILINEAR) {

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-05 03:00:31 +02:00
James Almer f6d83920b5 tests/fate/probe: add test for mp3 misdetected as mpeg
As fixed in de647bfbbc.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-04 21:56:55 -03:00
Andreas Rheinhardt e076b602c0 avformat/tls_{gnutls,mbedtls,openssl}: Add config_components.h
Forgotten in fb5dd6ec60,
effectively disabling the #if CONFIG_UDP_PROTOCOL block;
it triggered a -Wundef warning as well as an unused-variable
warning in tls_openssl.c.
Also use the TLSShared* in tls_openssl to avoid an unused
variable warning if the UDP protocol is disabled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-05 00:43:20 +02:00
Ramiro Polla a16e674f7f swscale/tests/swscale: add -api parameter (supersedes -legacy parameter)
The "-legacy 1" option was added in 101a2f6fc6 to run the main
conversion with the legacy scaler. This was done by forcing the use of
the legacy API. This way, it was possible to pass "-flags unstable" and
still ensure the legacy scaler path was being taken.

New legacy-related parameters will be added to the test tool, so it
makes sense to rename the -legacy option to reflect what it was
actually doing.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-04 22:55:30 +02:00
Ramiro Polla c458346de2 swscale/tests/swscale: reuse init_frame() for src
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-04 22:54:33 +02:00
Ramiro Polla b9968758ab swscale/tests/swscale: add optional destination size to -s option
This lets us test specific scaling operations, for example:
$ ./libswscale/tests/swscale -s 96x96:128x128 -src yuva444p -dst rgb24 -flags unstable+neighbor
yuva444p 96x96 -> rgb24 128x128, flags=0x100010 dither=1, SSIM={Y=0.999932 U=0.999957 V=0.999937 A=1.000000} loss=6.514788e-05

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-04 22:54:30 +02:00
Ramiro Polla 2e50831755 swscale/tests/swscale: propagate ret out of parse_options()
This will make it easier to keep function-scoped variables.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-06-04 22:54:27 +02:00
Ramiro Polla cc0d904795 Revert "swscale/tests/swscale: check if formats require the legacy path with -hw"
This reverts commit ac611d3120.
2026-06-04 22:54:23 +02:00
Andreas Rheinhardt 8c2c31f80c avcodec/utils: Don't attempt to derive CodecID name from de/encoders
The list of codec descriptors is supposed to encompass all codec IDs;
it certainly encompasses all codec IDs used by de/encoders (this is
checked in the avcodec test program which is run via FATE).
So the avcodec_find_decoder()/avcodec_find_encoder() are pointless.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-04 19:44:02 +00:00
Andreas Rheinhardt 72f751ef78 doc/examples/encode_audio: Don't access deprecated AVCodec fields
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-04 19:39:32 +00:00
Andreas Rheinhardt 27d49179e1 doc/examples/mux: Don't access deprecated AVCodec fields
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-04 19:39:32 +00:00
Andreas Rheinhardt ed18f8a463 doc/examples/transcode_aac: Don't access deprecated AVCodec.sample_fmts
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-04 19:39:32 +00:00
Andreas Rheinhardt e816b39fb2 avcodec/aacenc: Make AACPCEInfo smaller
Reduces sizeof(AACPCEInfo) from 296 to 120 bytes.
This reduces .rodata by 4576B here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-04 19:17:43 +00:00
Martin Storsjö 4569ab7eaa configure: Provide checkasm_header_config_generated.h as well
This is required for overriding defines that exist in the public
headers of checkasm, when e.g. building with assembly disabled
for an architecture where we normally would use the checked_call
wrapper.

This fixes a leftover in how checkasm is integrated into the
ffmpeg build system; there were many different approaches
considered for fixing --disable-asm, and the ffmpeg configure
integration didn't end up matching the final solution.

This fixes building with --disable-asm.
2026-06-04 18:26:50 +00:00
Martin Storsjö c2f499d979 configure: Fix a mismatched include guard end comment 2026-06-04 18:26:50 +00:00
Andreas Rheinhardt 5b9d8901a9 avformat/shared: use av_fallthrough to mark fallthroughs
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-04 19:43:15 +02:00
Kacper Michajłow ca1b3c79a4 avformat: don't use deprecated .lcevc field
It's the same as `.layered_video` now.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-04 17:03:05 +00:00
James Almer 1d45522806 avcodec/aacenc: remove excess initializers
pairing has only three elements.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-04 13:44:28 -03:00
Niklas Haas afce637550 avformat/shared: add option to verify cache file contents
This will effectively disable the cache but allows the cache layer to verify
cached files against the original input file. Useful only for debugging
the shared cache protocol itself, as file corruption can already be caught by
the CRC check.
2026-06-04 17:48:12 +02:00
Niklas Haas ca748964fe avformat/shared: implement 16-bit CRC check
Decided to split this off from the previous commit in case we
ever want to revert it, since it does double the overhead of the spacemap
as well as adding extra overhead to both the read and write path.

Bump the cache version to 2 to reflect the changed disk format.
2026-06-04 17:48:12 +02:00
Niklas Haas 56de70a2e6 avformat: add shared concurrent block cache protocol
This adds a new protocol shared:URI which is distinct from the existing
`cache:` in that it is explicity designed to be thread-safe and cross-process,
enabling multiple ffmpeg processes (or multiple ffmpeg decoders within the same
process) to share a single cache file, for e.g. a remote HTTP stream. As such,
it uses a radically different internal design.

To facilitate zero-knowledge cross-process interoperability, the cache file
itself is just a memory-mapped representation of the underlying file data,
which has the side benefit that the resulting cache file will contain a
working copy of the streamed file (assuming the stream was read to
completion).

To keep track of which regions are cached and which are not, we use a
secondary file that contains a minimal header along with a static bytemap of
blocks within the file. This secondary file is also used to store metadata
such as the filesize, if known, as well as marking "failed" blocks.

Both files can grow dynamically in order to accommodate larger/growing files,
and can be atomically updated (through the use of shared space maps). I have
extensively checked the space map initalization and update code for race
conditions, and I believe the current design to be solid.

That said, it is the user's responsibility to some extent to ensure that the
same URI is not used for different streams, as we rely on the URI to uniquely
identify the cache files. That said, we use a cryptographic hash with
sufficient collision resistance to protect against possible abuse. The lack of
any implicit default on `-cache_dir` also means that `shared:` can't be enabled
via URL injection to possibly access random files on the disk (or intentionally
leak content from other streams with similar URIs, even if the cryptograhic
hash function is broken).
2026-06-04 17:48:12 +02:00
Niklas Haas cd3f335207 avformat/file: return ENOSYS for filesize query on files with follow=1
If the input is expected to grow, we shouldn't make any assumptions about
the file size. This matches e.g. the behavior of streamed protocols like
chunked HTTP, which similarly return ENOSYS for streams of unknown size.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-04 17:48:12 +02:00
Niklas Haas 7cb93fb200 avformat/http: return ENOSYS instead of UINT64_MAX for unknown filesize
This matches the behavior of e.g. the pipe: protocol, which returns ENOSYS
on account of ffurl_seek() not being implemented.

The previous behavior of returning s->filesize directly is almost surely a
bug, as s->filesize is UINT64_MAX when never initialized.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-04 17:48:12 +02:00
James Almer bca473e155 avcodec/aacenc: don't write SIDE position elements
Most parsers outright dislike anything being signaled as SIDE, as they expect layouts
to follow how ordering is pre-defined in non-0 channel_config values.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-04 14:18:35 +00:00
James Almer 55b510c702 avcodec/aacenc: fix signaled channel pairing for 6.1 PCE layout
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-04 14:18:35 +00:00
Niklas Haas c27a3b12e3 configure: re-indent after previous change
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-04 11:44:52 +02:00
Niklas Haas 310ff99f62 configure: support building without checkasm
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-04 11:44:52 +02:00
Niklas Haas 3b1d7cd1f7 tests/checkasm: switch to shared libcheckasm implementation
The checkasm tool originated in x264. It was later rewritten and
modernized for FFmpeg (and relicensed to LGPL). For the dav1d
project, it was relicensed again to 2-clause BSD (with permission
from the relevant authors).

The FFmpeg and dav1d implementations of checkasm have since evolved
independently (with some amount of ported code between the two,
with relicensing permission where relevant).

To synchronize the development, and to make it possible to easily
adopt checkasm in other projects, it has been split out into a
standalone project/library on its own, developed at
https://code.videolan.org/videolan/checkasm/.

That version has all the features of checkasm in both FFmpeg and
dav1d, and has got a number of extra improvements on top:

- More/fixed tests (e.g. properly clobbering high bits of 32-bit registers
  on most platforms),

- Vastly improved overall performance / runtime for benchmarking, due
  primarily to the ability to scale the runtime of each test to that test's
  complexity.

- Much more robust statistical analysis of benchmarking results; including
  robust outlier rejection, an estimation of the histogram, and the ability
  to report the variance / stddev in addition to the (trimmed) mean.

- Interactive HTML and JSON output formats in addition to CSV/TSV.

- More readable and user-friendly output across the board, especially for
  failures and data dumps (e.g. also showing errors inside padding bytes).

- Better cross-platform support, including dynamic fallback of timer
  implementations on ARM platforms, a better RISC-V and AArch64 harness,
  and more.

  On AArch64, it tests which timer out of pmccntr_el0, linux perf,
  macos kperf, cntvct_el0 is available, without the user needing to
  configure things, and falling back on clock_gettime if neither of
  them can be used. This means one automatically gets the best
  available timer, if userspace access to pmccntr_el0 has been
  unlocked with a kernel module, or if one has permission to use
  the perf API, or if the cntvct_el0 is exact enough to be useful.

  On AArch64 macOS, there is now a test harness that catches clobbered
  registers and stack clobbering, like on other platforms.

- An option for setting affinity, for benchmarking on heterogenous
  core systems. (On Linux, this is already easily done through
  taskset, but on Windows, the checkasm built in option makes it
  possible there as well, and portable.)

- Printing of the tested CPU core name, where possible.

To integrate this external implementation of checkasm into FFmpeg,
without having to build libcheckasm as an external library, the upstream
sources are added as a git subtree, and integrated into the FFmpeg
build system as a foreign source.

For the long and storied history of how we arrived at this solution,
see: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22546

The relevant config headers for checkasm are generated by configure,
and the sources are built as part of the main ffmpeg build. The
upstream sources, while they use meson as primary build system,
are structured to make it easy to build as part of a foreign build
system.

The existing testcases are mostly kept untouched (only three minor
changes are required, in crc.c, sw_ops.c and vp8dsp.c), while the
majority of the logic from checkasm.c, checkasm.h and the arch
specific assembly files are removed, replaced with the external
implementation.

Co-Authored-By: Martin Storsjö <martin@martin.st>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-04 11:44:52 +02:00
Niklas Haas 21ac0b276e Merge commit 'df966476d760f1bfe4c5f52c463b82be5bf6b9ed' as 'tests/checkasm/ext'
To reproduce this commit, run:

$ git subtree add --squash --prefix=tests/checkasm/ext \
  https://code.ffmpeg.org/FFmpeg/checkasm.git master

To update at a later point in time, replace `add` by `pull`
2026-06-04 11:44:40 +02:00
Niklas Haas 66eaaa644a Squashed 'tests/checkasm/ext/' content from commit 0df02535c7
git-subtree-dir: tests/checkasm/ext
git-subtree-split: 0df02535c7435cf3969ca141c9e3ff7b1c1e6c28
2026-06-04 11:44:26 +02:00
Niklas Haas 362e309710 forgejo/codespell: exclude tests/checkasm/ext
Pre-emptively exclude the external checkasm sources. Split off from the
following merge commit to make the history easier to follow.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-04 11:44:22 +02:00
Niklas Haas 566dd20247 tests/fate/source-check.sh: exclude tests/checkasm/ext
Pre-emptively exclude the external checkasm sources. Split off from the
following merge commit to make the history easier to follow.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-04 11:44:22 +02:00
Niklas Haas 068173f329 tests/checkasm: factorize out randomize_buffer for doubles
Not only is this duplicating code, but it also hard-codes a reference to
`checkasm_lfg`, which I want to eliminate in the interest of being able to
switch out the checkasm implementation.
2026-06-04 11:44:22 +02:00
Anthony Hurtado 495b402f27 avcodec/diracdec: fix heap buffer overflow in edge_emu_buffer
Fixes: poc_dirac_v2_*
2026-06-03 23:37:46 +00:00
Michael Niedermayer 92804c9e25 avformat/rtmppkt: Check recursion depth
Based on flvdec.c

Fixes: out of array access

Found-by: Xueqing
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-03 23:36:13 +00:00
Niklas Haas 8df8f8b1bb swscale/x86/ops: fix typo
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 23:53:47 +02:00
Niklas Haas 71b4666ba5 tests/checkasm/sw_ops: re-indent after previous change
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 23:53:37 +02:00
Niklas Haas 7af4faf6df tests/checkasm/sw_ops: skip test data setup if not testing anything
The test data size is quite large, so re-setting up unused data is eating up
quite a significant amount of CPU time.

This commit cuts execution time of sw_ops in half.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 23:53:23 +02:00
Niklas Haas ef182f2289 swscale/tests/sws_ops: avoid confusing double label
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 23:53:15 +02:00
Niklas Haas b8bfd7800a swscale/graph: only prefer unstable backends with SWS_UNSTABLE
If the user passes `-backends all` but without `-flags unstable`, then the
default/legacy backend will be picked unless it doesn't support a given
pixel format.

This allows gradually opting into the new code to handle more pixel formats
than what the legacy backend currently supports, without disturbing the
predictable output/behavior.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 21:39:55 +00:00
Niklas Haas 57541f5f41 swscale/graph: move legacy fallback out of add_convert_pass()
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 21:39:55 +00:00
Niklas Haas dfeb4fdbc7 swscale/graph: add metadata about backends in use
Not currently publicly visible, but useful inside the test framework
nonetheless.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 21:39:55 +00:00
Niklas Haas 6df223ce02 swscale/format: generalize ff_test_fmt() to take SwsBackend
This allows us to test support in either the legacy code, or the ops-based
code, or both.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 21:39:55 +00:00
Niklas Haas 945151851e swscale/tests/swscale: add -backends option
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 21:39:55 +00:00
Niklas Haas 972c0cf91f swscale: add new SwsContext.backends option
This allows constraining the set of available backends. This serves as a
better replacement for the "unstable" flag, which is a bit ambiguous. Allows
users to, for example, opt into the memcpy or x86 backend, while excluding
e.g. the upcoming JIT backends.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 21:39:55 +00:00
Niklas Haas dc902654de swscale: add missing validation for newly added enums
Gives slightly better error messages for invalid values.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 21:39:55 +00:00
Michael Niedermayer 47f3996bdd avcodec/tdsc: propagate max_pixels to the JPEG tile decoder
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-03 20:35:41 +00:00
Michael Niedermayer c1d3e8c46f avcodec/imm5: propagate max_pixels to the H264/HEVC sub-decoders
Fixes: 501794495/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IMM5_fuzzer-5192457796255744
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-03 20:35:41 +00:00
Michael Niedermayer cdba2d76dc avcodec/cri: propagate max_pixels to the JPEG tile decoder
Fixes: 489941776/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-4845035614175232
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-03 20:35:41 +00:00
Michael Niedermayer 3669a742dd avcodec/jpeglsdec: only apply color transform to decoded rows
Fixes: Timeout
Fixes: 503996733/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_DEC_fuzzer-4948713016721408
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-03 20:34:28 +00:00
David Korczynski 6d8f7882ae avcodec/adpcm: require block_align to be a multiple of channels in ADPCM_PSXC init
The ADPCM_PSXC block loop in adpcm_decode_frame() (libavcodec/adpcm.c:
2770) iterates 'block < avpkt->size / block_align' times and, for
each block, consumes
    channels * (1 + (block_align - 1) / channels)
input bytes via the *unchecked* bytestream2_get_byteu() reader. The
loop divides avpkt->size by block_align, so the loop bound is sound
only when the per-block consumption equals block_align — i.e. when
block_align is an exact multiple of channels. For any other
combination (e.g. block_align=9 with channels=8), each block consumes
more than block_align bytes; iterating avpkt->size/block_align
blocks then walks the input bytestream past avpkt->data +
avpkt->size, producing the heap-buffer-overflow READ at
libavcodec/bytestream.h:99 reported as ANT-2026-04052.

adpcm_decode_init() previously only enforced 'channels > 0' and
'block_align > 0' for PSXC. Tighten the init check to additionally
require 'block_align % channels == 0', which is the precise
invariant the decode loop depends on.

Reproducer: a crafted WAV header declaring channels=8, block_align=9
with the decoder forced via 'ffmpeg -c:a adpcm_psxc -i evil.wav'.

Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
2026-06-03 20:33:19 +00:00
Diego de Souza 6e857f12a7 avfilter/vf_scale_cuda: avoid <stdint.h> in CUDA device compilation
The device-only compilation path of vf_scale_cuda.h pulled in <stdint.h>
solely to obtain uint8_t for the CUdeviceptr typedef. On Windows-on-ARM
(aarch64 mingw) this drags in _mingw.h, whose ARM __prefetch intrinsic is
guarded by !__has_builtin(__prefetch). During clang's --cuda-device-only
pass __has_builtin has deferred/inconsistent semantics on the auxiliary
(host) target, so the guard mis-fires, the inline __prefetch definition is
emitted, and clang rejects it:

    _mingw.h: error: definition of builtin function '__prefetch'

This broke the msys2-clangarm64 FATE slot once ffnvcodec (and thus the
nvcc-compiled CUDA filters) was enabled for aarch64 Windows.

uint8_t is unsigned char, so use that directly and drop the <stdint.h>
include. Device-only code should not depend on the host C runtime headers.
No functional or ABI change.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-03 19:45:19 +00:00
Tim Walker 34ebcabcf1 avformat/aiffenc: write CHAN chunk after COMM
COMM is where the channel count is indicated
Channel count can be useful when parsing the CHAN chunk
2026-06-03 14:32:19 +00:00
jiale yao e8031e5b9a avfilter/avf_showcwt: fix out-of-bounds read in du scroll
Fixes: out of array access
Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-03 12:25:00 +00:00
Zhao Zhili 520968debb avcodec/vc1dsp: always inline vc1_loop_filter
vc1_loop_filter() is only reached through the six C wrappers. Clang 14
keeps it out of line with plain static inline, adding a 224-byte stack
frame before the tiny bestcase path on rpi 5. gcc 12 already inlines
it.

rpi 5 clang 14:
                                before  after
vc1_v_loop_filter4_bestcase_c   27.2     8.3   (3.3x)
vc1_h_loop_filter4_bestcase_c   26.4    10.2   (2.6x)
vc1_v_loop_filter8_bestcase_c   32.5    20.3   (1.6x)
vc1_h_loop_filter8_bestcase_c   31.7    19.5   (1.6x)
vc1_v_loop_filter16_bestcase_c  42.1    33.2   (1.3x)
vc1_h_loop_filter16_bestcase_c  41.6    25.3   (1.6x)

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-06-03 10:41:08 +00:00
Zhao Zhili 200914853d aarch64/sbrdsp: unroll sum64x5 to 16 floats/iter
The C version is faster than the previous asm with clang and gcc > 12 on
rpi5, since compiler basically does the same unroll.

sum64x5_neon:             before          after
  Cortex-A76 (gcc 12.4):  72.3 (3.63x)    47.4 (5.56x)
  Cortex-A76 (gcc 14.2):  72.3 (0.69x)    47.4 (1.05x)
  Apple M1 (clang 16):     0.2 (0.98x)     0.2 (0.99x)

Signed-off-by: Zhao Zhili <quinkblack@foxmail.com>
2026-06-03 10:40:20 +00:00
Zhao Zhili 1e86a92a1c lavu/aarch64: unroll butterflies_float to 8 floats/iter
butterflies_float_neon:   before           after
  Cortex-A76 (gcc 12.4):  163.1 (3.95x)    147.0 (4.37x)
  Apple M1 (clang 16):      0.7 (0.85x)      0.6 (0.99x)

Signed-off-by: Zhao Zhili <quinkblack@foxmail.com>
2026-06-03 09:36:59 +00:00
Zhao Zhili 1f66f9041b lavu/aarch64: split FMLA chain in scalarproduct_float
Unroll to 16 floats per iteration with four independent accumulators
and reduce them once after the loop.

scalarproduct_float_neon:  before          after
  Apple M1 (clang 16):      0.9 (3.56x)    0.4 (9.18x)
  Cortex-A76 (gcc 12.4):  118.7 (4.43x)   85.3 (6.15x)

Signed-off-by: Zhao Zhili <quinkblack@foxmail.com>
2026-06-03 09:36:59 +00:00
Lynne 4d63e3dd4c vulkan_ffv1: add Bayer encoder
Sponsored-by: Sovereign Tech Fund
2026-06-03 14:12:50 +09:00
Lynne bade9e6bd0 vulkan_ffv1: detect float remap from pixfmt, not f->flt
The decode-shader picker fell over for integer remapped streams.

Sponsored-by: Sovereign Tech Fund
2026-06-03 14:12:50 +09:00
Lynne 713f191c24 vulkan_ffv1: add Bayer decoder
Sponsored-by: Sovereign Tech Fund
2026-06-03 14:12:50 +09:00
James Almer 151fe3a5ac avcodec/itut35: unref existing buffers before allocating new ones
Finishes fixing memleaks.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 23:24:19 -03:00
James Almer 9dd48f7d25 avcodec/itut35: add missing unref calls in ff_itut_t35_unref()
Fixes memleaks.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 23:23:32 -03:00
Michael Niedermayer 537e87e3c2 avfilter/f_ebur128: avoid signed-int wrap when sizing per-channel cache
Fixes: integer overflow
Fixes: out of array access

Found-by: Claude (Anthropic), reported by Omkhar Arasaratnam <omkhar@linkedin.com>.
2026-06-03 01:45:08 +00:00
Yong Yu e1be70dcac swscale/x86/yuv2rgb: fix planar GBRP boundary check in ssse3 assembly
In yuv420_gbrp_ssse3, the boundary safeguard check "h_size * 3 >
    FFABS(dstStride[0])" was erroneously set based on probably packed RGB24
    formats (where each pixel spans 3 bytes per row).

    For GBRP (planar GBR), each plane contains only 1 component per pixel
    per row, meaning dstStride[0] corresponds exactly to width.
    Multiplying h_size by 3 mistakenly triggers the condition for normal
    widths, decreasing h_size by 8. This leaves the rightmost 8 pixels
    of every row completely uninitialized (black).

    Fix this by checking "h_size > FFABS(dstStride[0])" instead.

    How to Reproduce the error:
    1. Generate buggy and fixed outputs as PNGs using the 600x600 pipeline:

       buggy output without the fix
       $ ffmpeg -f lavfi -i color=c=red:size=600x600:rate=1 \
           -vf format=yuv420p,format=gbrp \
           -frames:v 1 -y buggy_red_600.png
       fixed output with the fix
       $ ffmpeg -f lavfi -i color=c=red:size=600x600:rate=1 \
           -vf format=yuv420p,format=gbrp \
           -frames:v 1 -y fixed_red_600.png

    2. Verify buggy_red_600.png in an image viewer:
       A strict, 8-pixel wide vertical black stripe (columns 592 to 599) is
       clearly visible running top-to-bottom down the rightmost edge of the image.

    3. Verify fixed_red_600.png in an image viewer as well:
       The output renders a perfect, uniform, fully solid red square across
       the entire 600x600 canvas, indicating the boundary bug is successfully resolved.
2026-06-02 23:42:01 +00:00
James Almer 361c1079c4 fate/lavf-container: add an ADTS muxing test
This covers writing a ChannelConfig of 0, plus parsing the stream's PCE
bits in a 5.1.2(back) sample.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 20:06:21 -03:00
James Almer a1e4aee2f0 avcodec/aac/aacdec: support height channels signaled with PCE
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 20:06:00 -03:00
James Almer 070bd112be avcodec/h2645_sei: use the ITU-T T35 parsing helpers
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer cf5284b491 avcodec/itut35: add support for HDR Vivid
Needed by h2645_sei.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer 04ae5788df avcodec/itut35: add support for Active Format Description
Needed by h2645_sei.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer f1929d75a2 avcodec/itut35: add support for AOM film graim
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer c500c786ab avcodec/libaomdec: use the ITU-T T35 parsing helpers
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer e40dd45f0d avcodec/libdav1d: use the ITU-T T35 parsing helpers
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer 19b3d47007 avcodec/av1dec: use the ITU-T T35 parsing helpers
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer 4fcd2349ff avcodec/itut35: add ITU-T T35 parsing helpers
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
Omkhar Arasaratnam 711cdae64f avformat/mov: cap HEIF ICC profile copies via c*max_streams to bound CPU and memory
Found-by: Claude (Anthropic). Human-verified and reported by
Omkhar Arasaratnam <omkhar@linkedin.com>.
Signed-off-by: Omkhar Arasaratnam <omkhar@linkedin.com>
2026-06-02 20:55:14 +00:00
Anton Kesy 344a9ce2da avcodec/qsvenc: add unsupported codec level log
Adds missing log of struct mfxInfoMFX member: codec level.

Signed-off-by: Anton Kesy <anton@kesy.de>
2026-06-02 20:51:32 +00:00
zhanghongyuan 02da2c46d2 fftools/opt_common: print encoder-specific capabilities in print_codec()
Add printing of AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
AV_CODEC_CAP_ENCODER_FLUSH, and AV_CODEC_CAP_ENCODER_RECON_FRAME
capabilities that were defined but not displayed.
2026-06-02 20:39:56 +00:00
Niklas Haas 8a6027a54f swscale/x86/ops_int: fix write_bits over-write
This writes 4 bytes but in SSE4 mode only produces 2 bytes per vector. We
can avoid over-writing by using the appropriately sized register.

Reproducible by:
  make libswscale/tests/swscale
  libswscale/tests/swscale -dst monob -unscaled 1 -flags unstable -align_src 1 -align_dst 1

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 15:37:54 +02:00
Niklas Haas 8f38703323 swscale/ops_dispatch: calculate correct slice line count for tail copy
These loops were both assuming that `h` lines need to be copied; but this
varies. First of all, for plane subsampling; but more importantly, when
vertically scaling, the input line count may be substantially lower than the
actual line count.

This fixes an out-of-bounds read/write when vertically upscaling with a tail
buffer.

Verifiable via e.g.:
  make libswscale/tests/swscale
  valgrind -- libswscale/tests/swscale -s 63x63 -src yuv444p -dst rgb24 \
              -flags unstable -align_src 1 -align_dst 1

(As well as the SSIM scores, which drop from ~e-5 to ~e-3 without this fix)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 15:36:42 +02:00
Niklas Haas a00db63da7 swscale/tests/swscale: add option to force specific buffer alignment
Useful to make sure the memcpy_in/out paths work as expected.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 15:35:00 +02:00
Niklas Haas bb5c461a47 avfilter/vf_libplacebo: setup pl_vulkan_queue.flags on import params
libplacebo versions before v365 passed .flags = 0 when retrieving the queues
from imported Vulkan devices, so we have to error out in the case of a mismatch
to avoid undefined behavior (Vulkan spec).

See-Also: https://code.videolan.org/videolan/libplacebo/-/merge_requests/856
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 13:32:44 +02:00
Niklas Haas 9b9d29e09a avfilter/vf_libplacebo: don't unnecessarily set fields to 0 (cosmetic)
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 13:32:44 +02:00
Niklas Haas 9fe5758da5 avutil/hwcontext_vulkan: publicly expose queue device creation flags
These are needed for interop with e.g. libplacebo, which needs to know the
correct flags to call vkGetDeviceQueue2.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 13:32:43 +02:00
Romain Beauxis 80375ca773 avformat/mpegts: update stream metadata from timed_id3 packets
Set AVSTREAM_EVENT_FLAG_METADATA_UPDATED so applications can detect
mid-stream metadata changes without inspecting packet side data.
2026-06-01 21:53:36 -05:00
Romain Beauxis f6838b8636 tests/fate/demux.mak: add FATE test for timed ID3 packet demuxing in HLS
streams.
2026-06-01 21:53:36 -05:00
Michael Niedermayer 69c9f1158c avcodec/aac/aacdec_usac: avoid signed overflow in decode_tsd
decode_tsd() computes the binomial coefficient c = C(k, p) incrementally.
this commit makes it less overflow prone

Fixes: 515703905/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_DEC_fuzzer-4890954254581760
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-02 00:59:38 +00:00
Michael Niedermayer e711e60827 avcodec/aac/aacdec: reject decoded frame without a valid sample rate
Later code will turn this into AVERROR_BUG

When returning sample_rate == 0 samples is considered a bug, we have no
nice choice but to error out cleanly

Fixes: assertion failure
Fixes: ffmpeg_AV_CODEC_ID_AAC_DEC_fuzzer crash-0a86d46fef2442b222ee34403c21f7f582ffccb0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-02 00:59:38 +00:00
Michael Niedermayer 620e59bbec avcodec/aac/aacdec: More detailed warning about sample rates
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-02 00:59:38 +00:00
Michael Niedermayer 263374ac7d avcodec/aac/aacdec_usac: reject explicit usacSamplingFrequency of 0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-02 00:59:38 +00:00
Jun Zhao d092269996 lavfi/vf_drawtext: log inferred shaping properties at verbose
Log the script and direction picked by HarfBuzz, plus codepoint and
glyph counts, so the shaper choice can be verified. Differing
codepoint and glyph counts indicate reordering / ligation /
decomposition.

Codepoints are sampled before hb_shape(), which flips the buffer
content type to GLYPHS.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-02 00:52:03 +00:00
Jun Zhao 1f9888beb0 lavfi/vf_drawtext: fix HarfBuzz shaping of Bengali / Indic scripts
shape_text_hb() set HB_SCRIPT_LATIN and called
hb_buffer_guess_segment_properties() on an empty buffer, so the
inference was a no-op. Bengali and other Indic / USE scripts reached
the default OT shaper instead of their script-specific shaper,
leaving the virama visible and consonants disjointed (e.g. স্টারমার
rendered as স্ টারমার).

Add the UTF-8 text first, keep the existing LTR direction used by the
FriBidi visual-order pipeline, then guess segment properties so the
script comes from the actual Unicode contents.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/23014
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-02 00:52:03 +00:00
Michael Niedermayer 43f712d917 avformat/iff: check av_get_packet() result in ANIM branch
Fixes: 494958338/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-6265824670449664
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-01 22:56:47 +00:00
Diego de Souza 93f653f95c configure: enable ffnvcodec, nvenc, nvdec for aarch64 Windows
Adding support to build FFmpeg with HW accelerated decode (nvdec) and
encode (nvenc) on aarch64 Windows, covering both the MinGW (mingw32/
mingw64) and MSVC (win32/win64) toolchains. The dynamically-loaded
NVIDIA codec headers and the CUDA loader are architecture-agnostic, so
the only gate was the target_os check in the aarch64/ppc64 branch.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-01 17:00:46 +00:00
Romain Beauxis dba111c34d .forgejo: add pull request template with fate-samples section 2026-06-01 10:40:57 -05:00
Romain Beauxis 78fff004f0 .forgejo: add support for ephemeral FATE samples via PR attachments
Developers can attach sample files to a PR and list their target paths
within the fate-suite in a fate-samples block in the PR description:

  ```fate-samples
  vorbis/tos.ogg
  mov/some-new-sample.mov
  ```

A new inject-pr-samples.py script fetches the PR metadata from the
Forgejo API, resolves each listed path to its matching attachment by
filename, and downloads the files into the fate-suite directory before
FATE runs.

The script validates that pr-number is an integer, that paths are
relative, contain no '..', and are at most 3 components deep (matching
the deepest paths in the existing fate-suite).  Attachment URLs are
restricted to the code.ffmpeg.org domain.

The script exports a new_samples=true/false output via $FORGEJO_OUTPUT.
After FATE completes, a final workflow step fails the run if any new
sample was injected, reminding contributors to add their samples to the
official fate-suite before the PR can be merged.

The script can also be used locally:
  SAMPLES=/path/to/fate-suite .forgejo/inject-pr-samples.py <pr-number>
2026-06-01 10:40:57 -05:00
Zhao Zhili 6f1de91492 fftools/ffmpeg_filter: free input filter channel layout
Fixes the LeakSanitizer failure in fate-dca-xll-coded. It was exposed
by c65c8f1f49.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-06-01 14:31:21 +00:00
James Almer 95fe0658d7 avformat/mov: don't abort on unsupported or invalid chnl boxes
They are optional and just define a channel layout, which may also be defined
by the underlying codec.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-01 09:53:54 -03:00
James Almer fd1c8fa0e6 avformat/mov_chan: keep the layout untouched on chan/chnl box failure
Needed to keep the process going if some issue was found while parsing these boxes.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-01 09:53:54 -03:00
James Almer cd92ef77c9 avformat/mov: add support for version 1 of chnl box
Fixes ticket #11183.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-01 09:53:54 -03:00
James Almer bf608f16fd avcodec/cbs_h266_syntax_template: Fix pps_exp_slice_height_in_ctus_minus1 range
Found-by: Claude (Anthropic). Human-verified and reported by Omkhar Arasaratnam <omkhar@linkedin.com>.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-01 03:42:50 +00:00
Michael Niedermayer 97ea5da419 avfilter/vf_scale: split rational multiply
Fixes: integer overflow in SAR
Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 21:20:54 +00:00
Kacper Michajłow 59619a1917 tests/fate/hevc: add dovi_split BSF tests 2026-05-31 16:58:23 +02:00
Kacper Michajłow 6026988b75 avcodec/bsf: add dovi_split BSF
Allows splitting interleaved BL+EL HEVC bitstream into separate streams.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 16:58:23 +02:00
Michael Niedermayer 054dffd133 avcodec/bsf/dts2pts: fix binary tree invariant violation on selective dec_poc
Modifying the keys of a sorted structure, be that a tree or other
can lead to changes in the ordering and undefined behavior.
It can also lead to collisions with existing keys.

All these cases need to be handled unless there is a bug elsewhere
that would prevent them.

Fixes: out of array access
Fixes: 504281984/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-6032368162111488

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-31 13:41:57 +00:00
Kacper Michajłow a76eae2765 avfilter/Makefile: fix build with Vulkan and runtime GLSL compilation
Fixes: avfilter/vulkan_shaderc.c:90: undefined reference to `ff_vk_shader_print'
Fixes: #23231

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 13:38:30 +00:00
Lynne 49a77d37be ffv1enc: write f->flt to extradata
The parser has been reading f->flt for combined_version >= 0x40004
since commit c1b330bf24 (avcodec/ffv1: Basic float16 support), but
ff_ffv1_write_extradata() never had a matching put_symbol().
The result was that the parsed f->flt was whatever the next symbol's
worth of rangecoded bits happened to decode to — often 0, but for a
yuv420p16le -level 4 -strict experimental stream produced locally it
parses as 1.  The software decoder doesn't notice because the YUV
pixfmt-selection branches never check f->flt, but anything else that
trusts it gets garbage.

Sponsored-by: Sovereign Tech Fund
2026-05-31 20:04:02 +09:00
Lynne 0678077143 ffv1enc: add RCT coefficient search for Bayer
Sponsored-by: Sovereign Tech Fund
2026-05-31 20:04:02 +09:00
Lynne 4f509c9e43 ffv1dec: implement Bayer pixel format encoding
Sponsored-by: Sovereign Tech Fund
2026-05-31 20:04:02 +09:00
Lynne d62686b50f ffv1enc: implement Bayer pixel format encoding
Sponsored-by: Sovereign Tech Fund
2026-05-31 20:03:57 +09:00
James Almer f778a7e241 avformat: deprecate AVStreamGroupLCEVC
It's been replaced with AVStreamGroupLayeredVideo, which is functionally the
same while generic enough to be shared with other kinds of layered video
implementations.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-31 03:43:29 +00:00
Kacper Michajłow b31fdbfde0 avformat/matroskadec: create Dolby Vision stream group
Matroska has no explicit cross-track Dolby Vision reference, so the
pairing is recovered from the dvcC/dvvC config records. Find a single
HEVC track whose record declares a profile 7 enhancement layer
(el_present_flag=1) and a single sibling HEVC BL candidate. If either
side is ambiguous, leave the streams ungrouped.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 03:43:29 +00:00
Kacper Michajłow 29bc8ec8d1 avformat/mpegts: create Dolby Vision stream group
See: https://professionalsupport.dolby.com/s/article/How-to-signal-Dolby-Vision-in-MPEG-2-TS

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 03:43:29 +00:00
Kacper Michajłow 8d89d7c25a avformat/mov: create Dolby Vision stream group
See: https://professionalsupport.dolby.com/s/article/How-to-signal-Dolby-Vision-in-ISOBMFF-format-AKA-mp4-container

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 03:43:29 +00:00
Kacper Michajłow 0a2e0b28d0 avformat/mov: add support for vdep based tref
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 03:43:29 +00:00
Kacper Michajłow d7c7ee4e2e avformat: add AV_STREAM_GROUP_PARAMS_DOLBY_VISION
This uses existing AVStreamGroupLayeredVideo.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 03:43:29 +00:00
Kacper Michajłow 1e3883df9f avformat: rename AVStreamGroupLCEVC to AVStreamGroupLayeredVideo
It will be reused for other similar groups.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 03:43:29 +00:00
Michael Niedermayer 073c44b8bc avfilter/vf_drawtext: Avoid double free in glyph_enu_border_free()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 03:25:21 +00:00
Michael Niedermayer 77554d85d7 avfilter/vf_drawtext: shape_text_hb() free allocated things on error
Fixes: memleak
Found-by: Fairy

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 03:25:21 +00:00
Michael Niedermayer 47c503c6a9 avfilter/vf_drawtext: plug error-path leaks in measure_text/draw_text
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 03:25:21 +00:00
Michael Niedermayer 9efca1d946 avfilter/vf_drawtext: avoid double-free of aliased FT_Glyph in glyph_enu_free
For glyphs whose source is already in bitmap form (color emoji fonts such
as NotoColorEmoji.ttf), FT_Glyph_To_Bitmap(..., destroy=0) returns the
input pointer unchanged. The result is that glyph->bglyph[idx] aliases
glyph->glyph (and analogously border_bglyph[t] may alias border_glyph).
glyph_enu_free then called FT_Done_Glyph on both, double-freeing the
underlying object.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 03:25:21 +00:00
Michael Niedermayer c51789b052 avfilter/vf_drawtext: don't double-free glyph that has been cached in tree
Reproducer:
  ffmpeg -f lavfi -i color=s=640x120:d=1 \
      -vf "drawtext=fontfile=/usr/share/fonts/truetype/noto/NotoColorEmoji.ttf:\
text='FFmpeg':fontsize=109:fontcolor=white:x=20:y=35" \
      -frames:v 1 out.png

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 03:25:21 +00:00
Michael Niedermayer c8c4e2d2a5 avfilter/vf_drawtext: always check pixel_mode == FT_PIXEL_MODE_MONO
The code as written can add such glyphs in the cache so we need to check
glyphs from the cache too.
This should be the most robust and simple solution

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 03:25:21 +00:00
James Almer c65c8f1f49 avcodec/dcadec: output a custom channel layout when requesting coded channel ordering
Outputting an UNSPEC layout will make most callers guess the speaker layout, and
more likely than not get it wrong.
Now that we can freely export custom order layouts, lets use them.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-30 22:37:09 -03:00
James Almer de647bfbbc avformat/mpeg: lower PES stream score compared to mp3/ac3
The heuristics run to detect PES streams are much laxer than mp3/ac3 ones,
which check for valid headers, so it should not have a higher score than the
latter.

Fixes misdetection of some mp3 files with big id3v2 tags at the beginning.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-31 00:39:51 +00:00
James Almer 1a0ab27954 avfilter/af_aresample: propagate the matrix encoding used for downmixing
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-30 21:37:33 -03:00
James Almer 971da26361 avfilter/af_aresample: fix layout comparison when applying downmix coeffs
out_layout at this point is a zeroed struct, and even after being filled below in the code
it's ensured it will be the same as outlink->side_data.
The actual check should be between inlink and outlink layouts. If they differ, then swr
will do remixing and as such the downmix info side data will no longer be valid for any
filter or encoder down the chain.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-30 21:37:33 -03:00
James Almer fd9e4fa081 avformat/dump: remove unused variable
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-30 16:02:26 -03:00
Romain Beauxis 6ef1a9579f avformat/matroskaenc: write hvcE BlockAdditionMapping for Dolby Vision EL
When AV_PKT_DATA_HEVC_CONF is present on an HEVC track, write
an hvcE BlockAdditionMapping alongside the existing dvcC/dvvC one,
carrying the raw HEVCDecoderConfigurationRecord for the enhancement layer.
2026-05-30 17:37:28 +00:00
Romain Beauxis 523b9faa94 avformat/matroskadec: parse hvcE block addition mapping as AV_PKT_DATA_HEVC_CONF
Handle MATROSKA_BLOCK_ADD_ID_TYPE_HVCE in mkv_parse_block_addition_mappings
and store the raw HEVCDecoderConfigurationRecord as
AV_PKT_DATA_HEVC_CONF on the stream's coded side data, mirroring
the existing dvcC/dvvC handling.
2026-05-30 17:37:28 +00:00
Romain Beauxis e2cfc80f32 avformat/matroska: add hvcE block addition mapping type
Add MATROSKA_BLOCK_ADD_ID_TYPE_HVCE (0x68766345) for the Dolby Vision
enhancement-layer HEVC configuration, alongside the existing dvcC/dvvC
entries.
2026-05-30 17:37:28 +00:00
Romain Beauxis 199e49d9b6 avformat/movenc: write hvcE box for Dolby Vision enhancement layer
When AV_PKT_DATA_HEVC_CONF is present on a MODE_MP4 HEVC
track, write it as an hvcE box alongside hvcC and dvcC. Like dvcC,
writing requires -strict unofficial.
2026-05-30 17:37:28 +00:00
Romain Beauxis 2c74d197ee avformat/mov: parse hvcE box as AV_PKT_DATA_HEVC_CONF side data
The hvcE box carries the HEVCDecoderConfigurationRecord for the Dolby
Vision enhancement layer in ISOM-based containers. Store its raw
contents as AV_PKT_DATA_HEVC_CONF on the stream's coded side data,
mirroring the existing dvcC/dvvC handling.
2026-05-30 17:37:28 +00:00
Romain Beauxis 5f6dff5e7d avcodec/packet: add AV_PKT_DATA_HEVC_CONF side data type
Carries a raw HEVCDecoderConfigurationRecord for the Dolby Vision
enhancement layer, parsed from the hvcE box (ISOM) or the corresponding
BlockAdditionMapping (Matroska).
2026-05-30 17:37:28 +00:00
Romain Beauxis 8c86d82703 fate: add tests for Dolby Vision Profile 7 hvcE preservation
Tests covering demux and remux of DV P7 dual-layer content with both
dvcC and hvcE BlockAdditionMapping/box across MP4 and Matroska.
2026-05-30 17:37:28 +00:00
Lynne ac611d3120 swscale/tests/swscale: check if formats require the legacy path with -hw
The issue is the legacy path does not support hardware frames, so falling
back means erroring with ENOTSUP, which would fail the tests.

Sponsored-by: Sovereign Tech Fund
2026-05-31 01:14:08 +09:00
Lynne cd89df8f99 vulkan/swscale: don't hardcode source type as float when filtering
Sponsored-by: Sovereign Tech Fund
2026-05-31 01:14:04 +09:00
Tau Gärtli 3023060139 tests/fate/generic-tags: Fix testing with --disable-swresample 2026-05-30 14:11:03 +00:00
David Korczynski 1152139b48 avcodec/cook: bound subpacket channel sum against channel count
Fixes: out of array read
Fixes: evil.rm

Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-30 13:57:13 +00:00
Andreas Rheinhardt b8c5376eb4 avcodec/vorbis_parser: Improve returned error codes
av_vorbis_parse_init() doesn't return an error code which is a slight
problem in libvorbisenc.c. Fix this by making the internal
initialization function behind av_vorbis_parse_init() available. This
also avoids allocations and frees.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-30 13:10:07 +02:00
Lynne 80405d3ceb swscale/vulkan: support interlaced filtering
Sponsored-by: Sovereign Tech Fund
2026-05-30 12:10:06 +09:00
Lynne 6de9576fca swscale/vulkan: implement filtered reads for the SPIRV backend
Same as GLSL, but much more annoying due to descriptors.
2026-05-30 12:10:06 +09:00
Lynne d66552e676 vulkan/ffv1: add 32-bit float RGB encoding and a rice + remap path
This implements 32-bit float RGB encoding and makes the Vulkan implementation
on-par with the C implementation.

Sponsored-by: Sovereign Tech Fund
2026-05-30 12:10:01 +09:00
Michael Niedermayer 7a2424eb43 avcodec/apv_decode: avoid using apv_cbc
Fixes: out of array access
Fixes: evil.apv

Found-by: Claude (Anthropic). Human-verified and reported by Omkhar Arasaratnam <omkhar@linkedin.com>. on 05-20
Found-by: Anthropic agents; validated and reported by Ada Logics. on 05-26
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-29 20:10:14 +00:00
Michael Niedermayer aaac0989e6 avformat/mxfdec: Remove unneeded check
size is 16bit only

Found-by: Tomas Härdin
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-29 18:23:06 +00:00
Jerome Berclaz 468a743af1 avformat/dashenc: add options for live MPD timing 2026-05-29 03:25:53 +00:00
Michael Niedermayer 4d24cb1c39 avformat/ftp: Check string used for RNTO
Found-by: Forgejo Fairy
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-29 01:49:20 +00:00
Michael Niedermayer 090838497c avformat/ftp: Check for Telnet IAC characters and other non printable ASCII chars
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-29 01:49:20 +00:00
Franciszek Kalinowski 640f32b1b6 avformat/ftp: reject CR/LF in the URL path to prevent FTP command injection
ftp_connect() interpolates the URL path into SIZE/RETR/STOR/CWD/DELE/RMD/RNFR
commands without checking for CR/LF, although it already rejects CR/LF in the
user and password fields. Reject CR/LF in s->path the same way.

Reported and reviewed by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Śmigielski.
2026-05-29 01:49:20 +00:00
Michael Niedermayer 6631bbc5d4 avcodec/jpeg2000dec: Clear header derived variables
Fixes: NULL pointer dereference

Found-by: Oguzhan Akkaya with AFL++ fuzzing (May 2026)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-28 22:31:36 +00:00
Michael Niedermayer 0834dbed1c avcodec/bsf/smpte436m_to_eia608: properly frees stuff on errors in ff_smpte436m_to_eia608_filter()
Fixes: memleaks
Fixes: 501913473/clusterfuzz-testcase-minimized-ffmpeg_BSF_SMPTE436M_TO_EIA608_fuzzer-5607133705207808

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-28 22:24:58 +00:00
James Almer de261b9bb2 tests/checkasm/crc: use libavutil memory allocation helpers
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-28 22:04:27 +00:00
James Almer 224659360a tests/checkasm/crc: retain offset values between calls
Should fix buffer overflows as reported by clang-asan and use of uninitialized
values as reported by valgrind.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-28 22:04:27 +00:00
James Almer 93512bc2fd avformat/avc: Adjust get_ue_golomb() to handle 32 bit
Fixes: assertion failure
Fixes: PR-009/bad_extra_idr_only.avi

Found-by: mosskappa
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-28 21:46:48 +00:00
Michael Niedermayer af86ff142a fate/voice: add comfortnoise encoder-decoder FATE test
Add a CNG (comfortnoise) round-trip FATE test using the existing enc_dec_pcm + framemd5 pattern and include its generated reference output.
and a 2nd test that compares MD5 of the encoded stream

Tested on x86-32 & 64, arm, mips qemu

Co-Authored-with: AI
2026-05-28 21:01:13 +00:00
James Almer af4caa17a7 avcodec/libfdk_aac: simplify setting the layout mask
We can combine some cases in these switches as they set the same flags.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-28 13:23:42 +00:00
Omkhar Arasaratnam 7b46c6a2a3 avformat/whip: require remote DTLS fingerprint in SDP answer
WHIP relies on the SDP a=fingerprint to bind the peer identity to
the SRTP keying material (RFC 8842 §§ 5.1, 5.3). parse_answer()
walks the SDP body looking for `a=ice-lite`, `a=ice-ufrag:`,
`a=ice-pwd:`, and `a=candidate:` lines and ignores everything else,
including `a=fingerprint`. WHIP intentionally runs the OpenSSL DTLS
backend with s->verify=0 (DTLS-SRTP uses self-signed certs by
design, so a CA chain check would be meaningless); the peer cert is
accepted regardless of identity. The spec's compensating identity
control — verifying the DTLS peer cert against the SDP a=fingerprint
hash — is missing, so the SRTP keys are derived from a session
whose peer identity was never authenticated. Any on-path attacker,
or a malicious WHIP server URL, can substitute their own DTLS
material and the publisher's RTP stream will be encrypted to them.

The full fix is a two-step process:
  (a) Require a=fingerprint to be present in the SDP answer
      (RFC 8842 § 5.3 MUST).
  (b) After DTLS handshake, compute the peer-cert hash and compare
      against the stored fingerprint (RFC 8842 § 5.1 MUST); tear
      down the session on mismatch.
This patch implements step (a) only; step (b) requires plumbing
the cert hash out of dtls_start() through the openssl TLS context
and is left as a follow-up.

Add a remote_fingerprint field to WHIPContext, extract the
a=fingerprint value from the SDP answer in parse_answer(), and
return AVERROR(EINVAL) when it is absent. This raises the bar from
"no fingerprint required" to "any fingerprint required"; the
follow-up patch will raise it again to "fingerprint MUST hash-match
the DTLS peer cert."

Found-by: Claude (Anthropic). Human-verified and reported by
Omkhar Arasaratnam <omkhar@linkedin.com>.
Signed-off-by: Omkhar Arasaratnam <omkhar@linkedin.com>
2026-05-28 04:41:06 +00:00
Tim Walker c591ddd453 avformat/movenc: don't write a 'chan' atom with an incorrect channel bitmap or description. 2026-05-28 03:22:29 +00:00
Tim Walker 29bb6a771a avformat/movenc: re-order mov_codec_ch_layouts 2026-05-28 03:22:29 +00:00
Tim Walker 55ba902d71 avformat/movenc: re-indent mov_codec_ch_layouts 2026-05-28 03:22:29 +00:00
Tim Walker d4125bbce7 avformat/movenc: add channel layout mappings for a few codecs
These codecs cannot self-report layout in the bitstream, and
are known or expected to use a libavutil-compatible channel
order, and as such can use mov_ch_layouts_wav for tag lookup.
2026-05-28 03:22:29 +00:00
James Almer 3e402514e5 avcodec/aacencdsp: move init methods outside of the header
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-28 00:04:06 -03:00
Tim Walker 5f14108864 avcodec/libfdk-aacdec: support streams with 5 front channels 2026-05-27 21:06:41 +02:00
Vann Harl fb5dd6ec60 avformat/tls_{openssl,gnutls,mbedtls}: gate DTLS udp helpers on CONFIG_UDP_PROTOCOL
ff_udp_get_last_recv_addr and ff_udp_set_remote_addr are defined in
udp.c which only compiles under CONFIG_UDP_PROTOCOL. Building with
--disable-everything plus a protocol whitelist that excludes UDP
left these references unresolved at link time, even though TLS
itself uses TCP. Wrap the DTLS UDP-remote-addr blocks accordingly
2026-05-27 11:41:32 +00:00
Aditya Banavi 28b92b9b2e avformat/tls_gnutls:fix crash when connecting to peer
When ffmpeg whip client takes up dtls_active role when using gnutls,
it tries to connect to the server over udp and intermittently crashes.
This is because s->host is NULL, and ffmpeg is in ice controlling mode.
The gnutls api - gnutls_server_name_set() crashes if the hostname is NULL.

This commit assigns valid value to s->host in such scenarios.

Signed-off-by: Aditya Banavi <adityabanavi@gmail.com>
2026-05-27 11:39:32 +00:00
Aditya Banavi df3511db5b avformat/tls: Moved the parsing of host uri into a separate function - ff_tls_parse_host()
This makes the function reusable and modular

Signed-off-by: Aditya Banavi <adityabanavi@gmail.com>
2026-05-27 11:39:32 +00:00
DROOdotFOO 30595cbc5d swscale/aarch64/yuv2rgb_neon: aggregate 16bpp predicates
The six .ifc cascades that gate 16bpp behavior in yuv2rgb_neon.S
(linesize padding in three load_args macros, d8/d9 save/restore,
main-loop pack dispatch) all branch on the same four output formats.
Aggregate the predicate into four GAS .set symbols emitted once per
declare_func via a new set_rgb16_predicates macro:

  rgb16   - 1 for *565le and *555le outputs; 0 otherwise
  r_first - 1 for rgb*le (R high); 0 for bgr*le (B high)
  gshift  - 2 for 565, 3 for 555 (passed as pack_rgb16's g_shr)
  hshift  - 11 for 565, 10 for 555 (passed as pack_rgb16's high_shl)

Call sites become a flat ".if rgb16" gate (five places) plus a 2-way
".if r_first" inside ".if rgb16" for the pack dispatch (one place).
.if/.endif count drops from 46 to 33; -88/+49 lines net.

Pure source-level refactor: the full object disassembly is byte-for-byte
identical to the pre-refactor build (MD5 2a6ac497cabc81849e0c80ec0fde0550
on Apple M1, clang). checkasm --test=sw_yuv2rgb 110/110, full checkasm
7657/7657.

Signed-off-by: DROOdotFOO <drew@axol.io>
2026-05-26 19:26:28 +02:00
Ramiro Polla 0ac3b00a18 avcodec/mjpegdec: simplify bayer width handling
Double s->avctx->width directly, simplifying width-related code in
ljpeg_decode_rgb_scan().
2026-05-26 11:19:14 +02:00
Ramiro Polla 2065ead16e avcodec/mjpegdec: remove redundant vpred variable for bayer
The vpred variable in ljpeg_decode_rgb_scan() is redundant with
buffer[0][i], which is used by the generic codepath.
2026-05-26 11:19:14 +02:00
Lynne 9a6b5ca197 vulkan/ffv1_enc_rct_search: fix slice dimension iterations
This was a mess, we were using incorrect pixels outside of the image boundaries as
valid, the iteration had undefined behaviour since it was non-uniform across the workgroup.

Calculate the per-invoc iterations from the slice dimensions instead, making all of
them identical. And add a valid flag to decide whether to use them or not. And fix the
synchronization.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:04 +09:00
Lynne 9cabb12f74 vulkan/ffv1_enc_rct_search: write slice_rct_coef directly by main invoc
The issue is that SliceContext was passed as an inout, which caused all
invocs to locally copy and modify it.
When the main invoc wrote it, only the very last written value was used,
choosing the wrong coeffs.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:04 +09:00
Lynne 5fc56fbf96 vulkan/ffv1_enc_rct_search: barrier before reading score_mode
There was a race condition where the main invocation would race ahead and use
values not yet written by other invocs.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:04 +09:00
Lynne 2806afd28f vulkan/ffv1: read raw 16-bit float images via R16_UINT view to preserve denormals
GPUs filter out denormals when reading floats via imageLoad. Denormals shouldn't
be present in general, but if they are, this is a lossless codec, and we have to
preserve them. This allows reading the exact values.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:04 +09:00
Lynne 50e6668c83 vulkan/ffv1_enc: skip GOLOMB encode_line when !bits for FLOAT formats
Same as the arithmetic coded path. I skipped out on adding this here.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:04 +09:00
Lynne e14e43aeaa vulkan/ffv1_enc: pass the correct base and offset to OFFBUF in init_golomb
Ugh, my previous fix on this was only right in some cases, this is a general fix.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:03 +09:00
Lynne d1e0a292ce vulkan/ffv1_enc_remap: clear the full 65536-entry fltmap
Float pixfmts are meant to be normalized between [0, 1], but in case they
were not, and negative numbers were present, then the top bits would be
filled with garbage.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:03 +09:00
Lynne 4675271e7a vulkan/rangecoder: fix encoding issue when -1 != 0xFF
This was an oversight while microoptimizing. The outstanding_byte can
reach 0xFF in some situations, which was causing errors when encoding,
particularly with 32-bit floats.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:46:59 +09:00
Hassan Hany 9288681068 avcodec/x86/vorbisdsp: change cmpleps to cmpltps in inverse coupling
Changed the comparison from cmpleps to strictly less than
(cmpltps) to strictly follow the Vorbis spec

Fixes https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/21501
2026-05-26 04:46:04 +00:00
Soham Kute 8885116f4d avcodec/liboapvenc: derive and validate APV profile from pixel format 2026-05-25 23:12:05 +00:00
Ramiro Polla 3040962167 swscale/swscale_unscaled: fix packed30togbra10() and gbr16ptopacked30() for GBRP 10 and 12 bit MSB formats
The formats added in e93de9948d keep the values in the most significant
bits of the uint16_t, and packed30togbra10() and gbr16ptopacked30()
weren't taking into consideration the shift field from AVComponentDescriptor.

Reproducible with:
$ ./libswscale/tests/swscale -unscaled 1 -src gbrp10msbbe -dst x2rgb10le
$ ./libswscale/tests/swscale -unscaled 1 -src x2rgb10le -dst gbrp10msbbe
2026-05-25 22:44:21 +00:00
Michael Niedermayer 4945e33e98 avformat/dashdec: bound manifest reloads and fragment-open retries
Mirror the HLS demuxer's max_reload pattern

Reported as a DoS finding by Xueqing. Verified with the supplied PoC
server: a 30s ffmpeg run that previously generated ~10000 requests
without termination now exits in ~100ms after exactly max_reload
fragment-open failures.
2026-05-25 22:35:21 +00:00
Franciszek Kalinowski 461fb22053 avfilter/af_join: fix wrong loop bound in buffer dedup (use-after-free)
try_push_frame() decides whether an input buffer is already tracked by testing
`j == i` (the channel index) instead of `j == nb_buffers`. Once an earlier
channel shared a buffer, nb_buffers falls behind i and a genuinely new buffer is
never referenced, so it is freed while the output frame still points at it.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-05-25 22:21:41 +00:00
Omkhar Arasaratnam 387ad6d102 avformat/mov: validate APV access unit length before passing to decoder
libavformat/mov.c read the APV AU length field directly from the
sample without sanity-checking against the remaining sample size or
a documented maximum. The patch validates that au_size is bounded by
the remaining sample bytes and that the AU envelope (4 bytes plus
au_size) fits inside the declared sample size.

Validate the access unit length at the demuxer boundary so that the
decoder is not handed an attacker-controllable buffer size. Returns
AVERROR_INVALIDDATA on the bound failure with an explicit log line.

Found-by: Claude (Anthropic). Human-verified and reported by
Omkhar Arasaratnam <omkhar@linkedin.com>.
Signed-off-by: Omkhar Arasaratnam <omkhar@linkedin.com>
2026-05-25 21:53:01 +00:00
marcos ashton 0bdda94ccc tests/fate/libavutil: add FATE test for csp
Test the five public functions not already covered by
tests/color_utils: av_csp_luma_coeffs_from_avcsp,
av_csp_primaries_desc_from_id, av_csp_primaries_id_from_desc,
av_csp_approximate_trc_gamma, and av_csp_approximate_eotf_gamma.
Iterates every AVCOL_SPC, AVCOL_PRI, and AVCOL_TRC value including
the extended ranges, round-trips primaries via desc_eq so the
canonical first-match (e.g. smpte170m for smpte240m) is accepted,
checks that a garbage desc returns AVCOL_PRI_UNSPECIFIED, and that
out-of-range enum values return NULL or 0.0 as documented. The
trc/eotf gamma values come from static lookup tables so the
floating point output is bitexact across platforms.

Coverage for libavutil/csp.c: 88.50% -> 94.46%
2026-05-25 21:18:34 +00:00
marcos ashton 907b738995 tests/fate/libavutil: add FATE test for ambient_viewing_environment
Test av_ambient_viewing_environment_alloc with and without the size
out-parameter, and av_ambient_viewing_environment_create_side_data.
Verifies the {0, 1} rational defaults set by get_defaults(),
write/read-back of the three AVRational fields, frame side data
attachment, and OOM paths via av_max_alloc.

Coverage for libavutil/ambient_viewing_environment.c: 60.00% -> 100.00%
2026-05-25 21:18:34 +00:00
Zuxy Meng 3921b435fc avcodec/x86/h264_intrapred: cosmetic fix
Mark needed xmm regs for pred8x8_top_dc_8; fix indentation for pred8x8_dc_8.

Signed-off-by: Zuxy Meng <zuxy.meng@gmail.com>
2026-05-25 12:18:09 -07:00
Franciszek Kalinowski 69bdb05f36 avcodec/pngdec: bound decompressed zTXt/iCCP size (decompression-bomb guard)
decode_zbuf() inflates zTXt (compressed text) and iCCP (ICC profile) chunk
payloads into an AVBPrint created with AV_BPRINT_SIZE_UNLIMITED and never
checks the decompressed size. A ~100 KB zTXt chunk of compressed zeros
expands to 100 MB; larger ratios or multiple chunks can exhaust memory.

Abort with AVERROR_INVALIDDATA once the decompressed output crosses a hard
cap (16 MiB).

Verified with a crafted PNG (1 KB compressed -> 100 MB decompressed): without
the patch the chunk fully decompresses, taking >100 MB; with the patch the
inflate loop aborts and the decoder logs "Compressed PNG chunk expands
beyond 16777216 bytes" / "Broken zTXt chunk" while the rest of the image
decodes normally.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-05-25 15:09:20 +00:00
Franciszek Kalinowski c79dfd29e6 avcodec/h264_slice: guard color_frame() against chroma-width underflow
In the >= 9 bit path, color_frame() does
`av_memcpy_backptr(dst + 2, 2, bytes - 2)`. When the effective chroma width
is 1 pixel (bytes == 1) the count becomes -1 and the underlying fill16()
loop runs roughly 2^32 times, producing a heap overflow. The original count
was also wrong in units (pixels rather than bytes); fix that at the same
time so the 2-pixel case still fills both pixels.

Confirmed via a standalone harness reproducing av_memcpy_backptr's fill16
loop with cnt = -1; reaching the call from a crafted H.264 bitstream
requires Hi10P plus a frame_num gap on a frame whose effective chroma width
is 1 pixel, which is hard to express but is reachable via mid-stream SPS
changes. Compiles cleanly; no regressions seen running existing crafted
H.264 PoCs and trivial transcodes.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-05-25 13:16:03 +00:00
Zuxy Meng 34dfa8bf2b avcodec/x86/h264_intrapred: SSE2 impl. of pred8x8l_top_dc_8
Deprecate MMX with less instruction count. Remove the SSSE3 impl. as we
no longer use palignr.

pred8x8l_top_dc_8_mmxext:                                8.7 ( 2.29x)
pred8x8l_top_dc_8_ssse3:                                 7.9 ( 2.51x)
pred8x8l_top_dc_8_sse2:                                  6.7 ( 3.01x)

Signed-off-by: Zuxy Meng <zuxy.meng@gmail.com>
2026-05-25 07:05:09 +00:00
Macdu f16c3cc5aa avcodec/atrac9dec: improve output of atrac9_decode_frame 2026-05-25 03:18:53 +00:00
Zhao Zhili 78a0309735 avformat/movenc: don't overwrite track_duration on every src_track
When a tmcd or similar metadata track references multiple source
tracks, the per-iteration assignment overwrote track->track_duration
on each loop step, leaving it set to whatever the last source happened
to be.
2026-05-25 02:31:09 +00:00
Michael Niedermayer c23d4da312 avcodec/magicyuv: Fix 1 line MEDIAN slices
No testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-25 02:05:30 +00:00
Michael Niedermayer 5806e8b9f3 avcodec/magicyuv: Expand the s->interlaced slice-height sanity check
Fixes: poc_magicyuv.avi
Fixes: out of array access

Found-by: Ori Hollander of the JFrog Vulnerability Research team
2026-05-25 02:05:30 +00:00
Ori Hollander 374b726ffa avcodec/magicyuv: reject slice_height misaligned with chroma vshift
Fixes: poc_magicyuv.avi
Fixes: out of array access

Found-by: Ori Hollander of the JFrog Vulnerability Research team
2026-05-25 02:05:30 +00:00
Michael Niedermayer 8f1769703c avformat/mxfdec: zero-init Sony MPEG-4 extradata and add padding
Found-by: Calm (AI security-research agent, for John Bradley / Credex)
2026-05-25 01:34:28 +00:00
Michael Niedermayer d2d79dca9a avformat/soxdec: Check sample_rate for nan
Found-by: iceray-Li
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-25 01:15:28 +00:00
Nicolas Gaullier b79a7422f5 fftools/ffprobe: print downmix_info frame side data
Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-05-25 00:55:19 +00:00
Nicolas Gaullier 6b401344e8 fftools/textformat: add support for decibel formatting
Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-05-25 00:55:19 +00:00
Nicolas Gaullier 0099a5fbdd fftools/textformat: stop using char * as identifiers
Add an enum instead.
As a result, fix honor -byte_binary_prefix.
In value_string(), add support for float values (beyond seconds),
and allow unit to be null or empty.
Also remove unused variable unit_second_str in ffprobe.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-05-25 00:55:19 +00:00
Balling 8cd7465565 tests/tiny_ssim: fixed mistake in ssim_c1 calculation
Reporter uses this code in production.

Signed-off-by: Valerii Zapodovnikov <val.zapod.vz@gmail.com>
2026-05-25 00:35:22 +00:00
Michael Niedermayer c2047918e6 avformat/hls: Check url_offset and size
Fixes: integer overflow

Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-25 00:10:18 +00:00
Michael Niedermayer 59094859a8 avformat/hls: Check TIME-OFFSET value
Fixes: UB with out of range values
Fixes: poc_overflow.m3u8

Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-25 00:10:18 +00:00
amhurtado d3f59f9b7f avcodec/prores_raw: reject invalid tile alignment values
Fixes: out of array access

Regression since d8cb567 ("prores_raw: fix tile alignment
issues").

Found-by: amhurtado <amhurtado@pm.me>
Signed-off-by: amhurtado <amhurtado@pm.me>
2026-05-24 22:27:08 +00:00
Zhao Zhili a0def8f915 avformat/movenc: skip the metadata stream itself when populating tref
A tref stream group lists the metadata stream (e.g. tmcd) alongside the
streams it references. The init loop iterated over every stream in the
group and added it to the metadata track's src_track array, which made
the tmcd track reference itself.

Regression since 4444a755.

Signed-off-by: Zhao Zhili <quinkblack@foxmail.com>
2026-05-24 21:14:31 +00:00
Timo Rothenpieler 3baab604db forgejo/workflows: run at least one test out-of-tree 2026-05-24 00:12:16 +02:00
Timo Rothenpieler 0b52ae8aa6 tests/fate/generic-tags: fix out-of-tree testing 2026-05-23 23:16:57 +02:00
Romain Beauxis 2bae6f9d52 avformat/ogg: drop CELT support 2026-05-23 10:16:38 -05:00
RossWang bce8d61d12 avformat/libsrt: fix ipv6 wildcard listener
For now it fails on srt://[::]:1234?mode=listener

This modification makes it accept a new option "ipv6only"

Reference:
https://github.com/Haivision/srt/pull/2608
https://github.com/Haivision/srt/blob/master/docs/API/API-socket-options.md#SRTO_IPV6ONLY

fix #10539
2026-05-23 10:03:33 -05:00
Tau Gärtli 8d817a1150 libavformat: Add generic disc_subtitle tag mapping for Vorbis
The mapping is taken from Picard's [1] and taglib's [2] documentation.

The official list [3] of standard field names is pretty short and
does not include one for a disc/part subtitle. Some taggers use
SETSUBTITLE here instead. However, I think DISCSUBTITLE is much more
consistent with the already existing DISCNUMBER field and it matches
what Picard and taglib do.

[1]: https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#disc-subtitle
[2]: https://taglib.org/api/p_propertymapping.html
[3]: https://xiph.org/vorbis/doc/v-comment.html
2026-05-23 16:09:55 +02:00
Tau Gärtli 504c135f8c libavformat: Add generic disc_subtitle tag mapping for MOV/MP4
The mapping is taken from Picard's [1] and taglib's [2] documentation.

[1]: https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#disc-subtitle
[2]: https://taglib.org/api/p_propertymapping.html
2026-05-23 16:07:57 +02:00
Tau Gärtli 752abe97ab libavformat: Add generic disc_subtitle tag mapping for ID3v2
The mapping is taken from Picard's [1] and taglib's [2] documentation.

The `TSST` frame is part of ID3v2.4.0:
> The 'Set subtitle' frame is intended for the subtitle of the part
> of a set this track belongs to.

[1]: https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#disc-subtitle
[2]: https://taglib.org/api/p_propertymapping.html
2026-05-23 16:07:50 +02:00
Tau Gärtli 0abe230566 libavformat: Add generic disc_subtitle tag mapping for asf
The mapping is taken from Picard's [1] and taglib's [2] documentation.

The mapping in Microsoft's docs [3] maps `TSST` from ID3 to
`WM/SetSubTitle`. However, some taggers [4] [5] use `WM/SubTitle` instead.
I believe this to be an error, especially since the official docs say otherwise.

[1]: https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#disc-subtitle
[2]: https://taglib.org/api/p_propertymapping.html
[3]: https://learn.microsoft.com/en-gb/windows/win32/wmformat/id3-tag-support
[4]: https://github.com/quodlibet/quodlibet/blob/db95540de69c7f7cda662fbad6d90eeca89611ce/quodlibet/formats/wma.py#L43
[5]: https://invent.kde.org/multimedia/kid3/-/blob/989fb5b8f98e20387c704e229f8c8b9cd00ae453/src/plugins/taglibmetadata/taglibasfsupport.cpp#L93
2026-05-23 16:07:39 +02:00
Tau Gärtli ac4fc01d6f libavformat: Add generic disc_subtitle tag 2026-05-23 16:07:21 +02:00
Tau Gärtli b64d0c6db6 tests/fate: Add tests for generic metadata tags 2026-05-23 16:07:18 +02:00
Daniil Cherednik dfd11985e8 Add silence ut 2026-05-23 10:38:28 +00:00
Daniil Cherednik 816d74e0bb avcodec/opus/enc: fix CELT psy analysis and packet sizing
The CELT psychoacoustic path was effectively broken: analysis could use
the wrong queued audio and stale scratch samples, and raw band scores were
folded into the frame bit budget, where they could overflow instead of
only driving alloc_boost.

On top of that, c3aea7628c changed avctx->frame_size from fixed
120-sample steps to a configuration-derived value, while the CELT input
and psy paths still treated queue entries as 120-sample steps. That could
misalign psy analysis, read before a short overlap frame, stall silent
flushes, poison rate control with zero-bit silent frames, and overrun the
range coder on EOF or short tails.

This commit fixes these cases by using avctx->frame_size for psy step
accounting, aligning bufqueue analysis with actual audio, padding short
overlaps, and avoiding invalid bit-budget updates for silent or EOF
packets. This lets CELT produce valid packets again.
2026-05-23 10:38:28 +00:00
Niklas Haas aa08cf8112 swscale/options: add missing option value for SWS_STRICT
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 11:31:54 +02:00
Niklas Haas 03dfac5630 fftools/ffmpeg_sched: allow throttling decoder outputs
This is a departure from the conventional idea of decoders always outputting
data as fast as possible. Instead, this allows decoders to be throttled in the
same way filter graphs can be.

This comes into play when e.g. a demuxer is feeding into two decoders, but
only one of the two decoders is actually currently needed (e.g. due to
A/V misalignment). In that case, what typically happens is that the unneeded
decoder alse decodes all frames, and then piles them up on the "buffersrc"
filter's downstream link (growing indefinitely).

Another issue this solves manifests when e.g. a single demuxer is feeding many
decoders that all try to feed frames to the same filter graph. In this case,
all decoders run as fast as posssible, leading to lock contention on the
filter graph input queue; resulting in (again) many frames piling up on the
buffersrc (or downstream filters) for the unneeded inputs that are not actually
the bottleneck, while the input that's actually undersatisfied can end up
starved for CPU time, possibly for long enough to exhaust memory limits. The
normal rate limiting fails to apply in this scenario because all decoders share
a single demuxer, and are hence rate-limited only by the demuxer speed; whereas
the demuxer is not choked because from the PoV of the scheduler, the filter
graph is simply not getting enough frames.

In a more general sense, there's a philosophical argument to be made here.
Since a decoder is typically also a decompressor, it produces more data than
it consumes. So, it a sense, it's acting like a type of producer also - in
the same way that a filter graph can produce more input that outputs.

Solve all of these issues by allowing decoders to be output-choked, which
gives the scheduler control over when decoders are allowed to output frames.
This does mean we have to add some sort of internal packet queue, because the
decoder thread may need to continue *accepting* upstream packets from the
demuxer (or else we risk stalling the demuxer), but defer the actual decoding
by placing them inside an internal "overflow" queue.

This effectively simulates a sort of "filter graph"-type semantics but
for the decoder queue.

This overflow logic is fairly self-contained inside `sch_dec_receive`, though
it is quite nontrivial. I have added as much documentation as is hopefully
needed to understand the logic.

Importantly, we cannot simply unlimit the decoder input thread queue because
the demuxer relies on backpressure from the decoder to rate limit itself. (Note
that demuxers may only be active if there is at least one downstream decoder
that is alse active, so we always have at least one decoder providing
backpressure)

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Niklas Haas 2b72d5243c fftools/ffmpeg_sched: drain incoming frames before blocking filters
When a filter is choked, but upstream threads are trying to write to its input,
this can result in the filter's input queue getting stuck. Normally, the
unchoke_downstream() logic would prevent this from happening, since the
filter would itself get unchoked as a result of upstream decoders receiving
pressure from the demuxer.

However, upcoming changes to this logic will require weakening this upstream
unchoking logic, so preventing the deadlock in a more elegant way helps with
making the code more robust.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Niklas Haas 95391352b5 fftools/thread_queue: add THREAD_QUEUE_FLAG_NO_BLOCK
Exactly what it says on the tin. There is some ambiguity as to whether this
should also prevent reading from *choked*, as opposed to empty queue, but
I think it makes sense to consider them equivalent, as I struggle to think
of a use case where it would be beneficial to allow draining a queue that
was explicitly choked by the upstream (to e.g. prevent further reads).

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Niklas Haas 321b0e36a3 fftools/thread_queue: add flags parameter to tq_receive()
I want to use this to allow a non-blocking use of this function.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Marton Balint f48e5d4db4 fftools/ffmpeg_filter: rate control all filter graphs
It was never reliable to detect if a filtergraph have sources, because a filter
can act as a source only after some time, for example the loop filter.

So it is better to remove the source detection entirely and always give the
scheduler an oppurtunity to stop processing.

Fixes ticket #11604.

Signed-off-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Niklas Haas 6a563dab71 fftools/ffmpeg_sched: allow choosing nodes to unchoke
This level of granularity will help for the upcoming patch.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Niklas Haas 04888287b3 fftools/ffmpeg_sched: fix sch_stop() and schedule_update_locked() race
schedule_update_locked() is supposed to be a no-op when `sch->terminate`
is 1. However, there is a TOCTOU error here, where a different thread may
currently be executing schedule_update_locked(), having successfully passed
the sch->terminate check but without actually updating the choke status.

This does not matter for the current code, but will matter with the following
commit, where it creates the theoretical possibility of a race where sch_stop()
is trying to choke the demuxers (and unchoke the decoders) while
schedule_update_locked() is simultaneously trying to choke the decoders,
leading to a deadlock if the last decoder is left choked and unable to
propagate EOF downstream.

The cleanest solution is to just take the scheduler lock while updating the
choke status here. This ensures that any other schedule_update_locked() calls
will have completed.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Niklas Haas 0d123a3c23 fftools/ffmpeg_sched: use macros for schedule_update_locked() loops
Instead of awkwardly looping over the type, just split this up into
multiple loops. The loss in complexity seems worth the loss in conciseness
to me, and more importantly, this allows us to easily add more waiter types.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Michael Niedermayer 4492ad7228 avformat/ty: check rec_size
Fixes: ada-4-poc.ty

change is based on the suggested fix

Found-by: Claude and Ada Logics. This issue was found by Anthropic from using agents to study security of open source projects
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-23 00:04:46 +00:00
James Almer 3a042a5ab8 avcodec/libfdk-aacdec: support streams with more than six channels
Before this change, the decoder was forcing downmixing everything to a max of
six channels.
Layouts 6.1(back), 7.1(wide), 7.1 and 5.1.2 (Channel Configurations 11, 7, 12,
and 14 respectively, as well as the equivalent PCE version) should be supported
now.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-22 23:10:05 +00:00
James Almer 7755d264bd avcodec/libfdk-aacdec: fix the check for downmix layout order
The code reads a mask afer this check, meaning it expects NATIVE order, not
others.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-22 23:10:05 +00:00
Zhao Zhili 268c37fdae avformat/iamf_writer: fix stream id log argument
Signed-off-by: Zhao Zhili <quinkblack@foxmail.com>
2026-05-23 02:41:31 +08:00
Lynne 5b38e6eafb apv_decode: add update_thread_context callback
An earliear commit added hwaccel hooks and a pix_fmt internal state
but did not synchronize its state when using frame threading with
a hwaccel.
2026-05-22 23:06:42 +09:00
Lynne dd0ac641a5 vulkan: properly check if the internally synchronized queue extension is supported
libplacebo enables the extension string but does not enable the extension flag
if it's unsupported.
2026-05-22 23:06:38 +09:00
Dale Curtis 6e0e13b0bf avformat/ogg: Fix overflow and stale oggvorbis_private values
- Prevent integer overflow when summing header lengths; add bounds check.
- Re-initialize priv->vp with the new stream's extradata once all chained
  stream headers are collected.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
2026-05-22 13:27:18 +00:00
Romain Beauxis cd02463dc6 lavf: wire id3v2 fdebug option
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-05-22 08:20:13 -05:00
Romain Beauxis 274bc5f9ae avformat: deprecate FF_FDEBUG_TS in favor of AV_FDEBUG_TS, add AV_FDEBUG_ID3V2
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-05-22 08:20:13 -05:00
DROOdotFOO 2e142e52ae swscale/aarch64: add NEON yuv->rgb16 fast paths
Add NEON unscaled converters for {yuv420p, yuv422p, yuva420p, nv12, nv21}
to {rgb565le, bgr565le, rgb555le, bgr555le}.

The 16bpp packing uses v8/v9 as the output accumulator. Since AAPCS-64
requires d8-d15 to be callee-saved, declare_func now wraps a
stp d8, d9 / ldp d8, d9 around 16bpp paths only (gated by .ifc on the
output format). Pattern matches libswscale/aarch64/hscale.S.

yuva420p -> 16bpp drops alpha and routes through the yuv420p wrappers,
mirroring how yuva420p -> rgb24/bgr24 already work in tree.

Speedup vs C at width=1920 on Apple M1 (checkasm --bench):

  | input    | rgb565le | bgr565le | rgb555le | bgr555le |
  |----------|----------|----------|----------|----------|
  | yuv420p  | 3.69x    | 3.68x    | 3.28x    | 3.31x    |
  | yuv422p  | 4.70x    | 4.70x    | 4.32x    | 4.35x    |
  | yuva420p | 3.67x    | 3.66x    | 3.32x    | 3.27x    |

NEON cycles are ~48 for planar and ~50.5 for semi-planar across all
four outputs. yuv422p shows the biggest speedup because its C
reference is the most expensive. 555 ratios trail 565 because the C
reference is faster for 555 (one fewer mask bit); NEON cycles are the
same. nv12/nv21 are bench-only (see the preceding checkasm commit) and
run at the same ~50.5 cycles.

This only handles the little endian forms of the 16 bit RGB formats.

Verified with checkasm --test=sw_yuv2rgb (110/110) and the full
checkasm regression (7657/7657) on Apple M1.

Signed-off-by: DROOdotFOO <drew@axol.io>
2026-05-22 10:03:07 +00:00
DROOdotFOO 34501921fd tests/checkasm/sw_yuv2rgb: cover nv12 and nv21
The previous chroma stride formula (width >> log2_chroma_w) is correct
for planar yuv but wrong for semi-planar nv12/nv21, where the UV plane
is interleaved at width bytes per row (width/2 UV pairs of 2 bytes
each). Use av_image_get_linesize() so the test feeds a valid stride to
libswscale regardless of input format; for the existing planar suites
the value is unchanged.

With the stride fixed, add nv12 and nv21 to check_yuv2rgb() so the
upcoming NEON 16bpp paths get bench coverage. ff_get_unscaled_swscale
does not wire a C yuv2rgb fast path for these inputs, so the suites
report bench-only (no correctness reference); they still run clobber
detection and cycle counts.

Signed-off-by: DROOdotFOO <drew@axol.io>
2026-05-22 10:03:07 +00:00
Marvin Scholz 61a0b8fb41 avcodec: remove CELT decoder
libcelt, which it depends on, was not updated in a very long time and is
considered deprecated, as Opus exists which has a CELT mode. Therefore
remove standalone CELT decoding support.

It was already broken since b8604a9761,
11 years ago, and no one noticed and complained.
2026-05-22 09:33:52 +00:00
Lynne f17c8db820 swscale/vulkan: add a non-bitexact version of OP_LINEAR
Uses matrix*vector + vector multiplication.

Sponsored-by: Sovereign Tech Fund
2026-05-22 15:27:08 +09:00
Lynne 6d57426b6a swscale/vulkan: create a constant matrix from linear op constants
Sponsored-by: Sovereign Tech Fund
2026-05-22 15:27:07 +09:00
Lynne 2423a719e0 swscale/vulkan: put entire linear matrix+vector as constant data
Rather than only using what we need.
The driver will remove any unused constants.

Sponsored-by: Sovereign Tech Fund
2026-05-22 15:27:07 +09:00
Lynne 198991372c swscale/vulkan: move linear op handling to a separate function
Sponsored-by: Sovereign Tech Fund
2026-05-22 15:27:03 +09:00
Lynne 437aa4d208 lavfi/blackdetect_vulkan: use integer timestamps and fix crash 2026-05-22 14:06:03 +09:00
Lynne a189413832 vf_blackdetect_vulkan: port to compile-time SPIR-V generation 2026-05-22 14:06:03 +09:00
Lynne 2e25da3121 vf_nlmeans_vulkan: port to compile-time SPIR-V generation 2026-05-22 14:06:01 +09:00
Lynne c40ac0f03a swscale/vulkan: add support for filtering on SWS_OP_READ
Sponsored-by: Sovereign Tech Fund
2026-05-22 14:05:27 +09:00
Lynne 448e08aa80 swscale/vulkan: allocate buffers for scaling filters
Simply allocates buffers to hold filter data.

Sponsored-by: Sovereign Tech Fund
2026-05-22 14:05:26 +09:00
Lynne b7ccdaa018 swscale/vulkan: make buffer descriptor generation generic
Again, simple rename.

Sponsored-by: Sovereign Tech Fund
2026-05-22 14:05:26 +09:00
Lynne d0af60afa8 swscale/vulkan: make dither buffer allocation path generic
Just a simple rename.

Sponsored-by: Sovereign Tech Fund
2026-05-22 14:05:26 +09:00
Lynne c8ddaa97db swscale/vulkan: base dispatch size on output image size, rather than input
Sponsored-by: Sovereign Tech Fund
2026-05-22 14:05:26 +09:00
Lynne 51d4406e07 swscale/graph: support allocating hardware intermediate frames
Sponsored-by: Sovereign Tech Fund
2026-05-22 14:05:21 +09:00
James Almer b67570b765 avformat/mov_chan: don't share a function that's only used where it's defined
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-21 18:04:02 -03:00
Franciszek Kalinowski 99e1ecca36 avformat/icecast: reject CR/LF in metadata header values
Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-05-21 18:05:39 +00:00
Franciszek Kalinowski 87439ed619 avformat/oggparsecelt: bound extra_headers to avoid an effectively infinite loop
celt_header() reads a uint32 `extra_headers` field from the CELT identification
header and stores `1 + extra_headers` into the signed int extra_headers_left.
With extra_headers = 0x7FFFFFFE this becomes INT_MAX and the OGG parser
consumes every subsequent page as a CELT "extra header" without ever reaching
audio data, hanging on any streaming input. A value of 0xFFFFFFFE wraps the
signed addition negative, with the same family of consequences.

Reject any extra_headers count above a small fixed cap (16, well above any
real CELT-over-Ogg stream).

Verified with the audit PoC (a crafted file plus an infinite-page FIFO):
without the patch, ffmpeg consumes pages forever; with the patch it logs
"Too many CELT extra headers (...)" and exits in ~70 ms with
AVERROR_INVALIDDATA.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-05-21 14:19:54 +00:00
Franciszek Kalinowski 0857141823 avformat/rtpenc_xiph: bail out when the max payload size underflows
Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-05-21 01:15:30 +00:00
Franciszek Kalinowski a44cae9025 avformat/rtpenc_aac: reject packets smaller than the ADTS header
When extradata_size == 0, ff_rtp_send_aac() does `size -= 7` to skip the
ADTS header without checking size >= 7. A short packet makes size negative,
and the value is later passed to memcpy() as size_t, reading past the buffer
end. Bail out instead.

The vulnerable branch is not reached when using the built-in AAC encoder
(which always emits extradata), but an application that feeds raw
ADTS-stripped AAC packets through the libavformat RTP muxer can hit it. The
fix is a one-line lower-bound check and compiles/runs cleanly; see audit
PoC for the static analysis and reachable-by-API write-up.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-05-21 01:09:37 +00:00
Michael Niedermayer 59367afc3d avcodec/jpeg2000dec: compute mask in decode_clnpass() like in decode_sigpass()
Fixes: integer overflow

Found by: Jiale Yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-21 01:08:30 +00:00
Niklas Haas d94c293e62 swscale/ops_dispatch: prevent float over-read when horizontal filtering
The code made the fundamental assumption that over-read into the padding
bytes is okay to do; because the most that can happen is that those pixel
values end up corrupted, which doesn't affect any adjacent pixels.

However, this is not true for SWS_OP_FILTER_H, because this operation
fundamentally mixes together horizontal pixels. Normally, this was fine,
because the filter weights for those pixels are set to 0, and 0 * x = 0.

However, that is not true for floating point inputs, which can contain
Infinity; and 0 * Infinity = NaN, thus corrupting the entire pixel.

Solve it by specifically preventing over-read when it would be unsafe.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-20 21:45:28 +00:00
Niklas Haas 6bc0f9517c swscale/ops_dispatch: rename filter_size to filter_size_h
Since this is not set for vertical filters.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-20 21:45:28 +00:00
James Almer 79e30c18e6 avcodec/aacdec_tab: add side channels to ff_aac_channel_map
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-20 13:05:57 -03:00
James Almer b2ba26a694 avformat/adtsenc: don't accept channeConfiguration values that can't be coded
the ADTS header only has 3 bits for it, so anything higher than 7 can't be
used.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-20 10:59:02 -03:00
James Almer 2bad226f89 avcodec/aacenc: add missing default Channel Configurations
And stop writing 7.1 as 7.1(wide) (channel conf 7). Lets not create any more
non-spec compliant files that the native decoder needs to work around with now
that we can use PCE configuration for it, getting rid of the ambiguity.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-20 10:59:02 -03:00
James Almer c92c6cbf19 avcodec/aacenc: fix PCE configs for known native layouts
Many of the entries were downright wrong, like mistagging LFE elements as
SCE, as well as trying to match the native channel ordering in the PCE
by placing CPE elements before SCE ones in some cases (like with FRONT
elements), which is not spec compliant and results in unparseable streams.

Remove the three layouts that define top channels. It's not clear how they
should be signaled in PCE.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-20 10:59:01 -03:00
Damiano Galassi 1aefacfda4 avformat/movenc: fix mov_create_dvd_sub_decoder_specific_info
It has been broken since 3064487.
2026-05-20 13:53:37 +00:00
Tim Walker 9e71ea2d60 avformat/movenc: write stsd v2 atom when nb_channels > 2
Required by the QuickTime File Format specification.
2026-05-20 12:31:15 +00:00
Tim Walker 6181195d1f avformat/movenc: use sample_rate to determine audio stsd version.
timescale should be equal sample_rate, but the latter is
the actual source field used when writing the stsd atom
since 3b5d4428ac
2026-05-20 12:31:15 +00:00
arch1t3cht e8a4d1ca5c avformat/assdec: Treat negative-duration events as comments
Subtitle events with duration <= 0 may be generated by some authoring
scripts like karoke templates, and are simply treated as hidden by
renderers.

Parsing such subtitle events normally will cause the <= 0 duration to
get mangled by ff_subtitles_queue_finalize() and later
compute_pkt_fields(), causing rendering differences.

Hence, treat such events like comments instead by adding them to the
header so that they are preserved during remuxes, albeit in a different
order.

Signed-off-by: arch1t3cht <arch1t3cht@gmail.com>
2026-05-20 10:10:38 +00:00
crueter 77c3a7349e configure: ignore -I directives on MSVC for link flags
Signed-off-by: crueter <crueter@eden-emu.dev>
2026-05-20 01:07:24 +00:00
crueter 91f8703536 configure: prefer negative-or case for MSVC linker -L flags
This is preferred over positive-and casing because it can mess with
`set -e`.

Signed-off-by: crueter <crueter@eden-emu.dev>
2026-05-20 01:07:24 +00:00
Michael Niedermayer cc1459ed85 avformat/flvdec: Check size at the top of the main loop
Fixes: signed integer overflow
Fixes: ffmpeg_flv_read_packet_libavformat_flvdec.c_1900_26.poc

Found-by: iceray-Li
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-19 23:12:31 +00:00
Michael Niedermayer 84a48165f0 avformat/vividas: fix misaligned access
Fixes: ffmpeg_xor_block_libavformat_vividas.c_134_15.poc

Found-by: iceray-Li
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-19 23:11:33 +00:00
Diego de Souza 197f854a2e avcodec/nvenc: warn when av1_nvenc qp_cr_offset differs from qp_cb_offset
The NVENC driver currently forces deltaQ_v_ac equal to deltaQ_u_ac for
AV1, so crQPIndexOffset is silently ignored. The SDK header annotates
the field as "for future use only" (nvEncodeAPI.h, NV_ENC_RC_PARAMS).

Reported in #22737

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-05-19 14:22:13 +00:00
Thilo Borgmann via ffmpeg-devel 1572784128 fate: add test for animated WebP
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-05-19 11:36:10 +02:00
Ramiro Polla 20b009e301 avformat/webp: add Animated WebP demuxer
Original work by Josef Zlomek <josef@pex.com>

Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-05-19 11:36:10 +02:00
Ramiro Polla a3d8ba6613 avcodec/webp: add support for Animated WebP decoding
Fixes: 4907

Adds Animated WebP feature according to spec:
https://developers.google.com/speed/webp/docs/riff_container#animation

Original work by Josef Zlomek <josef@pex.com>
and Thilo Borgmann <thilo.borgmann@mail.de>

Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-05-19 11:36:10 +02:00
Ramiro Polla 2ca634f5db avcodec/codec_id: add Animated WebP codec ID and descriptor
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-05-19 11:36:10 +02:00
Lynne 5ad8c67e6c apv_decode: add a Vulkan hwaccel 2026-05-19 17:43:53 +09:00
Lynne 704df177aa apv_decode: switch slice decode printout to TRACE
It's much too noisy with multiple thousands of slices.
2026-05-19 17:43:53 +09:00
Lynne 54b618ab5c apv_decode: expose the current frame header
We need to know the quantization matrix.
2026-05-19 17:43:53 +09:00
Lynne 46e67ad945 apv_decode: expose decode_lut
This makes it usable outside of apv_decode.c
2026-05-19 17:43:53 +09:00
Lynne feb8a37767 apv_decode: add hardware decoding hooks 2026-05-19 17:43:52 +09:00
Michael Niedermayer 2bfc7ce3ec avformat/mccdec: dont pass NULL to bytestream2_put_buffer()
Fixes: passing NULL pointer

Found-by: iceray-Li
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-19 02:33:28 +00:00
Diego de Souza 7ac3d83e7a avcodec/nvdec: fix dimension rounding for monochrome/444 formats
frames_ctx->width/height were unconditionally rounded to even, causing
odd-dimension monochrome/444 clips to be reported with incorrect
surface pool dimensions. Round only for 4:2:0 and 4:2:2; for
monochrome/444 use avctx->coded_width/coded_height unchanged,
matching the dimensions set by the software codec layer.

Patch by: Aniket Dhok <adhok@nvidia.com>
Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-05-18 20:47:15 +00:00
Diego de Souza fa1ba61775 avcodec/cuviddec: fix dimension rounding for monochrome/444 formats
Both paths unconditionally rounded display dimensions to even via
(dim + 1) & ~1. This is required for 4:2:0 and 4:2:2 (chroma
subsampling requires even-aligned surfaces) but incorrect for
monochrome and 4:4:4. AV1 monochrome clips with odd dimensions
(e.g. 1273x713) were output as 1274x714.

cuinfo.ulTargetWidth/Height still receives the even-aligned value
for internal NVDEC surface allocation. avctx->width/height are only
updated to the rounded value for 420/422; for monochrome/444 the
original display dimensions are preserved and the cuMemcpy2D copy
crops naturally.

Patch by: Aniket Dhok <adhok@nvidia.com>
Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-05-18 20:47:15 +00:00
Diego de Souza 1356714d11 avcodec/nvenc: force frameIntervalP=1 for H.264 Baseline profile
H.264 Baseline profile cannot contain B-frames, but the NVENC preset
defaults and the max_b_frames-derived frameIntervalP override leave
frameIntervalP > 1 when -profile:v baseline is requested. The
unconditional check at the end of nvenc_setup_encoder() then sets
has_b_frames = 2, which propagates to the muxer and causes
compute_muxer_pkt_fields() to back-calculate
DTS = PTS - (delay + 1) * frame_duration. The resulting bitstream
contains no B-frames, yet every packet has a spurious 3-frame PTS/DTS
gap, breaking MPEG-TS/HLS output and DTS-based players.

This patch forces frameIntervalP to 1 in the Baseline branch of
nvenc_setup_h264_config() and warn if the user (or preset) had asked
for B-frames. The later has_b_frames assignment then sees the corrected
value and leaves avctx->has_b_frames at 0.

Fixes #22727.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-05-18 18:38:06 +00:00
Lynne 489a3834d2 swscale/vulkan: implement SWS_OP_PACK/SWS_OP_UNPACK
The issue is that while Vulkan already does the decomposition for us,
swscale assumes that the pixels will be in bitstream order, rather than
in their decomposed form.
This is valid for all packed formats for which these instructions are
issued (XV30 and X2RGB10).
This allows us to support the formats in Vulkan.

Sponsored-by: Sovereign Tech Fund
2026-05-19 03:22:29 +09:00
Lynne 5f2877b532 hwcontext_vulkan: enable X2BGR10
The format itself was working perfectly. Unlike BGR0/BGRA, all known
Vulkan implementations support storage images just fine.
2026-05-19 03:22:29 +09:00
Lynne 561e32c9cf hwcontext_vulkan: reenable X2RGB10
Now that all issues are fixed, we can go ahead with it.

Sponsored-by: Sovereign Tech Fund
2026-05-19 03:22:29 +09:00
Lynne f73acb8618 hwcontext_vulkan: reenable and remap XV30
The issue was that XV30 is a native 444 10-bit format, rather than
16-bits. This resulted in padding leaking into bits where it shouldn't.

Sponsored-by: Sovereign Tech Fund
2026-05-19 03:22:24 +09:00
Zhao Zhili b4d11dffbf avformat/rtpdec_av1: fix operator precedence in packet allocation
The closing parenthesis in the av_new_packet() branch was misplaced,
making result store the boolean comparison instead of the AVERROR
code, so allocation failures were silently lost.

av_grow_packet() handles both an empty and a non-empty packet, so use
it for both cases and drop the broken branch.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-05-18 04:00:18 +00:00
David Korczynski 989e621bcd avcodec/g2meet: The stack is EPIC_PIX_STACK_SIZE
Fixes: out of array access
Fixes: ada-5-poc.avi

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-17 17:49:59 +00:00
Michael Niedermayer f435ce22e1 avcodec/h2645_sei: Initialize side data before deallocation
Fixes: use after free
Fixes: poc_hvcc_modified.mp4

Found by: Jiale Yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-17 16:00:37 +00:00
James Almer af739541bf avformat/mov: factorize out tmcd track parsing
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-17 12:27:59 -03:00
James Almer 4444a75590 avformat/movenc: support writing more than one entry per tref tag
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-17 11:16:56 -03:00
James Almer 90dd8673ce avformat/mov: handle all references in tref boxes
tref types can have more than one value, as is the case of tmcd in
fcp_export8-236.mov, where the single video track references all timecode
tracks.
Handle them in a generic and extensible way.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-17 11:16:56 -03:00
James Almer a5822fca94 avformat/avformat: add a Track Reference Stream Group
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-17 11:16:51 -03:00
Niklas Haas 0c1a1ee12e swscale/ops_optimizer: don't push scale past truncating conversions
In an op list like:

  [ u8 +XXX] SWS_OP_READ         : 1 elem(s) planar >> 3
  [ u8 .XXX] SWS_OP_FILTER_V     : 256 -> 320 bilinear (2 taps)
  [f32 .XXX] SWS_OP_SCALE        : * 65535
  [f32 +XXX] SWS_OP_CONVERT      : f32 -> u16
  [u16 zXXX] SWS_OP_SWAP_BYTES
  [u16 zzzX] SWS_OP_SWIZZLE      : 0003
  [u16 zzz+] SWS_OP_CLEAR        : {_ _ _ 65535}
  [u16 XXXX] SWS_OP_WRITE        : 4 elem(s) packed >> 0

The current version of the code would happily push the SWS_OP_SCALE past
the truncating conversion, leading to degenerate loss of information. (In
this case, the result was quite extreme)

Affects quality across a wide range of formats, e.g.:

 rgb24 16x16 -> rgb48be 16x32:
   [ u8 +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 ...X] SWS_OP_FILTER_V     : 16 -> 32 bilinear (2 taps)
     min: {0 0 0 _}, max: {255 255 255 _}
+  [f32 ...X] SWS_OP_SCALE        : * 257
+    min: {0 0 0 _}, max: {65535 65535 65535 _}
   [f32 +++X] SWS_OP_CONVERT      : f32 -> u16
-    min: {0 0 0 _}, max: {255 255 255 _}
-  [u16 +++X] SWS_OP_SCALE        : * 257
     min: {0 0 0 _}, max: {65535 65535 65535 _}
   [u16 zzzX] SWS_OP_SWAP_BYTES
     min: {0 0 0 _}, max: {65535 65535 65535 _}
   [u16 XXXX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-17 10:41:34 +00:00
Niklas Haas 812b5654ae swscale/tests/sws_ops: use SWS_SCALE_BILINEAR for printing ops lists
This actually changes the behavior vs SWS_SCALE_POINT, because point scaling
is bit-exact and thus implies a different set of optimizations.

Ideally, we would still try and somehow merge this with tests/swscale.c to
allow testing a different set of scalers; but I still don't have a good idea
for how to accomplish that here.

As it stands, results in additional extra dithering steps in almost all
filters involving scaling, e.g.:

 rgb24 16x16 -> rgb24 16x32:
   [ u8 +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
     min: {0 0 0 _}, max: {255 255 255 _}
-  [ u8 +++X] SWS_OP_FILTER_V     : 16 -> 32 point (1 taps)
+  [ u8 ...X] SWS_OP_FILTER_V     : 16 -> 32 bilinear (2 taps)
     min: {0 0 0 _}, max: {255 255 255 _}
+  [f32 ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 -1}
+    min: {1/512 1/512 1/512 _}, max: {255.998047 255.998047 255.998047 _}
+  [f32 ...X] SWS_OP_MIN          : x <= {255 255 255 _}
+    min: {1/512 1/512 1/512 _}, max: {255 255 255 _}
   [f32 +++X] SWS_OP_CONVERT      : f32 -> u8
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-17 10:41:34 +00:00
Niklas Haas 2dfe055ddd swscale/tests/sws_ops: print split sub-passes for lists with filters
This allows us to inspect exactly the logic that is going on inside the CPU
backends (which don't support bare filter passes).

 rgb24 16x16 -> rgb24 16x32:
   [ u8 +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 +++X] SWS_OP_FILTER_V     : 16 -> 32 point (1 taps)
     min: {0 0 0 _}, max: {255 255 255 _}
   [f32 +++X] SWS_OP_CONVERT      : f32 -> u8
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)
+ Retrying with split passes:
+  [ u8 +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
+    min: {0 0 0 _}, max: {255 255 255 _}
+  [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+    (X = unused, z = byteswapped, + = exact, 0 = zero)
+ Sub-pass #1:
+  [ u8 +++X] SWS_OP_READ         : 3 elem(s) planar >> 0 + 1 tap point filter (V)
+    min: {0 0 0 _}, max: {255 255 255 _}
+  [f32 +++X] SWS_OP_CONVERT      : f32 -> u8
+    min: {0 0 0 _}, max: {255 255 255 _}
+  [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
+    (X = unused, z = byteswapped, + = exact, 0 = zero)
 rgb24 16x16 -> rgb24 32x16:
   [ u8 +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 +++X] SWS_OP_FILTER_H     : 16 -> 32 point (1 taps)
     min: {0 0 0 _}, max: {255 255 255 _}
   [f32 +++X] SWS_OP_CONVERT      : f32 -> u8
     min: {0 0 0 _}, max: {255 255 255 _}
   [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)
+ Retrying with split passes:
+  [ u8 +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
+    min: {0 0 0 _}, max: {255 255 255 _}
+  [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+    (X = unused, z = byteswapped, + = exact, 0 = zero)
+ Sub-pass #1:
+  [ u8 +++X] SWS_OP_READ         : 3 elem(s) planar >> 0 + 1 tap point filter (H)
+    min: {0 0 0 _}, max: {255 255 255 _}
+  [f32 +++X] SWS_OP_CONVERT      : f32 -> u8
+    min: {0 0 0 _}, max: {255 255 255 _}
+  [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
+    (X = unused, z = byteswapped, + = exact, 0 = zero)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-17 10:41:34 +00:00
Niklas Haas 369a301669 swscale/tests/sws_ops: use a dummy ops backend for printing
This ensures that the ops printing path goes through the same code as the
actual ops dispatch backend, including all sub-passes etc.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-17 10:41:34 +00:00
wangbin 239c679c54 lavc: add ProRes RAW videotoolbox hwaccel 2026-05-17 03:47:23 +00:00
Lynne 3b9ab7f119 prores_raw: label every field
This labels every field and completes the reverse engineering.
2026-05-17 12:17:19 +09:00
Lynne 9c40552965 prores_raw: synchronize decoder with reference implementation
This completes the reverse engineering of the decoder.
The commit applies the linearization curve from the previous patch.
2026-05-17 12:17:16 +09:00
Lynne f8b7f05844 prores_raw: parse the linearization curve from the bitstream
After an extended Ghidra session, it turns out that the camera/recorder bakes a
custom curve that *has* to be applied. It contains both the camera's inverse
transfer curve, plus whatever else the camera applied. It could (and does) contain
quantization refinements. And its used to switch between low and high quality encoding
by boosting coeffs (thus acting as an additional dequant curve).
2026-05-17 12:02:52 +09:00
Lynne d8cb567171 prores_raw: fix tile alignment issues
Reverse engineered the decoder a bit more. All tiles are always 16x1.
The issue is that at the edges, tiles don't have the same width.
Instead, the first tile that starts to clip is half, and then the
next tile after that is also half the previous tile's width.
2026-05-17 12:02:52 +09:00
Lynne eb24fb0c7f vulkan/common: fix LOAD64 again
duh, gb.buf is incremented in the loop and I missed that. ugh.
2026-05-17 12:02:52 +09:00
Lynne 0e8cf39541 hwcontext_vulkan: add support for AV_PIX_FMT_RGBAF16 2026-05-17 12:02:51 +09:00
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
1729 changed files with 83672 additions and 32156 deletions
+18
View File
@@ -57,6 +57,7 @@ libavcodec/.*png.* @Traneptora
libavcodec/.*prores.* @lynne
libavcodec/rangecoder.* @michaelni
libavcodec/ratecontrol.* @michaelni
libavcodec/rkmpp* @quink
libavcodec/rv60.* @pross
libavcodec/sgirle.* @pross
libavcodec/.*siren.* @lynne
@@ -109,6 +110,7 @@ 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
@@ -139,6 +141,8 @@ 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
@@ -153,6 +157,7 @@ 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
@@ -193,6 +198,7 @@ libavutil/aarch64/.* @lynne @mstorsjo
libavutil/arm/.* @mstorsjo
libavutil/ppc/.* @sean_mcg
libavutil/riscv/.* @Courmisch
libavutil/wasm/.* @quink
libavutil/x86/.* @lynne
# swresample
@@ -226,8 +232,20 @@ doc/.* @GyanD
# tests
# =====
tests/checkasm/riscv/.* @Courmisch
libavutil/tests/ambient_viewing_environment.* @MarcosAsh
libavutil/tests/buffer.* @MarcosAsh
libavutil/tests/csp.* @MarcosAsh
libavutil/tests/hdr_dynamic_vivid_metadata.* @MarcosAsh
libavutil/tests/tdrdi.* @MarcosAsh
libavutil/tests/timestamp.* @MarcosAsh
tests/ref/.*drawvg.* @ayosec
tests/ref/fate/ambient_viewing_environment @MarcosAsh
tests/ref/fate/buffer @MarcosAsh
tests/ref/fate/csp @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
# =======
+14
View File
@@ -0,0 +1,14 @@
# Summary of changes
Briefly describe what this PR does and why.
<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).
Attached filenames must match the sample's filename:
```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->
+174
View File
@@ -0,0 +1,174 @@
#!/usr/bin/env python3
# Copyright (c) 2026 Romain Beauxis <romain.beauxis@gmail.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
"""Inject PR attachment samples into the fate-suite directory.
Usage: inject-pr-samples.py <pr-number>
Reads SAMPLES from the environment (defaults to fate-suite). For each path
listed in a ```fate-samples``` block in the PR description, downloads the
matching PR attachment into $SAMPLES/<path>.
The PR description should contain a block like:
```fate-samples
vorbis/tos.ogg
mov/some-new-sample.mov
```
Each filename must match a file attached to the PR.
"""
import hashlib
import json
import os
import re
import sys
import tempfile
import urllib.request
from pathlib import Path, PurePosixPath
FORGEJO_API = "https://code.ffmpeg.org/api/v1/repos/ffmpeg/ffmpeg/issues"
ATTACHMENT_BASE = "https://code.ffmpeg.org/attachments/"
def fetch_json(url):
with urllib.request.urlopen(url) as r:
return json.load(r)
def parse_fate_samples(body):
paths = []
in_block = False
for line in body.splitlines():
if line == "```fate-samples":
in_block = True
elif line == "```" and in_block:
break
elif in_block:
parts = line.split()
if len(parts) == 1:
paths.append(parts[0])
return paths
MAX_PATH_DEPTH = 3
def validate_path(path):
p = PurePosixPath(path)
if p.is_absolute():
raise ValueError(f"path must be relative: {path!r}")
if ".." in p.parts:
raise ValueError(f"path must not contain '..': {path!r}")
if not p.parts:
raise ValueError(f"empty path")
if len(p.parts) > MAX_PATH_DEPTH:
raise ValueError(f"path too deep (max {MAX_PATH_DEPTH} components): {path!r}")
def validate_url(url):
if not url.startswith(ATTACHMENT_BASE):
raise ValueError(f"unexpected attachment URL: {url!r}")
def digest(path):
h = hashlib.sha256()
with open(path, "rb") as f:
while chunk := f.read(1 << 16):
h.update(chunk)
return h.digest()
def download(url, dst):
dst.parent.mkdir(parents=True, exist_ok=True)
with tempfile.NamedTemporaryFile(dir=dst.parent, delete=False) as tmp:
tmp_path = Path(tmp.name)
try:
with urllib.request.urlopen(url) as r:
while chunk := r.read(1 << 16):
tmp.write(chunk)
if dst.exists() and digest(dst) != digest(tmp_path):
raise ValueError(f"already exists with different content: {dst}")
tmp_path.rename(dst)
except:
tmp_path.unlink(missing_ok=True)
raise
def main():
if len(sys.argv) != 2 or not re.fullmatch(r"[0-9]+", sys.argv[1]):
print(f"Usage: {sys.argv[0]} <pr-number>", file=sys.stderr)
sys.exit(1)
pr_number = sys.argv[1]
samples_dir = Path(os.environ.get("SAMPLES", "fate-suite"))
pr = fetch_json(f"{FORGEJO_API}/{pr_number}")
assets = {a["name"]: a["browser_download_url"] for a in pr.get("assets", [])}
paths = parse_fate_samples(pr.get("body", ""))
if not paths:
sys.exit(0)
new_samples = False
for path in paths:
try:
validate_path(path)
except ValueError as e:
print(f"fate-samples: {e}", file=sys.stderr)
sys.exit(1)
name = PurePosixPath(path).name
url = assets.get(name)
if url is None:
print(f"fate-samples: no attachment named {name!r}", file=sys.stderr)
sys.exit(1)
try:
validate_url(url)
except ValueError as e:
print(f"fate-samples: {e}", file=sys.stderr)
sys.exit(1)
dst = samples_dir / path
is_new = not dst.exists()
try:
download(url, dst)
except ValueError as e:
print(f"fate-samples: {e}", file=sys.stderr)
sys.exit(1)
if is_new:
new_samples = True
print(f"Injected: {path}")
output_file = os.environ.get("FORGEJO_OUTPUT")
if output_file:
with open(output_file, "a") as f:
print(f"new_samples={'true' if new_samples else 'false'}", file=f)
if __name__ == "__main__":
main()
-74
View File
@@ -1,74 +0,0 @@
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',
'avdevice': 'avdevice',
'avfilter': 'avfilter',
'avformat': 'avformat',
'avutil': 'avutil',
'swresample': 'swresample',
'swscale': 'swscale',
'fftools': 'CLI',
'vulkan': 'vulkan'
};
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');
}
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);
}
}
}
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
labels: labels,
});
}
}
-35
View File
@@ -1,35 +0,0 @@
avcodec:
- changed-files:
- any-glob-to-any-file: 'libavcodec/**'
avdevice:
- changed-files:
- any-glob-to-any-file: 'libavdevice/**'
avfilter:
- changed-files:
- any-glob-to-any-file: 'libavfilter/**'
avformat:
- changed-files:
- any-glob-to-any-file: 'libavformat/**'
avutil:
- changed-files:
- any-glob-to-any-file: 'libavutil/**'
swresample:
- changed-files:
- any-glob-to-any-file: 'libswresample/**'
swscale:
- changed-files:
- any-glob-to-any-file: 'libswscale/**'
CLI:
- changed-files:
- any-glob-to-any-file: 'fftools/**'
vulkan:
- changed-files:
- any-glob-to-any-file: '**/*vulkan*'
+19 -4
View File
@@ -1,5 +1,14 @@
exclude: ^tests/ref/
# This repository keeps its pre-commit config in this nondefault path.
# Install hooks from here with:
# pre-commit install -c .forgejo/pre-commit/config.yaml
# The command above installs both the pre-commit and commit-msg hooks because
# default_install_hook_types includes them below.
default_install_hook_types:
- pre-commit
- commit-msg
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
@@ -20,9 +29,15 @@ repos:
- id: trailing-whitespace
- repo: local
hooks:
- id: aarch64-asm-indent
name: fix aarch64 assembly indentation
files: ^.*/aarch64/.*\.S$
- id: check-commit-message
name: validate commit message format
language: script
entry: ./tools/check_commit_msg.sh
stages: [commit-msg]
always_run: true
- 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
@@ -33,4 +48,4 @@ repos:
args:
- --ignore-words=.forgejo/pre-commit/ignored-words.txt
- --ignore-multiline-regex=codespell:off.*?(codespell:on|\Z)
exclude: ^tools/(patcheck|clean-diff)$
exclude: ^tools/(patcheck|clean-diff)|tests/checkasm/ext/.*$
+1
View File
@@ -69,6 +69,7 @@ pEvents
PixelX
Psot
quater
re-use
readd
recuse
redY
-31
View File
@@ -1,31 +0,0 @@
name: Autolabel
on:
pull_request_target:
types: [opened, edited, synchronize, closed, assigned, labeled, unlabeled]
issues:
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@v6
- name: Label by file-changes
uses: actions/labeler@v6
if: ${{ forge.event_name == 'pull_request_target' }}
with:
configuration-path: .forgejo/labeler/labeler.yml
repo-token: ${{ secrets.AUTOLABELER_TOKEN }}
- name: Label by title-match
uses: actions/github-script@v8
with:
script: |
const script = require('.forgejo/labeler/labeler.js')
await script({github, context})
github-token: ${{ secrets.AUTOLABELER_TOKEN }}
+1 -1
View File
@@ -3,7 +3,7 @@ name: Lint
on:
push:
branches:
- master
- release/9.0
pull_request:
concurrency:
+27 -6
View File
@@ -3,7 +3,7 @@ name: Test
on:
push:
branches:
- master
- release/9.0
pull_request:
concurrency:
@@ -58,26 +58,38 @@ jobs:
with:
path: fate-suite
key: fate-suite-${{ steps.fate.outputs.hash }}
- name: Inject PR Samples
id: inject
if: ${{ forge.event_name == 'pull_request' }}
run: SAMPLES=$PWD/fate-suite .forgejo/inject-pr-samples.py ${{ forge.event.pull_request.number }}
- name: Run Fate
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}
- name: Fail if new samples were injected
if: ${{ steps.inject.outputs.new_samples == 'true' }}
run: |
echo "New FATE samples were injected from PR attachments. Please add them to the official fate-suite before merging."
exit 1
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-9.0:latest']
target_exec: ['wine']
runs-on: linux-amd64
container: ${{ matrix.image }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
path: ffmpeg
- name: Configure
run: |
./configure --pkg-config-flags="--static" $FFBUILD_TARGET_FLAGS $FF_CONFIGURE \
mkdir build && cd build
../ffmpeg/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" \
@@ -87,7 +99,7 @@ jobs:
cat ffbuild/config.log
exit ${CFGRES:-0}
- name: Build
run: make -j$(nproc)
run: make -C build -j$(nproc)
- name: Restore Cached Fate-Suite
id: cache
uses: actions/cache/restore@v5
@@ -99,7 +111,7 @@ jobs:
- name: Sync Fate-Suite
id: fate
run: |
make fate-rsync SAMPLES=$PWD/fate-suite
make -C build 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
@@ -107,12 +119,21 @@ jobs:
with:
path: fate-suite
key: fate-suite-${{ steps.fate.outputs.hash }}
- name: Inject PR Samples
id: inject
if: ${{ forge.event_name == 'pull_request' }}
run: SAMPLES=$PWD/fate-suite ffmpeg/.forgejo/inject-pr-samples.py ${{ forge.event.pull_request.number }}
- 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=$?
LD_LIBRARY_PATH="$(printf "%s:" "$PWD"/lib*)$PWD" make -C build 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}
- name: Fail if new samples were injected
if: ${{ steps.inject.outputs.new_samples == 'true' }}
run: |
echo "New FATE samples were injected from PR attachments. Please add them to the official fate-suite before merging."
exit 1
+6
View File
@@ -26,6 +26,9 @@
*.spv
*.spv.c
*.spv.gz
*.gen.asm
*.gen.c
*.gen.S
*.ptx
*.ptx.c
*.ptx.gz
@@ -37,6 +40,9 @@
/ffmpeg
/ffplay
/ffprobe
/checkasm_config_generated.asm
/checkasm_config_generated.h
/checkasm_header_config_generated.h
/config.asm
/config.h
/config_components.asm
+1
View File
@@ -1,4 +1,5 @@
# Note to Github users
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.
+19 -1
View File
@@ -1,7 +1,25 @@
Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest.
version <next>:
version 9.0:
- 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
- ProRes RAW VideoToolbox hwaccel
- APV Vulkan hwaccel
- Animated WebP decoder
- Animated WebP demuxer
- Remove CELT decoding support (doesn't affect Opus CELT)
- Remove ogg/celt parsing
- Bitstream filter to split Dolby Vision multi-layer HEVC
- Add AMF hardware memory mapping support.
- ONNX Runtime DNN backend with GPU execution provider support
- Remove deprecated NVENC options and support for pre-11.1 SDK versions
version 8.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.
+17 -8
View File
@@ -65,14 +65,14 @@ Communication
=============
website (T: https://git.ffmpeg.org/ffmpeg-web) Deby Barbara Lepage
fate.ffmpeg.org (L: fate-admin@ffmpeg.org) (W: https://fate.ffmpeg.org) (P: https://ffmpeg.org/fate.html) (S: https://git.ffmpeg.org/fateserver) Timo Rothenpieler
Trac bug tracker (W: https://trac.ffmpeg.org) Alexander Strasser, Michael Niedermayer, Carl Eugen Hoyos
Trac bug tracker [X] (W: https://trac.ffmpeg.org) Alexander Strasser, Michael Niedermayer, Carl Eugen Hoyos
Forgejo issue tracker (W: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues)
Patchwork [2] (W: https://patchwork.ffmpeg.org) Andriy Gelman
mailing lists (W: https://ffmpeg.org/contact.html#MailingLists) Baptiste Coudurier
Twitter Reynaldo H. Verdejo Pinochet
Launchpad Timothy Gu
ffmpeg-security [2] (L: ffmpeg-security@ffmpeg.org) (W: https://ffmpeg.org/security.html) Michael Niedermayer, Reimar Doeffinger
libavutil
=========
@@ -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
@@ -158,7 +159,7 @@ Codecs:
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
@@ -232,7 +233,7 @@ Codecs:
msvideo1.c Mike Melanson
nuv.c Reimar Doeffinger
nvdec*, nvenc* Timo Rothenpieler
omx.c Martin Storsjo, Aman Gupta
oh* Zhao Zhili
opus* Rostislav Pehlivanov
pcx.c Ivo van Poorten
pgssubdec.c Reimar Doeffinger
@@ -243,6 +244,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
@@ -250,7 +252,6 @@ Codecs:
sanm.c Manuel Lauss
smc.c Mike Melanson
snow* Michael Niedermayer, Loren Merritt
sonic.c Alex Beregszaszi
speedhq.c Steinar H. Gunderson
srt* Aurelien Jacobs
sunrast.c Ivo van Poorten
@@ -317,6 +318,10 @@ libavfilter
===========
Generic parts:
Framework and orphaned filters Nicolas George
(except hardware acceleration)
graphdump.c Nicolas George
motion_estimation.c Davinder Singh
@@ -348,7 +353,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>)
@@ -406,7 +413,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
@@ -442,9 +451,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
+2 -1
View File
@@ -187,7 +187,8 @@ clean::
$(RM) -rf coverage.info coverage.info.in lcov
distclean:: clean
$(RM) .version config.asm config.h config_components.* mapfile \
$(RM) .version config.asm config.h config_components.* mapfile \
checkasm_config_generated.* checkasm_header_config_generated.h \
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 @@
8.0.git
9.0
+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); }
Vendored
+284 -105
View File
File diff suppressed because it is too large Load Diff
+71 -1
View File
@@ -1,7 +1,77 @@
The last version increases of all libraries were on 2025-03-28
The last version increases of all libraries were on 2026-06-23.
API changes, most recent first:
2026-06-23 - 61693f6c35f - lavu 60.34.100 - hwcontext_vulkan.h
Switch AVVkFrame.access to VkAccessFlagBits2.
2026-06-23 - 191be14fb6d - lavc 62.37.100 - packet.h
av_packet_pack_dictionary() now accepts const AVDictionary*.
2026-06-10 - 12dc67b6fe0 - lavu 60.33.100 - frame.h
Add AV_FRAME_DATA_RAW_COLOR_PARAMS.
2026-06-03 - 972c0cf91f4 - lsws 9.8.100 - swscale.h
Add enum SwsBackend and SwsContext.backends
2026-06-02 - 9fe5758da5c - lavu 60.32.100 - hwcontext_vulkan.h
Add AVVulkanDeviceContext.queue_flags.
2026-05-31 - 1e3883df9f0 - lavf 62.19.100 - avformat.h
Add AVStreamGroupLayeredVideo
Add AVStreamGroup.params.layered_video
Add AV_STREAM_GROUP_PARAMS_DOLBY_VISION
Deprecate AVStreamGroupLCEVC
Deprecate AVStreamGroup.params.lcevc
2026-05-30 - 5f6dff5e7db - lavc 62.35.100 - packet.h
Add AV_PKT_DATA_HEVC_CONF side data type.
2026-05-14 - xxxxxxxxxxx - lavf 62.18.100 - avformat.h
Add AV_FDEBUG_ID3V2 debug flag, deprecate FF_FDEBUG_TS in favor of
AV_FDEBUG_TS.
2026-05-17 - a5822fca94f - lavf 62.17.100 - avformat.h
Add AV_STREAM_GROUP_PARAMS_TREF.
Add AVStreamGroupTREF.
2026-05-16 - c0bdc3b62a5 - lavf 62.16.100 - avformat.h
Add AVFMT_FIXED_FRAMESIZE.
2026-05-16 - b1120b1ed80 - lavc 62.33.100 - avcodec.h
Add AV_CODEC_FLAG2_FIXED_FRAME_SIZE.
2026-05-12 - 99908c6e05e - 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 - 5c557dd5d55 - lavf 62.15.100 - avformat.h
Add av_program_copy().
2026-05-05 - 7623379a770 - 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 - c102e89448a - lavu 60.29.100 - hwcontext_vulkan.h
Deprecate AVVulkanDeviceContext.lock_queue and
AVVulkanDeviceContext.unlock_queue without replacement.
2026-03-12 - 3503b19711c - 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.
+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
@@ -38,7 +38,7 @@ PROJECT_NAME = FFmpeg
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER =
PROJECT_NUMBER = 9.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
+3 -3
View File
@@ -54,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)
@@ -69,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)
+27
View File
@@ -124,6 +124,33 @@ that this level currently behaves the same as @samp{limited} in libavcodec.
@end table
@end table
@section dovi_split
Split a Dolby Vision Profile 7 multi-layer HEVC bitstream. Profile 7 carries the
enhancement-layer HEVC bitstream interleaved inside the base-layer access units,
wrapped in user-unspecified NAL units of type 63 (UNSPEC63), and the RPU metadata
as a sibling user-unspecified NAL of type 62 (UNSPEC62).
@table @option
@item mode
Which Dolby Vision components to keep in the output bitstream.
@table @samp
@item bl
Base layer only: drop every UNSPEC63 (EL) and every UNSPEC62 (RPU).
The output is a plain HEVC stream with no Dolby Vision markers. This is the
default.
@item bl_rpu
Base layer with the RPU NAL kept.
@item el
Enhancement layer only: for every UNSPEC63 NAL, strip the two-byte outer NAL
header and emit the inner payload. The result is a standalone HEVC bitstream.
UNSPEC62 (RPU) is dropped.
@item el_rpu
Enhancement layer with the RPU NAL kept verbatim. Same as @samp{el}, but the
UNSPEC62 RPU NALs are also emitted alongside the unwrapped EL NALs.
@end table
@end table
@section dump_extra
Add extradata to the beginning of the filtered packets except when
-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.
+2
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})
-8
View File
@@ -307,14 +307,6 @@ This decoder generates wave patterns according to predefined sequences. Its
use is purely internal and the format of the data it accepts is not publicly
documented.
@section libcelt
libcelt decoder wrapper.
libcelt allows libavcodec to decode the Xiph CELT ultra-low delay audio codec.
Requires the presence of the libcelt headers and library during configuration.
You need to explicitly configure the build with @code{--enable-libcelt}.
@section libgsm
libgsm decoder wrapper.
+41
View File
@@ -1181,10 +1181,51 @@ RIFF Wave Audio demuxer.
This demuxer accepts the following options:
@table @option
@item ignore_length @var{bool}
Ignore the size of the @code{data} chunk and keep reading until the end of the file if set.
May be useful to read broken or partial files where the header was not properly updated,
but will misinterpret files with non-audio chunks after the @code{data} chunk.
Default is disabled.
@item max_size
Specify the maximum packet size in bytes for the demuxed packets. By default
this is set to 0, which means that a sensible value is chosen based on the
input format.
@end table
@section webp
Animated WebP demuxer.
It accepts the following options:
@table @option
@item -min_delay @var{int}
Set the minimum valid delay between frames in milliseconds.
Range is 0 to 60000. Default value is 10.
@item -max_webp_delay @var{int}
Set the maximum valid delay between frames in milliseconds.
Range is 0 to 16777215. Default value is 16777215 (over four hours),
the maximum value allowed by the specification.
@item -default_delay @var{int}
Set the default delay between frames in milliseconds.
Range is 0 to 60000. Default value is 100.
@item -ignore_loop @var{bool}
WebP files can contain information to loop a certain number of times
(or infinitely). If @option{ignore_loop} is set to true, then the loop
setting from the input will be ignored and looping will not occur.
If set to false, then looping will occur and will cycle the number
of times according to the WebP. Default value is true.
@item usebgcolor @var{bool}
WebP files contain a background color hint in the ANIM chunk, but the
WebP specification says that viewer applications are not required to
use it. If @option{usebgcolor} is set to true, then the background
color hint will be used, otherwise transparent black will be used for
the background. Default value is false.
@end table
@c man end DEMUXERS
+33 -4
View File
@@ -225,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,
@@ -368,7 +387,7 @@ symbols. If in doubt, just avoid names starting with @code{_} altogether.
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 micro seconds.
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
@@ -469,15 +488,25 @@ later on.
Also if you have doubts about splitting or not splitting, do not hesitate to
ask/discuss it on the developer mailing list.
@subheading Bug fixes intended for backporting should stay focused.
Keep bug fixes as small as possible while fully fixing the reported issue.
Changes not needed for correctness or robustness should be submitted separately,
especially if they increase complexity or affect backporting.
@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
+4
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
+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);
}
+31 -9
View File
@@ -41,7 +41,17 @@
/* check that a given sample format is supported by the encoder */
static int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat sample_fmt)
{
const enum AVSampleFormat *p = codec->sample_fmts;
const void *out_config;
int ret = avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_FORMAT,
0, &out_config, NULL);
if (ret < 0) {
fprintf(stderr, "Error getting supported sample formats\n");
exit(1);
}
const enum AVSampleFormat *p = out_config;
if (!p)
return 1;
while (*p != AV_SAMPLE_FMT_NONE) {
if (*p == sample_fmt)
@@ -54,13 +64,19 @@ static int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat sample_fmt
/* just pick the highest supported samplerate */
static int select_sample_rate(const AVCodec *codec)
{
const int *p;
const void *out_config;
int ret = avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_RATE,
0, &out_config, NULL);
if (ret < 0) {
fprintf(stderr, "Error getting supported sample rates\n");
exit(1);
}
const int *p = out_config;
int best_samplerate = 0;
if (!codec->supported_samplerates)
if (!p)
return 44100;
p = codec->supported_samplerates;
while (*p) {
if (!best_samplerate || abs(44100 - *p) < abs(44100 - best_samplerate))
best_samplerate = *p;
@@ -72,13 +88,19 @@ static int select_sample_rate(const AVCodec *codec)
/* select layout with the highest channel count */
static int select_channel_layout(const AVCodec *codec, AVChannelLayout *dst)
{
const AVChannelLayout *p, *best_ch_layout;
const void *out_config;
int ret = avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_CHANNEL_LAYOUT,
0, &out_config, NULL);
if (ret < 0) {
fprintf(stderr, "Error getting supported channel layouts\n");
exit(1);
}
const AVChannelLayout *p = out_config, *best_ch_layout;
int best_nb_channels = 0;
if (!codec->ch_layouts)
if (!p)
return av_channel_layout_copy(dst, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO);
p = codec->ch_layouts;
while (p->nb_channels) {
int nb_channels = p->nb_channels;
@@ -218,10 +240,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);
+6 -1
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;
}
@@ -232,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) {
+25 -9
View File
@@ -127,7 +127,7 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
enum AVCodecID codec_id)
{
AVCodecContext *c;
int i;
int ret;
/* find the encoder */
*codec = avcodec_find_encoder(codec_id);
@@ -157,21 +157,37 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
ost->enc = c;
switch ((*codec)->type) {
case AVMEDIA_TYPE_AUDIO:
c->sample_fmt = (*codec)->sample_fmts ?
(*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
case AVMEDIA_TYPE_AUDIO: {
const void *codec_config;
c->bit_rate = 64000;
c->sample_rate = 44100;
if ((*codec)->supported_samplerates) {
c->sample_rate = (*codec)->supported_samplerates[0];
for (i = 0; (*codec)->supported_samplerates[i]; i++) {
if ((*codec)->supported_samplerates[i] == 44100)
ret = avcodec_get_supported_config(c, NULL, AV_CODEC_CONFIG_SAMPLE_FORMAT,
0, &codec_config, NULL);
if (ret < 0) {
fprintf(stderr, "Failed to get supported sample formats\n");
exit(1);
}
c->sample_fmt = codec_config ? *(const enum AVSampleFormat*)codec_config
: AV_SAMPLE_FMT_FLTP;
ret = avcodec_get_supported_config(c, NULL, AV_CODEC_CONFIG_SAMPLE_RATE,
0, &codec_config, NULL);
if (ret < 0) {
fprintf(stderr, "Failed to get supported sample rates\n");
exit(1);
}
if (codec_config) {
const int *supported_samplerates = codec_config;
c->sample_rate = supported_samplerates[0];
for (; *supported_samplerates; supported_samplerates++) {
if (*supported_samplerates == 44100)
c->sample_rate = 44100;
}
} else {
c->sample_rate = 44100;
}
av_channel_layout_copy(&c->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO);
ost->st->time_base = (AVRational){ 1, c->sample_rate };
break;
}
case AVMEDIA_TYPE_VIDEO:
c->codec_id = codec_id;
+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);
+3 -1
View File
@@ -430,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);
+6 -1
View File
@@ -152,6 +152,7 @@ static int open_output_file(const char *filename,
AVIOContext *output_io_context = NULL;
AVStream *stream = NULL;
const AVCodec *output_codec = NULL;
const void *sample_fmts;
int error;
/* Open the output file to write to it. */
@@ -207,8 +208,12 @@ static int open_output_file(const char *filename,
/* Set the basic encoder parameters.
* The input file's sample rate is used to avoid a sample rate conversion. */
av_channel_layout_default(&avctx->ch_layout, OUTPUT_CHANNELS);
error = avcodec_get_supported_config(avctx, NULL, AV_CODEC_CONFIG_SAMPLE_FORMAT,
0, &sample_fmts, NULL);
av_assert0(error >= 0);
avctx->sample_fmt = sample_fmts ? *(const enum AVSampleFormat*)sample_fmts
: input_codec_context->sample_fmt;
avctx->sample_rate = input_codec_context->sample_rate;
avctx->sample_fmt = output_codec->sample_fmts[0];
avctx->bit_rate = OUTPUT_BIT_RATE;
/* Set the sample rate for the container. */
+3 -3
View File
@@ -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);
+28 -13
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}
@@ -2367,25 +2388,19 @@ If either the input or output is blocked leading to actual read speed falling be
specified readrate, then this rate takes effect till the input catches up with the
specified readrate. Must not be lower than the primary readrate.
@item -vsync @var{parameter} (@emph{global})
@itemx -fps_mode[:@var{stream_specifier}] @var{parameter} (@emph{output,per-stream})
Set video sync method / framerate mode. vsync is applied to all output video streams
but can be overridden for a stream by setting fps_mode. vsync is deprecated and will be
removed in the future.
For compatibility reasons some of the values for vsync can be specified as numbers (shown
in parentheses in the following table).
@item -fps_mode[:@var{stream_specifier}] @var{parameter} (@emph{output,per-stream})
Set video sync method / framerate mode.
@table @option
@item passthrough (0)
@item passthrough
Each frame is passed with its timestamp from the demuxer to the muxer.
@item cfr (1)
@item cfr
Frames will be duplicated and dropped to achieve exactly the requested
constant frame rate.
@item vfr (2)
@item vfr
Frames are passed through with their timestamp or dropped so as to
prevent 2 frames from having the same timestamp.
@item auto (-1)
@item auto
Chooses between cfr and vfr depending on muxer capabilities. This is the
default method.
@end table
@@ -2415,7 +2430,7 @@ Do not process input timestamps, but keep their values without trying
to sanitize them. In particular, do not remove the initial start time
offset value.
Note that, depending on the @option{vsync} option or on specific muxer
Note that, depending on the @option{fps_mode} option or on specific muxer
processing (e.g. in case the format option @option{avoid_negative_ts}
is enabled) the output timestamps may mismatch with the input
timestamps even when this option is selected.
+1
View File
@@ -357,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>
+260 -317
View File
@@ -7743,6 +7743,11 @@ The file path of the downloaded whisper.cpp model (mandatory).
The language to use for transcription ('auto' for auto-detect).
Default value: @code{"auto"}
@item translate
If enabled, translate the transcription from the source language to English. A
multilingual model is required to enable this option.
Default value: @code{"false"}
@item queue
The maximum size that will be queued into the filter before processing the audio
with whisper. Using a small value the audio stream will be processed more often,
@@ -7775,8 +7780,8 @@ Default value: @code{"text"}
@item max_len
Maximum segment length in characters. When set to a value greater than 0,
transcription segments will be split to not exceed this length. This is useful
for generating subtitles with shorter lines.
transcription segments will be split by word to not exceed this length. This is
useful for generating subtitles with shorter lines.
Default value: @code{"0"}
@item vad_model
@@ -8606,21 +8611,24 @@ Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
and libavformat to work. On the other hand, it is limited to ASS (Advanced
Substation Alpha) subtitles files.
This filter accepts the following option in addition to the common options from
the @ref{subtitles} filter:
This filter accepts @option{filename}/@option{f}, @option{original_size},
@option{fontsdir}, and @option{alpha} from the @ref{subtitles} filter, plus the
following option:
@table @option
@item shaping
Set the shaping engine
Set the shaping engine.
Available values are:
@table @samp
@item auto
The default libass shaping engine, which is the best available.
@item simple
Fast, font-agnostic shaper that can do only substitutions
Fast, font-agnostic shaper that can do only substitutions.
@item complex
Slower shaper using OpenType for substitutions and positioning
Slower shaper using OpenType for substitutions and positioning. Required
for correct rendering of complex scripts such as Arabic, Hebrew, Devanagari
and Thai. Requires libass to be built with HarfBuzz.
@end table
The default is @code{auto}.
@@ -12216,18 +12224,42 @@ and configure FFmpeg with @code{--enable-libtorch
--extra-cflags=-I/libtorch_root/libtorch/include/torch/csrc/api/include
--extra-ldflags=-L/libtorch_root/libtorch/lib/}
@item onnx
ONNX Runtime backend. To enable this backend you need to install the
ONNX Runtime library (see @url{https://onnxruntime.ai/}) and configure
FFmpeg with @code{--enable-libonnxruntime}.
The current ONNX Runtime backend expects 4-D input and output tensors
with NCHW layout and 32-bit floating-point element type (ONNX
@code{FLOAT}); models with integer or other element types (e.g.
@code{UINT8}) are not supported and will be rejected at load time.
Models using NHWC layout or other ranks are not yet
supported. Only single-input models are supported; the backend binds
exactly one input tensor when running the model.
The @option{input} and @option{output} options are optional for the
ONNX Runtime backend; when they are omitted the backend resolves the
tensor names from the session.
The ONNX Runtime backend runs inference synchronously using a single
inference request. The shared @option{async} and @option{nireq} options
therefore have no effect for @code{dnn_backend=onnx}; inference always
runs synchronously regardless of their values.
@end table
@item model
Set path to model file specifying network architecture and its parameters.
Note that different backends use different file formats. TensorFlow, OpenVINO
and Libtorch backend can load files for only its format.
Note that different backends use different file formats. TensorFlow, OpenVINO,
Libtorch, and ONNX Runtime backends can load files for only their respective formats.
@item input
Set the input name of the dnn network.
Set the input name of the dnn network. Required for the TensorFlow backend;
optional for the ONNX Runtime backend.
@item output
Set the output name of the dnn network.
Set the output name of the dnn network. Required for the TensorFlow backend;
optional for the ONNX Runtime backend.
@item backend_configs
Set the configs to be passed into backend. To use async execution, set async (default: set).
@@ -12236,6 +12268,20 @@ Roll back to sync execution if the backend does not support async.
For tensorflow backend, you can set its configs with @option{sess_config} options,
please use tools/python/tf_sess_config.py to get the configs of TensorFlow backend for your system.
@item device
Set the device to run the model. For the ONNX Runtime backend this selects the
execution provider: @code{cpu} (default), @code{cuda} (NVIDIA GPU),
@code{dml} (DirectML, Windows only) or @code{vitisai} (AMD Ryzen AI NPU).
@item device_id
Set the device index used by GPU execution providers (e.g. @code{cuda} or
@code{dml}) for the ONNX Runtime backend. Default is 0.
@item threads_per_operation
ONNX Runtime backend only. Set the number of CPU threads used per ONNX
Runtime operator when running with @code{device=cpu}. Default is 0 (let
ONNX Runtime choose automatically). Has no effect for GPU/NPU providers.
@end table
@subsection Examples
@@ -14744,6 +14790,73 @@ This flag is enabled by default.
@end table
@end table
@section frc_amf
Double the frame rate, using Frame Rate Converter (FRC) provided by
AMD Advanced Media Framework library for hardware acceleration.
The filter accepts the following options:
@table @option
@item engine_type
Specify the engine used to run shaders.
@table @samp
@item dx11
DirectX 11.
@item dx12
DirectX 12 (Default value).
@end table
@item enable
Boolean value: enable/disable FRC. Dynamic value, can be altered at a runtime
without re-initializing the filter. (Default value: enabled).
@item fallback_mode
Fallback behavior in case of low interpolation confidence.
@table @samp
@item duplicate
Duplicate frame.
@item blend
Blend two frames together (Default value).
@end table
@item indicator
Boolean value: show FRC indicator square in the top left corner of the video
(Default value: disabled).
@item profile
Level of hierarchical motion search.
@table @samp
@item low
Less levels of hierarchical motion search.
Only recommended for extremely low resolutions.
@item high
Recommended for any resolution up to 1440p. (Default value)
@item super
More levels of hierarchical motion search. Recommended for resolutions 1440p
or higher.
@end table
@item mv_search_mode
Performance mode of the motion search.
@table @samp
@item native
Conduct motion search on the full resolution of source images.
@item performance
Conduct motion search on the down scaled source images.
Recommended for APU or low end GPU for better performance.
@end table
@item use_future_frame
Boolean value: enable dependency on future frame, improves quality for the cost
of latency (Default value: enabled).
@end table
@section framestep
Select one frame every N-th frame.
@@ -23279,6 +23392,23 @@ at least libass release 0.17.0 (or LIBASS_VERSION 0x01600010), @emph{and} libass
have been built with libunibreak.
The option is enabled by default except for native ASS.
@item shaping
Set the shaping engine.
Available values are:
@table @samp
@item auto
The default libass shaping engine, which is the best available.
@item simple
Fast, font-agnostic shaper that can do only substitutions.
@item complex
Slower shaper using OpenType for substitutions and positioning. Required
for correct rendering of complex scripts such as Arabic, Hebrew, Devanagari
and Thai. Requires libass to be built with HarfBuzz.
@end table
The default is @code{auto}.
@end table
If the first key is not specified, it is assumed that the first value
@@ -23647,9 +23777,9 @@ The value must be between @code{0} and @var{nb_frames - 1}. Default is @code{0}.
@item
Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
@example
ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -fps_mode passthrough keyframes%03d.png
@end example
The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
The @option{-fps_mode passthrough} is necessary to prevent @command{ffmpeg} from
duplicating each output frame to accommodate the originally detected frame
rate.
@@ -25648,6 +25778,22 @@ Work the same as the identical @ref{scale} filter options.
@item reset_sar
Works the same as the identical @ref{scale} filter option.
@item in_color_range
Override input color range.
@item out_color_range
Specify output color range.
The accepted values for in_trc and out_trc are:
@table @samp
@item studio
Studio (or restricted, or MPEG) color range.
@item full
Full (or JPEG) color range.
@end table
@anchor{color_profile}
@item color_profile
Specify all color properties at once.
@@ -25665,10 +25811,13 @@ BT.2020
@end table
@item trc
@item in_trc
Override input transfer characteristics.
@item out_trc
Specify output transfer characteristics.
The accepted values are:
The accepted values for in_trc and out_trc are:
@table @samp
@item bt709
BT.709
@@ -25720,10 +25869,13 @@ ARIB_STD_B67
@end table
@item primaries
@item in_primaries
Override input color primaries.
@item out_primaries
Specify output color primaries.
The accepted values are:
The accepted values for in_primaries and out_primaries are:
@table @samp
@item bt709
BT.709
@@ -25775,6 +25927,13 @@ Upscale to 4K and change color profile to bt2020.
@example
vpp_amf=4096:2160:color_profile=bt2020
@end example
@item
Override input primaries and input transfer characteristics, change both to bt709.
@example
vpp_amf=color_profile=bt2020:in_trc=smpte2084:in_primaries=bt2020:out_trc=bt709:out_primaries=bt709
@end example
@end itemize
@anchor{vstack}
@@ -26956,7 +27115,19 @@ value.
@chapter CUDA Video Filters
@c man begin CUDA Video Filters
To enable CUDA and/or NPP filters please refer to configuration guidelines for @ref{CUDA} and for @ref{CUDA NPP} filters.
Below is a description of the currently available Nvidia CUDA video filters.
Prerequisites:
@itemize
@item Install Nvidia CUDA Toolkit
@end itemize
Note: If FFmpeg detects the Nvidia CUDA Toolkit during configuration, it will enable CUDA filters automatically without requiring any additional flags. If you want to explicitly enable them, use the following options:
@itemize
@item Configure FFmpeg with @code{--enable-cuda-nvcc --enable-nonfree}.
@item Configure FFmpeg with @code{--enable-cuda-llvm}. Additional requirement: @code{llvm} lib must be installed.
@end itemize
Running CUDA filters requires you to initialize a hardware device and to pass that device to all filters in any filter graph.
@table @option
@@ -26991,23 +27162,7 @@ Since CUDA filters operate exclusively on GPU memory, frame data must sometimes
@end itemize
Note that @ref{hwupload} uploads data to a surface with the same layout as the software frame, so it may be necessary to add a @ref{format} filter immediately before @ref{hwupload} to ensure the input is in the correct format. Similarly, @ref{hwdownload} may not support all output formats, so an additional @ref{format} filter may need to be inserted immediately after @ref{hwdownload} in the filter graph to ensure compatibility.
@anchor{CUDA}
@section CUDA
Below is a description of the currently available Nvidia CUDA video filters.
Prerequisites:
@itemize
@item Install Nvidia CUDA Toolkit
@end itemize
Note: If FFmpeg detects the Nvidia CUDA Toolkit during configuration, it will enable CUDA filters automatically without requiring any additional flags. If you want to explicitly enable them, use the following options:
@itemize
@item Configure FFmpeg with @code{--enable-cuda-nvcc --enable-nonfree}.
@item Configure FFmpeg with @code{--enable-cuda-llvm}. Additional requirement: @code{llvm} lib must be installed.
@end itemize
@subsection bilateral_cuda
@section bilateral_cuda
CUDA accelerated bilateral filter, an edge preserving filter.
This filter is mathematically accurate thanks to the use of GPU acceleration.
For best output quality, use one to one chroma subsampling, i.e. yuv444p format.
@@ -27027,7 +27182,7 @@ Set window size of the bilateral function to determine the number of neighbours
If the number entered is even, one will be added automatically.
Allowed range is 1 to 255. Default is 1.
@end table
@subsubsection Examples
@subsection Examples
@itemize
@item
@@ -27046,7 +27201,7 @@ Apply the bilateral filter on a video.
@end itemize
@subsection bwdif_cuda
@section bwdif_cuda
Deinterlace the input video using the @ref{bwdif} algorithm, but implemented
in CUDA so that it can work as part of a GPU accelerated pipeline with nvdec
@@ -27098,13 +27253,13 @@ Only deinterlace frames marked as interlaced.
The default value is @code{all}.
@end table
@subsection chromakey_cuda
@section chromakey_cuda
CUDA accelerated YUV colorspace color/chroma keying.
This filter works like normal chromakey filter but operates on CUDA frames.
for more details and parameters see @ref{chromakey}.
@subsubsection Examples
@subsection Examples
@itemize
@item
@@ -27140,7 +27295,7 @@ Process two software sources, explicitly uploading the frames:
@end itemize
@subsection colorspace_cuda
@section colorspace_cuda
CUDA accelerated implementation of the colorspace filter.
@@ -27173,7 +27328,7 @@ JPEG (full) range
@end table
@anchor{overlay_cuda}
@subsection overlay_cuda
@section overlay_cuda
Overlay one video on top of another.
@@ -27252,13 +27407,13 @@ This filter also supports the @ref{framesync} options.
@anchor{pad_cuda}
@subsection pad_cuda
@section pad_cuda
Add paddings to an input video stream using CUDA.
This filter is the CUDA-accelerated version of the @ref{pad} filter. It accepts the same options and expressions and provides the same core functionality.
For a detailed description of available options, please see the documentation for the @ref{pad} filter.
@subsubsection Examples
@subsection Examples
@itemize
@item
@@ -27275,7 +27430,7 @@ ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 -vf "pad_cuda=w=ih
@end itemize
@anchor{scale_cuda}
@subsection scale_cuda
@section scale_cuda
Scale (resize) and convert (pixel format) the input video, using accelerated CUDA kernels.
Setting the output width and height works in the same way as for the @ref{scale} filter.
@@ -27324,6 +27479,12 @@ frame-consumer that exhausts the limited decoder frame pool.
If set to 1, frames are passed through as-is if they match the desired output
parameters. This is the default behaviour.
@item use_filters
If set to 1, filter with a generic weight LUT instead of using fixed-function
shader kernels. May be faster or slower depending on the hardware. A value
of @code{auto} (the default) enables this automatically when required for
correct anti-aliasing when downscaling.
@item param
Algorithm-Specific parameter.
@@ -27338,7 +27499,7 @@ Works the same as the identical @ref{scale} filter option.
@end table
@subsubsection Examples
@subsection Examples
@itemize
@item
@@ -27362,7 +27523,7 @@ scale_cuda=passthrough=0
@end example
@end itemize
@subsection thumbnail_cuda
@section thumbnail_cuda
Select the most representative frame in a given sequence of consecutive frames using CUDA.
@@ -27378,7 +27539,7 @@ the end. Default is @code{100}.
Since the filter keeps track of the whole frames sequence, a bigger @var{n}
value will result in a higher memory usage, so a high value is not recommended.
@subsubsection Example
@subsection Example
@itemize
@@ -27390,7 +27551,57 @@ Thumbnails are extracted from every @var{n}=150-frame batch, selecting one per b
@end itemize
@subsection yadif_cuda
@section transpose_cuda
Transpose rows with columns in the input video and optionally flip it.
For more in depth examples see the @ref{transpose} video filter, which shares mostly the same options.
It accepts the following parameters:
@table @option
@item dir
Specify the transposition direction.
Can assume the following values:
@table @samp
@item cclock_flip
Rotate by 90 degrees counterclockwise and vertically flip. (default)
@item clock
Rotate by 90 degrees clockwise.
@item cclock
Rotate by 90 degrees counterclockwise.
@item clock_flip
Rotate by 90 degrees clockwise and vertically flip.
@item reversal
Rotate by 180 degrees.
@item hflip
Flip horizontally.
@item vflip
Flip vertically.
@end table
@item passthrough
Do not apply the transposition if the input geometry matches the one
specified by the specified value. It accepts the following values:
@table @samp
@item none
Always apply transposition. (default)
@item portrait
Preserve portrait geometry (when @var{height} >= @var{width}).
@item landscape
Preserve landscape geometry (when @var{width} >= @var{height}).
@end table
@end table
@section yadif_cuda
Deinterlace the input video using the @ref{yadif} algorithm, but implemented
in CUDA so that it can work as part of a GPU accelerated pipeline with nvdec
@@ -27448,274 +27659,6 @@ Only deinterlace frames marked as interlaced.
The default value is @code{all}.
@end table
@anchor{CUDA NPP}
@section CUDA NPP
Below is a description of the currently available NVIDIA Performance Primitives (libnpp) video filters.
Prerequisites:
@itemize
@item Install Nvidia CUDA Toolkit
@item Install libnpp
@end itemize
To enable CUDA NPP filters:
@itemize
@item Configure FFmpeg with @code{--enable-nonfree --enable-libnpp}.
@end itemize
@anchor{scale_npp}
@subsection scale_npp
Use the NVIDIA Performance Primitives (libnpp) to perform scaling and/or pixel
format conversion on CUDA video frames. Setting the output width and height
works in the same way as for the @var{scale} filter.
The following additional options are accepted:
@table @option
@item format
The pixel format of the output CUDA frames. If set to the string "same" (the
default), the input format will be kept. Note that automatic format negotiation
and conversion is not yet supported for hardware frames
@item interp_algo
The interpolation algorithm used for resizing. One of the following:
@table @option
@item nn
Nearest neighbour.
@item linear
@item cubic
@item cubic2p_bspline
2-parameter cubic (B=1, C=0)
@item cubic2p_catmullrom
2-parameter cubic (B=0, C=1/2)
@item cubic2p_b05c03
2-parameter cubic (B=1/2, C=3/10)
@item super
Supersampling
@item lanczos
@end table
@item force_original_aspect_ratio
Enable decreasing or increasing output video width or height if necessary to
keep the original aspect ratio. Possible values:
@table @samp
@item disable
Scale the video as specified and disable this feature.
@item decrease
The output video dimensions will automatically be decreased if needed.
@item increase
The output video dimensions will automatically be increased if needed.
@end table
One useful instance of this option is that when you know a specific device's
maximum allowed resolution, you can use this to limit the output video to
that, while retaining the aspect ratio. For example, device A allows
1280x720 playback, and your video is 1920x800. Using this option (set it to
decrease) and specifying 1280x720 to the command line makes the output
1280x533.
Please note that this is a different thing than specifying -1 for @option{w}
or @option{h}, you still need to specify the output resolution for this option
to work.
@item force_divisible_by
Ensures that both the output dimensions, width and height, are divisible by the
given integer when used together with @option{force_original_aspect_ratio}. This
works similar to using @code{-n} in the @option{w} and @option{h} options.
This option respects the value set for @option{force_original_aspect_ratio},
increasing or decreasing the resolution accordingly. The video's aspect ratio
may be slightly modified.
This option can be handy if you need to have a video fit within or exceed
a defined resolution using @option{force_original_aspect_ratio} but also have
encoder restrictions on width or height divisibility.
@item reset_sar
Works the same as the identical @ref{scale} filter option.
@item eval
Specify when to evaluate @var{width} and @var{height} expression. It accepts the following values:
@table @samp
@item init
Only evaluate expressions once during the filter initialization or when a command is processed.
@item frame
Evaluate expressions for each incoming frame.
@end table
@end table
The values of the @option{w} and @option{h} options are expressions
containing the following constants:
@table @var
@item in_w
@item in_h
The input width and height
@item iw
@item ih
These are the same as @var{in_w} and @var{in_h}.
@item out_w
@item out_h
The output (scaled) width and height
@item ow
@item oh
These are the same as @var{out_w} and @var{out_h}
@item a
The same as @var{iw} / @var{ih}
@item sar
input sample aspect ratio
@item dar
The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
@item n
The (sequential) number of the input frame, starting from 0.
Only available with @code{eval=frame}.
@item t
The presentation timestamp of the input frame, expressed as a number of
seconds. Only available with @code{eval=frame}.
@item pos
The position (byte offset) of the frame in the input stream, or NaN if
this information is unavailable and/or meaningless (for example in case of synthetic video).
Only available with @code{eval=frame}.
Deprecated, do not use.
@end table
@subsection scale2ref_npp
Use the NVIDIA Performance Primitives (libnpp) to scale (resize) the input
video, based on a reference video.
See the @ref{scale_npp} filter for available options, scale2ref_npp supports the same
but uses the reference video instead of the main input as basis. scale2ref_npp
also supports the following additional constants for the @option{w} and
@option{h} options:
@table @var
@item main_w
@item main_h
The main input video's width and height
@item main_a
The same as @var{main_w} / @var{main_h}
@item main_sar
The main input video's sample aspect ratio
@item main_dar, mdar
The main input video's display aspect ratio. Calculated from
@code{(main_w / main_h) * main_sar}.
@item main_n
The (sequential) number of the main input frame, starting from 0.
Only available with @code{eval=frame}.
@item main_t
The presentation timestamp of the main input frame, expressed as a number of
seconds. Only available with @code{eval=frame}.
@item main_pos
The position (byte offset) of the frame in the main input stream, or NaN if
this information is unavailable and/or meaningless (for example in case of synthetic video).
Only available with @code{eval=frame}.
@end table
@subsubsection Examples
@itemize
@item
Scale a subtitle stream (b) to match the main video (a) in size before overlaying
@example
'scale2ref_npp[b][a];[a][b]overlay_cuda'
@end example
@item
Scale a logo to 1/10th the height of a video, while preserving its display aspect ratio.
@example
[logo-in][video-in]scale2ref_npp=w=oh*mdar:h=ih/10[logo-out][video-out]
@end example
@end itemize
@subsection sharpen_npp
Use the NVIDIA Performance Primitives (libnpp) to perform image sharpening with
border control.
The following additional options are accepted:
@table @option
@item border_type
Type of sampling to be used ad frame borders. One of the following:
@table @option
@item replicate
Replicate pixel values.
@end table
@end table
@subsection transpose_npp
Transpose rows with columns in the input video and optionally flip it.
For more in depth examples see the @ref{transpose} video filter, which shares mostly the same options.
It accepts the following parameters:
@table @option
@item dir
Specify the transposition direction.
Can assume the following values:
@table @samp
@item cclock_flip
Rotate by 90 degrees counterclockwise and vertically flip. (default)
@item clock
Rotate by 90 degrees clockwise.
@item cclock
Rotate by 90 degrees counterclockwise.
@item clock_flip
Rotate by 90 degrees clockwise and vertically flip.
@end table
@item passthrough
Do not apply the transposition if the input geometry matches the one
specified by the specified value. It accepts the following values:
@table @samp
@item none
Always apply transposition. (default)
@item portrait
Preserve portrait geometry (when @var{height} >= @var{width}).
@item landscape
Preserve landscape geometry (when @var{width} >= @var{height}).
@end table
@end table
@c man end CUDA Video Filters
@chapter OpenCL Video Filters
@@ -32333,7 +32276,7 @@ select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] over
Select useful frames from an ffconcat file which is using inpoints and
outpoints but where the source files are not intra frame only.
@example
ffmpeg -copyts -vsync 0 -segment_time_metadata 1 -i input.ffconcat -vf select=concatdec_select -af aselect=concatdec_select output.avi
ffmpeg -copyts -segment_time_metadata 1 -i input.ffconcat -fps_mode passthrough -vf select=concatdec_select -af aselect=concatdec_select output.avi
@end example
@end itemize
+3
View File
@@ -100,6 +100,9 @@ Print specific debug info.
Possible values:
@table @samp
@item ts
Print timestamp information.
@item id3v2
Print ID3v2 frame data when demuxing files containing ID3v2 tags.
@end table
@item max_delay @var{integer} (@emph{input/output})
+33 -2
View File
@@ -205,6 +205,39 @@ FFmpeg can make use of this library, originating in Modplug-XMMS, to read from M
See @url{https://github.com/Konstanty/libmodplug}. Pass @code{--enable-libmodplug} to configure to
enable it.
@section ONNX Runtime
FFmpeg can make use of the ONNX Runtime library as a backend for DNN based filters.
Go to @url{https://onnxruntime.ai/} and follow the instructions for installing
the library. Pre-built packages are available for various platforms.
Configure FFmpeg with ONNX Runtime support:
@example
./configure \
--enable-libonnxruntime \
--extra-cflags="-I/path/to/onnxruntime/include" \
--extra-ldflags="-L/path/to/onnxruntime/lib"
@end example
On ELF-based systems (Linux, BSD) you may also want to embed the
library search path so that the installed @file{ffmpeg} binary finds the
shared library at run time without setting @env{LD_LIBRARY_PATH}:
@example
./configure \
--enable-libonnxruntime \
--extra-cflags="-I/path/to/onnxruntime/include" \
--extra-ldflags="-L/path/to/onnxruntime/lib -Wl,-rpath,/path/to/onnxruntime/lib"
@end example
The @code{-Wl,-rpath} flag is ELF-specific and should be omitted on
other platforms (Windows, macOS).
For MinGW GCC builds, add the @code{-D_stdcall=__stdcall} flag for compatibility
with ONNX Runtime headers.
@section OpenCORE, VisualOn, and Fraunhofer libraries
Spun off Google Android sources, OpenCore, VisualOn and Fraunhofer
@@ -1295,8 +1328,6 @@ following image formats are supported:
@item Bink Audio @tab @tab X
@tab Used in Bink and Smacker files in many games.
@item Bonk audio @tab @tab X
@item CELT @tab @tab E
@tab decoding supported through external library libcelt
@item codec2 @tab E @tab E
@tab en/decoding supported through external library libcodec2
@item CRI HCA @tab @tab X
+2 -1
View File
@@ -52,7 +52,8 @@ Web, mail, and public facing git, also website git
fftrac VM:
----------
trac.ffmpeg.org Issue tracking
trac.ffmpeg.org Legacy issue tracking
code.ffmpeg.org Primary issue tracking
gpg encrypted backups of the trac repositories are created once a day
and can be downloaded by any of the admins.
+4 -1
View File
@@ -21,7 +21,10 @@ a mail for every change to every issue.
The subscription URL for the ffmpeg-trac list is:
https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-trac
The URL of the webinterface of the tracker is:
The primary issue tracker is:
https://code.ffmpeg.org/FFmpeg/FFmpeg/issues
Legacy issues may still exist on:
https://trac.ffmpeg.org
Type:
+111 -4
View File
@@ -1330,11 +1330,21 @@ element. Imply that the @option{single_file} option is set to
@var{true}. In the template, @code{$ext$} is replaced with the file
name extension specific for the segment format.
@item availability_start_time_ms @var{milliseconds}
Set the MPD @code{availabilityStartTime} attribute as Unix epoch time in
milliseconds. If set to @code{0}, the wall clock is used when the first
packet is written. This is useful for live outputs that need a stable
availability start time across restarts.
@item streaming @var{bool}
Enable or disable chunk streaming mode of output. In chunk streaming
mode, each frame will be a @code{moof} fragment which forms a
chunk. This is disabled by default.
@item suggested_presentation_delay @var{duration}
Set the MPD @code{suggestedPresentationDelay} attribute. If set to
@code{0}, the last segment duration is used.
@item target_latency @var{target_latency}
Set an intended target latency in seconds for serving (fractional
value can be set). Applicable only when the @option{streaming} and
@@ -1759,7 +1769,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
@@ -2652,7 +2662,7 @@ containing the @code{:} special character must be escaped.
Use @command{ffmpeg} for creating a sequence of files @file{img-001.jpeg},
@file{img-002.jpeg}, ..., taking one image every second from the input video:
@example
ffmpeg -i in.avi -vsync cfr -r 1 -f image2 'img-%03d.jpeg'
ffmpeg -i in.avi -fps_mode cfr -r 1 -f image2 'img-%03d.jpeg'
@end example
Note that with @command{ffmpeg}, if the format is not specified with the
@@ -2660,7 +2670,7 @@ Note that with @command{ffmpeg}, if the format is not specified with the
format, the image2 muxer is automatically selected, so the previous
command can be written as:
@example
ffmpeg -i in.avi -vsync cfr -r 1 'img-%03d.jpeg'
ffmpeg -i in.avi -fps_mode cfr -r 1 'img-%03d.jpeg'
@end example
Note also that the pattern must not necessarily contain "%d" or
@@ -2751,6 +2761,14 @@ song lyrics with an audio file, such as MP3, Vorbis, or MIDI.
This muxer accepts a single @samp{subrip} or @samp{text} subtitles stream.
@subsection Options
@table @option
@item precision @var{number}
Set the number of decimal digits used for the fractional (sub-second)
part of the timestamps. Range is @code{1} to @code{6}. Default is
@code{2}, i.e. centiseconds.
@end table
@subsection Metadata
The following metadata tags are converted to the format corresponding
metadata:
@@ -3069,7 +3087,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 +3114,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 +3292,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
@@ -3808,6 +3841,76 @@ ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac
@end example
@end itemize
@section wav
RIFF Wave Audio muxer.
@subsection Options
@table @option
@item rf64 @var{mode}
Choose whether to use the RF64 file format instead of RIFF.
RF64 allows files larger than 4 gigabytes, but RF64 support is not as
universal as RIFF.
The following modes are recognized:
@table @samp
@item auto
Start writing a standard RIFF file to retain compatibility with non-RF64-aware
software, but switch to RF64 if the output file grows larger than 4 gigabytes.
Reserves a small amount of extra space in the header using a @code{JUNK} chunk,
which should be ignored by all compliant RIFF readers, but some extremely
simplistic WAV readers may be confused by this.
@item always
Always use the RF64 format regardless of file size. The output file will only
be readable by RF64-compatible software and is no longer a standard RIFF WAVE
file.
@item never
Always use plain RIFF, never RF64. This mode is the most compatible with legacy
software, but if the output file grows beyond 4 gigabytes, the 32-bit size field
in the @code{data} chunk will no longer be able to correctly represent the size,
and most audio software will not be able to read some or all of the data.
(The @ref{wav} demuxer's @code{ignore_length} option can be used to recover such
a file.)
This is the default mode.
@end table
@item write_bext @var{bool}
Add a Broadcast Wave Format @code{BEXT} chunk containing extended audio
metadata if enabled. Defaults to false.
@item write_peak @var{mode}
Add a Peak Envelope chunk (EBU Tech 3285 Supplement 3) if enabled.
Defaults to off.
@table @samp
@item off
Do not add the Peak Envelope chunk.
@item on
Add the Peak Envelope chunk, calculating the peak values based on the
@code{peak_block_size}, @code{peak_format}, and @code{peak_ppv} options.
@item only
Like @code{on}, but skip writing the actual audio data (no @code{data}
chunk will be written to the file; only the Peak Envelope and other metadata
chunks will be written.)
@end table
@item peak_block_size @var{int}
Number of audio samples used to generate each peak frame, up to 65536.
Default is 256.
@item peak_format @var{format}
The format of the peak envelope data (1: uint8, 2: uint16). Default is 2 (uint16).
@item peak_ppv @var{int}
Number of peak points per peak value (1 or 2). Default is 2.
@end table
@section webm_chunk
WebM Live Chunk Muxer.
@@ -3951,6 +4054,10 @@ 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 1200.
+1 -6
View File
@@ -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)
+67 -5
View File
@@ -169,6 +169,7 @@ Read angle 2 of playlist 4 from BluRay mounted to /mnt/bluray, start from chapte
-playlist 4 -angle 2 -chapter 2 bluray:/mnt/bluray
@end example
@anchor{cache}
@section cache
Caching wrapper for input stream.
@@ -343,7 +344,8 @@ time, which is valuable for files on slow medium.
If set to 1, the protocol will retry reading at the end of the file, allowing
reading files that still are being written. In order for this to terminate,
you either need to use the rw_timeout option, or use the interrupt callback
(for API users).
(for API users). Setting this option also ignores the file size reported by
the file system.
@item seekable
Controls if seekability is advertised on the file. 0 means non-seekable, -1
@@ -1569,6 +1571,62 @@ If set to any value, listen for an incoming connection. Outgoing connection is d
Set the maximum number of streams. By default no limit is set.
@end table
@section shared
Thread-safe, persistent, cross-process cache wrapper for input streams. Caches
the input stream to a file in the specified directory. This is similar to
@ref{cache}, but with a persistent cache on disk that may be shared between
multiple processes or demuxers, even concurrently.
The filename of the cache is obtained by hashing the input URL, so there is
some risk of collision if the same URL is used for different content (e.g.
as a result of extra POST data being used to select the stream ID). To avoid
this, make sure to only use this protocol for URLs that uniquely identify
the content; otherwise you may get a garbled mix of sources.
The accepted options are:
@table @option
@item cache_dir
Path to the directory where cache files are stored. This option is required.
@item block_shift
Shift factor (log2) of the block size used for internal reads/writes. Defaults
to 15, i.e. 32KB blocks. If this does not match the value that was specified
when an existing cache file was created, the previously specified value will
be used instead.
@item read_only
If true, use the shared cache for reads but don't write any new blocks to it.
Default is false. Note that even with this option enabled, the cache file will
be initialized if it does not already exist.
@item cache_verify
If true, verify any data read from the cache against the underlying input
stream, and report any mismatches. Note that this will make the cache layer
effectively useless. This is purely a debug option.
@item cache_timeout
If set to a nonzero value, specifies the maximum time (in microseconds) to wait
for data to become available, if another process is currently trying to fetch
and cache the same block at the same time. If this timeout elapses, it's
assumed that the other process may have gotten stuck or died in the meantime.
If set to zero, no waiting is done and all processes will immediately race
to try and fetch the same missing blocks themselves. Defaults to 10000 (10 ms).
@item retry_errors
If true (the default), transient read errors from the underlying input stream
are ignored and retried again. If false, any blocks that previously failed
being read from will be treated as permanently inaccessible.
@end table
URL Syntax is
@example
shared:@var{URL}
@end example
@section srt
Haivision Secure Reliable Transport Protocol via libsrt.
@@ -1857,6 +1915,10 @@ When true, use Timestamp-based Packet Delivery mode. The default behavior
depends on the transmission type: enabled in live mode, disabled in file
mode.
@item ipv6only=@var{1|0}
Accept IPv4 or not while using the IPv6 wildcard address. This should be set
when listening on a IPv6 wildcard address.
@end table
For more information see: @url{https://github.com/Haivision/srt}.
@@ -2023,8 +2085,8 @@ database, but it does not validate that the certificate actually
matches the host name we are trying to connect to. (With other backends,
the host name is validated as well.)
This is disabled by default since it requires a CA database to be
provided by the caller in many cases.
This is enabled by default. Verifying the peer requires a CA database,
which in some cases has to be provided by the caller.
@item cert_file, cert=@var{filename}
A file containing a certificate to use in the handshake with the peer.
@@ -2095,8 +2157,8 @@ 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.
This is enabled by default. Verifying the peer requires a CA database,
which in some cases has to be provided by the caller.
@item cert_file, cert=@var{filename}
A file containing a certificate to use in the handshake with the peer.
+94 -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.
@@ -151,6 +191,47 @@ No blending
@end table
@item sws_backends
Set the allowed swscale backends. This is a flags option, so multiple backends
may be combined.
@table @samp
@item auto
Automatic selection. Equal to either @samp{stable} or @samp{all} depending on
whether or not the @samp{unstable} flag is set. This is the default value.
@item stable
All stable backends.
@item unstable
All unstable backends.
@item all
All available backends.
@item legacy
Legacy swscale code.
@item c
Template-based reference code.
@item memcpy
Fast path using libc @code{memcpy}.
@item x86
x86 SIMD kernels.
@item aarch64
AArch64 NEON kernels.
@item spirv
Vulkan SPIR-V backend.
@item glsl
Vulkan GLSL backend.
@end table
@end table
@c man end SCALER OPTIONS
+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:
+3 -15
View File
@@ -2,14 +2,6 @@
# common bits used by all libraries
#
DEFAULT_X86ASMD=.dbg
ifeq ($(DBG),1)
X86ASMD=$(DEFAULT_X86ASMD)
else
X86ASMD=
endif
ifndef SUBDIR
LINK = $(LD) $(1)
@@ -105,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) $@)
@@ -197,7 +185,7 @@ 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:
@@ -266,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 *.spv *.spv.gz *.spv.c *.ver *.version *.html.gz *.html.c *.css.min.gz *.css.min *.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.asm *.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
@@ -276,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) $(SPVOBJS:.spv.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))
+18 -2
View File
@@ -14,6 +14,15 @@ INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%)
all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)lib$(FULLNAME).pc
all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)lib$(FULLNAME).pc
# Make <4.0 does not support the built-in file function;
# versions that do support it should use it, as it's
# faster and isn't bound by command line length limits.
ifeq (4.0,$(firstword $(sort 4.0 $(MAKE_VERSION))))
HAVE_BUILTIN_FILE := yes
else
HAVE_BUILTIN_FILE := no
endif
LIBOBJS := $(OBJS) $(SHLIBOBJS) $(STLIBOBJS) $(SUBDIR)%.h.o $(TESTOBJS)
$(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H
@@ -36,7 +45,11 @@ endif
$(SUBDIR)$(LIBNAME): $(OBJS) $(STLIBOBJS)
$(RM) $@
ifeq ($(RESPONSE_FILES),yes)
ifeq ($(HAVE_BUILTIN_FILE),yes)
$(file >$@.objs,$^)
else
$(Q)echo $^ > $@.objs
endif
$(AR) $(ARFLAGS) $(AR_O) @$@.objs
else
$(AR) $(ARFLAGS) $(AR_O) $^
@@ -53,8 +66,6 @@ define RULES
$(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB))
$(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)
@@ -77,7 +88,12 @@ $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SHLIBOBJS) $(SUBDIR)lib$(NAME).ver
$(SLIB_CREATE_DEF_CMD)
ifeq ($(RESPONSE_FILES),yes)
ifeq ($(HAVE_BUILTIN_FILE),yes)
$$(file >$$@.objs,$$(filter %.o,$$^))
else
$(Q)echo $$(filter %.o,$$^) > $$@.objs
endif
$$(call LINK,$$(call $(NAME)LINK_SO_ARGS) $$(LD_O) @$$@.objs $$(call $(NAME)LINK_EXTRA))
else
$$(call LINK,$$(call $(NAME)LINK_SO_ARGS) $$(LD_O) $$(filter %.o,$$^) $$(call $(NAME)LINK_EXTRA))
+1 -1
View File
@@ -1267,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)
+3 -2
View File
@@ -253,7 +253,6 @@ void term_init(void)
/* read a key without blocking */
static int read_key(void)
{
unsigned char ch = -1;
#if HAVE_TERMIOS_H
int n = 1;
struct timeval tv;
@@ -265,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;
@@ -289,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;
@@ -300,7 +301,7 @@ static int read_key(void)
if(kbhit())
return(getch());
#endif
return ch;
return -1;
}
static int decode_interrupt_cb(void *ctx)
+4 -34
View File
@@ -51,16 +51,6 @@
#include "libswresample/swresample.h"
// deprecated features
#define FFMPEG_OPT_QPHIST 1
#define FFMPEG_OPT_ADRIFT_THRESHOLD 1
#define FFMPEG_OPT_ENC_TIME_BASE_NUM 1
#define FFMPEG_OPT_TOP 1
#define FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP 1
#define FFMPEG_OPT_VSYNC_DROP 1
#define FFMPEG_OPT_VSYNC 1
#define FFMPEG_OPT_FILTER_SCRIPT 1
#define FFMPEG_ERROR_RATE_EXCEEDED FFERRTAG('E', 'R', 'E', 'D')
enum VideoSyncMethod {
@@ -69,9 +59,6 @@ enum VideoSyncMethod {
VSYNC_CFR,
VSYNC_VFR,
VSYNC_VSCFR,
#if FFMPEG_OPT_VSYNC_DROP
VSYNC_DROP,
#endif
};
enum EncTimeBase {
@@ -218,21 +205,17 @@ 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;
SpecifierOptList chroma_intra_matrices;
#if FFMPEG_OPT_TOP
SpecifierOptList top_field_first;
#endif
SpecifierOptList metadata_map;
SpecifierOptList presets;
SpecifierOptList copy_initial_nonkeyframes;
SpecifierOptList copy_prior_start;
SpecifierOptList filters;
#if FFMPEG_OPT_FILTER_SCRIPT
SpecifierOptList filter_scripts;
#endif
SpecifierOptList reinit_filters;
SpecifierOptList drop_changed;
SpecifierOptList fix_sub_duration;
@@ -434,9 +417,6 @@ enum DecoderFlags {
// decoder should override timestamps by fixed framerate
// from DecoderOpts.framerate
DECODER_FLAG_FRAMERATE_FORCED = (1 << 2),
#if FFMPEG_OPT_TOP
DECODER_FLAG_TOP_FIELD_FIRST = (1 << 3),
#endif
DECODER_FLAG_SEND_END_TS = (1 << 4),
// force bitexact decoding
DECODER_FLAG_BITEXACT = (1 << 5),
@@ -469,7 +449,7 @@ typedef struct Decoder {
enum AVMediaType type;
const uint8_t *subtitle_header;
uint8_t *subtitle_header;
int subtitle_header_size;
// number of frames/samples retrieved from the decoder
@@ -500,9 +480,6 @@ typedef struct InputStream {
/* framerate forced with -r */
AVRational framerate;
#if FFMPEG_OPT_TOP
int top_field_first;
#endif
int fix_sub_duration;
@@ -604,9 +581,6 @@ typedef struct EncStats {
enum {
KF_FORCE_SOURCE = 1,
#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,
};
@@ -663,10 +637,6 @@ typedef struct OutputStream {
Encoder *enc;
/* video only */
#if FFMPEG_OPT_TOP
int top_field_first;
#endif
int bitexact;
int bits_per_raw_sample;
@@ -813,7 +783,7 @@ 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, enum VideoSyncMethod *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 filtergraph_is_simple(const FilterGraph *fg);
int fg_create_simple(FilterGraph **pfg,
+11 -9
View File
@@ -136,6 +136,8 @@ void dec_free(Decoder **pdec)
av_frame_free(&dp->sub_prev[i]);
av_frame_free(&dp->sub_heartbeat);
av_freep(&dp->dec.subtitle_header);
av_freep(&dp->parent_name);
av_freep(&dp->views_requested);
@@ -385,13 +387,6 @@ fail:
static int video_frame_process(DecoderPriv *dp, AVFrame *frame,
unsigned *outputs_mask)
{
#if FFMPEG_OPT_TOP
if (dp->flags & DECODER_FLAG_TOP_FIELD_FIRST) {
av_log(dp, AV_LOG_WARNING, "-top is deprecated, use the setfield filter instead\n");
frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
}
#endif
if (frame->format == dp->hwaccel_pix_fmt) {
int err = hwaccel_retrieve_data(dp->dec_ctx, frame);
if (err < 0)
@@ -1621,8 +1616,15 @@ static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts,
dp->dec_ctx->extra_hw_frames = extra_frames;
}
dp->dec.subtitle_header = dp->dec_ctx->subtitle_header;
dp->dec.subtitle_header_size = dp->dec_ctx->subtitle_header_size;
if (dp->dec_ctx->subtitle_header) {
/* ASS code assumes this buffer is null terminated so add extra byte. */
dp->dec.subtitle_header = av_mallocz(dp->dec_ctx->subtitle_header_size + 1);
if (!dp->dec.subtitle_header)
return AVERROR(ENOMEM);
memcpy(dp->dec.subtitle_header, dp->dec_ctx->subtitle_header,
dp->dec_ctx->subtitle_header_size);
dp->dec.subtitle_header_size = dp->dec_ctx->subtitle_header_size;
}
if (param_out) {
if (dp->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+203 -53
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"
@@ -68,6 +69,8 @@ typedef struct DemuxStream {
int autorotate;
int apply_cropping;
int force_display_matrix;
int force_mastering_display;
int force_content_light;
int drop_changed;
@@ -96,12 +99,6 @@ typedef struct DemuxStream {
uint64_t nb_packets;
// combined size of all the packets read
uint64_t data_size;
// latest wallclock time at which packet reading resumed after a stall - used for readrate
int64_t resume_wc;
// timestamp of first packet sent after the latest stall - used for readrate
int64_t resume_pts;
// measure of how far behind packet reading is against spceified readrate
int64_t lag;
} DemuxStream;
typedef struct DemuxStreamGroup {
@@ -144,6 +141,13 @@ typedef struct Demuxer {
double readrate_initial_burst;
float readrate_catchup;
// latest wallclock time at which packet reading resumed after a stall - used for readrate
int64_t resume_wc;
// relative timestamp of first packet sent after the latest stall - used for readrate
int64_t resume_progress;
// measure of how far behind packet reading is against spceified readrate
int64_t lag;
Scheduler *sch;
AVPacket *pkt_heartbeat;
@@ -514,43 +518,55 @@ static void readrate_sleep(Demuxer *d)
int64_t initial_burst = AV_TIME_BASE * d->readrate_initial_burst;
int resume_warn = 0;
DemuxStream *slowest = NULL;
int64_t progress = INT64_MAX;
for (int i = 0; i < f->nb_streams; i++) {
InputStream *ist = f->streams[i];
DemuxStream *ds = ds_from_ist(ist);
int64_t stream_ts_offset, pts, now, wc_elapsed, elapsed, lag, max_pts, limit_pts;
int64_t stream_ts_offset, pts, pts_diff;
if (ds->discard || ds->finished || ds->first_dts == AV_NOPTS_VALUE)
continue;
if (ds->discard) continue;
stream_ts_offset = FFMAX(ds->first_dts != AV_NOPTS_VALUE ? ds->first_dts : 0, file_start);
stream_ts_offset = FFMAX(ds->first_dts, file_start);
pts = av_rescale(ds->dts, 1000000, AV_TIME_BASE);
now = av_gettime_relative();
wc_elapsed = now - d->wallclock_start;
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;
ds->resume_wc = now;
ds->resume_pts = pts;
av_log_once(ds, AV_LOG_WARNING, AV_LOG_DEBUG, &resume_warn,
"Resumed reading at pts %0.3f with rate %0.3f after a lag of %0.3fs\n",
(float)pts/AV_TIME_BASE, d->readrate_catchup, (float)lag/AV_TIME_BASE);
pts_diff = pts - stream_ts_offset;
if (pts_diff < progress) {
progress = pts_diff;
slowest = ds;
}
if (ds->lag && !lag)
ds->lag = ds->resume_wc = ds->resume_pts = 0;
if (ds->resume_wc) {
elapsed = now - ds->resume_wc;
limit_pts = ds->resume_pts + (int64_t)(elapsed * d->readrate_catchup);
} else {
elapsed = wc_elapsed;
limit_pts = max_pts;
}
if (pts > limit_pts)
av_usleep(pts - limit_pts);
}
if (!slowest || progress <= initial_burst)
return;
int64_t now = av_gettime_relative();
int64_t wc_elapsed = now - d->wallclock_start;
int64_t max_prog = initial_burst + (int64_t)(wc_elapsed * d->readrate);
int64_t lag = FFMAX(max_prog - progress, 0);
int64_t limit;
if ( (!d->lag && lag > 0.3 * AV_TIME_BASE) || ( lag > d->lag + 0.3 * AV_TIME_BASE) ) {
d->lag = lag;
d->resume_wc = now;
d->resume_progress = progress;
int64_t pts = FFMAX(slowest->first_dts, file_start) + progress;
av_log_once(slowest, AV_LOG_WARNING, AV_LOG_DEBUG, &resume_warn,
"Resumed reading at pts %0.3f with rate %0.3f after a lag of %0.3fs\n",
(float)pts/AV_TIME_BASE, d->readrate_catchup, (float)lag/AV_TIME_BASE);
}
if (d->lag && !lag)
d->lag = d->resume_wc = d->resume_progress = 0;
if (d->resume_wc) {
int64_t elapsed = now - d->resume_wc;
limit = d->resume_progress + (int64_t)(elapsed * d->readrate_catchup);
} else {
limit = max_prog;
}
if (progress > limit)
av_usleep(progress - limit);
}
static int do_send(Demuxer *d, DemuxStream *ds, AVPacket *pkt, unsigned flags,
@@ -982,11 +998,7 @@ int ist_use(InputStream *ist, int decoding_needed,
ds->dec_opts.flags |= (!!ist->fix_sub_duration * DECODER_FLAG_FIX_SUB_DURATION) |
(!!is_unreliable * DECODER_FLAG_TS_UNRELIABLE) |
(!!(d->loop && is_audio) * DECODER_FLAG_SEND_END_TS)
#if FFMPEG_OPT_TOP
| ((ist->top_field_first >= 0) * DECODER_FLAG_TOP_FIELD_FIRST)
#endif
;
(!!(d->loop && is_audio) * DECODER_FLAG_SEND_END_TS);
if (ist->framerate.num) {
ds->dec_opts.flags |= DECODER_FLAG_FRAMERATE_FORCED;
@@ -1248,6 +1260,125 @@ static int add_display_matrix_to_stream(const OptionsContext *o,
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;
}
static const char *input_stream_item_name(void *obj)
{
const DemuxStream *ds = obj;
@@ -1301,6 +1432,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);
@@ -1366,6 +1498,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);
@@ -1483,15 +1623,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) {
char buf[32];
if (av_dict_get(ds->decoder_opts, "side_data_prefer_packet", NULL, 0))
buf[0] = ',';
else
buf[0] = '\0';
av_strlcat(buf, "displaymatrix", sizeof(buf));
av_dict_set(&ds->decoder_opts, "side_data_prefer_packet", buf, AV_DICT_APPEND);
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)
@@ -1508,12 +1659,6 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
return ret;
}
}
#if FFMPEG_OPT_TOP
ist->top_field_first = -1;
opt_match_per_stream_int(ist, &o->top_field_first, ic, st, &ist->top_field_first);
#endif
break;
case AVMEDIA_TYPE_AUDIO: {
const char *ch_layout_str = NULL;
@@ -1659,6 +1804,11 @@ static int istg_parse_tile_grid(const OptionsContext *o, Demuxer *d, InputStream
if (tg->nb_tiles == 1)
return 0;
if (!tg->nb_tiles) {
av_log(istg, AV_LOG_FATAL, "A demuxer exported an invalid tile group stream group. "
"This is a bug, please report it.\n");
return AVERROR_BUG;
}
memset(&opts, 0, sizeof(opts));
+5 -18
View File
@@ -227,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;
@@ -280,17 +283,8 @@ int enc_open(void *opaque, const AVFrame *frame)
}
if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) ||
(frame->flags & AV_FRAME_FLAG_INTERLACED)
#if FFMPEG_OPT_TOP
|| ost->top_field_first >= 0
#endif
) {
int top_field_first =
#if FFMPEG_OPT_TOP
ost->top_field_first >= 0 ?
ost->top_field_first :
#endif
!!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
(frame->flags & AV_FRAME_FLAG_INTERLACED)) {
int top_field_first = !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
if (enc->id == AV_CODEC_ID_MJPEG)
enc_ctx->field_order = top_field_first ? AV_FIELD_TT : AV_FIELD_BB;
@@ -802,13 +796,6 @@ static int frame_encode(OutputStream *ost, AVFrame *frame, AVPacket *pkt)
if (type == AVMEDIA_TYPE_VIDEO) {
frame->quality = e->enc_ctx->global_quality;
frame->pict_type = forced_kf_apply(e, &ost->kf, frame);
#if FFMPEG_OPT_TOP
if (ost->top_field_first >= 0) {
frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * (!!ost->top_field_first);
}
#endif
} else {
if (!(e->enc_ctx->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE) &&
e->enc_ctx->ch_layout.nb_channels != frame->ch_layout.nb_channels) {
+21 -37
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"
@@ -50,8 +51,6 @@ typedef struct FilterGraphPriv {
// true when the filtergraph contains only meta filters
// that do not modify the frame data
int is_meta;
// source filters are present in the graph
int have_sources;
int disable_conversions;
unsigned nb_outputs_done;
@@ -1038,6 +1037,7 @@ void fg_free(FilterGraph **pfg)
av_frame_free(&ifp->opts.fallback);
av_buffer_unref(&ifp->hw_frames_ctx);
av_channel_layout_uninit(&ifp->ch_layout);
av_freep(&ifilter->linklabel);
av_freep(&ifp->opts.name);
av_frame_side_data_free(&ifp->side_data, &ifp->nb_side_data);
@@ -1143,16 +1143,6 @@ int fg_create(FilterGraph **pfg, char **graph_desc, Scheduler *sch,
if (ret < 0)
goto fail;
for (unsigned i = 0; i < graph->nb_filters; i++) {
const AVFilter *f = graph->filters[i]->filter;
if ((!avfilter_filter_pad_count(f, 0) &&
!(f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)) ||
!strcmp(f->name, "apad")) {
fgp->have_sources = 1;
break;
}
}
for (AVFilterInOut *cur = inputs; cur; cur = cur->next) {
InputFilter *const ifilter = ifilter_alloc(fg);
@@ -1681,7 +1671,10 @@ static int configure_output_video_filter(FilterGraphPriv *fgp, AVFilterGraph *gr
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)) {
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;
@@ -1806,10 +1799,8 @@ static int configure_output_audio_filter(FilterGraphPriv *fgp, AVFilterGraph *gr
pad_idx = 0;
}
if (ofilter->apad) {
if (ofilter->apad)
AUTO_INSERT_FILTER("-apad", "apad", ofilter->apad);
fgp->have_sources = 1;
}
snprintf(name, sizeof(name), "trim for output %s", ofilter->output_name);
ret = insert_trim(fgp, ofp->trim_start_us, ofp->trim_duration_us,
@@ -2266,8 +2257,7 @@ 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) ||
frame->side_data[i]->type == AV_FRAME_DATA_DISPLAYMATRIX)
if (!(desc->props & AV_SIDE_DATA_PROP_GLOBAL))
continue;
ret = av_frame_side_data_clone(&ifp->side_data,
@@ -2278,8 +2268,11 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr
}
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX);
if (sd)
if (sd) {
memcpy(ifp->displaymatrix, sd->data, sizeof(ifp->displaymatrix));
if (ifp->opts.flags & IFILTER_FLAG_AUTOROTATE)
av_frame_side_data_remove(&ifp->side_data, &ifp->nb_side_data, AV_FRAME_DATA_DISPLAYMATRIX);
}
ifp->displaymatrix_present = !!sd;
/* Copy downmix related side data to InputFilterPriv so it may be propagated
@@ -2547,11 +2540,7 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame,
if (delta0 < 0 &&
delta > 0 &&
fps->vsync_method != VSYNC_PASSTHROUGH
#if FFMPEG_OPT_VSYNC_DROP
&& fps->vsync_method != VSYNC_DROP
#endif
) {
fps->vsync_method != VSYNC_PASSTHROUGH) {
if (delta0 < -0.6) {
av_log(ofp, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0);
} else
@@ -2569,6 +2558,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) {
@@ -2589,9 +2579,6 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame,
ofp->next_pts = llrint(sync_ipts);
frame->duration = llrint(duration);
break;
#if FFMPEG_OPT_VSYNC_DROP
case VSYNC_DROP:
#endif
case VSYNC_PASSTHROUGH:
ofp->next_pts = llrint(sync_ipts);
frame->duration = llrint(duration);
@@ -2836,8 +2823,10 @@ static int fg_output_step(OutputFilterPriv *ofp, FilterGraphThread *fgt,
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)
if (ret < 0) {
av_frame_unref(frame);
return ret;
}
}
fd->wallclock[LATENCY_PROBE_FILTER_POST] = av_gettime_relative();
@@ -2871,7 +2860,6 @@ static int read_frames(FilterGraph *fg, FilterGraphThread *fgt,
AVFrame *frame)
{
FilterGraphPriv *fgp = fgp_from_fg(fg);
int did_step = 0;
// graph not configured, just select the input to request
if (!fgt->graph) {
@@ -2890,7 +2878,7 @@ static int read_frames(FilterGraph *fg, FilterGraphThread *fgt,
return AVERROR_BUG;
}
while (fgp->nb_outputs_done < fg->nb_outputs) {
if (fgp->nb_outputs_done < fg->nb_outputs) {
int ret;
/* Reap all buffers present in the buffer sinks */
@@ -2905,9 +2893,6 @@ static int read_frames(FilterGraph *fg, FilterGraphThread *fgt,
}
}
// return after one iteration, so that scheduler can rate-control us
if (did_step && fgp->have_sources)
return 0;
ret = avfilter_graph_request_oldest(fgt->graph);
if (ret == AVERROR(EAGAIN)) {
@@ -2924,7 +2909,8 @@ static int read_frames(FilterGraph *fg, FilterGraphThread *fgt,
}
fgt->next_in = fg->nb_inputs;
did_step = 1;
// return so that scheduler can rate-control us
return 0;
}
return AVERROR_EOF;
@@ -3181,7 +3167,7 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
const char *color_space_name = av_color_space_name(frame->colorspace);
const char *color_range_name = av_color_range_name(frame->color_range);
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,",
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(alpha_mode));
@@ -3337,8 +3323,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;
-5
View File
@@ -139,11 +139,6 @@ static int mux_fixup_ts(Muxer *mux, MuxStream *ms, AVPacket *pkt)
{
OutputStream *ost = &ms->ost;
#if FFMPEG_OPT_VSYNC_DROP
if (ost->type == AVMEDIA_TYPE_VIDEO && ms->ts_drop)
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
#endif
// rescale timestamps to the stream timebase
if (ost->type == AVMEDIA_TYPE_AUDIO && !ost->enc) {
// use av_rescale_delta() for streamcopying audio, to preserve
-3
View File
@@ -81,9 +81,6 @@ typedef struct MuxStream {
int copy_initial_nonkeyframes;
int copy_prior_start;
int streamcopy_started;
#if FFMPEG_OPT_VSYNC_DROP
int ts_drop;
#endif
AVRational frame_rate;
AVRational max_frame_rate;
+24 -83
View File
@@ -417,45 +417,19 @@ static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc,
OutputStream *ost, char **dst)
{
const char *filters = NULL;
#if FFMPEG_OPT_FILTER_SCRIPT
const char *filters_script = NULL;
opt_match_per_stream_str(ost, &o->filter_scripts, oc, ost->st, &filters_script);
#endif
opt_match_per_stream_str(ost, &o->filters, oc, ost->st, &filters);
if (!ost->ist) {
if (
#if FFMPEG_OPT_FILTER_SCRIPT
filters_script ||
#endif
filters) {
if (filters) {
av_log(ost, AV_LOG_ERROR,
"%s '%s' was specified for a stream fed from a complex "
"Filtergraph '%s' was specified for a stream fed from a complex "
"filtergraph. Simple and complex filtering cannot be used "
"together for the same stream.\n",
#if FFMPEG_OPT_FILTER_SCRIPT
filters ? "Filtergraph" : "Filtergraph script",
filters ? filters : filters_script
#else
"Filtergraph", filters
#endif
);
"together for the same stream.\n", filters);
return AVERROR(EINVAL);
}
return 0;
}
#if FFMPEG_OPT_FILTER_SCRIPT
if (filters_script && filters) {
av_log(ost, AV_LOG_ERROR, "Both -filter and -filter_script set\n");
return AVERROR(EINVAL);
}
if (filters_script)
*dst = read_file_to_string(filters_script);
else
#endif
if (filters)
*dst = av_strdup(filters);
else
@@ -761,21 +735,10 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
opt_match_per_stream_int(ost, &o->force_fps, oc, st, &ms->force_fps);
#if FFMPEG_OPT_TOP
ost->top_field_first = -1;
opt_match_per_stream_int(ost, &o->top_field_first, oc, st, &ost->top_field_first);
if (ost->top_field_first >= 0)
av_log(ost, AV_LOG_WARNING, "-top is deprecated, use the setfield filter instead\n");
#endif
#if FFMPEG_OPT_VSYNC
*vsync_method = video_sync_method;
#else
*vsync_method = VSYNC_AUTO;
#endif
opt_match_per_stream_str(ost, &o->fps_mode, oc, st, &fps_mode);
if (fps_mode) {
ret = parse_and_set_vsync(fps_mode, vsync_method, ost->file->index, ost->index, 0);
ret = parse_and_set_vsync(fps_mode, vsync_method, ost->file->index, ost->index);
if (ret < 0)
return ret;
}
@@ -810,10 +773,6 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
*vsync_method = VSYNC_VSCFR;
}
}
#if FFMPEG_OPT_VSYNC_DROP
if (*vsync_method == VSYNC_DROP)
ms->ts_drop = 1;
#endif
}
return 0;
@@ -1040,28 +999,12 @@ static int streamcopy_init(const OptionsContext *o, const Muxer *mux,
int ret = 0;
const char *filters = NULL;
#if FFMPEG_OPT_FILTER_SCRIPT
const char *filters_script = NULL;
opt_match_per_stream_str(ost, &o->filter_scripts, mux->fc, ost->st, &filters_script);
#endif
opt_match_per_stream_str(ost, &o->filters, mux->fc, ost->st, &filters);
if (
#if FFMPEG_OPT_FILTER_SCRIPT
filters_script ||
#endif
filters) {
if (filters) {
av_log(ost, AV_LOG_ERROR,
"%s '%s' was specified, but codec copy was selected. "
"Filtering and streamcopy cannot be used together.\n",
#if FFMPEG_OPT_FILTER_SCRIPT
filters ? "Filtergraph" : "Filtergraph script",
filters ? filters : filters_script
#else
"Filtergraph", filters
#endif
);
"Filtergraph '%s' was specified, but codec copy was selected. "
"Filtering and streamcopy cannot be used together.\n", filters);
return AVERROR(EINVAL);
}
@@ -1401,20 +1344,11 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
q = (AVRational){ ENC_TIME_BASE_FILTER, 0 };
} else {
ret = av_parse_ratio(&q, enc_time_base, INT_MAX, 0, NULL);
if (ret < 0 || q.den <= 0
#if !FFMPEG_OPT_ENC_TIME_BASE_NUM
|| q.num < 0
#endif
) {
if (ret < 0 || q.den <= 0 || q.num < 0) {
av_log(ost, AV_LOG_FATAL, "Invalid time base: %s\n", enc_time_base);
ret = ret < 0 ? ret : AVERROR(EINVAL);
goto fail;
}
#if FFMPEG_OPT_ENC_TIME_BASE_NUM
if (q.num < 0)
av_log(ost, AV_LOG_WARNING, "-enc_time_base -1 is deprecated,"
" use -enc_time_base demux\n");
#endif
}
enc_tb = q;
@@ -1531,6 +1465,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);
@@ -2127,7 +2063,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);
@@ -2552,6 +2489,10 @@ static int of_map_group(Muxer *mux, AVDictionary **dict, AVBPrint *bp, const cha
}
break;
}
case AV_STREAM_GROUP_PARAMS_LCEVC:
case AV_STREAM_GROUP_PARAMS_TREF:
case AV_STREAM_GROUP_PARAMS_DOLBY_VISION:
break;
default:
av_log(mux, AV_LOG_ERROR, "Unsupported mapped group type %d.\n", stg->type);
ret = AVERROR(EINVAL);
@@ -2574,6 +2515,10 @@ 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" },
{ "tref", NULL, 0, AV_OPT_TYPE_CONST,
{ .i64 = AV_STREAM_GROUP_PARAMS_TREF }, .unit = "type" },
{ NULL },
};
const AVClass class = {
@@ -2648,6 +2593,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;
@@ -2672,8 +2621,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;
}
@@ -3280,12 +3227,6 @@ static int process_forced_keyframes(Muxer *mux, const OptionsContext *o)
// parse it only for static kf timings
} else if (!strcmp(forced_keyframes, "source")) {
ost->kf.type = KF_FORCE_SOURCE;
#if FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP
} else if (!strcmp(forced_keyframes, "source_no_drop")) {
av_log(ost, AV_LOG_WARNING, "The 'source_no_drop' value for "
"-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 {
+13 -109
View File
@@ -56,9 +56,6 @@ char *vstats_filename;
float dts_delta_threshold = 10;
float dts_error_threshold = 3600*30;
#if FFMPEG_OPT_VSYNC
enum VideoSyncMethod video_sync_method = VSYNC_AUTO;
#endif
float frame_drop_threshold = 0;
int do_benchmark = 0;
int do_benchmark_all = 0;
@@ -359,38 +356,17 @@ int view_specifier_parse(const char **pspec, ViewSpecifier *vs)
return 0;
}
int parse_and_set_vsync(const char *arg, enum VideoSyncMethod *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)
{
if (!av_strcasecmp(arg, "cfr")) *vsync_var = VSYNC_CFR;
else if (!av_strcasecmp(arg, "vfr")) *vsync_var = VSYNC_VFR;
else if (!av_strcasecmp(arg, "passthrough")) *vsync_var = VSYNC_PASSTHROUGH;
#if FFMPEG_OPT_VSYNC_DROP
else if (!av_strcasecmp(arg, "drop")) {
av_log(NULL, AV_LOG_WARNING, "-vsync/fps_mode drop is deprecated\n");
*vsync_var = VSYNC_DROP;
}
#endif
else if (!is_global && !av_strcasecmp(arg, "auto")) *vsync_var = VSYNC_AUTO;
else if (!is_global) {
else if (!av_strcasecmp(arg, "auto")) *vsync_var = VSYNC_AUTO;
else {
av_log(NULL, AV_LOG_FATAL, "Invalid value %s specified for fps_mode of #%d:%d.\n", arg, file_idx, st_idx);
return AVERROR(EINVAL);
}
#if FFMPEG_OPT_VSYNC
if (is_global && *vsync_var == VSYNC_AUTO) {
int ret;
double num;
ret = parse_number("vsync", arg, OPT_TYPE_INT, VSYNC_AUTO, VSYNC_VFR, &num);
if (ret < 0)
return ret;
video_sync_method = num;
av_log(NULL, AV_LOG_WARNING, "Passing a number to -vsync is deprecated,"
" use a string argument as described in the manual.\n");
}
#endif
return 0;
}
@@ -645,6 +621,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],
@@ -1231,14 +1210,6 @@ static int opt_audio_filters(void *optctx, const char *opt, const char *arg)
return parse_option(o, "filter:a", arg, options);
}
#if FFMPEG_OPT_VSYNC
static int opt_vsync(void *optctx, const char *opt, const char *arg)
{
av_log(NULL, AV_LOG_WARNING, "-vsync is deprecated. Use -fps_mode\n");
return parse_and_set_vsync(arg, &video_sync_method, -1, -1, 1);
}
#endif
static int opt_timecode(void *optctx, const char *opt, const char *arg)
{
OptionsContext *o = optctx;
@@ -1279,31 +1250,6 @@ static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
return 0;
}
#if FFMPEG_OPT_FILTER_SCRIPT
static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
{
GlobalOptionsContext *go = optctx;
char *graph_desc;
int ret;
graph_desc = read_file_to_string(arg);
if (!graph_desc)
return AVERROR(EINVAL);
av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -/filter_complex %s instead\n",
opt, arg);
ret = GROW_ARRAY(go->filtergraphs, go->nb_filtergraphs);
if (ret < 0) {
av_freep(&graph_desc);
return ret;
}
go->filtergraphs[go->nb_filtergraphs - 1] = graph_desc;
return 0;
}
#endif
void show_help_default(const char *opt, const char *arg)
{
int show_advanced = 0, show_avoptions = 0;
@@ -1594,22 +1540,6 @@ int opt_timelimit(void *optctx, const char *opt, const char *arg)
return 0;
}
#if FFMPEG_OPT_QPHIST
static int opt_qphist(void *optctx, const char *opt, const char *arg)
{
av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt);
return 0;
}
#endif
#if FFMPEG_OPT_ADRIFT_THRESHOLD
static int opt_adrift_threshold(void *optctx, const char *opt, const char *arg)
{
av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt);
return 0;
}
#endif
static const char *const alt_channel_layout[] = { "ch_layout", NULL};
static const char *const alt_codec[] = { "c", "acodec", "vcodec", "scodec", "dcodec", NULL };
static const char *const alt_filter[] = { "af", "vf", NULL };
@@ -1816,11 +1746,6 @@ const OptionDef options[] = {
{ "filter_buffered_frames", OPT_TYPE_INT, OPT_EXPERT,
{ &filter_buffered_frames },
"maximum number of buffered frames in a filter graph" },
#if FFMPEG_OPT_FILTER_SCRIPT
{ "filter_script", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
{ .off = OFFSET(filter_scripts) },
"deprecated, use -/filter", "filename" },
#endif
{ "reinit_filter", OPT_TYPE_INT, OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
{ .off = OFFSET(reinit_filters) },
"reinit filtergraph on input parameter changes", "" },
@@ -1836,11 +1761,6 @@ const OptionDef options[] = {
{ "lavfi", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
{ .func_arg = opt_filter_complex },
"create a complex filtergraph", "graph_description" },
#if FFMPEG_OPT_FILTER_SCRIPT
{ "filter_complex_script", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
{ .func_arg = opt_filter_complex_script },
"deprecated, use -/filter_complex instead", "filename" },
#endif
{ "print_graphs", OPT_TYPE_BOOL, 0,
{ &print_graphs },
"print execution graph data to stderr" },
@@ -1940,6 +1860,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" },
@@ -1987,7 +1913,7 @@ const OptionDef options[] = {
.u1.name_canon = "tag", },
{ "fps_mode", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
{ .off = OFFSET(fps_mode) },
"set framerate mode for matching video streams; overrides vsync" },
"set framerate mode for matching video streams" },
{ "force_fps", OPT_TYPE_BOOL, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
{ .off = OFFSET(force_fps) },
"force the selected framerate, disable the best supported framerate selection" },
@@ -2172,27 +2098,5 @@ const OptionDef options[] = {
{ .func_arg = opt_filter_hw_device },
"set hardware device used when filtering", "device" },
// deprecated options
#if FFMPEG_OPT_ADRIFT_THRESHOLD
{ "adrift_threshold", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
{ .func_arg = opt_adrift_threshold },
"deprecated, does nothing", "threshold" },
#endif
#if FFMPEG_OPT_TOP
{ "top", OPT_TYPE_INT, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
{ .off = OFFSET(top_field_first) },
"deprecated, use the setfield video filter", "" },
#endif
#if FFMPEG_OPT_QPHIST
{ "qphist", OPT_TYPE_FUNC, OPT_VIDEO | OPT_EXPERT,
{ .func_arg = opt_qphist },
"deprecated, does nothing" },
#endif
#if FFMPEG_OPT_VSYNC
{ "vsync", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
{ .func_arg = opt_vsync },
"set video sync method globally; deprecated, use -fps_mode", "" },
#endif
{ NULL, },
};
+164 -53
View File
@@ -32,6 +32,7 @@
#include "libavcodec/packet.h"
#include "libavutil/avassert.h"
#include "libavutil/container_fifo.h"
#include "libavutil/error.h"
#include "libavutil/fifo.h"
#include "libavutil/frame.h"
@@ -86,6 +87,7 @@ typedef struct SchDec {
unsigned nb_outputs;
SchTask task;
SchWaiter waiter;
// Queue for receiving input packets, one stream.
ThreadQueue *queue;
@@ -95,6 +97,9 @@ typedef struct SchDec {
// temporary storage used by sch_dec_send()
AVFrame *send_frame;
// internal queue of undecoded packets used by sch_dec_receive()
AVContainerFifo *overflow;
} SchDec;
typedef struct SchSyncQueue {
@@ -435,7 +440,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;
@@ -445,7 +450,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;
@@ -457,6 +462,26 @@ 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];
@@ -528,6 +553,7 @@ void sch_free(Scheduler **psch)
tq_free(&dec->queue);
av_thread_message_queue_free(&dec->queue_end_ts);
av_container_fifo_free(&dec->overflow);
for (unsigned j = 0; j < dec->nb_outputs; j++) {
SchDecOutput *o = &dec->outputs[j];
@@ -539,6 +565,8 @@ void sch_free(Scheduler **psch)
av_freep(&dec->outputs);
av_frame_free(&dec->send_frame);
waiter_uninit(&dec->waiter);
}
av_freep(&sch->dec);
@@ -789,6 +817,14 @@ int sch_add_dec(Scheduler *sch, SchThreadFunc func, void *ctx, int send_end_ts)
return ret;
}
dec->overflow = av_container_fifo_alloc_avpacket(0);
if (!dec->overflow)
return AVERROR(ENOMEM);
ret = waiter_init(&dec->waiter);
if (ret < 0)
return ret;
return idx;
}
@@ -1282,7 +1318,15 @@ int sch_mux_sub_heartbeat_add(Scheduler *sch, unsigned mux_idx, unsigned stream_
return 0;
}
static void unchoke_for_stream(Scheduler *sch, SchedulerNode src);
enum {
UNCHOKE_DEMUX = (1 << 0),
UNCHOKE_FILTER = (1 << 1),
UNCHOKE_DECODE = (1 << 2),
UNCHOKE_ALL = UNCHOKE_DEMUX | UNCHOKE_FILTER | UNCHOKE_DECODE,
};
static void unchoke_for_stream(Scheduler *sch, SchedulerNode src, int flags);
// Unchoke any filter graphs that are downstream of this node, to prevent it
// from getting stuck trying to push data to a full queue
@@ -1294,8 +1338,10 @@ static void unchoke_downstream(Scheduler *sch, SchedulerNode *dst)
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);
if (!dec->waiter.choked_next) {
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];
@@ -1311,8 +1357,8 @@ static void unchoke_downstream(Scheduler *sch, SchedulerNode *dst)
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);
// input from a different upstream source
unchoke_for_stream(sch, fg->inputs[fg->best_input].src, UNCHOKE_ALL);
}
break;
default:
@@ -1321,23 +1367,30 @@ static void unchoke_downstream(Scheduler *sch, SchedulerNode *dst)
}
}
static void unchoke_for_stream(Scheduler *sch, SchedulerNode src)
static void unchoke_for_stream(Scheduler *sch, SchedulerNode src, int flags)
{
while (1) {
SchFilterGraph *fg;
SchDemux *demux;
SchDec *dec;
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);
if (flags & UNCHOKE_DEMUX) {
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;
dec = &sch->dec[src.idx];
if (!(flags & UNCHOKE_DECODE))
return;
dec->waiter.choked_next = 0;
src = dec->src;
continue;
case SCH_NODE_TYPE_ENC:
src = sch->enc[src.idx].src;
@@ -1347,7 +1400,8 @@ static void unchoke_for_stream(Scheduler *sch, SchedulerNode src)
// the filtergraph contains internal sources and
// requested to be scheduled directly
if (fg->best_input == fg->nb_inputs) {
fg->waiter.choked_next = 0;
if (flags & UNCHOKE_FILTER)
fg->waiter.choked_next = 0;
return;
}
src = fg->inputs[fg->best_input].src;
@@ -1399,17 +1453,23 @@ 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++)
for (unsigned i = 0; i < (type ? sch->nb_filters : sch->nb_demux); i++) {
SchWaiter *w = type ? &sch->filters[i].waiter : &sch->demux[i].waiter;
w->choked_prev = atomic_load(&w->choked);
w->choked_next = 1;
}
#define RESET_WAITER(field) \
do { \
for (unsigned i = 0; i < sch->nb_##field; i++) { \
SchWaiter *w = &sch->field[i].waiter; \
w->choked_prev = atomic_load(&w->choked); \
w->choked_next = 1; \
} \
} while (0)
RESET_WAITER(demux);
RESET_WAITER(filters);
RESET_WAITER(dec);
// figure out the sources that are allowed to proceed
for (unsigned i = 0; i < sch->nb_mux; i++) {
@@ -1420,15 +1480,18 @@ static void schedule_update_locked(Scheduler *sch)
// unblock sources for output streams that are not finished
// and not too far ahead of the trailing stream
if (ms->source_finished)
if (ms->source_finished) {
// still allow decoders to drain
unchoke_for_stream(sch, ms->src, UNCHOKE_DECODE);
continue;
}
if (dts == AV_NOPTS_VALUE && ms->last_dts != AV_NOPTS_VALUE)
continue;
if (dts != AV_NOPTS_VALUE && ms->last_dts - dts >= SCHEDULE_TOLERANCE)
continue;
// resolve the source to unchoke
unchoke_for_stream(sch, ms->src);
unchoke_for_stream(sch, ms->src, UNCHOKE_ALL);
have_unchoked = 1;
}
}
@@ -1441,33 +1504,41 @@ static void schedule_update_locked(Scheduler *sch)
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);
unchoke_for_stream(sch, fi->src, UNCHOKE_ALL);
}
}
// 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++) {
int exited = type ? sch->filters[i].task_exited : sch->demux[i].task_exited;
SchWaiter *w = type ? &sch->filters[i].waiter : &sch->demux[i].waiter;
if (!exited) {
w->choked_next = 0;
have_unchoked = 1;
break;
}
}
#define UNCHOKE_ONCE(field) \
do { \
for (unsigned i = 0; !have_unchoked && i < sch->nb_##field; i++) { \
SchWaiter *w = &sch->field[i].waiter; \
if (!sch->field[i].task_exited) { \
w->choked_next = 0; \
have_unchoked = 1; \
break; \
} \
} \
} while (0)
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) {
waiter_set(w, w->choked_next);
if (!type)
choke_demux(sch, i, w->choked_next);
}
}
}
UNCHOKE_ONCE(demux);
UNCHOKE_ONCE(filters);
#define UPDATE_WAITER(field) \
do { \
for (unsigned i = 0; i < sch->nb_##field; i++) { \
SchWaiter *w = &sch->field[i].waiter; \
if (w->choked_prev != w->choked_next) { \
waiter_set(w, w->choked_next); \
if (offsetof(Scheduler, field) == offsetof(Scheduler, demux)) \
choke_demux(sch, i, w->choked_next); \
} \
} \
} while (0)
UPDATE_WAITER(demux);
UPDATE_WAITER(filters);
UPDATE_WAITER(dec);
}
enum {
@@ -2186,7 +2257,7 @@ int sch_mux_receive(Scheduler *sch, unsigned mux_idx, AVPacket *pkt)
av_assert0(mux_idx < sch->nb_mux);
mux = &sch->mux[mux_idx];
ret = tq_receive(mux->queue, &stream_idx, pkt);
ret = tq_receive(mux->queue, &stream_idx, pkt, 0);
pkt->stream_index = stream_idx;
return ret;
}
@@ -2270,6 +2341,12 @@ int sch_dec_receive(Scheduler *sch, unsigned dec_idx, AVPacket *pkt)
av_assert0(dec_idx < sch->nb_dec);
dec = &sch->dec[dec_idx];
retry:
// Pull a packet from the overflow FIFO while unchoked or expecting EOF ts
if (av_container_fifo_can_read(dec->overflow) &&
(!atomic_load(&dec->waiter.choked) || dec->expect_end_ts))
return av_container_fifo_read(dec->overflow, pkt, 0);
// the decoder should have given us post-flush end timestamp in pkt
if (dec->expect_end_ts) {
Timestamp ts = (Timestamp){ .ts = pkt->pts, .tb = pkt->time_base };
@@ -2280,14 +2357,32 @@ int sch_dec_receive(Scheduler *sch, unsigned dec_idx, AVPacket *pkt)
dec->expect_end_ts = 0;
}
ret = tq_receive(dec->queue, &dummy, pkt);
ret = tq_receive(dec->queue, &dummy, pkt, 0);
av_assert0(dummy <= 0);
// drain packets from overflow queue before returning EOF
if (ret == AVERROR_EOF && av_container_fifo_can_read(dec->overflow)) {
int terminate = waiter_wait(sch, &dec->waiter);
if (terminate)
return ret;
return av_container_fifo_read(dec->overflow, pkt, 0);
} else if (ret < 0)
return ret;
// got a flush packet, on the next call to this function the decoder
// will give us post-flush end timestamp
if (ret >= 0 && !pkt->data && !pkt->side_data_elems && dec->queue_end_ts)
// should give us post-flush end timestamp (after draining overflow fifo)
if (!pkt->data && !pkt->side_data_elems && dec->queue_end_ts)
dec->expect_end_ts = 1;
// we got a packet, but we're currently choked or have existing overflow
// packets; so push it to the FIFO first
if (atomic_load(&dec->waiter.choked) || av_container_fifo_can_read(dec->overflow)) {
ret = av_container_fifo_write(dec->overflow, pkt, 0);
if (ret < 0)
return ret;
goto retry;
}
return ret;
}
@@ -2421,7 +2516,7 @@ int sch_enc_receive(Scheduler *sch, unsigned enc_idx, AVFrame *frame)
av_assert0(enc_idx < sch->nb_enc);
enc = &sch->enc[enc_idx];
ret = tq_receive(enc->queue, &dummy, frame);
ret = tq_receive(enc->queue, &dummy, frame, 0);
av_assert0(dummy <= 0);
return ret;
@@ -2510,6 +2605,7 @@ int sch_filter_receive(Scheduler *sch, unsigned fg_idx,
unsigned *in_idx, AVFrame *frame)
{
SchFilterGraph *fg;
int ret, idx;
av_assert0(fg_idx < sch->nb_filters);
fg = &sch->filters[fg_idx];
@@ -2530,14 +2626,20 @@ int sch_filter_receive(Scheduler *sch, unsigned fg_idx,
}
if (*in_idx == fg->nb_inputs) {
// drain incoming frames before waiting, to avoid blocking downstream
ret = tq_receive(fg->queue, &idx, frame, THREAD_QUEUE_FLAG_NO_BLOCK);
if (ret >= 0) {
av_assert0(idx >= 0);
*in_idx = idx;
return 0;
}
int terminate = waiter_wait(sch, &fg->waiter);
return terminate ? AVERROR_EOF : AVERROR(EAGAIN);
}
while (1) {
int ret, idx;
ret = tq_receive(fg->queue, &idx, frame);
ret = tq_receive(fg->queue, &idx, frame, 0);
if (idx < 0)
return AVERROR_EOF;
else if (ret >= 0) {
@@ -2724,6 +2826,10 @@ int sch_stop(Scheduler *sch, int64_t *finish_ts)
atomic_store(&sch->terminate, 1);
// Ensure no other thread is currently in schedule_update_locked while
// we are choking all demuxers
pthread_mutex_lock(&sch->schedule_lock);
for (unsigned type = 0; type < 2; type++)
for (unsigned i = 0; i < (type ? sch->nb_demux : sch->nb_filters); i++) {
SchWaiter *w = type ? &sch->demux[i].waiter : &sch->filters[i].waiter;
@@ -2732,6 +2838,11 @@ int sch_stop(Scheduler *sch, int64_t *finish_ts)
choke_demux(sch, i, 0); // unfreeze to allow draining
}
for (unsigned i = 0; i < sch->nb_dec; i++)
waiter_set(&sch->dec[i].waiter, 0); // unfreeze to allow draining
pthread_mutex_unlock(&sch->schedule_lock);
for (unsigned i = 0; i < sch->nb_demux; i++) {
SchDemux *d = &sch->demux[i];
@@ -2768,7 +2879,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;
+18 -9
View File
@@ -3007,6 +3007,7 @@ static int read_thread(void *arg)
// 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));
@@ -3175,16 +3176,24 @@ static int read_thread(void *arg)
is->eof = 0;
}
if (show_status && 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);
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 */
+22 -3
View File
@@ -23,9 +23,7 @@
#include "ffplay_renderer.h"
#if (SDL_VERSION_ATLEAST(2, 0, 6) && CONFIG_LIBPLACEBO)
/* Get PL_API_VER */
#include <libplacebo/config.h>
#define HAVE_VULKAN_RENDERER (PL_API_VER >= 278)
#define HAVE_VULKAN_RENDERER 1
#else
#define HAVE_VULKAN_RENDERER 0
#endif
@@ -43,6 +41,7 @@
#include "libavutil/bprint.h"
#include "libavutil/mem.h"
#include "libavutil/internal.h"
#endif
@@ -115,14 +114,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,
@@ -283,7 +290,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,
@@ -292,7 +303,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)
@@ -386,8 +401,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;
+188 -55
View File
@@ -39,6 +39,7 @@
#include "libavutil/avutil.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/downmix_info.h"
#include "libavutil/display.h"
#include "libavutil/film_grain_params.h"
#include "libavutil/hdr_dynamic_metadata.h"
@@ -215,6 +216,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,
@@ -298,7 +301,7 @@ static const 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" },
@@ -307,6 +310,8 @@ static const 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" },
@@ -340,12 +345,11 @@ static const char *print_input_filename;
static const AVInputFormat *iformat = NULL;
static const char *output_filename = NULL;
static const char unit_second_str[] = "s" ;
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;
@@ -432,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__); \
@@ -451,7 +455,9 @@ static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
#define print_ts(k, v) avtext_print_ts(tfc, k, v, 0)
#define print_duration_time(k, v, tb) avtext_print_time(tfc, k, v, tb, 1)
#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)
#define print_val(k, v, u) avtext_print_unit_integer(tfc, k, v, AV_TEXTFORMAT_VALUE_FMT_INT, u)
#define print_int_fmt(k, v, f, u) avtext_print_unit_integer(tfc, k, v, f, u)
#define print_decibel(k, v) avtext_print_unit_double(tfc, k, v, AV_TEXTFORMAT_VALUE_FMT_DECIBEL, 0)
static void print_integers(AVTextFormatContext *tfc, const char *key,
const void *data, int size, const char *format,
@@ -503,6 +509,30 @@ static inline int show_tags(AVTextFormatContext *tfc, AVDictionary *tags, int se
return ret;
}
static void print_downmix_info(AVTextFormatContext *tfc,
const AVDownmixInfo *downmix_info)
{
switch (downmix_info->preferred_downmix_type) {
case AV_DOWNMIX_TYPE_LORO:
print_str("preferred_downmix_type", "loro");
break;
case AV_DOWNMIX_TYPE_LTRT:
print_str("preferred_downmix_type", "ltrt");
break;
case AV_DOWNMIX_TYPE_DPLII:
print_str("preferred_downmix_type", "dplII");
break;
default:
print_str("preferred_downmix_type", "unknown");
break;
}
print_decibel("center_mix_level_db", downmix_info->center_mix_level);
print_decibel("center_mix_level_ltrt_db", downmix_info->center_mix_level_ltrt);
print_decibel("surround_mix_level_db", downmix_info->surround_mix_level);
print_decibel("surround_mix_level_ltrt_db", downmix_info->surround_mix_level_ltrt);
print_decibel("lfe_mix_level_db", downmix_info->lfe_mix_level);
}
static void print_displaymatrix(AVTextFormatContext *tfc, const int32_t matrix[9])
{
double rotation = av_display_rotation_get(matrix);
@@ -801,6 +831,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)
@@ -942,7 +1028,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;
@@ -1008,7 +1094,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)
{
@@ -1034,7 +1121,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);
@@ -1281,7 +1368,7 @@ static void show_packet(AVTextFormatContext *tfc, InputFile *ifile, AVPacket *pk
print_time("dts_time", pkt->dts, &st->time_base);
print_duration_ts("duration", pkt->duration);
print_duration_time("duration_time", pkt->duration, &st->time_base);
print_val("size", pkt->size, unit_byte_str);
print_int_fmt("size", pkt->size, AV_TEXTFORMAT_VALUE_FMT_BYTE, unit_byte_str);
if (pkt->pos != -1) print_fmt ("pos", "%"PRId64, pkt->pos);
else print_str_opt("pos", "N/A");
print_fmt("flags", "%c%c%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_',
@@ -1305,7 +1392,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);
}
@@ -1341,6 +1428,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)
@@ -1354,7 +1444,9 @@ static void print_frame_side_data(AVTextFormatContext *tfc,
avtext_print_section_header(tfc, sd, SECTION_ID_FRAME_SIDE_DATA);
name = av_frame_side_data_name(sd->type);
print_str("side_data_type", name ? name : "unknown");
if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
if (sd->type == AV_FRAME_DATA_DOWNMIX_INFO) {
print_downmix_info(tfc, (AVDownmixInfo *)sd->data);
} else if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
print_displaymatrix(tfc, (const int32_t*)sd->data);
} else if (sd->type == AV_FRAME_DATA_AFD && sd->size > 0) {
print_int("active_format", *sd->data);
@@ -1379,6 +1471,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) {
@@ -1400,6 +1495,11 @@ static void print_frame_side_data(AVTextFormatContext *tfc,
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);
}
@@ -1433,7 +1533,7 @@ static void show_frame(AVTextFormatContext *tfc, AVFrame *frame, AVStream *strea
print_duration_time("duration_time", frame->duration, &stream->time_base);
if (fd && fd->pkt_pos != -1) print_fmt ("pkt_pos", "%"PRId64, fd->pkt_pos);
else print_str_opt("pkt_pos", "N/A");
if (fd && fd->pkt_size != -1) print_val ("pkt_size", fd->pkt_size, unit_byte_str);
if (fd && fd->pkt_size != -1) print_int_fmt("pkt_size", fd->pkt_size, AV_TEXTFORMAT_VALUE_FMT_BYTE, unit_byte_str);
else print_str_opt("pkt_size", "N/A");
switch (stream->codecpar->codec_type) {
@@ -1696,12 +1796,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);
}
}
@@ -1715,17 +1813,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;
@@ -1738,7 +1852,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)
@@ -1961,7 +2075,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);
}
@@ -1978,10 +2092,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)
@@ -1995,7 +2109,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);
@@ -2009,7 +2123,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)
@@ -2026,10 +2140,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;
@@ -2053,7 +2167,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);
@@ -2061,6 +2175,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);
}
@@ -2068,12 +2191,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);
@@ -2082,7 +2214,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: {
@@ -2116,7 +2248,9 @@ 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,
@@ -2131,7 +2265,7 @@ static void print_iamf_audio_element_params(AVTextFormatContext *tfc, const AVSt
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);
@@ -2167,7 +2301,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);
@@ -2190,7 +2324,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);
@@ -2220,7 +2354,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
@@ -2242,7 +2376,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);
@@ -2267,7 +2401,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)
@@ -2285,10 +2419,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);
@@ -2302,10 +2436,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);
@@ -2342,7 +2476,7 @@ static int show_format(AVTextFormatContext *tfc, InputFile *ifile)
}
print_time("start_time", fmt_ctx->start_time, &AV_TIME_BASE_Q);
print_time("duration", fmt_ctx->duration, &AV_TIME_BASE_Q);
if (size >= 0) print_val ("size", size, unit_byte_str);
if (size >= 0) print_int_fmt("size", size, AV_TEXTFORMAT_VALUE_FMT_BYTE, unit_byte_str);
else print_str_opt("size", "N/A");
if (fmt_ctx->bit_rate > 0) print_val ("bit_rate", fmt_ctx->bit_rate, unit_bit_per_second_str);
else print_str_opt("bit_rate", "N/A");
@@ -2425,7 +2559,7 @@ static const AVCodec *get_decoder_for_stream(AVFormatContext *fmt_ctx, AVStream
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;
@@ -2466,7 +2600,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);
@@ -2484,7 +2618,7 @@ 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;
@@ -2542,10 +2676,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);
@@ -2558,7 +2691,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;
@@ -2578,7 +2711,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],
@@ -2796,9 +2929,9 @@ static inline void mark_section_show_entries(SectionID section_id,
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))) {
@@ -3238,7 +3371,7 @@ int main(int argc, char **argv)
char *buf;
char *f_name = NULL, *f_args = NULL;
int ret, input_ret;
AVTextFormatDataDump data_dump_format_id;
AVTextFormatDataDump data_dump_format_id = AV_TEXTFORMAT_DATADUMP_XXD;
init_dynload();
+2 -1
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"
@@ -140,7 +141,7 @@ typedef struct GraphPrintContext {
#define print_q(k, v, s) avtext_print_rational(tfc, k, v, s)
#define print_str(k, v) avtext_print_string(tfc, k, v, 0)
#define print_str_opt(k, v) avtext_print_string(tfc, k, v, gpc->opt_flags)
#define print_val(k, v, u) avtext_print_unit_integer(tfc, k, v, u)
#define print_val(k, v, u) avtext_print_unit_integer(tfc, k, v, AV_TEXTFORMAT_VALUE_FMT_INT, u)
#define print_fmt(k, f, ...) do { \
av_bprint_clear(&gpc->pbuf); \
+20 -9
View File
@@ -68,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;
@@ -321,6 +326,12 @@ static void print_codec(const AVCodec *c)
printf("hardware ");
if (c->capabilities & AV_CODEC_CAP_HYBRID)
printf("hybrid ");
if (c->capabilities & AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE)
printf("reorderedopaque ");
if (c->capabilities & AV_CODEC_CAP_ENCODER_FLUSH)
printf("flush ");
if (c->capabilities & AV_CODEC_CAP_ENCODER_RECON_FRAME)
printf("reconframe ");
if (!c->capabilities)
printf("none");
printf("\n");
@@ -591,9 +602,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")) {
@@ -708,16 +719,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;
}
}
@@ -774,12 +785,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)
@@ -876,7 +887,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);
+38 -17
View File
@@ -18,19 +18,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/mem.h"
#include "libavutil/avassert.h"
#include "libavutil/avutil.h"
#include "libavutil/base64.h"
#include "libavutil/bprint.h"
#include "libavutil/common.h"
#include "libavutil/error.h"
#include "libavutil/hash.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/macros.h"
#include "libavutil/opt.h"
#include "avtextformat.h"
@@ -238,12 +240,7 @@ fail:
return ret;
}
/* Temporary definitions during refactoring */
static const char unit_second_str[] = "s";
static const char unit_hertz_str[] = "Hz";
static const char unit_byte_str[] = "byte";
static const char unit_bit_per_second_str[] = "bit/s";
void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, int section_id)
{
@@ -367,24 +364,30 @@ struct unit_value {
int64_t i;
} val;
AVTextFormatValueFormat fmt;
const char *unit;
};
static const char float_fmt_full[] = "%f";
static const char float_fmt_singledigit[] = "%.1f";
static char *value_string(const AVTextFormatContext *tctx, char *buf, int buf_size, struct unit_value uv)
{
double vald;
int64_t vali = 0;
int show_float = 0;
const char *float_fmt = 0;
if (uv.unit == unit_second_str) {
if (uv.fmt == AV_TEXTFORMAT_VALUE_FMT_DECIBEL) {
vald = 20 * log10(uv.val.d);
float_fmt = float_fmt_singledigit;
} else if (uv.fmt >= AV_TEXTFORMAT_VALUE_FMT_DOUBLE) {
vald = uv.val.d;
show_float = 1;
float_fmt = float_fmt_full;
} else {
vald = (double)uv.val.i;
vali = uv.val.i;
}
if (uv.unit == unit_second_str && tctx->opts.use_value_sexagesimal_format) {
if (uv.fmt == AV_TEXTFORMAT_VALUE_FMT_SECOND && tctx->opts.use_value_sexagesimal_format) {
double secs;
int hours, mins;
secs = vald;
@@ -399,7 +402,7 @@ static char *value_string(const AVTextFormatContext *tctx, char *buf, int buf_si
if (tctx->opts.use_value_prefix && vald > 1) {
int64_t index;
if (uv.unit == unit_byte_str && tctx->opts.use_byte_value_binary_prefix) {
if (uv.fmt == AV_TEXTFORMAT_VALUE_FMT_BYTE && 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;
@@ -413,29 +416,46 @@ static char *value_string(const AVTextFormatContext *tctx, char *buf, int buf_si
vali = (int64_t)vald;
}
if (show_float || (tctx->opts.use_value_prefix && vald != (int64_t)vald))
snprintf(buf, buf_size, "%f", vald);
if (float_fmt || (tctx->opts.use_value_prefix && vald != (int64_t)vald))
snprintf(buf, buf_size, float_fmt ? float_fmt : "%f", vald);
else
snprintf(buf, buf_size, "%"PRId64, vali);
av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || tctx->opts.show_value_unit ? " " : "",
prefix_string, tctx->opts.show_value_unit ? uv.unit : "");
av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || tctx->opts.show_value_unit && uv.unit && *uv.unit ? " " : "",
prefix_string, tctx->opts.show_value_unit && uv.unit ? uv.unit : "");
}
return buf;
}
void avtext_print_unit_integer(AVTextFormatContext *tctx, const char *key, int64_t val, const char *unit)
void avtext_print_unit_integer(AVTextFormatContext *tctx, const char *key, int64_t val, AVTextFormatValueFormat fmt, const char *unit)
{
char val_str[128];
struct unit_value uv;
av_assert0(fmt < AV_TEXTFORMAT_VALUE_FMT_DOUBLE);
uv.val.i = val;
uv.fmt = fmt;
uv.unit = unit;
avtext_print_string(tctx, key, value_string(tctx, val_str, sizeof(val_str), uv), 0);
}
void avtext_print_unit_double(AVTextFormatContext *tctx, const char *key, double val, AVTextFormatValueFormat fmt, const char *unit)
{
char val_str[128];
struct unit_value uv;
av_assert0(fmt >= AV_TEXTFORMAT_VALUE_FMT_DOUBLE);
uv.val.d = val;
uv.fmt = fmt;
uv.unit = unit;
avtext_print_string(tctx, key, value_string(tctx, val_str, sizeof(val_str), uv), 0);
}
int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags)
{
const AVTextFormatSection *section;
@@ -495,6 +515,7 @@ void avtext_print_time(AVTextFormatContext *tctx, const char *key,
double d = av_q2d(*time_base) * ts;
struct unit_value uv;
uv.val.d = d;
uv.fmt = AV_TEXTFORMAT_VALUE_FMT_SECOND;
uv.unit = unit_second_str;
value_string(tctx, buf, sizeof(buf), uv);
avtext_print_string(tctx, key, buf, 0);
+11 -1
View File
@@ -161,6 +161,14 @@ struct AVTextFormatContext {
unsigned int string_validation_utf8_flags;
};
typedef enum {
AV_TEXTFORMAT_VALUE_FMT_INT,
AV_TEXTFORMAT_VALUE_FMT_BYTE,
AV_TEXTFORMAT_VALUE_FMT_DOUBLE = 0x100,
AV_TEXTFORMAT_VALUE_FMT_SECOND,
AV_TEXTFORMAT_VALUE_FMT_DECIBEL,
} AVTextFormatValueFormat;
#define AV_TEXTFORMAT_PRINT_STRING_OPTIONAL 1
#define AV_TEXTFORMAT_PRINT_STRING_VALIDATE 2
@@ -178,7 +186,9 @@ void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t va
int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags);
void avtext_print_unit_integer(AVTextFormatContext *tctx, const char *key, int64_t val, const char *unit);
void avtext_print_unit_integer(AVTextFormatContext *tctx, const char *key, int64_t val, AVTextFormatValueFormat fmt, const char *unit);
void avtext_print_unit_double(AVTextFormatContext *tctx, const char *key, double val, AVTextFormatValueFormat fmt, const char *unit);
void avtext_print_rational(AVTextFormatContext *tctx, const char *key, AVRational q, char sep);
+2 -2
View File
@@ -18,13 +18,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <inttypes.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "avtextformat.h"
#include "libavutil/avutil.h"
#include "libavutil/bprint.h"
#include "libavutil/error.h"
#include "libavutil/opt.h"
+2 -1
View File
@@ -18,13 +18,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <inttypes.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "avtextformat.h"
#include "libavutil/avutil.h"
#include "libavutil/bprint.h"
#include "libavutil/opt.h"
#include "tf_internal.h"
+1 -2
View File
@@ -18,10 +18,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <inttypes.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "avtextformat.h"
+3 -4
View File
@@ -18,14 +18,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <inttypes.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "avtextformat.h"
#include "libavutil/attributes.h"
#include "libavutil/bprint.h"
#include "libavutil/opt.h"
#include "tf_internal.h"
@@ -74,7 +73,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);
+1 -2
View File
@@ -18,10 +18,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <inttypes.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "avtextformat.h"
+1 -2
View File
@@ -18,10 +18,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <inttypes.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "avtextformat.h"
+2 -2
View File
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include <string.h>
#include <inttypes.h>
#include <stddef.h>
#include "avtextformat.h"
#include "libavutil/bprint.h"
+2 -2
View File
@@ -194,7 +194,7 @@ static int receive_locked(ThreadQueue *tq, int *stream_idx,
return nb_finished == tq->nb_streams ? AVERROR_EOF : AVERROR(EAGAIN);
}
int tq_receive(ThreadQueue *tq, int *stream_idx, void *data)
int tq_receive(ThreadQueue *tq, int *stream_idx, void *data, int flags)
{
int ret;
@@ -211,7 +211,7 @@ int tq_receive(ThreadQueue *tq, int *stream_idx, void *data)
if (can_read != av_container_fifo_can_read(tq->fifo))
pthread_cond_broadcast(&tq->cond);
if (ret == AVERROR(EAGAIN)) {
if (ret == AVERROR(EAGAIN) && !(flags & THREAD_QUEUE_FLAG_NO_BLOCK)) {
pthread_cond_wait(&tq->cond, &tq->lock);
continue;
}
+10 -1
View File
@@ -26,6 +26,12 @@ enum ThreadQueueType {
THREAD_QUEUE_PACKETS,
};
enum ThreadQueueFlags {
/* When set, tq_receive() will return AVERROR(EAGAIN) instead of blocking
* when the queue is empty or choked. */
THREAD_QUEUE_FLAG_NO_BLOCK = (1 << 0),
};
typedef struct ThreadQueue ThreadQueue;
/**
@@ -74,6 +80,8 @@ void tq_choke(ThreadQueue *tq, int choked);
* written here
* @param data the data item will be written here on success using the
* callback provided to tq_alloc()
* @param flags combination of THREAD_QUEUE_FLAG_*
*
* @return
* - 0 a data item was successfully read; *stream_idx contains a non-negative
* stream index
@@ -81,7 +89,8 @@ void tq_choke(ThreadQueue *tq, int choked);
* side has marked the given stream as finished. This will happen at most once
* for each stream. When *stream_idx is -1, all streams are done.
*/
int tq_receive(ThreadQueue *tq, int *stream_idx, void *data);
int tq_receive(ThreadQueue *tq, int *stream_idx, void *data, int flags);
/**
* Mark the given stream finished from the receiving side.
*/
+13 -16
View File
@@ -115,10 +115,9 @@ OBJS-$(CONFIG_H264PARSE) += h264_parse.o h264_ps.o h264data.o \
h2645data.o h2645_parse.o h2645_vui.o
OBJS-$(CONFIG_H264PRED) += h264pred.o
OBJS-$(CONFIG_H264QPEL) += h264qpel.o
OBJS-$(CONFIG_H264_SEI) += h264_sei.o h2645_sei.o aom_film_grain.o
OBJS-$(CONFIG_H264_SEI) += h264_sei.o h2645_sei.o
OBJS-$(CONFIG_HEVCPARSE) += h2645data.o h2645_parse.o h2645_vui.o
OBJS-$(CONFIG_HEVC_SEI) += h2645_sei.o aom_film_grain.o \
dynamic_hdr_vivid.o
OBJS-$(CONFIG_HEVC_SEI) += h2645_sei.o
OBJS-$(CONFIG_HPELDSP) += hpeldsp.o
OBJS-$(CONFIG_HUFFMAN) += huffman.o
OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o
@@ -126,11 +125,12 @@ OBJS-$(CONFIG_HUFFYUVENCDSP) += huffyuvencdsp.o
OBJS-$(CONFIG_IDCTDSP) += idctdsp.o simple_idct.o jrevdct.o
OBJS-$(CONFIG_INFLATE_WRAPPER) += zlib_wrapper.o
OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o msmpeg4_vc1_data.o
OBJS-$(CONFIG_ITUT_T35) += itut35.o aom_film_grain.o dynamic_hdr_vivid.o
OBJS-$(CONFIG_IVIDSP) += ivi_dsp.o
OBJS-$(CONFIG_JNI) += ffjni.o jni.o
OBJS-$(CONFIG_JPEGTABLES) += jpegtables.o
OBJS-$(CONFIG_LCMS2) += fflcms2.o
OBJS-$(CONFIG_LIBLCEVC_DEC) += lcevcdec.o
OBJS-$(CONFIG_LIBLCEVC_DEC) += lcevcdec.o lcevctab.o
OBJS-$(CONFIG_LLAUDDSP) += lossless_audiodsp.o
OBJS-$(CONFIG_LLVIDDSP) += lossless_videodsp.o
OBJS-$(CONFIG_LLVIDENCDSP) += lossless_videoencdsp.o
@@ -203,7 +203,7 @@ OBJS-$(CONFIG_AAC_FIXED_DECODER) += aactab.o \
sbrdsp_fixed.o aacpsdsp_fixed.o cbrt_data_fixed.o \
$(if $(!CONFIG_HARDCODED_TABLES), cbrt_tablegen_common.o)
OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o \
aacpsy.o aactab.o \
aacpsy.o aactab.o aacencdsp.o \
aacenc_is.o \
aacenc_tns.o \
psymodel.o kbdwin.o \
@@ -442,7 +442,6 @@ OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o
OBJS-$(CONFIG_H264_NVENC_ENCODER) += nvenc_h264.o nvenc.o
OBJS-$(CONFIG_H264_OH_DECODER) += ohcodec.o ohdec.o
OBJS-$(CONFIG_H264_OH_ENCODER) += ohcodec.o ohenc.o
OBJS-$(CONFIG_H264_OMX_ENCODER) += omx.o
OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec.o
OBJS-$(CONFIG_H264_QSV_ENCODER) += qsvenc_h264.o
OBJS-$(CONFIG_H264_RKMPP_DECODER) += rkmppdec.o
@@ -461,7 +460,7 @@ OBJS-$(CONFIG_HCA_DECODER) += hcadec.o
OBJS-$(CONFIG_HCOM_DECODER) += hcom.o
OBJS-$(CONFIG_HDR_DECODER) += hdrdec.o
OBJS-$(CONFIG_HDR_ENCODER) += hdrenc.o
OBJS-$(CONFIG_HEVC_DECODER) += aom_film_grain.o h274.o
OBJS-$(CONFIG_HEVC_DECODER) += h274.o
OBJS-$(CONFIG_HEVC_AMF_ENCODER) += amfenc_hevc.o
OBJS-$(CONFIG_HEVC_AMF_DECODER) += amfdec.o
OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuviddec.o
@@ -587,7 +586,6 @@ OBJS-$(CONFIG_MPEG4_ENCODER) += mpeg4videoenc.o
OBJS-$(CONFIG_MPEG4_CUVID_DECODER) += cuviddec.o
OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o
OBJS-$(CONFIG_MPEG4_MEDIACODEC_ENCODER) += mediacodecenc.o
OBJS-$(CONFIG_MPEG4_OMX_ENCODER) += omx.o
OBJS-$(CONFIG_MPEG4_V4L2M2M_DECODER) += v4l2_m2m_dec.o
OBJS-$(CONFIG_MPEG4_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
OBJS-$(CONFIG_MPL2_DECODER) += mpl2dec.o ass.o
@@ -626,6 +624,7 @@ OBJS-$(CONFIG_PBM_ENCODER) += pnmenc.o
OBJS-$(CONFIG_PCX_DECODER) += pcx.o
OBJS-$(CONFIG_PCX_ENCODER) += pcxenc.o
OBJS-$(CONFIG_PDV_DECODER) += pdvdec.o
OBJS-$(CONFIG_PDV_ENCODER) += pdvenc.o
OBJS-$(CONFIG_PFM_DECODER) += pnmdec.o pnm.o
OBJS-$(CONFIG_PFM_ENCODER) += pnmenc.o
OBJS-$(CONFIG_PGM_DECODER) += pnmdec.o pnm.o
@@ -723,9 +722,6 @@ OBJS-$(CONFIG_SNOW_ENCODER) += snowenc.o snow.o snow_dwt.o
h263data.o ituh263enc.o \
motion_est.o ratecontrol.o
OBJS-$(CONFIG_SOL_DPCM_DECODER) += dpcm.o
OBJS-$(CONFIG_SONIC_DECODER) += sonic.o
OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o
OBJS-$(CONFIG_SONIC_LS_ENCODER) += sonic.o
OBJS-$(CONFIG_SPEEDHQ_DECODER) += speedhqdec.o speedhq.o mpeg12.o \
mpeg12data.o
OBJS-$(CONFIG_SPEEDHQ_ENCODER) += speedhq.o mpeg12data.o mpeg12enc.o speedhqenc.o
@@ -836,7 +832,7 @@ OBJS-$(CONFIG_VP9_V4L2M2M_DECODER) += v4l2_m2m_dec.o
OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o
OBJS-$(CONFIG_VQC_DECODER) += vqcdec.o
OBJS-$(CONFIG_VVC_DECODER) += executor.o h2645data.o
OBJS-$(CONFIG_VVC_SEI) += h2645_sei.o aom_film_grain.o h274.o
OBJS-$(CONFIG_VVC_SEI) += h2645_sei.o h274.o
OBJS-$(CONFIG_WADY_DPCM_DECODER) += dpcm.o
OBJS-$(CONFIG_WAVARC_DECODER) += wavarc.o
OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o wavpackdata.o dsd.o
@@ -845,6 +841,7 @@ OBJS-$(CONFIG_WBMP_DECODER) += wbmpdec.o
OBJS-$(CONFIG_WBMP_ENCODER) += wbmpenc.o
OBJS-$(CONFIG_WCMV_DECODER) += wcmv.o
OBJS-$(CONFIG_WEBP_DECODER) += webp.o
OBJS-$(CONFIG_WEBP_ANIM_DECODER) += webp.o
OBJS-$(CONFIG_WEBVTT_DECODER) += webvttdec.o ass.o
OBJS-$(CONFIG_WEBVTT_ENCODER) += webvttenc.o ass_split.o
OBJS-$(CONFIG_WMALOSSLESS_DECODER) += wmalosslessdec.o wma_common.o
@@ -1046,6 +1043,7 @@ OBJS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.o
OBJS-$(CONFIG_VDPAU) += vdpau.o
OBJS-$(CONFIG_VULKAN) += vulkan.o vulkan_video.o
OBJS-$(CONFIG_APV_VULKAN_HWACCEL) += vulkan_decode.o vulkan_apv.o
OBJS-$(CONFIG_AV1_D3D11VA_HWACCEL) += dxva2_av1.o
OBJS-$(CONFIG_AV1_DXVA2_HWACCEL) += dxva2_av1.o
OBJS-$(CONFIG_AV1_D3D12VA_HWACCEL) += dxva2_av1.o d3d12va_av1.o
@@ -1127,7 +1125,7 @@ OBJS-$(CONFIG_FITS_DEMUXER) += fits.o
OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
# libavformat dependencies for static builds
STLIBOBJS-$(CONFIG_AVFORMAT) += to_upper4.o
STLIBOBJS-$(CONFIG_AVFORMAT) += h2645_parse.o lcevctab.o to_upper4.o
STLIBOBJS-$(CONFIG_ISO_MEDIA) += mpegaudiotabs.o
STLIBOBJS-$(CONFIG_FLV_MUXER) += mpeg4audio_sample_rates.o
STLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
@@ -1171,7 +1169,6 @@ OBJS-$(CONFIG_LIBAOM_AV1_DECODER) += libaomdec.o libaom.o
OBJS-$(CONFIG_LIBAOM_AV1_ENCODER) += libaomenc.o libaom.o
OBJS-$(CONFIG_LIBARIBB24_DECODER) += libaribb24.o ass.o
OBJS-$(CONFIG_LIBARIBCAPTION_DECODER) += libaribcaption.o ass.o
OBJS-$(CONFIG_LIBCELT_DECODER) += libcelt_dec.o
OBJS-$(CONFIG_LIBCODEC2_DECODER) += libcodec2.o
OBJS-$(CONFIG_LIBCODEC2_ENCODER) += libcodec2.o
OBJS-$(CONFIG_LIBDAV1D_DECODER) += libdav1d.o av1_parse.o
@@ -1277,7 +1274,7 @@ OBJS-$(CONFIG_IPU_PARSER) += ipu_parser.o
OBJS-$(CONFIG_JPEG2000_PARSER) += jpeg2000_parser.o
OBJS-$(CONFIG_JPEGXL_PARSER) += jpegxl_parser.o jpegxl_parse.o
OBJS-$(CONFIG_JPEGXS_PARSER) += jpegxs_parser.o
OBJS-$(CONFIG_LCEVC_PARSER) += lcevc_parser.o
OBJS-$(CONFIG_LCEVC_PARSER) += lcevc_parser.o lcevctab.o
OBJS-$(CONFIG_MISC4_PARSER) += misc4_parser.o
OBJS-$(CONFIG_MJPEG_PARSER) += mjpeg_parser.o
OBJS-$(CONFIG_MLP_PARSER) += mlp_parse.o mlp_parser.o mlp.o
@@ -1367,6 +1364,7 @@ TESTPROGS = avcodec \
bitstream_be \
bitstream_le \
codec_desc \
encinfo \
htmlsubtitles \
jpeg2000dwt \
mathops \
@@ -1379,7 +1377,6 @@ TESTPROGS-$(CONFIG_GOLOMB) += golomb
TESTPROGS-$(CONFIG_IDCTDSP) += dct
TESTPROGS-$(CONFIG_DXV_ENCODER) += hashtable
TESTPROGS-$(CONFIG_MJPEG_ENCODER) += mjpegenc_huffman
TESTPROGS-$(HAVE_MMX) += motion
TESTPROGS-$(CONFIG_MPEGVIDEO) += mpeg12framerate
TESTPROGS-$(CONFIG_H264_METADATA_BSF) += h264_levels
TESTPROGS-$(CONFIG_HEVC_METADATA_BSF) += h265_levels
+110 -17
View File
@@ -676,6 +676,7 @@ ChannelElement *ff_aac_get_che(AACDecContext *ac, int type, int elem_id)
ac->tags_mapped++;
return ac->tag_che_map[type][elem_id] = ac->che[type][elem_id];
}
av_fallthrough;
case 13:
if (ac->tags_mapped > 3 && ((type == TYPE_CPE && elem_id < 8) ||
(type == TYPE_SCE && elem_id < 6) ||
@@ -683,17 +684,20 @@ ChannelElement *ff_aac_get_che(AACDecContext *ac, int type, int elem_id)
ac->tags_mapped++;
return ac->tag_che_map[type][elem_id] = ac->che[type][elem_id];
}
av_fallthrough;
case 12:
case 7:
if (ac->tags_mapped == 3 && type == TYPE_CPE) {
ac->tags_mapped++;
return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2];
}
av_fallthrough;
case 11:
if (ac->tags_mapped == 3 && type == TYPE_SCE) {
ac->tags_mapped++;
return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
}
av_fallthrough;
case 6:
/* Some streams incorrectly code 5.1 audio as
* SCE[0] CPE[0] CPE[1] SCE[1]
@@ -711,11 +715,13 @@ ChannelElement *ff_aac_get_che(AACDecContext *ac, int type, int elem_id)
ac->tags_mapped++;
return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0];
}
av_fallthrough;
case 5:
if (ac->tags_mapped == 2 && type == TYPE_CPE) {
ac->tags_mapped++;
return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1];
}
av_fallthrough;
case 4:
/* Some streams incorrectly code 4.0 audio as
* SCE[0] CPE[0] LFE[0]
@@ -739,6 +745,7 @@ ChannelElement *ff_aac_get_che(AACDecContext *ac, int type, int elem_id)
ac->tags_mapped++;
return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
}
av_fallthrough;
case 3:
case 2:
if (ac->tags_mapped == (ac->oc[1].m4ac.chan_config != 2) &&
@@ -750,11 +757,13 @@ ChannelElement *ff_aac_get_che(AACDecContext *ac, int type, int elem_id)
ac->tags_mapped++;
return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
}
av_fallthrough;
case 1:
if (!ac->tags_mapped && type == TYPE_SCE) {
ac->tags_mapped++;
return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0];
}
av_fallthrough;
default:
return NULL;
}
@@ -822,8 +831,8 @@ static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac,
sampling_index = get_bits(gb, 4);
if (m4ac->sampling_index != sampling_index)
av_log(avctx, AV_LOG_WARNING,
"Sample rate index in program config element does not "
"match the sample rate index configured by the container.\n");
"Sample rate index (%d) in program config element does not "
"match the sample rate index (%d) configured by the container.\n", sampling_index, m4ac->sampling_index);
num_front = get_bits(gb, 4);
num_side = get_bits(gb, 4);
@@ -866,6 +875,91 @@ static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac,
av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err);
return AVERROR_INVALIDDATA;
}
// Height extension
int height_ext = 0;
if (comment_len >= 16 + (num_front * 2 + num_side * 2 + num_back * 2))
height_ext = show_bits(gb, 8) == 0xAC;
if (height_ext) {
uint8_t height_map[4 /* ChannelPosition */][16 /* Channel */]; // 0 == base, 1 == top, 2 == bottom.
uint8_t tag[6 /* ChannelPosition */ ][16 /* Channel */][3];
int i, invalid = 0, height_tags = 0;
skip_bits(gb, 8);
// Read height extension bits to height_map, which define which layer each element belongs to.
// Also make a copy of layout_map that will then be used to rearrange it.
for (i = 0; i < num_front; i++) {
int height = get_bits(gb, 2);
invalid |= height > 2;
height_map [AAC_CHANNEL_FRONT][i] = height;
memcpy(&tag[AAC_CHANNEL_FRONT][i], layout_map + height_tags, sizeof(*layout_map));
height_tags++;
}
for (i = 0; i < num_side; i++) {
int height = get_bits(gb, 2);
invalid |= height > 2;
height_map [AAC_CHANNEL_SIDE][i] = height;
memcpy(&tag[AAC_CHANNEL_SIDE][i], layout_map + height_tags, sizeof(*layout_map));
height_tags++;
}
for (i = 0; i < num_back; i++) {
int height = get_bits(gb, 2);
invalid |= height > 2;
height_map [AAC_CHANNEL_BACK][i] = height;
memcpy(&tag[AAC_CHANNEL_BACK][i], layout_map + height_tags, sizeof(*layout_map));
height_tags++;
}
for (i = 0; i < num_lfe; i++) {
memcpy(&tag[AAC_CHANNEL_LFE][i], layout_map + height_tags, sizeof(*layout_map));
height_tags++;
}
for (i = 0; i < num_cc; i++) {
memcpy(&tag[AAC_CHANNEL_CC][i], layout_map + height_tags, sizeof(*layout_map));
height_tags++;
}
av_assert0(height_tags == tags);
if (!invalid) {
height_tags = 0;
// For each height layer, check that an element belongs to it and copy it back to layout_map.
// We need to take into account LFE and CC elements that may be present.
for (i = 0; i < 3; i++) {
for (int j = 0; j < num_front; j++) {
if (height_map[AAC_CHANNEL_FRONT][j] == i) {
memcpy(layout_map + height_tags, &tag[AAC_CHANNEL_FRONT][j], sizeof(*layout_map));
height_tags++;
}
}
for (int j = 0; j < num_side; j++) {
if (height_map[AAC_CHANNEL_SIDE][j] == i) {
memcpy(layout_map + height_tags, &tag[AAC_CHANNEL_SIDE][j], sizeof(*layout_map));
height_tags++;
}
}
for (int j = 0; j < num_back; j++) {
if (height_map[AAC_CHANNEL_BACK][j] == i) {
memcpy(layout_map + height_tags, &tag[AAC_CHANNEL_BACK][j], sizeof(*layout_map));
height_tags++;
}
}
if (i == 0) { // Base height, copy LFE and CC elements before moving to Top and Bottom
for (int j = 0; j < num_lfe; j++) {
memcpy(layout_map + height_tags, &tag[AAC_CHANNEL_LFE][j], sizeof(*layout_map));
height_tags++;
}
for (int j = 0; j < num_cc; j++) {
memcpy(layout_map + height_tags, &tag[AAC_CHANNEL_CC][j], sizeof(*layout_map));
height_tags++;
}
}
}
av_assert0(height_tags == tags);
}
comment_len -= 8 + (num_front * 2 + num_side * 2 + num_back * 2);
}
skip_bits_long(gb, comment_len);
return tags;
}
@@ -889,12 +983,6 @@ static int decode_ga_specific_config(AACDecContext *ac, AVCodecContext *avctx,
int tags = 0;
m4ac->frame_length_short = get_bits1(gb);
if (m4ac->frame_length_short && m4ac->sbr == 1) {
avpriv_report_missing_feature(avctx, "SBR with 960 frame length");
if (ac) ac->warned_960_sbr = 1;
m4ac->sbr = 0;
m4ac->ps = 0;
}
if (get_bits1(gb)) // dependsOnCoreCoder
skip_bits(gb, 14); // coreCoderDelay
@@ -1246,7 +1334,7 @@ av_cold int ff_aac_decode_init(AVCodecContext *avctx)
ac->oc[1].m4ac.chan_config = i;
if (ac->oc[1].m4ac.chan_config) {
int ret = ff_aac_set_default_channel_config(ac, avctx, layout_map,
ret = ff_aac_set_default_channel_config(ac, avctx, layout_map,
&layout_map_tags,
ac->oc[1].m4ac.chan_config);
if (!ret)
@@ -1946,17 +2034,11 @@ static int decode_extension_payload(AACDecContext *ac, GetBitContext *gb, int cn
switch (type) { // extension type
case EXT_SBR_DATA_CRC:
crc_flag++;
av_fallthrough;
case EXT_SBR_DATA:
if (!che) {
av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first channel element.\n");
return res;
} else if (ac->oc[1].m4ac.frame_length_short) {
if (!ac->warned_960_sbr)
avpriv_report_missing_feature(ac->avctx,
"SBR with 960 frame length");
ac->warned_960_sbr = 1;
skip_bits_long(gb, 8 * cnt - 4);
return res;
} else if (!ac->oc[1].m4ac.sbr) {
av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n");
skip_bits_long(gb, 8 * cnt - 4);
@@ -1977,7 +2059,8 @@ static int decode_extension_payload(AACDecContext *ac, GetBitContext *gb, int cn
ac->avctx->profile = AV_PROFILE_AAC_HE;
}
ac->proc.sbr_decode_extension(ac, che, gb, crc_flag, cnt, elem_type);
ac->proc.sbr_decode_extension(ac, che, gb, crc_flag, cnt, elem_type,
ac->oc[1].m4ac.frame_length_short);
if (ac->oc[1].m4ac.ps == 1 && !ac->warned_he_aac_mono) {
av_log(ac->avctx, AV_LOG_VERBOSE, "Treating HE-AAC mono as stereo.\n");
@@ -2087,6 +2170,7 @@ static void spectral_to_sample(AACDecContext *ac, int samples)
}
if (ac->oc[1].m4ac.sbr > 0) {
ac->proc.sbr_apply(ac, che, type,
ac->oc[1].m4ac.frame_length_short,
che->ch[0].output,
che->ch[1].output);
}
@@ -2383,6 +2467,12 @@ static int decode_frame_ga(AVCodecContext *avctx, AACDecContext *ac,
ac->oc[1].status = OC_LOCKED;
}
if (samples && avctx->sample_rate <= 0) {
av_log(avctx, AV_LOG_ERROR,
"Cannot output a frame without a valid sample rate\n");
return AVERROR_INVALIDDATA;
}
if (!ac->frame->data[0] && samples) {
av_log(avctx, AV_LOG_ERROR, "no frame data found\n");
return AVERROR_INVALIDDATA;
@@ -2558,6 +2648,9 @@ static const AVOption options[] = {
{ "coded", "order in which the channels are coded in the bitstream",
0, AV_OPT_TYPE_CONST, { .i64 = CHANNEL_ORDER_CODED }, .flags = AACDEC_FLAGS, .unit = "channel_order" },
{ "target_level", "Target output loudness in dBFS for xHE-AAC normalization (0 = disabled)",
OFF(target_level), AV_OPT_TYPE_INT, { .i64 = 0 }, -70, 0, AACDEC_FLAGS },
{NULL},
};
+31 -4
View File
@@ -98,6 +98,12 @@ enum AACUSACLoudnessExt {
UNIDRCLOUDEXT_EQ = 0x1,
};
enum AACUSACDRCExt {
UNIDRCCONFEXT_TERM = 0x0,
UNIDRCCONFEXT_PARAM_DRC = 0x1,
UNIDRCCONFEXT_V1 = 0x2,
};
// Supposed to be equal to AAC_RENAME() in case of USE_FIXED.
#define RENAME_FIXED(name) name ## _fixed
@@ -302,6 +308,7 @@ typedef struct ChannelElement {
typedef struct AACUSACLoudnessInfo {
uint8_t drc_set_id : 6;
uint8_t eq_set_id : 6; /* loudnessInfoV1() only, 0 otherwise */
uint8_t downmix_id : 7;
struct {
uint16_t lvl : 12;
@@ -377,6 +384,13 @@ typedef struct AACUsacElemConfig {
uint32_t pl_data_offset;
uint8_t *pl_buf;
} ext;
struct {
struct {
int lower;
int upper;
} loudness;
} drc;
} AACUsacElemConfig;
typedef struct AACUSACConfig {
@@ -392,6 +406,13 @@ typedef struct AACUSACConfig {
AACUSACLoudnessInfo album_info[64];
uint8_t nb_info;
AACUSACLoudnessInfo info[64];
/**
* Raw bsMethodValue (μ) of the program/anchor-loudness measurement
* selected for normalization at config time. -1 == none found.
* L_LKFS = -57.75 + 0.25 * input_method_val.
*/
int input_method_val;
} loudness;
} AACUSACConfig;
@@ -433,9 +454,9 @@ typedef struct AACDecProc {
int (*sbr_ctx_alloc_init)(AACDecContext *ac, ChannelElement **che, int id_aac);
int (*sbr_decode_extension)(AACDecContext *ac, ChannelElement *che,
GetBitContext *gb, int crc, int cnt, int id_aac);
void (*sbr_apply)(AACDecContext *ac, ChannelElement *che,
int id_aac, void /* INTFLOAT */ *L, void /* INTFLOAT */ *R);
GetBitContext *gb, int crc, int cnt, int id_aac, int fl960);
void (*sbr_apply)(AACDecContext *ac, ChannelElement *che, int id_aac, int fl960,
void /* INTFLOAT */ *L, void /* INTFLOAT */ *R);
void (*sbr_ctx_close)(ChannelElement *che);
} AACDecProc;
@@ -555,9 +576,15 @@ struct AACDecContext {
enum AACOutputChannelOrder output_channel_order;
/**
* Target output loudness in dBFS, used for xHE-AAC loudness normalization
* based on the parsed loudnessInfoSet() metadata. 0 disables normalization.
*/
int target_level;
int warned_loudness_missing;
OutputConfiguration oc[2];
int warned_num_aac_frames;
int warned_960_sbr;
unsigned warned_71_wide;
int warned_gain_control;
int warned_he_aac_mono;
+1 -1
View File
@@ -75,7 +75,7 @@ const uint8_t ff_aac_channel_layout_map[16][16][3] = {
const int16_t ff_aac_channel_map[3][4][6] = {
{
{ AV_CHAN_FRONT_CENTER, AV_CHAN_FRONT_LEFT_OF_CENTER, AV_CHAN_FRONT_RIGHT_OF_CENTER, AV_CHAN_FRONT_LEFT, AV_CHAN_FRONT_RIGHT, AV_CHAN_NONE },
{ AV_CHAN_UNUSED, AV_CHAN_NONE, AV_CHAN_NONE, AV_CHAN_NONE, AV_CHAN_NONE, AV_CHAN_NONE },
{ AV_CHAN_UNUSED, AV_CHAN_SIDE_LEFT, AV_CHAN_SIDE_RIGHT, AV_CHAN_NONE, AV_CHAN_NONE, AV_CHAN_NONE },
{ AV_CHAN_UNUSED, AV_CHAN_SIDE_LEFT, AV_CHAN_SIDE_RIGHT, AV_CHAN_BACK_LEFT, AV_CHAN_BACK_RIGHT, AV_CHAN_BACK_CENTER },
{ AV_CHAN_LOW_FREQUENCY, AV_CHAN_LOW_FREQUENCY_2, AV_CHAN_NONE, AV_CHAN_NONE, AV_CHAN_NONE, AV_CHAN_NONE },
},
+277 -29
View File
@@ -49,7 +49,7 @@ static inline uint32_t get_escaped_value(GetBitContext *gb, int nb1, int nb2, in
return val;
}
/* ISO/IEC 23003-3, Table 74 bsOutputChannelPos */
/* ISO/IEC 23003-3, Table 74: bsOutputChannelPos */
static const enum AVChannel usac_ch_pos_to_av[64] = {
[0] = AV_CHAN_FRONT_LEFT,
[1] = AV_CHAN_FRONT_RIGHT,
@@ -85,10 +85,23 @@ static const enum AVChannel usac_ch_pos_to_av[64] = {
[31] = AV_CHAN_TOP_SURROUND_RIGHT, ///< -110 degrees, Rvs, TpRS
};
/* ISO/IEC 23003-4, Table A.48: bit width of bsMethodValue depends on methodDef. */
static int methodvalue_width(int method_def)
{
switch (method_def) {
case 7: return 5; /* mixing level */
case 8: return 2; /* room type */
default: return 8; /* loudness (0..6, 9) + reserved */
}
}
/* ISO/IEC 23003-4, Table 58/60: loudnessInfo(), loudnessInfoV1().
* The only difference in V1 is the added eqSetId field. */
static int decode_loudness_info(AACDecContext *ac, AACUSACLoudnessInfo *info,
GetBitContext *gb)
GetBitContext *gb, int v1)
{
info->drc_set_id = get_bits(gb, 6);
info->eq_set_id = v1 ? get_bits(gb, 6) : 0;
info->downmix_id = get_bits(gb, 7);
if ((info->sample_peak.present = get_bits1(gb))) /* samplePeakLevelPresent */
@@ -103,7 +116,8 @@ static int decode_loudness_info(AACDecContext *ac, AACUSACLoudnessInfo *info,
info->nb_measurements = get_bits(gb, 4);
for (int i = 0; i < info->nb_measurements; i++) {
info->measurements[i].method_def = get_bits(gb, 4);
info->measurements[i].method_val = get_unary(gb, 0, 8);
info->measurements[i].method_val =
get_bits(gb, methodvalue_width(info->measurements[i].method_def));
info->measurements[i].measurement = get_bits(gb, 4);
info->measurements[i].reliability = get_bits(gb, 2);
}
@@ -111,6 +125,56 @@ static int decode_loudness_info(AACDecContext *ac, AACUSACLoudnessInfo *info,
return 0;
}
/* ISO/IEC 23003-4, Table 61: loudnessInfoSetExtension(), UNIDRCLOUDEXT_EQ */
static int decode_loudness_set_v1(AACDecContext *ac, AACUSACConfig *usac,
GetBitContext *gb)
{
int ret;
int nb_album = get_bits(gb, 6); /* loudnessInfoV1AlbumCount */
int nb_info = get_bits(gb, 6); /* loudnessInfoV1Count */
for (int i = 0; i < nb_album; i++) {
AACUSACLoudnessInfo tmp;
ret = decode_loudness_info(ac, &tmp, gb, 1);
if (ret < 0)
return ret;
if (usac->loudness.nb_album < FF_ARRAY_ELEMS(usac->loudness.album_info))
usac->loudness.album_info[usac->loudness.nb_album++] = tmp;
}
for (int i = 0; i < nb_info; i++) {
AACUSACLoudnessInfo tmp;
ret = decode_loudness_info(ac, &tmp, gb, 1);
if (ret < 0)
return ret;
if (usac->loudness.nb_info < FF_ARRAY_ELEMS(usac->loudness.info))
usac->loudness.info[usac->loudness.nb_info++] = tmp;
}
return 0;
}
/* Pick the bsMethodValue of a program- or anchor-loudness measurement.
* Per ISO/IEC 23003-4 6.1.2.5, downmixId, drcSetId and eqSetId identify the
* signal a loudnessInfo() applies to; only downmixId == 0 (base layout)
* together with drcSetId == 0 and eqSetId == 0 (no DRC/EQ) describes the
* unprocessed signal we output, so measurements for any other
* downmix/DRC/EQ set must not be used. */
static int select_loudness_measurement(const AACUSACConfig *usac)
{
for (int i = 0; i < usac->loudness.nb_info; i++) {
const AACUSACLoudnessInfo *info = &usac->loudness.info[i];
if (info->downmix_id != 0 || info->drc_set_id != 0 || info->eq_set_id != 0)
continue;
for (int j = 0; j < info->nb_measurements; j++) {
int method = info->measurements[j].method_def;
if (method == 1 || method == 2)
return info->measurements[j].method_val;
}
}
return -1;
}
static int decode_loudness_set(AACDecContext *ac, AACUSACConfig *usac,
GetBitContext *gb)
{
@@ -120,13 +184,13 @@ static int decode_loudness_set(AACDecContext *ac, AACUSACConfig *usac,
usac->loudness.nb_info = get_bits(gb, 6); /* loudnessInfoCount */
for (int i = 0; i < usac->loudness.nb_album; i++) {
ret = decode_loudness_info(ac, &usac->loudness.album_info[i], gb);
ret = decode_loudness_info(ac, &usac->loudness.album_info[i], gb, 0);
if (ret < 0)
return ret;
}
for (int i = 0; i < usac->loudness.nb_info; i++) {
ret = decode_loudness_info(ac, &usac->loudness.info[i], gb);
ret = decode_loudness_info(ac, &usac->loudness.info[i], gb, 0);
if (ret < 0)
return ret;
}
@@ -134,16 +198,25 @@ static int decode_loudness_set(AACDecContext *ac, AACUSACConfig *usac,
if (get_bits1(gb)) { /* loudnessInfoSetExtPresent */
enum AACUSACLoudnessExt type;
while ((type = get_bits(gb, 4)) != UNIDRCLOUDEXT_TERM) {
uint8_t size_bits = get_bits(gb, 4) + 4;
uint8_t bit_size = get_bits(gb, size_bits) + 1;
uint8_t size_bits = get_bits(gb, 4) + 4; /* bitSizeLen */
uint32_t bit_size = get_bits_long(gb, size_bits) + 1; /* bitSize */
int start = get_bits_count(gb);
int skip;
switch (type) {
case UNIDRCLOUDEXT_EQ:
avpriv_report_missing_feature(ac->avctx, "loudnessInfoV1");
return AVERROR_PATCHWELCOME;
ret = decode_loudness_set_v1(ac, usac, gb);
if (ret < 0)
return ret;
break;
default:
for (int i = 0; i < bit_size; i++)
skip_bits1(gb);
break;
}
/* The extension size is explicit, so unparsed (or unknown)
* data can be skipped without desynchronizing. */
skip = bit_size - (get_bits_count(gb) - start);
if (skip < 0)
return AVERROR_INVALIDDATA;
skip_bits_long(gb, skip);
}
}
@@ -215,6 +288,11 @@ static int decode_usac_element_pair(AACDecContext *ac,
if (e->stereo_config_index) {
e->mps.freq_res = get_bits(gb, 3); /* bsFreqRes */
if (!e->mps.freq_res)
return AVERROR_INVALIDDATA; /* value 0 is reserved */
int numBands = ((int[]){0,28,20,14,10,7,5,4})[e->mps.freq_res]; // ISO/IEC 23003-1:2007, 5.2, Table 39
e->mps.fixed_gain = get_bits(gb, 3); /* bsFixedGainDMX */
e->mps.temp_shape_config = get_bits(gb, 2); /* bsTempShapeConfig */
e->mps.decorr_config = get_bits(gb, 2); /* bsDecorrConfig */
@@ -222,12 +300,21 @@ static int decode_usac_element_pair(AACDecContext *ac,
e->mps.phase_coding = get_bits1(gb); /* bsPhaseCoding */
e->mps.otts_bands_phase_present = get_bits1(gb);
if (e->mps.otts_bands_phase_present) /* bsOttBandsPhasePresent */
e->mps.otts_bands_phase = get_bits(gb, 5); /* bsOttBandsPhase */
int otts_bands_phase = ((int[]){0,10,10,7,5,3,2,2})[e->mps.freq_res]; // Table 109: Default value of bsOttBandsPhase
if (e->mps.otts_bands_phase_present) { /* bsOttBandsPhasePresent */
otts_bands_phase = get_bits(gb, 5); /* bsOttBandsPhase */
if (otts_bands_phase > numBands)
return AVERROR_INVALIDDATA;
}
e->mps.otts_bands_phase = otts_bands_phase;
e->mps.residual_coding = e->stereo_config_index >= 2; /* bsResidualCoding */
if (e->mps.residual_coding) {
e->mps.residual_bands = get_bits(gb, 5); /* bsResidualBands */
int residual_bands = get_bits(gb, 5); /* bsResidualBands */
if (residual_bands > numBands)
return AVERROR_INVALIDDATA;
e->mps.residual_bands = residual_bands;
e->mps.otts_bands_phase = FFMAX(e->mps.otts_bands_phase,
e->mps.residual_bands);
e->mps.pseudo_lr = get_bits1(gb); /* bsPseudoLr */
@@ -239,6 +326,114 @@ static int decode_usac_element_pair(AACDecContext *ac,
return 0;
}
/* ISO/IEC 23003-4, Table 62: channelLayout() */
static int decode_drc_channel_layout(GetBitContext *gb)
{
int base_channel_count = get_bits(gb, 7); /* baseChannelCount */
if (get_bits1(gb)) { /* layoutSignallingPresent */
if (get_bits(gb, 8) == 0) /* definedLayout == 0 */
for (int i = 0; i < base_channel_count; i++)
skip_bits(gb, 7); /* speakerPosition */
}
return base_channel_count;
}
/* ISO/IEC 23003-4, Table 63: downmixInstructions() */
static void skip_drc_downmix_instructions(GetBitContext *gb, int base_channel_count)
{
int target_channel_count;
skip_bits(gb, 7); /* downmixId */
target_channel_count = get_bits(gb, 7); /* targetChannelCount */
skip_bits(gb, 8); /* targetLayout */
if (get_bits1(gb)) /* downmixCoefficientsPresent */
skip_bits_long(gb, 4 * target_channel_count * base_channel_count);
}
/* ISO/IEC 23003-4, Table 70: drcInstructionsBasic(), common with the
* uniDrc variant up to the loudness-target fields. */
static void decode_drc_instructions_basic(AACUsacElemConfig *e, GetBitContext *gb)
{
int set_effects;
skip_bits(gb, 6); /* drcSetId */
skip_bits(gb, 4); /* drcLocation */
skip_bits(gb, 7); /* downmixId */
if (get_bits1(gb)) { /* additionalDownmixIdPresent */
int add_downmix_cnt = get_bits(gb, 3); /* additionalDownmixIdCount */
for (int j = 0; j < add_downmix_cnt; j++)
skip_bits(gb, 7); /* additionalDownmixId */
}
set_effects = get_bits(gb, 16); /* drcSetEffect */
if ((set_effects & (3 << 10)) == 0) {
if (get_bits1(gb)) /* limiterPeakTargetPresent */
skip_bits(gb, 8); /* bsLimiterPeakTarget */
}
if (get_bits1(gb)) { /* drcSetTargetLoudnessPresent */
e->drc.loudness.upper = get_bits(gb, 6); /* bsDrcSetTargetLoudnessValueUpper */
if (get_bits1(gb)) /* drcSetTargetLoudnessValueLowerPresent */
e->drc.loudness.lower = get_bits(gb, 6); /* bsDrcSetTargetLoudnessValueLower */
}
}
/* ISO/IEC 23003-4, Table 57: uniDrcConfig() */
static int decode_drc_config(AACDecContext *ac, AACUsacElemConfig *e,
GetBitContext *gb)
{
int nb_downmix_instr, nb_coeff_basic = 0, nb_instr_basic = 0;
int nb_coeff_uni, nb_instr_uni;
int base_channel_count;
e->drc.loudness.lower = -1;
e->drc.loudness.upper = -1;
if (get_bits1(gb)) /* sampleRatePresent */
skip_bits(gb, 18); /* bsSampleRate */
nb_downmix_instr = get_bits(gb, 7); /* downmixInstructionsCount */
if (get_bits1(gb)) { /* drcDescriptionBasicPresent */
nb_coeff_basic = get_bits(gb, 3); /* drcCoefficientsBasicCount */
nb_instr_basic = get_bits(gb, 4); /* drcInstructionsBasicCount */
}
nb_coeff_uni = get_bits(gb, 3); /* drcCoefficientsUniDrcCount */
nb_instr_uni = get_bits(gb, 6); /* drcInstructionsUniDrcCount */
if (nb_coeff_uni || nb_instr_uni) {
avpriv_report_missing_feature(ac->avctx,
"AAC USAC uniDrc DRC processing");
return AVERROR_PATCHWELCOME;
}
base_channel_count = decode_drc_channel_layout(gb);
for (int i = 0; i < nb_downmix_instr; i++)
skip_drc_downmix_instructions(gb, base_channel_count);
for (int i = 0; i < nb_coeff_basic; i++)
skip_bits(gb, 4 + 7); /* drcLocation, drcCharacteristic */
for (int i = 0; i < nb_instr_basic; i++)
decode_drc_instructions_basic(e, gb);
if (get_bits1(gb)) { /* uniDrcConfigExtPresent */
enum AACUSACDRCExt type;
while ((type = get_bits(gb, 4)) != UNIDRCCONFEXT_TERM) {
uint8_t size_bits = get_bits(gb, 4) + 4; /* bitSizeLen */
uint32_t bit_size = get_bits_long(gb, size_bits) + 1; /* extBitSize */
switch (type) {
default:
skip_bits_long(gb, bit_size);
break;
}
}
}
return 0;
}
static int decode_usac_extension(AACDecContext *ac, AACUsacElemConfig *e,
GetBitContext *gb)
{
@@ -262,9 +457,25 @@ static int decode_usac_extension(AACDecContext *ac, AACUsacElemConfig *e,
break;
case ID_EXT_ELE_SAOC:
break;
case ID_EXT_ELE_UNI_DRC:
break;
#endif
case ID_EXT_ELE_UNI_DRC: {
int start = get_bits_count(gb);
int ret = decode_drc_config(ac, e, gb);
int skip = 8*ext_config_len - (get_bits_count(gb) - start);
if (ret == AVERROR_PATCHWELCOME) {
/* Unsupported uniDrcConfig(): ignore the DRC metadata and treat
* the element as fill so the stream stays decodable. */
e->ext.type = ID_EXT_ELE_FILL;
ret = 0;
}
if (ret < 0)
return ret;
if (skip < 0)
return AVERROR_INVALIDDATA;
/* The config is byte-padded to usacExtElementConfigLength */
skip_bits_long(gb, skip);
break;
}
case ID_EXT_ELE_FILL:
break; /* This is what the spec does */
case ID_EXT_ELE_AUDIOPREROLL:
@@ -359,10 +570,13 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx,
return AVERROR_PATCHWELCOME;
memset(usac, 0, sizeof(*usac));
usac->loudness.input_method_val = -1;
freq_idx = get_bits(gb, 5); /* usacSamplingFrequencyIndex */
if (freq_idx == 0x1f) {
samplerate = get_bits(gb, 24); /* usacSamplingFrequency */
if (samplerate == 0)
return AVERROR(EINVAL);
} else {
samplerate = ff_aac_usac_samplerate[freq_idx];
if (samplerate < 0)
@@ -556,6 +770,13 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx,
ac->avctx->profile = AV_PROFILE_AAC_USAC;
usac->loudness.input_method_val = select_loudness_measurement(usac);
if (usac->loudness.input_method_val >= 0)
av_log(avctx, AV_LOG_VERBOSE,
"USAC input loudness: %.2f LKFS (bsMethodValue=%d)\n",
-57.75f + 0.25f * usac->loudness.input_method_val,
usac->loudness.input_method_val);
ret = ff_aac_usac_reset_state(ac, oc);
if (ret < 0)
return ret;
@@ -1293,7 +1514,8 @@ static void spectrum_decode(AACDecContext *ac, AACUSACConfig *usac,
SingleChannelElement *sce = &cpe->ch[ch];
AACUsacElemData *ue = &sce->ue;
spectrum_scale(ac, sce, ue);
if (!ue->core_mode)
spectrum_scale(ac, sce, ue);
}
if (nb_channels > 1 && us->common_window) {
@@ -1327,13 +1549,13 @@ static void spectrum_decode(AACDecContext *ac, AACUSACConfig *usac,
/* Save coefficients and alpha values for prediction reasons */
if (nb_channels > 1) {
AACUsacStereo *us = &cpe->us;
AACUsacStereo *us2 = &cpe->us;
for (int ch = 0; ch < nb_channels; ch++) {
SingleChannelElement *sce = &cpe->ch[ch];
memcpy(sce->prev_coeffs, sce->coeffs, sizeof(sce->coeffs));
}
memcpy(us->prev_alpha_q_re, us->alpha_q_re, sizeof(us->alpha_q_re));
memcpy(us->prev_alpha_q_im, us->alpha_q_im, sizeof(us->alpha_q_im));
memcpy(us2->prev_alpha_q_re, us2->alpha_q_re, sizeof(us2->alpha_q_re));
memcpy(us2->prev_alpha_q_im, us2->alpha_q_im, sizeof(us2->alpha_q_im));
}
for (int ch = 0; ch < nb_channels; ch++) {
@@ -1343,8 +1565,9 @@ static void spectrum_decode(AACDecContext *ac, AACUSACConfig *usac,
if (sce->tns.present && ((nb_channels == 1) || (us->tns_on_lr)))
ac->dsp.apply_tns(sce->coeffs, &sce->tns, &sce->ics, 1);
ac->oc[1].m4ac.frame_length_short ? ac->dsp.imdct_and_windowing_768(ac, sce) :
ac->dsp.imdct_and_windowing(ac, sce);
if (!sce->ue.core_mode)
ac->oc[1].m4ac.frame_length_short ? ac->dsp.imdct_and_windowing_768(ac, sce) :
ac->dsp.imdct_and_windowing(ac, sce);
}
}
@@ -1372,11 +1595,10 @@ static void decode_tsd(GetBitContext *gb, int *data,
break;
}
int64_t c = k - p + 1;
for (int h = 2; h <= p; h++) {
c *= k - p + h;
c /= h;
for (int h = 2; h <= p && c <= s; h++) {
c += c*(k-p)/h;
}
if (s >= (int)c) { /* c is long long for up to 32 slots */
if (s >= c) {
s -= c;
data[k] = 1;
p--;
@@ -1655,7 +1877,7 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac,
spectrum_decode(ac, usac, che, core_nb_channels);
if (ac->oc[1].m4ac.sbr > 0) {
ac->proc.sbr_apply(ac, che, nb_channels == 2 ? TYPE_CPE : TYPE_SCE,
ac->proc.sbr_apply(ac, che, nb_channels == 2 ? TYPE_CPE : TYPE_SCE, 0,
che->ch[0].output,
che->ch[1].output);
}
@@ -1719,8 +1941,8 @@ static int parse_audio_preroll(AACDecContext *ac, GetBitContext *gb)
}
/* Byte alignment is not guaranteed. */
for (int i = 0; i < au_len; i++)
tmp_buf[i] = get_bits(gb, 8);
for (int j = 0; j < au_len; j++)
tmp_buf[j] = get_bits(gb, 8);
ret = init_get_bits8(&gbc, tmp_buf, au_len);
if (ret < 0)
@@ -1811,6 +2033,10 @@ static int parse_ext_ele(AACDecContext *ac, AACUsacElemConfig *e,
case ID_EXT_ELE_AUDIOPREROLL:
ret = parse_audio_preroll(ac, gb2);
break;
case ID_EXT_ELE_UNI_DRC:
/* uniDrcGain() payload: DRC is not applied, just consume the
* bits via skip_bits_long below. */
break;
default:
/* This should never happen */
av_assert0(0);
@@ -1945,6 +2171,28 @@ int ff_aac_usac_decode_frame(AVCodecContext *avctx, AACDecContext *ac,
*got_frame_ptr = 0;
}
if (samples && ac->target_level) {
int method_val = usac->loudness.input_method_val;
if (method_val < 0) {
if (!ac->warned_loudness_missing) {
av_log(avctx, AV_LOG_WARNING,
"target_level set but no program/anchor loudness "
"measurement available; normalization skipped\n");
ac->warned_loudness_missing = 1;
}
} else {
/* Per ISO/IEC 23003-4 Table A.48: L = -57.75 + 0.25 * μ */
float input_loudness = -57.75f + 0.25f * method_val;
float gain_dB = (float)ac->target_level - input_loudness;
float gain = powf(10.0f, gain_dB / 20.0f);
for (int ch = 0; ch < frame->ch_layout.nb_channels; ch++)
ac->fdsp->vector_fmul_scalar((float *)frame->extended_data[ch],
(float *)frame->extended_data[ch],
gain, frame->nb_samples);
}
}
/* for dual-mono audio (SCE + SCE) */
is_dmono = ac->dmono_mode && elem_id[0] == 2 &&
!av_channel_layout_compare(&ac->oc[1].ch_layout,
+16 -18
View File
@@ -240,7 +240,7 @@ static void huff_data_2d(GetBitContext *gb, int16_t *part0_data[2], int16_t (*da
0, 2*esc_cnt, 0, (2*lav + 1));
for (i = 0; i < esc_cnt; i++) {
data[esc_idx[i]][0] = esc_data[0][i] - lav;
data[esc_idx[i]][0] = esc_data[0][i] - lav;
data[esc_idx[i]][1] = esc_data[1][i] - lav;
}
}
}
@@ -464,10 +464,10 @@ static int ec_pair_dec(GetBitContext *gb,
}
if (pair) {
p_data[0] = data_pair[0];
p_data[1] = data_pair[1];
p_data[0] = data_diff[0];
p_data[1] = data_diff[1];
} else {
p_data[0] = data_pair[0];
p_data[0] = data_diff[0];
p_data[1] = NULL;
}
@@ -480,7 +480,7 @@ static int ec_pair_dec(GetBitContext *gb,
if (pair && (diff_freq[0] || diff_time_back))
diff_freq[1] = !get_bits1(gb);
int time_pair;
int time_pair = 0;
huff_decode(gb, p_data, data_type, diff_freq,
nb_bands, &time_pair);
@@ -534,11 +534,11 @@ static int ec_pair_dec(GetBitContext *gb,
}
/* Decode LSBs */
attach_lsb(gb, p_data[0], quant_offset, attach_lsb_flag,
nb_bands, p_data[0]);
attach_lsb(gb, data_pair[0], quant_offset, attach_lsb_flag,
nb_bands, data_pair[0]);
if (pair)
attach_lsb(gb, p_data[1], quant_offset, attach_lsb_flag,
nb_bands, p_data[1]);
attach_lsb(gb, data_pair[1], quant_offset, attach_lsb_flag,
nb_bands, data_pair[1]);
memcpy(&set1[start_band], data_pair[0], 2*nb_bands);
if (pair)
@@ -591,9 +591,6 @@ static int get_freq_strides(int16_t *freq_strides, int band_stride,
}
}
for (int i = 0; i <= data_bands; i++)
freq_strides[i] = av_clip_uintp2(freq_strides[i], 2);
return data_bands;
}
@@ -643,15 +640,16 @@ int ff_aac_ec_data_dec(GetBitContext *gb, AACMPSLosslessData *ld,
fine_to_coarse(ld->last_data, data_type, start_band, end_band);
}
int data_bands = get_freq_strides(ld->freq_res,
int16_t freq_stride_map[MPS_MAX_PARAM_BANDS + 1];
int data_bands = get_freq_strides(freq_stride_map,
stride_table[ld->freq_res[set_idx]],
start_band, end_band);
if (set_idx + data_pair > MPS_MAX_PARAM_SETS)
if (set_idx + data_pair >= MPS_MAX_PARAM_SETS)
return AVERROR(EINVAL);
for (int j = 0; j < data_bands; j++)
ld->last_data[start_band + j] = ld->last_data[ld->freq_res[j]];
ld->last_data[start_band + j] = ld->last_data[freq_stride_map[j]];
int err = ec_pair_dec(gb,
ld->data[set_idx + 0], ld->data[set_idx + 1],
@@ -664,11 +662,11 @@ int ff_aac_ec_data_dec(GetBitContext *gb, AACMPSLosslessData *ld,
if (data_type == MPS_IPD) {
const int mask = ld->coarse_quant[set_idx] ? 0x7 : 0xF;
for (int j = 0; j < data_bands; j++)
for (int k = ld->freq_res[j + 0]; k < ld->freq_res[j + 1]; k++)
for (int k = freq_stride_map[j + 0]; k < freq_stride_map[j + 1]; k++)
ld->last_data[k] = ld->data[set_idx + data_pair][start_band + j] & mask;
} else {
for (int j = 0; j < data_bands; j++)
for (int k = ld->freq_res[j + 0]; k < ld->freq_res[j + 1]; k++)
for (int k = freq_stride_map[j + 0]; k < freq_stride_map[j + 1]; k++)
ld->last_data[k] = ld->data[set_idx + data_pair][start_band + j];
}
@@ -860,7 +858,7 @@ int ff_aac_map_index_data(AACMPSLosslessData *ld,
for (int i = 0; i < nb_param_sets; i++) {
if (ld->coarse_quant_no[i] == 1) {
coarse_to_fine(tmp_idx_data[i], data_type, start_band,
stop_band - start_band);
stop_band);
ld->coarse_quant_no[i] = 0;
}
}
+102 -128
View File
@@ -123,40 +123,40 @@ static const AACPCEInfo aac_pce_configs[] = {
{
.layout = AV_CHANNEL_LAYOUT_SURROUND,
.num_ele = { 2, 0, 0, 0 },
.pairing = { { 1, 0 }, },
.pairing = { { 0, 1 }, },
.index = { { 0, 0 }, },
.config_map = { 2, TYPE_CPE, TYPE_SCE, },
.reorder_map = { 0, 1, 2 },
.config_map = { 2, TYPE_SCE, TYPE_CPE },
.reorder_map = { 2, 0, 1 },
},
{
.layout = AV_CHANNEL_LAYOUT_3POINT1,
.num_ele = { 2, 0, 0, 1 },
.pairing = { { 1, 0 }, },
.pairing = { { 0, 1 }, },
.index = { { 0, 0 }, { 0 }, { 0 }, { 0 }, },
.config_map = { 3, TYPE_CPE, TYPE_SCE, TYPE_LFE },
.reorder_map = { 0, 1, 2, 3 },
.config_map = { 3, TYPE_SCE, TYPE_CPE, TYPE_LFE },
.reorder_map = { 2, 0, 1, 3 },
},
{
.layout = AV_CHANNEL_LAYOUT_4POINT0,
.num_ele = { 2, 0, 1, 0 },
.pairing = { { 1, 0 }, { 0 }, { 0 }, },
.pairing = { { 0, 1 }, { 0 }, { 0 }, },
.index = { { 0, 0 }, { 0 }, { 1 } },
.config_map = { 3, TYPE_CPE, TYPE_SCE, TYPE_SCE },
.reorder_map = { 0, 1, 2, 3 },
.config_map = { 3, TYPE_SCE, TYPE_CPE, TYPE_SCE },
.reorder_map = { 2, 0, 1, 3 },
},
{
.layout = AV_CHANNEL_LAYOUT_4POINT1,
.num_ele = { 2, 1, 1, 0 },
.pairing = { { 1, 0 }, { 0 }, { 0 }, },
.index = { { 0, 0 }, { 1 }, { 2 }, { 0 } },
.config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_SCE },
.reorder_map = { 0, 1, 2, 3, 4 },
.num_ele = { 2, 0, 1, 1 },
.pairing = { { 0, 1 }, { 0 }, { 0 }, },
.index = { { 0, 0 }, { 0 }, { 1 }, { 0 } },
.config_map = { 4, TYPE_SCE, TYPE_CPE, TYPE_SCE, TYPE_LFE },
.reorder_map = { 2, 0, 1, 4, 3 },
},
{
.layout = AV_CHANNEL_LAYOUT_2_2,
.num_ele = { 1, 1, 0, 0 },
.pairing = { { 1 }, { 1 }, },
.index = { { 0 }, { 1 }, },
.num_ele = { 1, 0, 1, 0 },
.pairing = { { 1 }, { 0 }, { 1 }, },
.index = { { 0 }, { 0 }, { 1 } },
.config_map = { 2, TYPE_CPE, TYPE_CPE },
.reorder_map = { 0, 1, 2, 3 },
},
@@ -170,158 +170,131 @@ static const AACPCEInfo aac_pce_configs[] = {
},
{
.layout = AV_CHANNEL_LAYOUT_5POINT0,
.num_ele = { 2, 1, 0, 0 },
.pairing = { { 1, 0 }, { 1 }, },
.index = { { 0, 0 }, { 1 } },
.config_map = { 3, TYPE_CPE, TYPE_SCE, TYPE_CPE },
.reorder_map = { 0, 1, 2, 3, 4 },
.num_ele = { 2, 0, 1, 0 },
.pairing = { { 0, 1 }, { 0 }, { 1 } },
.index = { { 0, 0 }, { 0 }, { 1 } },
.config_map = { 3, TYPE_SCE, TYPE_CPE, TYPE_CPE },
.reorder_map = { 2, 0, 1, 3, 4 },
},
{
.layout = AV_CHANNEL_LAYOUT_5POINT1,
.num_ele = { 2, 1, 1, 0 },
.pairing = { { 1, 0 }, { 0 }, { 1 }, },
.index = { { 0, 0 }, { 1 }, { 1 } },
.config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE },
.reorder_map = { 0, 1, 2, 3, 4, 5 },
.num_ele = { 2, 0, 1, 1 },
.pairing = { { 0, 1 }, { 0 }, { 1 }, },
.index = { { 0, 0 }, { 0 }, { 1 }, { 0 } },
.config_map = { 4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE },
.reorder_map = { 2, 0, 1, 4, 5, 3 },
},
{
.layout = AV_CHANNEL_LAYOUT_5POINT0_BACK,
.num_ele = { 2, 0, 1, 0 },
.pairing = { { 1, 0 }, { 0 }, { 1 } },
.pairing = { { 0, 1 }, { 0 }, { 1 } },
.index = { { 0, 0 }, { 0 }, { 1 } },
.config_map = { 3, TYPE_CPE, TYPE_SCE, TYPE_CPE },
.reorder_map = { 0, 1, 2, 3, 4 },
.config_map = { 3, TYPE_SCE, TYPE_CPE, TYPE_CPE },
.reorder_map = { 2, 0, 1, 3, 4 },
},
{
.layout = AV_CHANNEL_LAYOUT_5POINT1_BACK,
.num_ele = { 2, 1, 1, 0 },
.pairing = { { 1, 0 }, { 0 }, { 1 }, },
.index = { { 0, 0 }, { 1 }, { 1 } },
.config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE },
.reorder_map = { 0, 1, 2, 3, 4, 5 },
.num_ele = { 2, 0, 1, 1 },
.pairing = { { 0, 1 }, { 0 }, { 1 }, },
.index = { { 0, 0 }, { 0 }, { 1 }, { 0 } },
.config_map = { 4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE },
.reorder_map = { 2, 0, 1, 4, 5, 3 },
},
{
.layout = AV_CHANNEL_LAYOUT_6POINT0,
.num_ele = { 2, 1, 1, 0 },
.pairing = { { 1, 0 }, { 1 }, { 0 }, },
.index = { { 0, 0 }, { 1 }, { 1 } },
.config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
.reorder_map = { 0, 1, 2, 3, 4, 5 },
.num_ele = { 2, 0, 2, 0 },
.pairing = { { 0, 1 }, { 0 }, { 1, 0 } },
.index = { { 0, 0 }, { 0 }, { 1, 1 } },
.config_map = { 4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_SCE },
.reorder_map = { 2, 0, 1, 4, 5, 3 },
},
{
.layout = AV_CHANNEL_LAYOUT_6POINT0_FRONT,
.num_ele = { 2, 1, 0, 0 },
.pairing = { { 1, 1 }, { 1 } },
.index = { { 1, 0 }, { 2 }, },
.num_ele = { 2, 0, 1, 0 },
.pairing = { { 1, 1 }, { 0 }, { 1 } },
.index = { { 0, 1 }, { 0 }, { 2 }, },
.config_map = { 3, TYPE_CPE, TYPE_CPE, TYPE_CPE, },
.reorder_map = { 0, 1, 2, 3, 4, 5 },
.reorder_map = { 2, 3, 0, 1, 4, 5 },
},
{
.layout = AV_CHANNEL_LAYOUT_HEXAGONAL,
.num_ele = { 2, 0, 2, 0 },
.pairing = { { 1, 0 },{ 0 },{ 1, 0 }, },
.index = { { 0, 0 },{ 0 },{ 1, 1 } },
.config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE, },
.reorder_map = { 0, 1, 2, 3, 4, 5 },
.pairing = { { 0, 1 }, { 0 }, { 1, 0 } },
.index = { { 0, 0 }, { 0 }, { 1, 1 } },
.config_map = { 4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_SCE },
.reorder_map = { 2, 0, 1, 3, 4, 5 },
},
{
.layout = AV_CHANNEL_LAYOUT_6POINT1,
.num_ele = { 2, 1, 2, 0 },
.pairing = { { 1, 0 },{ 0 },{ 1, 0 }, },
.index = { { 0, 0 },{ 1 },{ 1, 2 } },
.config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
.reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
.num_ele = { 2, 0, 2, 1 },
.pairing = { { 0, 1 }, { 0 }, { 1, 0 }, },
.index = { { 0, 0 }, { 0 }, { 1, 1 }, { 0 } },
.config_map = { 5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_SCE, TYPE_LFE },
.reorder_map = { 2, 0, 1, 5, 6, 4, 3 },
},
{
.layout = AV_CHANNEL_LAYOUT_6POINT1_BACK,
.num_ele = { 2, 1, 2, 0 },
.pairing = { { 1, 0 }, { 0 }, { 1, 0 }, },
.index = { { 0, 0 }, { 1 }, { 1, 2 } },
.config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
.reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
.num_ele = { 2, 0, 2, 1 },
.pairing = { { 0, 1 },{ 0 },{ 1, 0 }, },
.index = { { 0, 0 },{ 0 },{ 1, 1 },{ 0 } },
.config_map = { 5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_SCE, TYPE_LFE },
.reorder_map = { 2, 0, 1, 4, 5, 6, 3 },
},
{
.layout = AV_CHANNEL_LAYOUT_6POINT1_FRONT,
.num_ele = { 2, 1, 2, 0 },
.pairing = { { 1, 0 }, { 0 }, { 1, 0 }, },
.index = { { 0, 0 }, { 1 }, { 1, 2 } },
.config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
.reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
.num_ele = { 2, 0, 1, 1 },
.pairing = { { 1, 1 }, { 0 }, { 1 }, },
.index = { { 0, 1 }, { 0 }, { 2 }, { 0 }, },
.config_map = { 4, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_LFE, },
.reorder_map = { 3, 4, 0, 1, 5, 6, 2 },
},
{
.layout = AV_CHANNEL_LAYOUT_7POINT0,
.num_ele = { 2, 1, 1, 0 },
.pairing = { { 1, 0 }, { 1 }, { 1 }, },
.index = { { 0, 0 }, { 1 }, { 2 }, },
.config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_CPE },
.reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
.num_ele = { 2, 0, 2, 0 },
.pairing = { { 0, 1 }, { 0 }, { 1, 1 }, },
.index = { { 0, 0 }, { 0 }, { 2, 1 }, },
.config_map = { 4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE },
.reorder_map = { 2, 0, 1, 3, 4, 5, 6 },
},
{
.layout = AV_CHANNEL_LAYOUT_7POINT0_FRONT,
.num_ele = { 2, 1, 1, 0 },
.pairing = { { 1, 0 }, { 1 }, { 1 }, },
.index = { { 0, 0 }, { 1 }, { 2 }, },
.config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_CPE },
.reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
.num_ele = { 3, 0, 1, 0 },
.pairing = { { 0, 1, 1 }, { 0 }, { 1 }, },
.index = { { 0, 0, 1 }, { 0 }, { 2 }, },
.config_map = { 4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE },
.reorder_map = { 2, 3, 4, 0, 1, 5, 6 },
},
{
.layout = AV_CHANNEL_LAYOUT_7POINT1,
.num_ele = { 2, 1, 2, 0 },
.pairing = { { 1, 0 }, { 0 }, { 1, 1 }, },
.index = { { 0, 0 }, { 1 }, { 1, 2 }, { 0 } },
.config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE, TYPE_CPE },
.reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
.num_ele = { 2, 0, 2, 1 },
.pairing = { { 0, 1 }, { 0 }, { 1, 1 }, },
.index = { { 0, 0 }, { 0 }, { 2, 1 }, { 0 } },
.config_map = { 5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_LFE },
.reorder_map = { 2, 0, 1, 4, 5, 6, 7, 3 },
},
{
.layout = AV_CHANNEL_LAYOUT_7POINT1_WIDE,
.num_ele = { 2, 1, 2, 0 },
.pairing = { { 1, 0 }, { 0 },{ 1, 1 }, },
.index = { { 0, 0 }, { 1 }, { 1, 2 }, { 0 } },
.config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE, TYPE_CPE },
.reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
.num_ele = { 3, 0, 1, 1 },
.pairing = { { 0, 1, 1 }, { 0 }, { 1 }, },
.index = { { 0, 0, 1 }, { 0 }, { 2 }, { 0 }, },
.config_map = { 5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_LFE },
.reorder_map = { 2, 4, 5, 0, 1, 6, 7, 3 },
},
{
.layout = AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK,
.num_ele = { 2, 1, 2, 0 },
.pairing = { { 1, 0 }, { 0 }, { 1, 1 }, },
.index = { { 0, 0 }, { 1 }, { 1, 2 }, { 0 } },
.config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE, TYPE_CPE },
.reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
.num_ele = { 3, 0, 1, 1 },
.pairing = { { 0, 1, 1 }, { 0 }, { 1 } },
.index = { { 0, 0, 1 }, { 0 }, { 2 }, { 0 } },
.config_map = { 5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_LFE },
.reorder_map = { 2, 6, 7, 0, 1, 4, 5, 3 },
},
{
.layout = AV_CHANNEL_LAYOUT_OCTAGONAL,
.num_ele = { 2, 1, 2, 0 },
.pairing = { { 1, 0 }, { 1 }, { 1, 0 }, },
.index = { { 0, 0 }, { 1 }, { 2, 1 } },
.config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_SCE },
.reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
},
{ /* Meant for order 2/mixed ambisonics */
.layout = { .order = AV_CHANNEL_ORDER_NATIVE, .nb_channels = 9,
.u.mask = AV_CH_LAYOUT_OCTAGONAL | AV_CH_TOP_CENTER },
.num_ele = { 2, 2, 2, 0 },
.pairing = { { 1, 0 }, { 1, 0 }, { 1, 0 }, },
.index = { { 0, 0 }, { 1, 1 }, { 2, 2 } },
.config_map = { 6, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
.reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8 },
},
{ /* Meant for order 2/mixed ambisonics */
.layout = { .order = AV_CHANNEL_ORDER_NATIVE, .nb_channels = 10,
.u.mask = AV_CH_LAYOUT_6POINT0_FRONT | AV_CH_BACK_CENTER |
AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT | AV_CH_TOP_CENTER },
.num_ele = { 2, 2, 2, 0 },
.pairing = { { 1, 1 }, { 1, 0 }, { 1, 0 }, },
.index = { { 0, 1 }, { 2, 0 }, { 3, 1 } },
.config_map = { 6, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
.reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
},
{
.layout = AV_CHANNEL_LAYOUT_HEXADECAGONAL,
.num_ele = { 4, 2, 4, 0 },
.pairing = { { 1, 0, 1, 0 }, { 1, 1 }, { 1, 0, 1, 0 }, },
.index = { { 0, 0, 1, 1 }, { 2, 3 }, { 4, 2, 5, 3 } },
.config_map = { 10, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
.reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
.num_ele = { 2, 0, 3, 0 },
.pairing = { { 0, 1 }, { 0 }, { 1, 1, 0 }, },
.index = { { 0, 0 }, { 0 }, { 1, 2, 1 }, },
.config_map = { 5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_SCE },
.reorder_map = { 2, 0, 1, 6, 7, 3, 4, 5 },
},
};
@@ -366,11 +339,10 @@ static void put_pce(PutBitContext *pb, AVCodecContext *avctx)
* Make AAC audio config object.
* @see 1.6.2.1 "Syntax - AudioSpecificConfig"
*/
static int put_audio_specific_config(AVCodecContext *avctx)
static int put_audio_specific_config(AVCodecContext *avctx, int chcfg)
{
PutBitContext pb;
AACEncContext *s = avctx->priv_data;
int channels = (!s->needs_pce)*(s->channels - (s->channels == 8 ? 1 : 0));
const int max_size = 32;
avctx->extradata = av_mallocz(max_size);
@@ -380,7 +352,7 @@ static int put_audio_specific_config(AVCodecContext *avctx)
init_put_bits(&pb, avctx->extradata, max_size);
put_bits(&pb, 5, s->profile+1); //profile
put_bits(&pb, 4, s->samplerate_index); //sample rate index
put_bits(&pb, 4, channels);
put_bits(&pb, 4, chcfg);
//GASpecificConfig
put_bits(&pb, 1, 0); //frame length - 1024 samples
put_bits(&pb, 1, 0); //does not depend on core coder
@@ -1182,6 +1154,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
{
AACEncContext *s = avctx->priv_data;
int i, ret = 0;
int chcfg;
const uint8_t *sizes[2];
uint8_t grouping[AAC_MAX_CHANNELS];
int lengths[2];
@@ -1196,8 +1169,8 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
s->channels = avctx->ch_layout.nb_channels;
s->needs_pce = 1;
for (i = 0; i < FF_ARRAY_ELEMS(aac_normal_chan_layouts); i++) {
if (!av_channel_layout_compare(&avctx->ch_layout, &aac_normal_chan_layouts[i])) {
for (chcfg = 1; chcfg < FF_ARRAY_ELEMS(aac_normal_chan_layouts); chcfg++) {
if (!av_channel_layout_compare(&avctx->ch_layout, &aac_normal_chan_layouts[chcfg])) {
s->needs_pce = s->options.pce;
break;
}
@@ -1217,9 +1190,10 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
s->pce = aac_pce_configs[i];
s->reorder_map = s->pce.reorder_map;
s->chan_map = s->pce.config_map;
chcfg = 0;
} else {
s->reorder_map = aac_chan_maps[s->channels - 1];
s->chan_map = aac_chan_configs[s->channels - 1];
s->reorder_map = aac_chan_maps[chcfg - 1];
s->chan_map = aac_chan_configs[chcfg - 1];
}
if (!avctx->bit_rate) {
@@ -1278,7 +1252,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
if ((ret = alloc_buffers(avctx, s)) < 0)
return ret;
if ((ret = put_audio_specific_config(avctx)))
if ((ret = put_audio_specific_config(avctx, chcfg)))
return ret;
sizes[0] = ff_aac_swb_size_1024[s->samplerate_index];
+3 -3
View File
@@ -167,9 +167,9 @@ typedef struct AACQuantizeBandCostCacheEntry {
typedef struct AACPCEInfo {
AVChannelLayout layout;
int num_ele[4]; ///< front, side, back, lfe
int pairing[3][8]; ///< front, side, back
int index[4][8]; ///< front, side, back, lfe
uint8_t num_ele[4]; ///< front, side, back, lfe
uint8_t pairing[3][8]; ///< front, side, back
uint8_t index[4][8]; ///< front, side, back, lfe
uint8_t config_map[16]; ///< configs the encoder's channel specific settings
uint8_t reorder_map[16]; ///< maps channels from lavc to aac order
} AACPCEInfo;
+60
View File
@@ -0,0 +1,60 @@
/*
* 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
*/
#include <math.h>
#include "config.h"
#include "libavutil/macros.h"
#include "aacencdsp.h"
static void abs_pow34_v(float *out, const float *in, const int size)
{
for (int i = 0; i < size; i++) {
float a = fabsf(in[i]);
out[i] = sqrtf(a * sqrtf(a));
}
}
static void quantize_bands(int *out, const float *in, const float *scaled,
int size, int is_signed, int maxval, const float Q34,
const float rounding)
{
for (int i = 0; i < size; i++) {
float qc = scaled[i] * Q34;
int tmp = (int)FFMIN((float)(qc + rounding), (float)maxval);
if (is_signed && in[i] < 0.0f) {
tmp = -tmp;
}
out[i] = tmp;
}
}
void ff_aacenc_dsp_init(AACEncDSPContext *s)
{
s->abs_pow34 = abs_pow34_v;
s->quant_bands = quantize_bands;
#if ARCH_RISCV
ff_aacenc_dsp_init_riscv(s);
#elif ARCH_X86 && HAVE_X86ASM
ff_aacenc_dsp_init_x86(s);
#elif ARCH_AARCH64
ff_aacenc_dsp_init_aarch64(s);
#endif
}
+1 -42
View File
@@ -19,12 +19,6 @@
#ifndef AVCODEC_AACENCDSP_H
#define AVCODEC_AACENCDSP_H
#include <math.h>
#include "config.h"
#include "libavutil/macros.h"
typedef struct AACEncDSPContext {
void (*abs_pow34)(float *out, const float *in, const int size);
void (*quant_bands)(int *out, const float *in, const float *scaled,
@@ -32,44 +26,9 @@ typedef struct AACEncDSPContext {
const float rounding);
} AACEncDSPContext;
void ff_aacenc_dsp_init(AACEncDSPContext *s);
void ff_aacenc_dsp_init_riscv(AACEncDSPContext *s);
void ff_aacenc_dsp_init_x86(AACEncDSPContext *s);
void ff_aacenc_dsp_init_aarch64(AACEncDSPContext *s);
static inline void abs_pow34_v(float *out, const float *in, const int size)
{
for (int i = 0; i < size; i++) {
float a = fabsf(in[i]);
out[i] = sqrtf(a * sqrtf(a));
}
}
static inline void quantize_bands(int *out, const float *in, const float *scaled,
int size, int is_signed, int maxval, const float Q34,
const float rounding)
{
for (int i = 0; i < size; i++) {
float qc = scaled[i] * Q34;
int tmp = (int)FFMIN((float)(qc + rounding), (float)maxval);
if (is_signed && in[i] < 0.0f) {
tmp = -tmp;
}
out[i] = tmp;
}
}
static inline void ff_aacenc_dsp_init(AACEncDSPContext *s)
{
s->abs_pow34 = abs_pow34_v;
s->quant_bands = quantize_bands;
#if ARCH_RISCV
ff_aacenc_dsp_init_riscv(s);
#elif ARCH_X86 && HAVE_X86ASM
ff_aacenc_dsp_init_x86(s);
#elif ARCH_AARCH64
ff_aacenc_dsp_init_aarch64(s);
#endif
}
#endif
+24 -4
View File
@@ -44,32 +44,46 @@ extern const uint8_t *const ff_aac_swb_size_1024[];
extern const uint8_t *const ff_aac_swb_size_128[];
/* Supported layouts without using a PCE */
static const AVChannelLayout aac_normal_chan_layouts[7] = {
static const AVChannelLayout aac_normal_chan_layouts[15] = {
{ 0 },
AV_CHANNEL_LAYOUT_MONO,
AV_CHANNEL_LAYOUT_STEREO,
AV_CHANNEL_LAYOUT_SURROUND,
AV_CHANNEL_LAYOUT_4POINT0,
AV_CHANNEL_LAYOUT_5POINT0_BACK,
AV_CHANNEL_LAYOUT_5POINT1_BACK,
{ 0 }, // AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK, disabled in favor or PCE configuration
{ 0 },
{ 0 },
{ 0 },
AV_CHANNEL_LAYOUT_6POINT1_BACK,
AV_CHANNEL_LAYOUT_7POINT1,
{ 0 },
AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK,
};
/** default channel configurations */
static const uint8_t aac_chan_configs[AAC_MAX_CHANNELS][6] = {
static const uint8_t aac_chan_configs[14][6] = {
{1, TYPE_SCE}, // 1 channel - single channel element
{1, TYPE_CPE}, // 2 channels - channel pair
{2, TYPE_SCE, TYPE_CPE}, // 3 channels - center + stereo
{3, TYPE_SCE, TYPE_CPE, TYPE_SCE}, // 4 channels - front center + stereo + back center
{3, TYPE_SCE, TYPE_CPE, TYPE_CPE}, // 5 channels - front center + stereo + back stereo
{4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, // 6 channels - front center + stereo + back stereo + LFE
{0}, // 7 channels - invalid without PCE
{0},
{0},
{0},
{0},
{5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_SCE, TYPE_LFE}, // 7 channels - front center + front stereo + back stereo + back center + LFE
{5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, // 8 channels - front center + front stereo + side stereo + back stereo + LFE
{0},
{5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE, TYPE_CPE}, // 8 channels - front center + front stereo + back stereo + LFE + top front stereo
};
/**
* Table to remap channels from libavcodec's default order to AAC order.
*/
static const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS] = {
static const uint8_t aac_chan_maps[14][AAC_MAX_CHANNELS] = {
{ 0 },
{ 0, 1 },
{ 2, 0, 1 },
@@ -77,7 +91,13 @@ static const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS] = {
{ 2, 0, 1, 3, 4 },
{ 2, 0, 1, 4, 5, 3 },
{ 0 },
{ 0 },
{ 0 },
{ 0 },
{ 2, 0, 1, 4, 5, 6, 3, },
{ 2, 0, 1, 6, 7, 4, 5, 3 },
{ 0 },
{ 2, 0, 1, 4, 5, 3, 6, 7 },
};
/** bits needed to code codebook run value for long windows */
+8 -4
View File
@@ -84,9 +84,11 @@ void ff_aac_sbr_ctx_close_fixed(ChannelElement *che);
/** Decode one SBR element. */
int ff_aac_sbr_decode_extension(AACDecContext *ac, ChannelElement *che,
GetBitContext *gb, int crc, int cnt, int id_aac);
GetBitContext *gb, int crc, int cnt, int id_aac,
int fl960);
int ff_aac_sbr_decode_extension_fixed(AACDecContext *ac, ChannelElement *che,
GetBitContext *gb, int crc, int cnt, int id_aac);
GetBitContext *gb, int crc, int cnt, int id_aac,
int fl960);
/** Due to channel allocation not being known upon SBR parameter transmission,
* supply the parameters separately.
@@ -101,9 +103,11 @@ int ff_aac_sbr_decode_usac_data(AACDecContext *ac, ChannelElement *che,
/** Apply one SBR element to one AAC element. */
void ff_aac_sbr_apply(AACDecContext *ac, ChannelElement *che,
int id_aac, void /* float */ *L, void /* float */ *R);
int id_aac, int fl960,
void /* float */ *L, void /* float */ *R);
void ff_aac_sbr_apply_fixed(AACDecContext *ac, ChannelElement *che,
int id_aac, void /* int */ *L, void /* int */ *R);
int id_aac, int fl960,
void /* int */ *L, void /* int */ *R);
FF_VISIBILITY_POP_HIDDEN
+42 -39
View File
@@ -636,12 +636,11 @@ static const int8_t ceil_log2[] = {
};
static int read_sbr_grid(AACDecContext *ac, SpectralBandReplication *sbr,
GetBitContext *gb, SBRData *ch_data)
GetBitContext *gb, SBRData *ch_data, int numTimeSlots)
{
int i;
int bs_pointer = 0;
// frameLengthFlag ? 15 : 16; 960 sample length frames unsupported; this value is numTimeSlots
int abs_bord_trail = 16;
int abs_bord_trail = numTimeSlots;
int num_rel_lead, num_rel_trail;
unsigned bs_num_env_old = ch_data->bs_num_env;
int bs_frame_class, bs_num_env;
@@ -991,15 +990,15 @@ static void read_sbr_extension(AACDecContext *ac, SpectralBandReplication *sbr,
}
static int read_sbr_single_channel_element(AACDecContext *ac,
SpectralBandReplication *sbr,
GetBitContext *gb)
SpectralBandReplication *sbr,
GetBitContext *gb, int numTimeSlots)
{
int ret;
if (get_bits1(gb)) // bs_data_extra
skip_bits(gb, 4); // bs_reserved
if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]))
if (read_sbr_grid(ac, sbr, gb, &sbr->data[0], numTimeSlots))
return -1;
read_sbr_dtdf(sbr, gb, &sbr->data[0], 0);
read_sbr_invf(sbr, gb, &sbr->data[0]);
@@ -1015,8 +1014,8 @@ static int read_sbr_single_channel_element(AACDecContext *ac,
}
static int read_sbr_channel_pair_element(AACDecContext *ac,
SpectralBandReplication *sbr,
GetBitContext *gb)
SpectralBandReplication *sbr,
GetBitContext *gb, int numTimeSlots)
{
int ret;
@@ -1024,7 +1023,7 @@ static int read_sbr_channel_pair_element(AACDecContext *ac,
skip_bits(gb, 8); // bs_reserved
if ((sbr->bs_coupling = get_bits1(gb))) {
if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]))
if (read_sbr_grid(ac, sbr, gb, &sbr->data[0], numTimeSlots))
return -1;
copy_sbr_grid(&sbr->data[1], &sbr->data[0]);
read_sbr_dtdf(sbr, gb, &sbr->data[0], 0);
@@ -1041,8 +1040,8 @@ static int read_sbr_channel_pair_element(AACDecContext *ac,
if((ret = read_sbr_noise(ac, sbr, gb, &sbr->data[1], 1)) < 0)
return ret;
} else {
if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]) ||
read_sbr_grid(ac, sbr, gb, &sbr->data[1]))
if (read_sbr_grid(ac, sbr, gb, &sbr->data[0], numTimeSlots) ||
read_sbr_grid(ac, sbr, gb, &sbr->data[1], numTimeSlots))
return -1;
read_sbr_dtdf(sbr, gb, &sbr->data[0], 0);
read_sbr_dtdf(sbr, gb, &sbr->data[1], 0);
@@ -1067,7 +1066,7 @@ static int read_sbr_channel_pair_element(AACDecContext *ac,
}
static unsigned int read_sbr_data(AACDecContext *ac, SpectralBandReplication *sbr,
GetBitContext *gb, int id_aac)
GetBitContext *gb, int id_aac, int numTimeSlots)
{
unsigned int cnt = get_bits_count(gb);
@@ -1075,12 +1074,12 @@ static unsigned int read_sbr_data(AACDecContext *ac, SpectralBandReplication *sb
sbr->ready_for_dequant = 1;
if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) {
if (read_sbr_single_channel_element(ac, sbr, gb)) {
if (read_sbr_single_channel_element(ac, sbr, gb, numTimeSlots)) {
sbr_turnoff(sbr);
return get_bits_count(gb) - cnt;
}
} else if (id_aac == TYPE_CPE) {
if (read_sbr_channel_pair_element(ac, sbr, gb)) {
if (read_sbr_channel_pair_element(ac, sbr, gb, numTimeSlots)) {
sbr_turnoff(sbr);
return get_bits_count(gb) - cnt;
}
@@ -1133,12 +1132,13 @@ static void sbr_reset(AACDecContext *ac, SpectralBandReplication *sbr)
*/
int AAC_RENAME(ff_aac_sbr_decode_extension)(AACDecContext *ac, ChannelElement *che,
GetBitContext *gb_host, int crc,
int cnt, int id_aac)
int cnt, int id_aac, int fl960)
{
SpectralBandReplication *sbr = get_sbr(che);
unsigned int num_sbr_bits = 0, num_align_bits;
unsigned bytes_read;
GetBitContext gbc = *gb_host, *gb = &gbc;
int numTimeSlots = fl960 ? 15 : 16;
skip_bits_long(gb_host, cnt*8 - 4);
sbr->reset = 0;
@@ -1166,7 +1166,7 @@ int AAC_RENAME(ff_aac_sbr_decode_extension)(AACDecContext *ac, ChannelElement *c
sbr_reset(ac, sbr);
if (sbr->start)
num_sbr_bits += read_sbr_data(ac, sbr, gb, id_aac);
num_sbr_bits += read_sbr_data(ac, sbr, gb, id_aac, numTimeSlots);
num_align_bits = ((cnt << 3) - 4 - num_sbr_bits) & 7;
bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3);
@@ -1272,7 +1272,7 @@ int ff_aac_sbr_decode_usac_data(AACDecContext *ac, ChannelElement *che,
if (sbr_ch == 1) { /* sbr_single_channel_element */
/* if (harmonicSBR) ... */
if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]))
if (read_sbr_grid(ac, sbr, gb, &sbr->data[0], 16))
return -1;
read_sbr_dtdf(sbr, gb, &sbr->data[0], indep_flag);
@@ -1291,7 +1291,7 @@ int ff_aac_sbr_decode_usac_data(AACDecContext *ac, ChannelElement *che,
/* if (harmonicSBR) ... */
if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]))
if (read_sbr_grid(ac, sbr, gb, &sbr->data[0], 16))
return -1;
copy_sbr_grid(&sbr->data[1], &sbr->data[0]);
@@ -1323,9 +1323,9 @@ int ff_aac_sbr_decode_usac_data(AACDecContext *ac, ChannelElement *che,
/* if (harmonicSBR) ... */
if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]))
if (read_sbr_grid(ac, sbr, gb, &sbr->data[0], 16))
return -1;
if (read_sbr_grid(ac, sbr, gb, &sbr->data[1]))
if (read_sbr_grid(ac, sbr, gb, &sbr->data[1], 16))
return -1;
read_sbr_dtdf(sbr, gb, &sbr->data[0], indep_flag);
@@ -1369,16 +1369,17 @@ static void sbr_qmf_analysis(AVFloatDSPContext *dsp, AVTXContext *mdct,
av_tx_fn mdct_fn,
#endif /* USE_FIXED */
SBRDSPContext *sbrdsp, const INTFLOAT *in, INTFLOAT *x,
INTFLOAT z[320], INTFLOAT W[2][32][32][2], int buf_idx)
INTFLOAT z[320], INTFLOAT W[2][32][32][2], int buf_idx,
int numTimeSlots)
{
int i;
#if USE_FIXED
int j;
#endif
memcpy(x , x+1024, (320-32)*sizeof(x[0]));
memcpy(x+288, in, 1024*sizeof(x[0]));
for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames
// are not supported
int nb = numTimeSlots * 64;
memcpy(x , x+nb, (320-32)*sizeof(x[0]));
memcpy(x+288, in, nb*sizeof(x[0]));
for (i = 0; i < numTimeSlots*2; i++) { // RATE*numTimeSlots = 2* 16 or 15
dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320);
sbrdsp->sum64x5(z);
sbrdsp->qmf_pre_shuffle(z);
@@ -1417,13 +1418,14 @@ static void sbr_qmf_synthesis(AVTXContext *mdct, av_tx_fn mdct_fn,
#endif /* USE_FIXED */
INTFLOAT *out, INTFLOAT X[2][38][64],
INTFLOAT mdct_buf[2][64],
INTFLOAT *v0, int *v_off, const unsigned int div)
INTFLOAT *v0, int *v_off, int numTimeSlots,
const unsigned int div)
{
int i, n;
const INTFLOAT *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us;
const int step = 128 >> div;
INTFLOAT *v;
for (i = 0; i < 32; i++) {
for (i = 0; i < numTimeSlots*2; i++) {
if (*v_off < step) {
int saved_samples = (1280 - 128) >> div;
memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(INTFLOAT));
@@ -1463,11 +1465,11 @@ static void sbr_qmf_synthesis(AVTXContext *mdct, av_tx_fn mdct_fn,
/// Generate the subband filtered lowband
static int sbr_lf_gen(SpectralBandReplication *sbr,
INTFLOAT X_low[32][40][2], const INTFLOAT W[2][32][32][2],
int buf_idx)
int buf_idx, int numTimeSlots)
{
int i, k;
const int t_HFGen = 8;
const int i_f = 32;
const int i_f = numTimeSlots*2;
memset(X_low, 0, 32*sizeof(*X_low));
for (k = 0; k < sbr->kx[1]; k++) {
for (i = t_HFGen; i < i_f + t_HFGen; i++) {
@@ -1523,10 +1525,10 @@ static int sbr_hf_gen(AACDecContext *ac, SpectralBandReplication *sbr,
/// Generate the subband filtered lowband
static int sbr_x_gen(SpectralBandReplication *sbr, INTFLOAT X[2][38][64],
const INTFLOAT Y0[38][64][2], const INTFLOAT Y1[38][64][2],
const INTFLOAT X_low[32][40][2], int ch)
const INTFLOAT X_low[32][40][2], int ch, int numTimeSlots)
{
int k, i;
const int i_f = 32;
const int i_f = numTimeSlots*2;
const int i_Temp = FFMAX(2*sbr->data[ch].t_env_num_env_old - i_f, 0);
memset(X, 0, 2*sizeof(*X));
for (k = 0; k < sbr->kx[0]; k++) {
@@ -1681,7 +1683,7 @@ static void sbr_env_estimate(AAC_FLOAT (*e_curr)[48], INTFLOAT X_high[64][40][2]
}
void AAC_RENAME(ff_aac_sbr_apply)(AACDecContext *ac, ChannelElement *che,
int id_aac, void *L_, void *R_)
int id_aac, int fl960, void *L_, void *R_)
{
INTFLOAT *L = L_, *R = R_;
SpectralBandReplication *sbr = get_sbr(che);
@@ -1689,6 +1691,7 @@ void AAC_RENAME(ff_aac_sbr_apply)(AACDecContext *ac, ChannelElement *che,
int ch;
int nch = (id_aac == TYPE_CPE) ? 2 : 1;
int err;
int numTimeSlots = fl960 ? 15 : 16;
if (id_aac != sbr->id_aac) {
av_log(ac->avctx, id_aac == TYPE_LFE ? AV_LOG_VERBOSE : AV_LOG_WARNING,
@@ -1718,10 +1721,10 @@ void AAC_RENAME(ff_aac_sbr_apply)(AACDecContext *ac, ChannelElement *che,
sbr_qmf_analysis(ac->fdsp, sbr->mdct_ana, sbr->mdct_ana_fn, &sbr->dsp,
ch ? R : L, sbr->data[ch].analysis_filterbank_samples,
(INTFLOAT*)sbr->qmf_filter_scratch,
sbr->data[ch].W, sbr->data[ch].Ypos);
sbr->data[ch].W, sbr->data[ch].Ypos, numTimeSlots);
sbr->c.sbr_lf_gen(sbr, sbr->X_low,
(const INTFLOAT (*)[32][32][2]) sbr->data[ch].W,
sbr->data[ch].Ypos);
sbr->data[ch].Ypos, numTimeSlots);
sbr->data[ch].Ypos ^= 1;
if (sbr->start) {
sbr->c.sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1,
@@ -1749,9 +1752,9 @@ void AAC_RENAME(ff_aac_sbr_apply)(AACDecContext *ac, ChannelElement *che,
/* synthesis */
sbr->c.sbr_x_gen(sbr, sbr->X[ch],
(const INTFLOAT (*)[64][2]) sbr->data[ch].Y[1-sbr->data[ch].Ypos],
(const INTFLOAT (*)[64][2]) sbr->data[ch].Y[ sbr->data[ch].Ypos],
(const INTFLOAT (*)[40][2]) sbr->X_low, ch);
(const INTFLOAT (*)[64][2]) sbr->data[ch].Y[1-sbr->data[ch].Ypos],
(const INTFLOAT (*)[64][2]) sbr->data[ch].Y[ sbr->data[ch].Ypos],
(const INTFLOAT (*)[40][2]) sbr->X_low, ch, numTimeSlots);
}
if (ac->oc[1].m4ac.ps == 1) {
@@ -1767,13 +1770,13 @@ void AAC_RENAME(ff_aac_sbr_apply)(AACDecContext *ac, ChannelElement *che,
L, sbr->X[0], sbr->qmf_filter_scratch,
sbr->data[0].synthesis_filterbank_samples,
&sbr->data[0].synthesis_filterbank_samples_offset,
downsampled);
numTimeSlots, downsampled);
if (nch == 2)
sbr_qmf_synthesis(sbr->mdct, sbr->mdct_fn, &sbr->dsp, ac->fdsp,
R, sbr->X[1], sbr->qmf_filter_scratch,
sbr->data[1].synthesis_filterbank_samples,
&sbr->data[1].synthesis_filterbank_samples_offset,
downsampled);
numTimeSlots, downsampled);
}
static void aacsbr_func_ptr_init(AACSBRContext *c)
+6 -2
View File
@@ -22,7 +22,8 @@ OBJS-$(CONFIG_VP8DSP) += aarch64/vp8dsp_init_aarch64.o
OBJS-$(CONFIG_AAC_DECODER) += aarch64/aacpsdsp_init_aarch64.o \
aarch64/sbrdsp_init_aarch64.o
OBJS-$(CONFIG_AAC_ENCODER) += aarch64/aacencdsp_init.o
OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_init.o
OBJS-$(CONFIG_DCA_DECODER) += aarch64/dcadsp_init_aarch64.o \
aarch64/synth_filter_init.o
OBJS-$(CONFIG_OPUS_DECODER) += aarch64/opusdsp_init.o
OBJS-$(CONFIG_RV40_DECODER) += aarch64/rv40dsp_init_aarch64.o
OBJS-$(CONFIG_VC1DSP) += aarch64/vc1dsp_init_aarch64.o
@@ -65,7 +66,8 @@ NEON-OBJS-$(CONFIG_VP8DSP) += aarch64/vp8dsp_neon.o
# decoders/encoders
NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/aacpsdsp_neon.o
NEON-OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_neon.o
NEON-OBJS-$(CONFIG_DCA_DECODER) += aarch64/dcadsp_neon.o \
aarch64/synth_filter_neon.o
NEON-OBJS-$(CONFIG_OPUS_DECODER) += aarch64/opusdsp_neon.o
NEON-OBJS-$(CONFIG_VORBIS_DECODER) += aarch64/vorbisdsp_neon.o
NEON-OBJS-$(CONFIG_VP9_DECODER) += aarch64/vp9itxfm_16bpp_neon.o \
@@ -78,6 +80,8 @@ NEON-OBJS-$(CONFIG_HEVC_DECODER) += aarch64/hevcdsp_deblock_neon.o \
aarch64/hevcdsp_dequant_neon.o \
aarch64/hevcdsp_idct_neon.o \
aarch64/hevcdsp_init_aarch64.o \
aarch64/hevcpred_neon.o \
aarch64/hevcpred_init_aarch64.o \
aarch64/h26x/epel_neon.o \
aarch64/h26x/qpel_neon.o \
aarch64/h26x/sao_neon.o

Some files were not shown because too many files have changed in this diff Show More