1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00
Commit Graph

42 Commits

Author SHA1 Message Date
TADANO Tokumei
dce56e75eb avfilter/v360_vulkan: support GoPro Max inputs
Add GoPro Max 360 projection for input.
Add tentative Equi-Angular Cubemap (EAC) projection for output
(for testing).

Signed-off-by: TADANO Tokumei <aimingoff@pc.nifty.jp>
2026-10-01 14:57:38 +00:00
TADANO Tokumei
cc6003d5f5 avfilter/v360_vulkan: reduce size of Push Constants
Remove `in_img_size[][]` from PushData.
Even though it is constant through a filter process, it occupies
128 bites of Push Constants. It may exceed limit of some hardware.
The information is passed via Specialization Constants.

In addition to `in_img_size`, number of planes is passed via
Specialization Constants, that was hard-coded with magic number.
`m_pi4` is for later enhancement.

Signed-off-by: TADANO Tokumei <aimingoff@pc.nifty.jp>
2026-10-01 14:57:38 +00:00
Kacper Michajłow
00e49750e8 avfilter/vf_scale_vulkan: convert to the negotiated chroma location
The output link accepts any location and the frames are converted to the
negotiated one. Format conversions tagged the output as top-left while the
chroma of each 2x2 block came from whichever of its four invocations
stored it last, and scaling without a format change scaled each plane on
its own grid, which only keeps center sited chroma in place. The chroma of
each block is now sampled once at its location, and the chroma planes are
resampled from the input location to the output one. Without a negotiated
location, subsampled input keeps its location and other input still gets
top-left, and input without a location is assumed to be sited like the
output.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-01 14:31:15 +00:00
Marcos Ashton Iglesias
e4c7773fdb avfilter/vulkan/gblur: repeat the edge pixels instead of reading black
Taps outside the frame were read as 0, which darkened the borders.
2026-10-01 03:11:19 +00:00
Marcos Ashton Iglesias
92a5c7e4f5 avfilter/vf_avgblur_vulkan: use the documented radius and edge handling
sizeX/sizeY were used as radius - 1, the normalisation ignored the
vertical radius and pixels outside the frame were read as black. Match
avgblur: use the radii, limited to half the chroma plane, and repeat the
edge pixels. Existing uses now blur one pixel more, as documented.
2026-10-01 03:11:19 +00:00
Marcos Ashton Iglesias
851bbd4dae avfilter/vulkan/transpose: fix all four directions
The shader runs per output pixel but mixed input and output coordinates:
cclock_flip left part of the output unwritten, clock came out mirrored
and cclock/clock_flip were off by one. Read the source pixel for each
output pixel instead, like the OpenCL filter.
2026-10-01 03:11:19 +00:00
Marcos Ashton Iglesias
7b7b8e1b17 avfilter/vulkan/flip: fix off-by-one in the mirrored position
The mirror of pos is size - 1 - pos, not size - pos. The picture was
shifted by one pixel and column (or row) 0 was never written.
2026-10-01 03:11:19 +00:00
Lynne
7bcb37ac20 vf_xfade_vulkan: match the software filter's transitions
The slides truncated the offset from the opposite end, landing one row
or column behind. The circles used the squared distance ratio. Every
edge now derives from the reversed progress the same way vf_xfade does,
and pixelize samples at integer coordinates.

Slides and wipes are now bit-exact. Fade, circles and pixelize remain
within 1 LSB, as the software filter truncates when storing.
2026-09-24 08:06:27 +09:00
Lynne
b3a2179e30 vulkan_filter: bind the output first in ff_vk_filter_process_Nin
Lets one shader serve a variable number of inputs, as the output and
the leading inputs keep their bindings when fewer are used.
2026-09-20 21:17:21 +09:00
Philip Langdale
964d4786ec avfilter/fruc_vulkan: don't recalculate warping for every plane
The warp calculation is currently done for every plane, but doesn't depend on
the plane contents, just the dimensions; so this is wasted work when plane
sizes don't vary (eg: RGB, 4:4:4 YUV).

This will not have a visible impact on performance at realistic interpolation
rates as the optical flow generation is the limiting factor until you are
doing something silly like 30->900fps.

But wasted work is wasted work, so best to stop doing it.
2026-08-29 17:07:54 -07:00
Philip Langdale
f6d7c08944 avfilter/fruc_vulkan: support planar RGB and additional packed formats
We have previously only supported some packed RGB and planar YUV, so the logic
for extracting the luma was not flexible enough to handle other scenarios.

To generalise this for planar RGB, we need to bind every colour plane to the
grayscale shader and derive luma from it.

Additionally, we add support packed 4:4:4 YUV formats.
2026-08-29 17:07:54 -07:00
Philip Langdale
a87d92d975 avfilter/fruc_vulkan: suppress spurious flow in featureless regions
In textureless regions the optical flow engine has no data to track and
its regularizer invents a smooth, often large, and internally
self-consistent flow field. Backward warping then traces a background
pixel along that invented flow onto a nearby moving object and pulls
object pixels into what should be empty background, leaving a ghost
outline at a distance from the object where nothing is actually moving.
Forward/backward flow consistency does not catch this because the
invented flow round-trips cleanly.

I have no idea if this is a common limitation in optical flow implementations
but it's definitely happening with the nvidia hardware, so this change
attempts to introduce a heuristic to work around it.

When the luma at a given location is sufficiently identical in both frames,
and the optical flow magnitude is sufficiently large, we will now assume that
the location is static and the flow is bogus. Genuine motion will usually lead
to luma differences, and low magnitude flow will be respected either way.

Again, this is all highly empirical, and the constants are justified purely by
by fiddling around with specific samples.
2026-08-29 17:07:53 -07:00
Philip Langdale
283565c4c9 avfilter/fruc_vulkan: warp frames with the computed optical flow
Replace the placeholder temporal blend in the interpolation shader with a
motion-compensated algorithm. This is finally the point where we are actually
using the optical flow information.

For each output pixel the source position on the f0 and f1 grids is recovered
by fixed-point Picard iteration before the samples are blended. The number of
iterations and the relaxation factor are established through empirical testing
on a couple of ad-hoc samples, representing highly uniform and non-uniform
motion respectively.

The approach here is hardly profound, and not meant to be. There are for sure
many more advanced algorithms for doing motion interpolation from optical flow,
and we can happily replace it with, or add, something more advanced once all
the machinery is in place.
2026-08-29 17:07:53 -07:00
Philip Langdale
2f00078367 avfilter/fruc_vulkan: add the initial optical-flow pipeline
Add the Vulkan optical-flow machinery on top of the filter skeleton:
* a grayscale-extraction compute shader
* the VK_NV_optical_flow session and its persistent input/flow images
* the cross-queue (compute -> optical flow -> compute) submission with
  binary-semaphore ordering
* an interpolation compute shader dispatched per output frame which blends each
  new frame instead of repeating the nearest source frame

Notable characteristics:

* At this stage we are doing a simple proportional blend that doesn't actually
  look at the optical flow information. That will happen in the next commit
* The optical flow is stored in a weird nvidia specific fixed point image
  format. Yay?
* Optical flow is calculated based purely on Luma. For YUV format, this is
  trivially obtained, but for RGB input, we should put some effort into getting
  accurate Luma. But we only need relative Luma differences, so we don't have
  to use the exactly correct colourspace conversion; I've just hard-coded
  BT.709
* We're doing host-synchronisation for initial simplicity, but this will get
  replaced in subsequent changes
* The accepted format set is deliberately narrow to begin with: planar and
  semi-planar YUV, gray, and packed RGB whose sampled channels are already
  in component order. Subsequent changes will expand the support set.
* We rely on VK_KHR_maintenance9 to enable implicit ownership transfers for
  images between the compute and optical flow queue families.
2026-08-29 17:07:53 -07:00
Lynne
6219d4fdd1 vf_scale_vulkan: port to compile-time SPIR-V generation
Same functionality as before, but cleaner.
2026-07-13 18:57:37 +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
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
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
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
Lynne
ae1a227cf6 Makefile: specify GLSL version via command line arguments
GLSL strictly mandates the version must be the very first non-comment
statement, which results in issues when #including for templating.
2026-02-19 19:42:20 +01:00
Lynne
8dcf02ac63 vulkan: remove IS_WITHIN macro
This is the more correct GLSL solution.
2026-01-19 16:37:15 +01:00
Lynne
80229c161b scale_vulkan: use compile-time SPIR-V generation for debayering 2026-01-12 17:28:43 +01:00
Lynne
f3b0ca4f2c avgblur_vulkan: generate SPIR-V during compilation 2026-01-12 17:28:42 +01:00
Lynne
a6391168f2 bwdif_vulkan: use compile-time SPIR-V 2026-01-12 17:28:42 +01:00
Lynne
f2affdfafb configure/make: support compile-time SPIR-V generation 2026-01-12 17:28:40 +01:00
Lynne
451e6bed43 lavfi/bwdif_vulkan: fix typo in temp_diff assignment
Thanks to Niklas Haas for pointing this out.
2025-08-20 22:06:21 +09:00
Lynne
b8c92e2893 scale_vulkan: add support for basic Debayering 2025-08-08 01:06:11 +09:00
Lynne
779763181f bwdif_vulkan: convert to storage images
texture() uses bilinear scaling; imageLoad() accesses the image directly.
The reason why texture() was used throughout Vulkan filters is that
back when they were written, they were targetting old Intel hardware,
which had a texel cache only for sampled images.

These days, GPUs have a generic cache that doesn't care what source it
gets populated with. Additionally, bypassing the sampling circuitry saves
us some performance.

Finally, all the old texture() code had an issue where unnormalized
coordinates were used, but an offset of 0.5 was not added, hence each
pixel ended up being interpolated. This fixes this.
2025-02-18 10:44:53 +01:00
Lynne
4d19be287f libavfilter/Makefile: add a makefile for Vulkan shaders 2024-10-15 17:45:20 +02:00
Lynne
e3d3ee516a bwdif_vulkan: split off main shader code as a separate file
The code to support this was still there, may as well use it.
2024-10-06 01:32:46 +02:00
Lynne
f31d0f1141 nlmeans_vulkan: parallelize workgroup invocations 2023-10-11 16:53:06 +02:00
Lynne
160a415e22 lavfi: add nlmeans_vulkan filter 2023-05-29 00:42:01 +02:00
Lynne
88e2cca3db tools/cl2c: change to tools/source2c and allow non-OpenCL source files 2023-05-29 00:42:00 +02:00