Go to the documentation of this file.
78 V360VulkanContext *
s =
ctx->priv;
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.5
f * ih_fov *
M_PI / 180.
f);
180 iflat_range[1] = tanf(0.5
f * 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.5
f * h_fov *
M_PI / 180.
f);
202 flat_range[1] = tanf(0.5
f * 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;
257 V360VulkanContext *
s =
ctx->priv;
305 V360VulkanContext *
s = avctx->
priv;
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,
379 .priv_size =
sizeof(V360VulkanContext),
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static void calculate_rotation_matrix(float yaw, float pitch, float roll, float rot_mat[4][4], const int rotation_order[3])
#define AV_LOG_WARNING
Something somehow does not look correct.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
AVFILTER_DEFINE_CLASS(v360_vulkan)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static void calculate_flat_range(int out, float h_fov, float v_fov, float *flat_range)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int ff_vk_filter_process_simple(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanShader *shd, AVFrame *out_f, AVFrame *in_f, VkSampler sampler, void *push_src, size_t push_size)
Submit a compute shader with a zero/one input and single out for execution.
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.
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
#define SPEC_LIST_ADD(name, idx, val_bits, val)
const char * name
Filter name.
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
A link between two filters.
const unsigned int ff_v360_comp_spv_len
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
const VkAllocationCallbacks * alloc
Custom memory allocator, else NULL.
void * priv
private data for use by the filter
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
A filter pad used for either input or output.
AVVulkanDeviceQueueFamily * qf
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FILTER_OUTPUTS(array)
static void calculate_iflat_range(int in, float ih_fov, float iv_fov, float *iflat_range)
static AVFormatContext * ctx
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
static const struct @582 planes[]
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static int get_rorder(char c)
int ff_vk_filter_config_output(AVFilterLink *outlink)
static int v360_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
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 void multiply_matrix(float c[4][4], const float a[4][4], const float b[4][4])
#define SPEC_LIST_CREATE(name, max_length, max_size)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int(* init)(AVBSFContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define i(width, name, range_min, range_max)
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
const FFFilter ff_vf_v360_vulkan
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
static void uninit(AVBSFContext *ctx)
int w
agreed upon image width
static void v360_vulkan_uninit(AVFilterContext *avctx)
const char * name
Pad name.
static const AVFilterPad v360_vulkan_inputs[]
const unsigned char ff_v360_comp_spv_data[]
int ff_vk_shader_add_push_const(FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
#define FILTER_INPUTS(array)
AVVulkanDeviceQueueFamily * ff_vk_qf_find(FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
Chooses an appropriate QF.
int ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular, int print_to_shader_only)
Add descriptor to a shader.
static const AVOption v360_vulkan_options[]
int h
agreed upon image height
@ AV_OPT_TYPE_INT
Underlying C type is int.
int ff_vk_filter_config_input(AVFilterLink *inlink)
AVFilter p
The public AVFilter.
AVVulkanDeviceContext * hwctx
static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
VkDevice act_dev
Active device.
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
@ 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...
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
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.
static const AVFilterPad v360_vulkan_outputs[]