FFmpeg
Loading...
Searching...
No Matches
ops.c File Reference
#include "libavutil/mem.h"
#include "libavutil/refstruct.h"
#include "../graph.h"
#include "../ops_internal.h"
#include "../swscale_internal.h"
#include "../uops.h"
#include "ops.h"
#include "spvasm.h"

Go to the source code of this file.

Data Structures

struct  VulkanPriv
 
struct  SPIRVIDs
 

Macros

#define MAX_DITHER_BUFS   4
 
#define MAX_FILT_BUFS   4
 
#define MAX_DATA_BUFS   (MAX_DITHER_BUFS + MAX_FILT_BUFS*4)
 

Functions

static void vk_ops_ctx_uninit (AVRefStructOpaque opaque, void *obj)
 Copyright (C) 2026 Lynne.
 
int ff_sws_vk_init (SwsContext *sws, AVBufferRef *dev_ref)
 
AVBufferRef * ff_sws_vk_device_ref (SwsContext *sws)
 Returns the Vulkan device reference associated with sws, or NULL if Vulkan has not been initialized for this context.
 
static void spirv_process (const SwsFrame *dst, const SwsFrame *src, int y, int h, const SwsPass *pass)
 
static void spirv_free (void *priv)
 
static int create_filter_buf (FFVulkanOpsCtx *s, const SwsFilterWeights *wd, FFVkBuffer *buf)
 
static int create_dither_buf (FFVulkanOpsCtx *s, const SwsUOp *uop, FFVkBuffer *buf)
 
static int type_scalar (const SPIRVIDs *id, SwsPixelType type)
 
static int type_vec4 (const SPIRVIDs *id, SwsPixelType type)
 
static int const_zero (const SPIRVIDs *id, SwsPixelType type)
 
static int const_pixel (SPICtx *spi, const SPIRVIDs *id, SwsPixelType type, SwsPixel px)
 
static int const_splat (SPICtx *spi, const SPIRVIDs *id, SwsPixelType type, SwsPixel px)
 
static void define_pack_consts (SPICtx *spi, const SPIRVIDs *id, const SwsUOp *uop, int *shift_id, int *mask_id)
 
static int emit_add (SPICtx *spi, SwsPixelType type, int res_type, int a, int b)
 
static int emit_mul (SPICtx *spi, SwsPixelType type, int res_type, int a, int b)
 
static int emit_min (SPICtx *spi, const SPIRVIDs *id, SwsPixelType type, int res_type, int a, int b)
 
static int emit_max (SPICtx *spi, const SPIRVIDs *id, SwsPixelType type, int res_type, int a, int b)
 
static int emit_convert (SPICtx *spi, SwsPixelType from, SwsPixelType to, int res_type, int a)
 
static void define_shader_header (SPICtx *spi, SPIRVIDs *id)
 
static void define_shader_consts (SPICtx *spi, SPIRVIDs *id)
 
static void define_shader_bindings (const SwsOpList *ops, SPICtx *spi, SPIRVIDs *id, int in_img_count, int out_img_count)
 
static void define_entry_point (FFVulkanShader *shd, SPICtx *spi, SPIRVIDs *id)
 
static int insert_vmat_linear (const SwsUOp *uop, SPICtx *spi, SPIRVIDs *id, int data)
 
static int insert_bitexact_linear (const SwsUOp *uop, SPICtx *spi, SPIRVIDs *id, int data)
 
static int add_buf_binding (SPIRVIDs *id)
 
static int emit_read_filtered (SPICtx *spi, SPIRVIDs *id, const SwsUOp *uop, int *data)
 
static VkFormat packed_word_fmt (const SwsOp *op)
 
static int get_view_fmts (VkFormat view_fmts[AV_NUM_DATA_POINTERS], enum AVPixelFormat fmt, const SwsOp *op)
 
static int rw_op_img_count (const SwsOp *op, const uint8_t *planes)
 
static int emit_read (SPICtx *spi, SPIRVIDs *id, const SwsUOp *uop, int *data)
 
static int emit_write (SPICtx *spi, SPIRVIDs *id, const SwsUOp *uop, int *data)
 
static int emit_clamp (SPICtx *spi, SPIRVIDs *id, const SwsUOp *uop, int *data)
 
static int emit_dither (SPICtx *spi, SPIRVIDs *id, const SwsUOp *uop, int *data)
 
static int emit_linear (SPICtx *spi, SPIRVIDs *id, const SwsUOp *uop, int *data)
 
static int emit_pack (SPICtx *spi, SPIRVIDs *id, const SwsUOp *uop, int *data)
 
static int emit_shader (SwsContext *sws, VulkanPriv *p, FFVulkanOpsCtx *s, const SwsOpList *ops, const SwsUOpList *uops, FFVulkanShader *shd, SPICtx *spi)
 
static int add_ops_spirv (SwsContext *sws, VulkanPriv *p, FFVulkanOpsCtx *s, const SwsOpList *ops, const SwsUOpList *uops, FFVulkanShader *shd)
 
static int compile_ops_spirv (SwsContext *sws, const SwsOpList *ops, SwsCompiledOp *out)
 

Variables

const SwsOpBackend backend_spirv
 

Macro Definition Documentation

◆ MAX_DITHER_BUFS

#define MAX_DITHER_BUFS   4

Definition at line 80 of file ops.c.

◆ MAX_FILT_BUFS

#define MAX_FILT_BUFS   4

Definition at line 81 of file ops.c.

◆ MAX_DATA_BUFS

#define MAX_DATA_BUFS   (MAX_DITHER_BUFS + MAX_FILT_BUFS*4)

Definition at line 82 of file ops.c.

Referenced by emit_dither(), and emit_read_filtered().

Function Documentation

◆ vk_ops_ctx_uninit()

static void vk_ops_ctx_uninit ( AVRefStructOpaque opaque,
void * obj )
static

Copyright (C) 2026 Lynne.

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

Definition at line 33 of file ops.c.

Referenced by ff_sws_vk_init().

◆ ff_sws_vk_init()

int ff_sws_vk_init ( SwsContext * sws,
AVBufferRef * dev_ref )

Definition at line 40 of file ops.c.

Referenced by sws_frame_setup().

◆ ff_sws_vk_device_ref()

AVBufferRef * ff_sws_vk_device_ref ( SwsContext * sws)

Returns the Vulkan device reference associated with sws, or NULL if Vulkan has not been initialized for this context.

Definition at line 73 of file ops.c.

Referenced by pass_alloc_output().

◆ spirv_process()

static void spirv_process ( const SwsFrame * dst,
const SwsFrame * src,
int y,
int h,
const SwsPass * pass )
static

Definition at line 95 of file ops.c.

Referenced by compile_ops_spirv().

◆ spirv_free()

static void spirv_free ( void * priv)
static

Definition at line 182 of file ops.c.

Referenced by compile_ops_spirv().

◆ create_filter_buf()

static int create_filter_buf ( FFVulkanOpsCtx * s,
const SwsFilterWeights * wd,
FFVkBuffer * buf )
static

Definition at line 193 of file ops.c.

Referenced by emit_read_filtered().

◆ create_dither_buf()

static int create_dither_buf ( FFVulkanOpsCtx * s,
const SwsUOp * uop,
FFVkBuffer * buf )
static

Definition at line 228 of file ops.c.

Referenced by emit_dither().

◆ type_scalar()

static int type_scalar ( const SPIRVIDs * id,
SwsPixelType type )
static

◆ type_vec4()

static int type_vec4 ( const SPIRVIDs * id,
SwsPixelType type )
static

◆ const_zero()

static int const_zero ( const SPIRVIDs * id,
SwsPixelType type )
static

Definition at line 343 of file ops.c.

Referenced by emit_read(), emit_shader(), and insert_bitexact_linear().

◆ const_pixel()

static int const_pixel ( SPICtx * spi,
const SPIRVIDs * id,
SwsPixelType type,
SwsPixel px )
static

◆ const_splat()

static int const_splat ( SPICtx * spi,
const SPIRVIDs * id,
SwsPixelType type,
SwsPixel px )
static

Definition at line 364 of file ops.c.

Referenced by emit_shader(), and insert_bitexact_linear().

◆ define_pack_consts()

static void define_pack_consts ( SPICtx * spi,
const SPIRVIDs * id,
const SwsUOp * uop,
int * shift_id,
int * mask_id )
static

Definition at line 372 of file ops.c.

Referenced by emit_pack(), and emit_shader().

◆ emit_add()

static int emit_add ( SPICtx * spi,
SwsPixelType type,
int res_type,
int a,
int b )
static

Definition at line 389 of file ops.c.

Referenced by emit_shader(), and insert_bitexact_linear().

◆ emit_mul()

static int emit_mul ( SPICtx * spi,
SwsPixelType type,
int res_type,
int a,
int b )
static

Definition at line 395 of file ops.c.

Referenced by emit_shader(), and insert_bitexact_linear().

◆ emit_min()

static int emit_min ( SPICtx * spi,
const SPIRVIDs * id,
SwsPixelType type,
int res_type,
int a,
int b )
static

Definition at line 401 of file ops.c.

Referenced by emit_clamp().

◆ emit_max()

static int emit_max ( SPICtx * spi,
const SPIRVIDs * id,
SwsPixelType type,
int res_type,
int a,
int b )
static

Definition at line 408 of file ops.c.

Referenced by emit_clamp().

◆ emit_convert()

static int emit_convert ( SPICtx * spi,
SwsPixelType from,
SwsPixelType to,
int res_type,
int a )
static

Definition at line 416 of file ops.c.

Referenced by emit_read_filtered(), and emit_shader().

◆ define_shader_header()

static void define_shader_header ( SPICtx * spi,
SPIRVIDs * id )
static

Definition at line 426 of file ops.c.

Referenced by emit_shader().

◆ define_shader_consts()

static void define_shader_consts ( SPICtx * spi,
SPIRVIDs * id )
static

Definition at line 442 of file ops.c.

Referenced by emit_shader().

◆ define_shader_bindings()

static void define_shader_bindings ( const SwsOpList * ops,
SPICtx * spi,
SPIRVIDs * id,
int in_img_count,
int out_img_count )
static

Definition at line 472 of file ops.c.

Referenced by emit_shader().

◆ define_entry_point()

static void define_entry_point ( FFVulkanShader * shd,
SPICtx * spi,
SPIRVIDs * id )
static

Definition at line 559 of file ops.c.

Referenced by emit_shader().

◆ insert_vmat_linear()

static int insert_vmat_linear ( const SwsUOp * uop,
SPICtx * spi,
SPIRVIDs * id,
int data )
static

Definition at line 567 of file ops.c.

Referenced by emit_linear().

◆ insert_bitexact_linear()

static int insert_bitexact_linear ( const SwsUOp * uop,
SPICtx * spi,
SPIRVIDs * id,
int data )
static

Definition at line 590 of file ops.c.

Referenced by emit_linear().

◆ add_buf_binding()

static int add_buf_binding ( SPIRVIDs * id)
static

Definition at line 646 of file ops.c.

Referenced by emit_dither(), and emit_read_filtered().

◆ emit_read_filtered()

static int emit_read_filtered ( SPICtx * spi,
SPIRVIDs * id,
const SwsUOp * uop,
int * data )
static

Definition at line 656 of file ops.c.

Referenced by emit_read().

◆ packed_word_fmt()

static VkFormat packed_word_fmt ( const SwsOp * op)
static

Definition at line 765 of file ops.c.

Referenced by get_view_fmts().

◆ get_view_fmts()

static int get_view_fmts ( VkFormat view_fmts[AV_NUM_DATA_POINTERS],
enum AVPixelFormat fmt,
const SwsOp * op )
static

Definition at line 778 of file ops.c.

Referenced by emit_shader().

◆ rw_op_img_count()

static int rw_op_img_count ( const SwsOp * op,
const uint8_t * planes )
static

Definition at line 802 of file ops.c.

Referenced by emit_shader().

◆ emit_read()

static int emit_read ( SPICtx * spi,
SPIRVIDs * id,
const SwsUOp * uop,
int * data )
static

Definition at line 811 of file ops.c.

Referenced by emit_shader().

◆ emit_write()

static int emit_write ( SPICtx * spi,
SPIRVIDs * id,
const SwsUOp * uop,
int * data )
static

Definition at line 849 of file ops.c.

Referenced by emit_shader().

◆ emit_clamp()

static int emit_clamp ( SPICtx * spi,
SPIRVIDs * id,
const SwsUOp * uop,
int * data )
static

Definition at line 877 of file ops.c.

Referenced by emit_shader().

◆ emit_dither()

static int emit_dither ( SPICtx * spi,
SPIRVIDs * id,
const SwsUOp * uop,
int * data )
static

Definition at line 898 of file ops.c.

Referenced by emit_shader().

◆ emit_linear()

static int emit_linear ( SPICtx * spi,
SPIRVIDs * id,
const SwsUOp * uop,
int * data )
static

Definition at line 961 of file ops.c.

Referenced by emit_shader().

◆ emit_pack()

static int emit_pack ( SPICtx * spi,
SPIRVIDs * id,
const SwsUOp * uop,
int * data )
static

Definition at line 971 of file ops.c.

Referenced by emit_shader().

◆ emit_shader()

static int emit_shader ( SwsContext * sws,
VulkanPriv * p,
FFVulkanOpsCtx * s,
const SwsOpList * ops,
const SwsUOpList * uops,
FFVulkanShader * shd,
SPICtx * spi )
static

Definition at line 989 of file ops.c.

Referenced by add_ops_spirv().

◆ add_ops_spirv()

static int add_ops_spirv ( SwsContext * sws,
VulkanPriv * p,
FFVulkanOpsCtx * s,
const SwsOpList * ops,
const SwsUOpList * uops,
FFVulkanShader * shd )
static

Definition at line 1244 of file ops.c.

Referenced by compile_ops_spirv().

◆ compile_ops_spirv()

static int compile_ops_spirv ( SwsContext * sws,
const SwsOpList * ops,
SwsCompiledOp * out )
static

Definition at line 1270 of file ops.c.

Variable Documentation

◆ backend_spirv

const SwsOpBackend backend_spirv
Initial value:
= {
.name = "spirv",
.compile = compile_ops_spirv,
.hw_format = AV_PIX_FMT_VULKAN,
}
@ SWS_BACKEND_SPIRV
Vulkan SPIR-V backend.
Definition swscale.h:120
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition pixfmt.h:379
static int compile_ops_spirv(SwsContext *sws, const SwsOpList *ops, SwsCompiledOp *out)
Definition ops.c:1270

Definition at line 1331 of file ops.c.