Commit Graph

125336 Commits

Author SHA1 Message Date
Philip Langdale
b9aa305686 avutil/hwcontext_vulkan: declare cuda as a transfer-compatible format
The cuda hwcontext has listed AV_PIX_FMT_VULKAN among its supported
formats since Vulkan interop was first added, so a device's frame
constraints advertise Vulkan as a transfer-compatible ("sw") format.
This is what allows an hwupload targeting a cuda device to accept a
Vulkan frame as input during format negotiation.

The Vulkan hwcontext never made the reciprocal declaration, so an
hwupload targeting a Vulkan device would not accept a cuda frame, and a
cuda -> Vulkan upload could not be configured even though the transfer
itself is supported. Advertise AV_PIX_FMT_CUDA in the Vulkan frame
constraints to ensure we have consistent behaviour in both directions.

(cherry picked from commit d09d5afc3a)
2026-07-12 13:48:17 +09:00
Lynne
6758e66fb5 ffv1enc_vulkan: fix VRAM size detection
The reduction accumulated into the zero-initialized context field
instead of the local variable, so the detected VRAM was whatever
device-local heap the implementation listed last, usually the
256MiB BAR heap rather than the multi-GiB VRAM heap.

This made the encoder take the host-memory fallback (or fail the
allocation outright at 12K and above) on hardware with plenty of VRAM.

(cherry picked from commit 43d0d365f3)
2026-07-12 13:47:24 +09:00
Zhao Zhili
30ae65e506 avutil/hwcontext_vulkan: query the actual image format in try_export_flags
GetPhysicalDeviceImageFormatProperties2() must be queried with the format
that will actually be used to create the image, otherwise the external
memory export capability check answers for a different format than the one
being allocated.

When AV_VK_FRAME_FLAG_DISABLE_MULTIPLANE is set (e.g. by ffplay for CUDA
interop), vulkan_frames_init selects the per-plane fallback format via
vkfmt_from_pixfmt2(disable_multiplane=1) and stores it in hwctx->format[].
The image is then created with that fallback format. Querying the
multiplane vkf instead returns capability for a format that is never
instantiated, and on NVIDIA GPUs with OPTIMAL tiling the answer differs
between the two formats, producing broken CUDA hwaccel output.

Read hwctx->format[0], which is populated by vulkan_frames_init before
vulkan_pool_alloc runs, so the query matches the image regardless of
whether the multiplane or fallback path was taken.

Fix artifacts with `ffplay -hwaccel cuda foo.mp4`.

(cherry picked from commit 0baa71b53c)
2026-07-12 13:47:24 +09:00
Zhao Zhili
68fa1f7f48 libavutil/vulkan: fix elem_size computation in vulkan_export_to_cuda
(cherry picked from commit b4b30ff8fd)
2026-07-12 13:47:24 +09:00
Philip Langdale
63211cbec1 avutil/hwcontext_vulkan: reject unsupported semi-planar CUDA imports
Cuda currently only supports packed and single-component planar formats, but
fails to import semi-planer (eg: NV12, P010). Even though there are now
semi-planar cuda array formats, which the latest nvdec can use, these formats
are not used when mapping Vulkan imports. Maybe they'll fix that some day.

But until then, let's explicitly detect the case and return a clear error
message for the user.

Exercising this error path revealed that vulkan_free_internal() frees
f->internal on a transfer error and then runs again when the frame is
destroyed, dereferencing the freed pointer; let's make it idempotent.

(cherry picked from commit c29d710cd5)
2026-07-12 13:47:24 +09:00
Philip Langdale
6f2c280187 avutil/hwcontext_vulkan: CUDA interop semaphores are per image
The current semaphore logic dates back to a time where we did not have any
multiplane images, and it has not kept up. As a result, we currently try and
manipulate too many semaphores when dealing with multiplane images, leading to
errors and crashes. Let's fix it.

(cherry picked from commit 30ba440386)
2026-07-12 13:47:24 +09:00
Philip Langdale
f1137f1074 avutil/hwcontext_vulkan: fix CUDA interop for packed formats
The current export_to_cuda logic only works for planar and semi-planar formats.
When presented with a single plane packed format, it will incorrectly
calculate the number of channels, resulting in failures later on when cuda
code tries to access the frame. Let's fix it.

(cherry picked from commit 927f205eb8)
2026-07-12 13:47:24 +09:00
Pavel Kohout
3d129a4a85 avcodec/vulkan_hevc: reject too many VPS HRD parameter sets
Fixes: stack buffer overflow
Fixes: tD7Mj0ST7ND3
Fixes: 82864c2111 (vulkan_hevc: use VK_KHR_video_maintenance2 if available)
Found-by: Pavel Kohout (Aisle Research)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 92737390dc)
2026-07-12 13:47:24 +09:00
Lynne
2a31f05fca vulkan/prores_raw: reconstruct DC values in 32-bit
DCs can go over int16_t, and when it does, dc_add wraps, so the wrong sign
is reported, which causes errors when decoding more DCs.

Do the prediction in int and narrow to int16 only at store time. The
read_ac_vals() sign change is cosmetic (the value is only ever 0/-1, and
the old code already widened it).

(cherry picked from commit 5784a775df)
2026-07-12 13:47:24 +09:00
Zhao Zhili
e1c08b9c0f avcodec/ffv1enc_vulkan: fix format specifier for VkDeviceSize
Fix build warning on macOS:
> format specifies type 'size_t' (aka 'unsigned long') but the
> argument has type 'VkDeviceSize' (aka 'unsigned long long')

VkDeviceSize is typedef as uint64_t.

(cherry picked from commit 97ba3c4a9a)
2026-07-12 13:47:24 +09:00
Lynne
8d9bd942ab apv_decode: call ff_thread_finish_setup()
"[...] decoders with update_thread_context callback have to call
ff_thread_finish_setup() themselves; it is not done implicitly in
ff_thread_get_buffer() any more.
Not doing so makes the decoder effectively single-threaded."

(cherry picked from commit 300cac3078)
2026-07-11 17:11:21 +09:00
Jack Lau
ca9d828102 avformat/whip: disable DTLS certificate verification
Fix DTLS failure since 9549c9ad79

WebRTC does not verify CA because it allows self-signed cerificate.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
(cherry picked from commit 6f2f3755a0)
2026-07-07 22:27:00 +08:00
Kacper Michajłow
b06c5316b7 avfilter/vsrc_gfxcapture_winrt: add missing system_error include
Fixes: error: no type named 'system_error' in namespace 'std'
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
(cherry picked from commit c6498178bb)
2026-07-06 09:55:38 +00:00
Martin Storsjö
9d97419239 configure: Pass the .objs response file to makedef
This fixes generating shared libraries with a toolchain that requires
makedef (MSVC, or mingw toolchains with LLD, that lacks support for
--version-script).

This uses the existing response file generated for linking, by
splitting out the choice of input parameter to makedef to a variable
expanded by make.

This avoids relying on "echo" within makedef supporting long command
lines; msys2/cygwin shells handle it fine, while busybox doesn't.

(cherry picked from commit 8512161c81)
2026-06-30 14:12:17 +03:00
Martin Storsjö
228c714a9f configure: Test for response file support in a way that works with busybox-w32
Don't use /dev/null as test input file for the test for response
file support.

Busybox on Windows does provide POSIX utilities to the point of
being able to build and test ffmpeg, but it doesn't provide full
POSIX emulation like msys2 and cygwin do.

Busybox utils do handle paths like /dev/null themselves. But when
busybox invokes a native Windows executable (like the "$ar" tool
in this test), it passes such a path as-is. Msys2 on the other hand
rewrites unixy paths in command line parameters - even when prefixed;
e.g. "@/dev/null" gets rewritten into "@nul".

Instead of testing with a /dev/null input, test with a real temp
file instead.

(cherry picked from commit 32d7e9d71e)
2026-06-30 14:12:16 +03:00
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