FFmpeg
avf_a3dscope.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Paul B Mahol
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/avassert.h"
23 #include "libavutil/opt.h"
24 #include "libavutil/parseutils.h"
25 #include "avfilter.h"
26 #include "filters.h"
27 #include "formats.h"
28 #include "audio.h"
29 #include "video.h"
30 
31 typedef struct Audio3dScopeContext {
32  const AVClass *class;
33  int w, h;
34  int size;
35  float fov;
36  float roll;
37  float pitch;
38  float yaw;
39  float zoom[3];
40  float eye[3];
41 
44 
45  float view_matrix[4][4];
46  float projection_matrix[4][4];
47 
50 
51 #define OFFSET(x) offsetof(Audio3dScopeContext, x)
52 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
53 #define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
54 
55 static const AVOption a3dscope_options[] = {
56  { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
57  { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
58  { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
59  { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
60  { "fov", "set camera FoV", OFFSET(fov), AV_OPT_TYPE_FLOAT, {.dbl=90.f}, 40, 150, TFLAGS },
61  { "roll", "set camera roll",OFFSET(roll), AV_OPT_TYPE_FLOAT, {.dbl=0.f}, -180, 180, TFLAGS },
62  { "pitch","set camera pitch",OFFSET(pitch), AV_OPT_TYPE_FLOAT, {.dbl=0.f}, -180, 180, TFLAGS },
63  { "yaw", "set camera yaw", OFFSET(yaw), AV_OPT_TYPE_FLOAT, {.dbl=0.f}, -180, 180, TFLAGS },
64  { "xzoom","set camera zoom", OFFSET(zoom[0]),AV_OPT_TYPE_FLOAT, {.dbl=1.f}, 0.01, 10, TFLAGS },
65  { "yzoom","set camera zoom", OFFSET(zoom[1]),AV_OPT_TYPE_FLOAT, {.dbl=1.f}, 0.01, 10, TFLAGS },
66  { "zzoom","set camera zoom", OFFSET(zoom[2]),AV_OPT_TYPE_FLOAT, {.dbl=1.f}, 0.01, 10, TFLAGS },
67  { "xpos", "set camera position", OFFSET(eye[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.f},-60.f, 60.f, TFLAGS },
68  { "ypos", "set camera position", OFFSET(eye[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.f},-60.f, 60.f, TFLAGS },
69  { "zpos", "set camera position", OFFSET(eye[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.f},-60.f, 60.f, TFLAGS },
70  { "length","set length", OFFSET(size), AV_OPT_TYPE_INT, {.i64=15}, 1, 60, FLAGS },
71  { NULL }
72 };
73 
74 AVFILTER_DEFINE_CLASS(a3dscope);
75 
76 static int query_formats(const AVFilterContext *ctx,
77  AVFilterFormatsConfig **cfg_in,
78  AVFilterFormatsConfig **cfg_out)
79 {
82  static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE };
83  int ret;
84 
86  if ((ret = ff_formats_ref(formats, &cfg_in[0]->formats)) < 0)
87  return ret;
88 
90  if ((ret = ff_formats_ref(formats, &cfg_out[0]->formats)) < 0)
91  return ret;
92 
93  return 0;
94 }
95 
97 {
98  AVFilterContext *ctx = inlink->dst;
99  Audio3dScopeContext *s = ctx->priv;
100 
101  s->nb_samples = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
102 
103  return 0;
104 }
105 
106 static int config_output(AVFilterLink *outlink)
107 {
108  FilterLink *l = ff_filter_link(outlink);
109  Audio3dScopeContext *s = outlink->src->priv;
110 
111  outlink->w = s->w;
112  outlink->h = s->h;
113  outlink->sample_aspect_ratio = (AVRational){1,1};
114  l->frame_rate = s->frame_rate;
115  outlink->time_base = av_inv_q(l->frame_rate);
116 
117  return 0;
118 }
119 
120 static void projection_matrix(float fov, float a, float near, float far,
121  float matrix[4][4])
122 {
123  float f;
124 
125  memset(matrix, 0, sizeof(*matrix));
126 
127  f = 1.0f / tanf(fov * 0.5f * M_PI / 180.f);
128  matrix[0][0] = f * a;
129  matrix[1][1] = f;
130  matrix[2][2] = -(far + near) / (far - near);
131  matrix[2][3] = -1.f;
132  matrix[3][2] = -(near * far) / (far - near);
133 }
134 
135 static inline void vmultiply(const float v[4], const float m[4][4], float d[4])
136 {
137  d[0] = v[0] * m[0][0] + v[1] * m[1][0] + v[2] * m[2][0] + v[3] * m[3][0];
138  d[1] = v[0] * m[0][1] + v[1] * m[1][1] + v[2] * m[2][1] + v[3] * m[3][1];
139  d[2] = v[0] * m[0][2] + v[1] * m[1][2] + v[2] * m[2][2] + v[3] * m[3][2];
140  d[3] = v[0] * m[0][3] + v[1] * m[1][3] + v[2] * m[2][3] + v[3] * m[3][3];
141 }
142 
143 static void mmultiply(const float m2[4][4], const float m1[4][4], float m[4][4])
144 {
145  vmultiply(m2[0], m1, m[0]);
146  vmultiply(m2[1], m1, m[1]);
147  vmultiply(m2[2], m1, m[2]);
148  vmultiply(m2[3], m1, m[3]);
149 }
150 
151 static float vdot(const float x[3], const float y[3])
152 {
153  return x[0] * y[0] + x[1] * y[1] + x[2] * y[2];
154 }
155 
156 static void view_matrix(const float eye[3],
157  const float z[3],
158  const float roll,
159  const float pitch,
160  const float yaw, float m[4][4])
161 {
162  float cr = cosf(roll * M_PI / 180.f);
163  float sr = sinf(roll * M_PI / 180.f);
164  float cp = cosf(pitch * M_PI / 180.f);
165  float sp = sinf(pitch * M_PI / 180.f);
166  float cy = cosf(yaw * M_PI / 180.f);
167  float sy = sinf(yaw * M_PI / 180.f);
168  float t[4][4];
169  float rx[4][4] = {
170  {z[0], 0.f, 0.f, 0.f },
171  { 0.f, cy, -sy, 0.f },
172  { 0.f, sy, cy, 0.f },
173  { 0.f, 0.f, 0.f, 1.f },
174  };
175 
176  float ry[4][4] = {
177  { cp, 0.f, sp, 0.f },
178  { 0.f,z[1], 0.f, 0.f },
179  {-sp, 0.f, cp, 0.f },
180  { 0.f, 0.f, 0.f, 1.f },
181  };
182 
183  float rz[4][4] = {
184  { cr, -sr, 0.f, 0.f },
185  { sr, cr, 0.f, 0.f },
186  { 0.f, 0.f,z[2], 0.f },
187  { 0.f, 0.f, 0.f, 1.f },
188  };
189 
190  memset(m, 0, sizeof(*m));
191 
192  mmultiply(rx, ry, t);
193  mmultiply(rz, t, m);
194 
195  m[3][0] = -vdot(m[0], eye);
196  m[3][1] = -vdot(m[1], eye);
197  m[3][2] = -vdot(m[2], eye);
198 }
199 
200 static void draw_dot(AVFrame *out, unsigned x, unsigned y, float z,
201  int r, int g, int b)
202 {
203  const ptrdiff_t linesize = out->linesize[0];
204  uint8_t *dst;
205 
206  dst = out->data[0] + y * linesize + x * 4;
207  dst[0] = r * z;
208  dst[1] = g * z;
209  dst[2] = b * z;
210  dst[3] = 255 * z;
211 }
212 
214 {
215  AVFilterContext *ctx = inlink->dst;
216  AVFilterLink *outlink = ctx->outputs[0];
217  Audio3dScopeContext *s = ctx->priv;
218  const float half_height = (s->h - 1) * 0.5f;
219  const float half_width = (s->w - 1) * 0.5f;
220  float matrix[4][4];
221  const int w = s->w;
222  const int h = s->h;
223  AVFrame *out;
224 
225  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
226  if (!out) {
227  av_frame_free(&in);
228  return AVERROR(ENOMEM);
229  }
230 
231  s->frames[0] = in;
232 
233  out->sample_aspect_ratio = (AVRational){1,1};
234  for (int y = 0; y < outlink->h; y++)
235  memset(out->data[0] + y * out->linesize[0], 0, outlink->w * 4);
236  out->pts = av_rescale_q(in->pts, inlink->time_base, outlink->time_base);
237  out->duration = 1;
238 
239  projection_matrix(s->fov, half_width / half_height, 0.1f, 1000000.f, s->projection_matrix);
240  view_matrix(s->eye, s->zoom, s->roll, s->pitch, s->yaw, s->view_matrix);
241  mmultiply(s->projection_matrix, s->view_matrix, matrix);
242 
243  for (int nb_frame = s->size - 1; nb_frame >= 0; nb_frame--) {
244  const float scale = 1.f / s->nb_samples;
245  AVFrame *frame = s->frames[nb_frame];
246  float channels;
247 
248  if (!frame)
249  continue;
250 
251  channels = frame->ch_layout.nb_channels;
252  for (int ch = 0; ch < channels; ch++) {
253  const float *src = (float *)frame->extended_data[ch];
254  const int r = 128.f + 127.f * sinf(ch / (channels - 1) * M_PI);
255  const int g = 128.f + 127.f * ch / (channels - 1);
256  const int b = 128.f + 127.f * cosf(ch / (channels - 1) * M_PI);
257 
258  for (int n = frame->nb_samples - 1, nn = s->nb_samples * nb_frame; n >= 0; n--, nn++) {
259  float v[4] = { src[n], ch - (channels - 1) * 0.5f, -0.1f + -nn * scale, 1.f };
260  float d[4];
261  int x, y;
262 
263  vmultiply(v, matrix, d);
264 
265  d[0] /= d[3];
266  d[1] /= d[3];
267 
268  x = d[0] * half_width + half_width;
269  y = d[1] * half_height + half_height;
270 
271  if (x >= w || y >= h || x < 0 || y < 0)
272  continue;
273 
274  draw_dot(out, x, y, av_clipf(1.f / d[3], 0.f, 1.f),
275  r, g, b);
276  }
277  }
278  }
279 
280  av_frame_free(&s->frames[59]);
281  memmove(&s->frames[1], &s->frames[0], 59 * sizeof(AVFrame *));
282  s->frames[0] = NULL;
283 
284  return ff_filter_frame(outlink, out);
285 }
286 
288 {
289  AVFilterLink *inlink = ctx->inputs[0];
290  AVFilterLink *outlink = ctx->outputs[0];
291  Audio3dScopeContext *s = ctx->priv;
292  AVFrame *in;
293  int ret;
294 
296 
297  ret = ff_inlink_consume_samples(inlink, s->nb_samples, s->nb_samples, &in);
298  if (ret < 0)
299  return ret;
300  if (ret > 0)
301  return filter_frame(inlink, in);
302 
303  if (ff_inlink_queued_samples(inlink) >= s->nb_samples) {
305  return 0;
306  }
307 
310 
311  return FFERROR_NOT_READY;
312 }
313 
315 {
316  Audio3dScopeContext *s = ctx->priv;
317 
318  for (int n = 0; n < 60; n++)
319  av_frame_free(&s->frames[n]);
320 }
321 
323  {
324  .name = "default",
325  .type = AVMEDIA_TYPE_AUDIO,
326  .config_props = config_input,
327  },
328 };
329 
331  {
332  .name = "default",
333  .type = AVMEDIA_TYPE_VIDEO,
334  .config_props = config_output,
335  },
336 };
337 
339  .name = "a3dscope",
340  .description = NULL_IF_CONFIG_SMALL("Convert input audio to 3d scope video output."),
341  .uninit = uninit,
342  .priv_size = sizeof(Audio3dScopeContext),
343  .activate = activate,
347  .priv_class = &a3dscope_class,
348  .process_command = ff_filter_process_command,
349 };
formats
formats
Definition: signature.h:47
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:116
Audio3dScopeContext::h
int h
Definition: avf_a3dscope.c:33
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: avf_a3dscope.c:76
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
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:435
out
FILE * out
Definition: movenc.c:55
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: avf_a3dscope.c:314
audio3dscope_inputs
static const AVFilterPad audio3dscope_inputs[]
Definition: avf_a3dscope.c:322
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1062
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:948
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition: opt.h:315
matrix
Definition: vc1dsp.c:43
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
zoom
static void zoom(float *u, float *v, float amount)
Definition: vf_xfade.c:1695
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:162
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:501
w
uint8_t w
Definition: llviddspenc.c:38
Audio3dScopeContext::w
int w
Definition: avf_a3dscope.c:33
AVOption
AVOption.
Definition: opt.h:429
Audio3dScopeContext::yaw
float yaw
Definition: avf_a3dscope.c:38
b
#define b
Definition: input.c:41
audio3dscope_outputs
static const AVFilterPad audio3dscope_outputs[]
Definition: avf_a3dscope.c:330
projection_matrix
static void projection_matrix(float fov, float a, float near, float far, float matrix[4][4])
Definition: avf_a3dscope.c:120
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
video.h
FF_FILTER_FORWARD_STATUS_BACK
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition: filters.h:434
Audio3dScopeContext::frame_rate
AVRational frame_rate
Definition: avf_a3dscope.c:42
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
mmultiply
static void mmultiply(const float m2[4][4], const float m1[4][4], float m[4][4])
Definition: avf_a3dscope.c:143
formats.h
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:472
cosf
#define cosf(x)
Definition: libm.h:78
config_input
static int config_input(AVFilterLink *inlink)
Definition: avf_a3dscope.c:96
view_matrix
static void view_matrix(const float eye[3], const float z[3], const float roll, const float pitch, const float yaw, float m[4][4])
Definition: avf_a3dscope.c:156
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
avassert.h
av_cold
#define av_cold
Definition: attributes.h:90
s
#define s(width, name)
Definition: cbs_vp9.c:198
g
const char * g
Definition: vf_curves.c:128
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:678
filters.h
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:304
ctx
AVFormatContext * ctx
Definition: movenc.c:49
channels
channels
Definition: aptx.h:31
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
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
draw_dot
static void draw_dot(AVFrame *out, unsigned x, unsigned y, float z, int r, int g, int b)
Definition: avf_a3dscope.c:200
Audio3dScopeContext::nb_samples
int nb_samples
Definition: avf_a3dscope.c:43
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
ff_inlink_consume_samples
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
Definition: avfilter.c:1511
NULL
#define NULL
Definition: coverity.c:32
config_output
static int config_output(AVFilterLink *outlink)
Definition: avf_a3dscope.c:106
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
TFLAGS
#define TFLAGS
Definition: avf_a3dscope.c:53
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
Audio3dScopeContext::pitch
float pitch
Definition: avf_a3dscope.c:37
Audio3dScopeContext::frames
AVFrame * frames[60]
Definition: avf_a3dscope.c:48
parseutils.h
a3dscope_options
static const AVOption a3dscope_options[]
Definition: avf_a3dscope.c:55
sinf
#define sinf(x)
Definition: libm.h:419
vmultiply
static void vmultiply(const float v[4], const float m[4][4], float d[4])
Definition: avf_a3dscope.c:135
av_clipf
av_clipf
Definition: af_crystalizer.c:122
AVFilterFormatsConfig
Lists of formats / etc.
Definition: avfilter.h:111
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:197
f
f
Definition: af_crystalizer.c:122
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
Audio3dScopeContext::view_matrix
float view_matrix[4][4]
Definition: avf_a3dscope.c:45
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
size
int size
Definition: twinvq_data.h:10344
FLAGS
#define FLAGS
Definition: avf_a3dscope.c:52
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:901
a
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
Definition: undefined.txt:41
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
M_PI
#define M_PI
Definition: mathematics.h:67
OFFSET
#define OFFSET(x)
Definition: avf_a3dscope.c:51
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
Audio3dScopeContext::size
int size
Definition: avf_a3dscope.c:34
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
ff_inlink_queued_samples
int ff_inlink_queued_samples(AVFilterLink *link)
Definition: avfilter.c:1466
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
AVFilter
Filter definition.
Definition: avfilter.h:201
ret
ret
Definition: filter_design.txt:187
Audio3dScopeContext
Definition: avf_a3dscope.c:31
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
Audio3dScopeContext::zoom
float zoom[3]
Definition: avf_a3dscope.c:39
vdot
static float vdot(const float x[3], const float y[3])
Definition: avf_a3dscope.c:151
channel_layout.h
Audio3dScopeContext::projection_matrix
float projection_matrix[4][4]
Definition: avf_a3dscope.c:46
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
audio.h
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:291
FF_FILTER_FORWARD_STATUS
FF_FILTER_FORWARD_STATUS(inlink, outlink)
cr
static double cr(void *priv, double x, double y)
Definition: vf_geq.c:248
Audio3dScopeContext::eye
float eye[3]
Definition: avf_a3dscope.c:40
activate
static int activate(AVFilterContext *ctx)
Definition: avf_a3dscope.c:287
h
h
Definition: vp9dsp_template.c:2070
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: avf_a3dscope.c:213
Audio3dScopeContext::fov
float fov
Definition: avf_a3dscope.c:35
ff_avf_a3dscope
const AVFilter ff_avf_a3dscope
Definition: avf_a3dscope.c:338
src
#define src
Definition: vp8dsp.c:248
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(a3dscope)
ff_filter_set_ready
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Definition: avfilter.c:239
Audio3dScopeContext::roll
float roll
Definition: avf_a3dscope.c:36