29typedef struct V360ulkanContext {
82 for (
int order = 0; order <
NB_RORDERS; order++) {
83 const char c =
s->rorder[order];
88 "Incomplete rorder option. "
89 "Direction for all 3 rotation orders should be specified. "
90 "Switching to default rorder.\n");
91 s->rotation_order[0] =
YAW;
92 s->rotation_order[1] =
PITCH;
93 s->rotation_order[2] =
ROLL;
100 "Incorrect rotation order symbol '%c' in rorder option. "
101 "Switching to default rorder.\n",
c);
102 s->rotation_order[0] =
YAW;
103 s->rotation_order[1] =
PITCH;
104 s->rotation_order[2] =
ROLL;
107 s->rotation_order[order] = rorder;
130 sl, (uint32_t []) { 16, 16, 1 }, 0);
133 VK_SHADER_STAGE_COMPUTE_BIT);
137 .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
138 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
143 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
144 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
164 for (
int i = 0;
i < 3;
i++) {
165 for (
int j = 0; j < 3; j++) {
167 for (
int k = 0; k < 3; k++)
168 sum +=
a[
i][k] *
b[k][j];
179 iflat_range[0] = tanf(0.5f * ih_fov *
M_PI / 180.f);
180 iflat_range[1] = tanf(0.5f * iv_fov *
M_PI / 180.f);
183 iflat_range[0] = tanf(
FFMIN(ih_fov, 359.f) *
M_PI / 720.f);
184 iflat_range[1] = tanf(
FFMIN(iv_fov, 359.f) *
M_PI / 720.f);
188 iflat_range[0] = ih_fov / 180.f;
189 iflat_range[1] = iv_fov / 180.f;
201 flat_range[0] = tanf(0.5f * h_fov *
M_PI / 180.f);
202 flat_range[1] = tanf(0.5f * v_fov *
M_PI / 180.f);
205 flat_range[0] = tanf(
FFMIN(h_fov, 359.f) *
M_PI / 720.f);
206 flat_range[1] = tanf(
FFMIN(v_fov, 359.f) *
M_PI / 720.f);
210 flat_range[0] = h_fov / 180.f;
211 flat_range[1] = v_fov / 180.f;
220 const int rotation_order[3])
222 const float yaw_rad = yaw *
M_PI / 180.f;
223 const float pitch_rad = pitch *
M_PI / 180.f;
224 const float roll_rad = roll *
M_PI / 180.f;
226 const float sin_yaw =
sinf(yaw_rad);
227 const float cos_yaw =
cosf(yaw_rad);
228 const float sin_pitch =
sinf(pitch_rad);
229 const float cos_pitch =
cosf(pitch_rad);
230 const float sin_roll =
sinf(roll_rad);
231 const float cos_roll =
cosf(roll_rad);
236 m[0][0][0] = cos_yaw; m[0][0][1] = 0; m[0][0][2] = sin_yaw;
237 m[0][1][0] = 0; m[0][1][1] = 1; m[0][1][2] = 0;
238 m[0][2][0] = -sin_yaw; m[0][2][1] = 0; m[0][2][2] = cos_yaw;
240 m[1][0][0] = 1; m[1][0][1] = 0; m[1][0][2] = 0;
241 m[1][1][0] = 0; m[1][1][1] = cos_pitch; m[1][1][2] = -sin_pitch;
242 m[1][2][0] = 0; m[1][2][1] = sin_pitch; m[1][2][2] = cos_pitch;
244 m[2][0][0] = cos_roll; m[2][0][1] = -sin_roll; m[2][0][2] = 0;
245 m[2][1][0] = sin_roll; m[2][1][1] = cos_roll; m[2][1][2] = 0;
246 m[2][2][0] = 0; m[2][2][1] = 0; m[2][2][2] = 1;
286 out, in,
s->sampler, 1,
321#define OFFSET(x) offsetof(V360VulkanContext, x)
322#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
323#define DYNAMIC (FLAGS | AV_OPT_FLAG_RUNTIME_PARAM)
375 .p.name =
"v360_vulkan",
377 .p.priv_class = &v360_vulkan_class,
const FFFilter ff_vf_v360_vulkan
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define i(width, name, range_min, range_max)
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int ff_vk_shader_load(FFVulkanShader *shd, VkPipelineStageFlags stage, VkSpecializationInfo *spec, uint32_t wg_size[3], uint32_t required_subgroup_size)
Initialize a shader object.
void ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular)
Add descriptor to a shader.
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
int ff_vk_exec_pool_init(FFVulkanContext *s, AVVulkanDeviceQueueFamily *qf, FFVkExecPool *pool, int nb_contexts, int nb_queries, VkQueryType query_type, int query_64bit, const void *query_create_pnext)
Allocates/frees an execution pool.
int ff_vk_shader_add_push_const(FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
AVVulkanDeviceQueueFamily * ff_vk_qf_find(FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
Chooses an appropriate QF.
int ff_vk_shader_link(FFVulkanContext *s, FFVulkanShader *shd, const char *spirv, size_t spirv_len, const char *entrypoint)
Link a shader into an executable.
static const struct @257111027162314367033347246032313251342043035002 planes[]
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
void * priv
private data for use by the filter
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
const VkAllocationCallbacks * alloc
Custom memory allocator, else NULL.
VkDevice act_dev
Active device.
AVVulkanDeviceContext * hwctx
AVVulkanDeviceQueueFamily * qf
static AVFormatContext * ctx
static const AVOption v360_vulkan_options[]
static const AVFilterPad v360_vulkan_outputs[]
static void v360_vulkan_uninit(AVFilterContext *avctx)
const unsigned char ff_v360_comp_spv_data[]
static void calculate_iflat_range(int in, float ih_fov, float iv_fov, float *iflat_range)
static void calculate_rotation_matrix(float yaw, float pitch, float roll, float rot_mat[4][4], const int rotation_order[3])
const unsigned int ff_v360_comp_spv_len
static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
static void calculate_flat_range(int out, float h_fov, float v_fov, float *flat_range)
static void multiply_matrix(float c[4][4], const float a[4][4], const float b[4][4])
static const AVFilterPad v360_vulkan_inputs[]
static int get_rorder(char c)
static int v360_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define SPEC_LIST_ADD(name, idx, val_bits, val)
#define SPEC_LIST_CREATE(name, max_length, max_size)
int ff_vk_filter_config_input(AVFilterLink *inlink)
int ff_vk_filter_config_output(AVFilterLink *outlink)
int ff_vk_filter_process_simple(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanShader *shd, AVFrame *out_f, AVFrame *in_f, VkSampler sampler, uint32_t wgc_z, void *push_src, size_t push_size)
Submit a compute shader with a zero/one input and single out for execution.
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.