FFmpeg
vsrc_testsrc_vulkan.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) Lynne
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/random_seed.h"
22 #include "libavutil/csp.h"
23 #include "libavutil/opt.h"
24 #include "vulkan_filter.h"
25 #include "vulkan_spirv.h"
26 #include "internal.h"
27 #include "filters.h"
28 #include "colorspace.h"
29 #include "video.h"
30 
33 };
34 
35 typedef struct TestSrcVulkanPushData {
36  float color_comp[4];
38 
39 typedef struct TestSrcVulkanContext {
41 
47 
48  /* Only used by color_vulkan */
49  uint8_t color_rgba[4];
50 
52 
53  int w, h;
54  int pw, ph;
57  unsigned int nb_frame;
59  int64_t pts;
60  int64_t duration; ///< duration expressed in microseconds
61  AVRational sar; ///< sample aspect ratio
62  int draw_once; ///< draw only the first frame, always put out the same picture
63  int draw_once_reset; ///< draw only the first frame or in case of reset
64  AVFrame *picref; ///< cached reference containing the painted picture
66 
68 {
69  int err;
70  uint8_t *spv_data;
71  size_t spv_len;
72  void *spv_opaque = NULL;
73  TestSrcVulkanContext *s = ctx->priv;
74  FFVulkanContext *vkctx = &s->vkctx;
75  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
76  FFVkSPIRVShader *shd = &s->shd;
77  FFVkSPIRVCompiler *spv;
79  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->vkctx.output_format);
80 
81  spv = ff_vk_spirv_init();
82  if (!spv) {
83  av_log(ctx, AV_LOG_ERROR, "Unable to initialize SPIR-V compiler!\n");
84  return AVERROR_EXTERNAL;
85  }
86 
87  ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
88  RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
89  RET(ff_vk_shader_init(&s->pl, &s->shd, "testsrc_compute",
90  VK_SHADER_STAGE_COMPUTE_BIT, 0));
91 
92  ff_vk_shader_set_compute_sizes(&s->shd, 32, 32, 1);
93 
94  GLSLC(0, layout(push_constant, std430) uniform pushConstants { );
95  GLSLC(1, vec4 color_comp; );
96  GLSLC(0, }; );
97  GLSLC(0, );
98 
99  ff_vk_add_push_constant(&s->pl, 0, sizeof(s->opts),
100  VK_SHADER_STAGE_COMPUTE_BIT);
101 
102  desc_set = (FFVulkanDescriptorSetBinding []) {
103  {
104  .name = "output_img",
105  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
106  .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format),
107  .mem_quali = "writeonly",
108  .dimensions = 2,
109  .elems = planes,
110  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
111  },
112  };
113 
114  RET(ff_vk_pipeline_descriptor_set_add(vkctx, &s->pl, shd, desc_set, 1, 0, 0));
115 
116  GLSLC(0, void main() );
117  GLSLC(0, { );
118  GLSLC(1, ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
119  if (mode == TESTSRC_COLOR) {
120  double rgb2yuv[3][3];
121  double rgbad[4];
122  double yuvad[4];
123 
124  enum AVColorSpace csp;
125  const AVLumaCoefficients *luma = NULL;
126 
127  s->draw_once = 1;
128 
129  if (desc->flags & AV_PIX_FMT_FLAG_RGB)
130  csp = AVCOL_SPC_RGB;
131  else
132  csp = AVCOL_SPC_SMPTE170M;
133 
134  if (!(desc->flags & AV_PIX_FMT_FLAG_RGB) && !(luma = av_csp_luma_coeffs_from_avcsp(csp)))
135  return AVERROR(EINVAL);
136  else if (!(desc->flags & AV_PIX_FMT_FLAG_RGB))
138 
139  for (int i = 0; i < 4; i++)
140  rgbad[i] = s->color_rgba[i] / 255.0;
141 
142  if (!(desc->flags & AV_PIX_FMT_FLAG_RGB))
143  ff_matrix_mul_3x3_vec(yuvad, rgbad, rgb2yuv);
144  else
145  memcpy(yuvad, rgbad, sizeof(rgbad));
146 
147  yuvad[3] = rgbad[3];
148 
149  if (!(desc->flags & AV_PIX_FMT_FLAG_RGB)) {
150  for (int i = 0; i < 3; i++) {
151  int chroma = (!(desc->flags & AV_PIX_FMT_FLAG_RGB) && i > 0);
152  if (s->out_range == AVCOL_RANGE_MPEG) {
153  yuvad[i] *= (chroma ? 224.0 : 219.0) / 255.0;
154  yuvad[i] += (chroma ? 128.0 : 16.0) / 255.0;
155  } else if (chroma) {
156  yuvad[i] += 0.5;
157  }
158  }
159  }
160 
161  /* Ensure we place the alpha appropriately for gray formats */
162  if (desc->nb_components <= 2)
163  yuvad[1] = yuvad[3];
164 
165  for (int i = 0; i < 4; i++)
166  s->opts.color_comp[i] = yuvad[i];
167 
168  GLSLC(1, vec4 r; );
169  GLSLC(0, );
170  for (int i = 0, c_off = 0; i < planes; i++) {
171  for (int c = 0; c < desc->nb_components; c++) {
172  if (desc->comp[c].plane == i) {
173  int off = desc->comp[c].offset / (FFALIGN(desc->comp[c].depth, 8)/8);
174  GLSLF(1, r[%i] = color_comp[%i]; ,off, c_off++);
175  }
176  }
177  GLSLF(1, imageStore(output_img[%i], pos, r); ,i);
178  GLSLC(0, );
179  }
180  }
181  GLSLC(0, } );
182 
183  RET(spv->compile_shader(spv, ctx, shd, &spv_data, &spv_len, "main",
184  &spv_opaque));
185  RET(ff_vk_shader_create(vkctx, shd, spv_data, spv_len, "main"));
186 
187  RET(ff_vk_init_compute_pipeline(vkctx, &s->pl, shd));
188  RET(ff_vk_exec_pipeline_register(vkctx, &s->e, &s->pl));
189 
190  s->initialized = 1;
191 
192 fail:
193  if (spv_opaque)
194  spv->free_shader(spv, &spv_opaque);
195  if (spv)
196  spv->uninit(&spv);
197 
198  return err;
199 }
200 
202 {
203  int err;
204  AVFilterLink *outlink = ctx->outputs[0];
205  TestSrcVulkanContext *s = ctx->priv;
206  AVFrame *frame;
207 
208  if (!s->initialized) {
210  err = init_filter(ctx, mode);
211  if (err < 0)
212  return err;
213  }
214 
215  if (!ff_outlink_frame_wanted(outlink))
216  return FFERROR_NOT_READY;
217  if (s->duration >= 0 &&
218  av_rescale_q(s->pts, s->time_base, AV_TIME_BASE_Q) >= s->duration) {
219  ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
220  return 0;
221  }
222 
223  if (s->draw_once) {
224  if (s->draw_once_reset) {
225  av_frame_free(&s->picref);
226  s->draw_once_reset = 0;
227  }
228  if (!s->picref) {
229  s->picref = ff_get_video_buffer(outlink, s->w, s->h);
230  if (!s->picref)
231  return AVERROR(ENOMEM);
232 
233  err = ff_vk_filter_process_simple(&s->vkctx, &s->e, &s->pl, s->picref, NULL,
234  VK_NULL_HANDLE, &s->opts, sizeof(s->opts));
235  if (err < 0)
236  return err;
237  }
238  frame = av_frame_clone(s->picref);
239  } else {
240  frame = ff_get_video_buffer(outlink, s->w, s->h);
241  }
242 
243  if (!frame)
244  return AVERROR(ENOMEM);
245 
246  frame->pts = s->pts;
247  frame->duration = 1;
248  frame->flags = AV_FRAME_FLAG_KEY;
249  frame->pict_type = AV_PICTURE_TYPE_I;
250  frame->sample_aspect_ratio = s->sar;
251  if (!s->draw_once) {
252  err = ff_vk_filter_process_simple(&s->vkctx, &s->e, &s->pl, frame, NULL,
253  VK_NULL_HANDLE, &s->opts, sizeof(s->opts));
254  if (err < 0) {
256  return err;
257  }
258  }
259 
260  s->pts++;
261  s->nb_frame++;
262 
263  return ff_filter_frame(outlink, frame);
264 }
265 
267 {
268  int err;
269  TestSrcVulkanContext *s = outlink->src->priv;
270  FFVulkanContext *vkctx = &s->vkctx;
271 
272  if (!s->out_format_string) {
274  } else {
275  vkctx->output_format = av_get_pix_fmt(s->out_format_string);
276  if (vkctx->output_format == AV_PIX_FMT_NONE) {
277  av_log(vkctx, AV_LOG_ERROR, "Invalid output format.\n");
278  return AVERROR(EINVAL);
279  }
280  }
281 
282  err = ff_vk_filter_init_context(outlink->src, vkctx, NULL,
283  s->w, s->h, vkctx->output_format);
284  if (err < 0)
285  return err;
286 
287  outlink->hw_frames_ctx = av_buffer_ref(vkctx->frames_ref);
288  if (!outlink->hw_frames_ctx)
289  return AVERROR(ENOMEM);
290 
291  s->time_base = av_inv_q(s->frame_rate);
292  s->nb_frame = 0;
293  s->pts = 0;
294 
295  s->vkctx.output_width = s->w;
296  s->vkctx.output_height = s->h;
297  outlink->w = s->w;
298  outlink->h = s->h;
299  outlink->sample_aspect_ratio = s->sar;
300  outlink->frame_rate = s->frame_rate;
301  outlink->time_base = s->time_base;
302 
303  return 0;
304 }
305 
307 {
308  TestSrcVulkanContext *s = avctx->priv;
309  FFVulkanContext *vkctx = &s->vkctx;
310 
311  av_frame_free(&s->picref);
312 
313  ff_vk_exec_pool_free(vkctx, &s->e);
314  ff_vk_pipeline_free(vkctx, &s->pl);
315  ff_vk_shader_free(vkctx, &s->shd);
316 
317  ff_vk_uninit(&s->vkctx);
318 
319  s->initialized = 0;
320 }
321 
322 #define OFFSET(x) offsetof(TestSrcVulkanContext, x)
323 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
324 
325 #define COMMON_OPTS \
326  { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, { .str = "1920x1080" }, 0, 0, FLAGS }, \
327  { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, { .str = "1920x1080" }, 0, 0, FLAGS }, \
328  \
329  { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "60" }, 0, INT_MAX, FLAGS }, \
330  { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "60" }, 0, INT_MAX, FLAGS }, \
331  \
332  { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, FLAGS }, \
333  { "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, FLAGS }, \
334  \
335  { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, { .dbl = 1 }, 0, INT_MAX, FLAGS }, \
336  \
337  { "format", "Output video format (software format of hardware frames)", OFFSET(out_format_string), AV_OPT_TYPE_STRING, .flags = FLAGS },
338 
339 static const AVOption color_vulkan_options[] = {
340  { "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, 0, 0, FLAGS },
341  { "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, 0, 0, FLAGS },
343  { "out_range", "Output colour range (from 0 to 2) (default 0)", OFFSET(out_range), AV_OPT_TYPE_INT, {.i64 = AVCOL_RANGE_UNSPECIFIED}, AVCOL_RANGE_UNSPECIFIED, AVCOL_RANGE_JPEG, .flags = FLAGS, .unit = "range" },
344  { "full", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, .unit = "range" },
345  { "limited", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, .unit = "range" },
346  { "jpeg", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, .unit = "range" },
347  { "mpeg", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, .unit = "range" },
348  { "tv", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, .unit = "range" },
349  { "pc", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, .unit = "range" },
350  { NULL },
351 };
352 
353 AVFILTER_DEFINE_CLASS(color_vulkan);
354 
356  {
357  .name = "default",
358  .type = AVMEDIA_TYPE_VIDEO,
359  .config_props = testsrc_vulkan_config_props,
360  },
361 };
362 
364  .name = "color_vulkan",
365  .description = NULL_IF_CONFIG_SMALL("Generate a constant color (Vulkan)"),
366  .priv_size = sizeof(TestSrcVulkanContext),
369  .inputs = NULL,
374  .priv_class = &color_vulkan_class,
375  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
376 };
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:112
TestSrcVulkanPushData::color_comp
float color_comp[4]
Definition: vsrc_testsrc_vulkan.c:36
ff_vk_pipeline_free
void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl)
Definition: vulkan.c:1844
r
const char * r
Definition: vf_curves.c:127
AVERROR
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
opt.h
TestSrcVulkanContext::qf
FFVkQueueFamilyCtx qf
Definition: vsrc_testsrc_vulkan.c:45
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: internal.h:351
testsrc_vulkan_uninit
static void testsrc_vulkan_uninit(AVFilterContext *avctx)
Definition: vsrc_testsrc_vulkan.c:306
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1015
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2965
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:264
ff_vk_qf_init
int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family)
Chooses a QF and loads it into a context.
Definition: vulkan.c:225
TestSrcVulkanContext::duration
int64_t duration
duration expressed in microseconds
Definition: vsrc_testsrc_vulkan.c:60
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:160
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:221
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:686
av_csp_luma_coeffs_from_avcsp
const struct AVLumaCoefficients * av_csp_luma_coeffs_from_avcsp(enum AVColorSpace csp)
Retrieves the Luma coefficients necessary to construct a conversion matrix from an enum constant desc...
Definition: csp.c:58
ff_vk_shader_create
int ff_vk_shader_create(FFVulkanContext *s, FFVkSPIRVShader *shd, uint8_t *spirv, size_t spirv_size, const char *entrypoint)
Definition: vulkan.c:1415
AVOption
AVOption.
Definition: opt.h:357
chroma
static av_always_inline void chroma(WaveformContext *s, AVFrame *in, AVFrame *out, int component, int intensity, int offset_y, int offset_x, int column, int mirror, int jobnr, int nb_jobs)
Definition: vf_waveform.c:1639
rgb2yuv
static const char rgb2yuv[]
Definition: vf_scale_vulkan.c:70
TestSrcVulkanContext::w
int w
Definition: vsrc_testsrc_vulkan.c:53
AVCOL_SPC_RGB
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Definition: pixfmt.h:610
TestSrcVulkanPushData
Definition: vsrc_testsrc_vulkan.c:35
AVLumaCoefficients
Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar calculations.
Definition: csp.h:48
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
Definition: vulkan.c:1873
init_filter
static av_cold int init_filter(AVFilterContext *ctx, enum TestSrcVulkanMode mode)
Definition: vsrc_testsrc_vulkan.c:67
FFVkSPIRVCompiler::uninit
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
Definition: vulkan_spirv.h:33
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
ff_vk_pipeline_descriptor_set_add
int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int nb, int read_only, int print_to_shader_only)
Add descriptor to a pipeline.
Definition: vulkan.c:1465
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(color_vulkan)
ff_vk_shader_set_compute_sizes
void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z)
Definition: vulkan.c:1373
video.h
TestSrcVulkanContext::pts
int64_t pts
Definition: vsrc_testsrc_vulkan.c:59
TestSrcVulkanContext::color_rgba
uint8_t color_rgba[4]
Definition: vsrc_testsrc_vulkan.c:49
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3005
TestSrcVulkanContext::shd
FFVkSPIRVShader shd
Definition: vsrc_testsrc_vulkan.c:46
COMMON_OPTS
#define COMMON_OPTS
Definition: vsrc_testsrc_vulkan.c:325
ff_vk_add_push_constant
int ff_vk_add_push_constant(FFVulkanPipeline *pl, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
Definition: vulkan.c:1143
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:422
fail
#define fail()
Definition: checkasm.h:182
vulkan_filter.h
OFFSET
#define OFFSET(x)
Definition: vsrc_testsrc_vulkan.c:322
colorspace.h
ff_vk_filter_init_context
int ff_vk_filter_init_context(AVFilterContext *avctx, FFVulkanContext *s, AVBufferRef *frames_ref, int width, int height, enum AVPixelFormat sw_format)
Can be called manually, if not using ff_vk_filter_config_output.
Definition: vulkan_filter.c:24
FLAGS
#define FLAGS
Definition: vsrc_testsrc_vulkan.c:323
TestSrcVulkanContext::initialized
int initialized
Definition: vsrc_testsrc_vulkan.c:42
TestSrcVulkanContext::draw_once_reset
int draw_once_reset
draw only the first frame or in case of reset
Definition: vsrc_testsrc_vulkan.c:63
FFVulkanContext::frames_ref
AVBufferRef * frames_ref
Definition: vulkan.h:256
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
main
int main
Definition: dovi_rpuenc.c:37
AV_FRAME_FLAG_KEY
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition: frame.h:625
ff_outlink_set_status
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition: filters.h:189
planes
static const struct @417 planes[]
s
#define s(width, name)
Definition: cbs_vp9.c:198
TestSrcVulkanContext::out_format_string
char * out_format_string
Definition: vsrc_testsrc_vulkan.c:55
TestSrcVulkanContext::e
FFVkExecPool e
Definition: vsrc_testsrc_vulkan.c:44
TestSrcVulkanContext::out_range
enum AVColorRange out_range
Definition: vsrc_testsrc_vulkan.c:56
AVCOL_SPC_SMPTE170M
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
Definition: pixfmt.h:616
TestSrcVulkanContext::picref
AVFrame * picref
cached reference containing the painted picture
Definition: vsrc_testsrc_vulkan.c:64
filters.h
TestSrcVulkanContext::pw
int pw
Definition: vsrc_testsrc_vulkan.c:54
ctx
AVFormatContext * ctx
Definition: movenc.c:49
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:593
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
testsrc_vulkan_activate
static int testsrc_vulkan_activate(AVFilterContext *ctx)
Definition: vsrc_testsrc_vulkan.c:201
ff_matrix_mul_3x3_vec
void ff_matrix_mul_3x3_vec(double dst[3], const double vec[3], const double mat[3][3])
Definition: colorspace.c:66
FFVkSPIRVCompiler::compile_shader
int(* compile_shader)(struct FFVkSPIRVCompiler *ctx, void *avctx, struct FFVkSPIRVShader *shd, uint8_t **data, size_t *size, const char *entrypoint, void **opaque)
Definition: vulkan_spirv.h:29
ff_vk_exec_pool_free
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
Definition: vulkan.c:256
if
if(ret)
Definition: filter_design.txt:179
ff_vsrc_color_vulkan
const AVFilter ff_vsrc_color_vulkan
Definition: vsrc_testsrc_vulkan.c:363
TestSrcVulkanContext::opts
TestSrcVulkanPushData opts
Definition: vsrc_testsrc_vulkan.c:51
NULL
#define NULL
Definition: coverity.c:32
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
TestSrcVulkanContext::nb_frame
unsigned int nb_frame
Definition: vsrc_testsrc_vulkan.c:57
activate
filter_frame For filters that do not use the activate() callback
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Definition: opt.h:260
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:279
ff_vk_init_compute_pipeline
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd)
Definition: vulkan.c:1785
testsrc_vulkan_outputs
static const AVFilterPad testsrc_vulkan_outputs[]
Definition: vsrc_testsrc_vulkan.c:355
ff_vk_exec_pool_init
int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *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.
Definition: vulkan.c:296
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
FFVulkanContext
Definition: vulkan.h:228
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:652
FFVulkanPipeline
Definition: vulkan.h:131
c
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
Definition: undefined.txt:32
ff_vk_shader_init
int ff_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name, VkShaderStageFlags stage, uint32_t required_subgroup_size)
Shader management.
Definition: vulkan.c:1347
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:366
FFVulkanDescriptorSetBinding
Definition: vulkan.h:83
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
TestSrcVulkanContext::vkctx
FFVulkanContext vkctx
Definition: vsrc_testsrc_vulkan.c:40
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:136
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:138
FFVkQueueFamilyCtx
Definition: vulkan.h:110
FFVulkanContext::output_format
enum AVPixelFormat output_format
Definition: vulkan.h:266
TestSrcVulkanMode
TestSrcVulkanMode
Definition: vsrc_testsrc_vulkan.c:31
csp.h
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
FFVulkanDescriptorSetBinding::name
const char * name
Definition: vulkan.h:84
TestSrcVulkanContext::sar
AVRational sar
sample aspect ratio
Definition: vsrc_testsrc_vulkan.c:61
TestSrcVulkanContext::ph
int ph
Definition: vsrc_testsrc_vulkan.c:54
internal.h
ff_vk_filter_process_simple
int ff_vk_filter_process_simple(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanPipeline *pl, 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.
Definition: vulkan_filter.c:230
FFVkSPIRVCompiler
Definition: vulkan_spirv.h:27
TestSrcVulkanContext::frame_rate
AVRational frame_rate
Definition: vsrc_testsrc_vulkan.c:58
layout
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 layout
Definition: filter_design.txt:18
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:172
color_vulkan_options
static const AVOption color_vulkan_options[]
Definition: vsrc_testsrc_vulkan.c:339
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
ff_fill_rgb2yuv_table
void ff_fill_rgb2yuv_table(const AVLumaCoefficients *coeffs, double rgb2yuv[3][3])
Definition: colorspace.c:125
TestSrcVulkanContext::pl
FFVulkanPipeline pl
Definition: vsrc_testsrc_vulkan.c:43
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AVColorSpace
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:609
ff_vk_shader_rep_fmt
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Returns the format to use for images in shaders.
Definition: vulkan.c:1207
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
vulkan_spirv.h
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
GLSLF
#define GLSLF(N, S,...)
Definition: vulkan.h:54
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:669
FFVkSPIRVCompiler::free_shader
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
Definition: vulkan_spirv.h:32
AVFilter
Filter definition.
Definition: avfilter.h:166
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
FFVkExecPool
Definition: vulkan.h:210
pos
unsigned int pos
Definition: spdifenc.c:414
av_get_pix_fmt
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition: pixdesc.c:2897
random_seed.h
FFVkSPIRVShader
Definition: vulkan.h:75
mode
mode
Definition: ebur128.h:83
TestSrcVulkanContext
Definition: vsrc_testsrc_vulkan.c:39
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:245
TestSrcVulkanContext::draw_once
int draw_once
draw only the first frame, always put out the same picture
Definition: vsrc_testsrc_vulkan.c:62
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
TestSrcVulkanContext::h
int h
Definition: vsrc_testsrc_vulkan.c:53
desc
const char * desc
Definition: libsvtav1.c:79
GLSLC
#define GLSLC(N, S)
Definition: vulkan.h:44
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
testsrc_vulkan_config_props
static int testsrc_vulkan_config_props(AVFilterLink *outlink)
Definition: vsrc_testsrc_vulkan.c:266
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
ff_vk_exec_pipeline_register
int ff_vk_exec_pipeline_register(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanPipeline *pl)
Register a pipeline with an exec pool.
Definition: vulkan.c:1579
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
TESTSRC_COLOR
@ TESTSRC_COLOR
Definition: vsrc_testsrc_vulkan.c:32
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
ff_vk_shader_free
void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd)
Definition: vulkan.c:1406
AVColorRange
AVColorRange
Visual content value range.
Definition: pixfmt.h:651
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:254
RET
#define RET(x)
Definition: vulkan.h:67
TestSrcVulkanContext::time_base
AVRational time_base
Definition: vsrc_testsrc_vulkan.c:58