Go to the documentation of this file.
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
127 f = 1.0f / tanf(fov * 0.5
f *
M_PI / 180.
f);
130 matrix[2][2] = -(far + near) / (far - near);
132 matrix[3][2] = -(near * far) / (far - near);
135 static inline void vmultiply(
const float v[4],
const float m[4][4],
float d[4])
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];
143 static void mmultiply(
const float m2[4][4],
const float m1[4][4],
float m[4][4])
151 static float vdot(
const float x[3],
const float y[3])
153 return x[0] * y[0] + x[1] * y[1] + x[2] * y[2];
160 const float yaw,
float m[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 },
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 },
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 },
190 memset(m, 0,
sizeof(*m));
195 m[3][0] = -
vdot(m[0], eye);
196 m[3][1] = -
vdot(m[1], eye);
197 m[3][2] = -
vdot(m[2], eye);
203 const ptrdiff_t linesize =
out->linesize[0];
206 dst =
out->data[0] + y * linesize + x * 4;
218 const float half_height = (
s->h - 1) * 0.5
f;
219 const float half_width = (
s->w - 1) * 0.5
f;
234 for (
int y = 0; y < outlink->
h; y++)
235 memset(
out->data[0] + y *
out->linesize[0], 0, outlink->
w * 4);
239 projection_matrix(
s->fov, half_width / half_height, 0.1f, 1000000.f,
s->projection_matrix);
243 for (
int nb_frame =
s->size - 1; nb_frame >= 0; nb_frame--) {
244 const float scale = 1.f /
s->nb_samples;
252 for (
int ch = 0; ch <
channels; ch++) {
253 const float *
src = (
float *)
frame->extended_data[ch];
255 const int g = 128.f + 127.f * ch / (
channels - 1);
258 for (
int n =
frame->nb_samples - 1, nn =
s->nb_samples * nb_frame; n >= 0; n--, nn++) {
268 x = d[0] * half_width + half_width;
269 y = d[1] * half_height + half_height;
271 if (x >=
w || y >=
h || x < 0 || y < 0)
281 memmove(&
s->frames[1], &
s->frames[0], 59 *
sizeof(
AVFrame *));
318 for (
int n = 0; n < 60; n++)
347 .priv_class = &a3dscope_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
@ AV_SAMPLE_FMT_FLTP
float, planar
AVPixelFormat
Pixel format.
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
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
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad audio3dscope_inputs[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static enum AVSampleFormat sample_fmts[]
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
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
static void zoom(float *u, float *v, float amount)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static const AVFilterPad audio3dscope_outputs[]
static void projection_matrix(float fov, float a, float near, float far, float matrix[4][4])
const char * name
Filter name.
A link between two filters.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Link properties exposed to filter code, but not external callers.
static void mmultiply(const float m2[4][4], const float m1[4][4], float m[4][4])
void * priv
private data for use by the filter
static int config_input(AVFilterLink *inlink)
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])
A filter pad used for either input or output.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
static enum AVPixelFormat pix_fmts[]
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static void draw_dot(AVFrame *out, unsigned x, unsigned y, float z, int r, int g, int b)
Describe the class of an AVClass context structure.
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.
static int config_output(AVFilterLink *outlink)
Rational number (pair of numerator and denominator).
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
static const AVOption a3dscope_options[]
static void vmultiply(const float v[4], const float m[4][4], float d[4])
static FilterLink * ff_filter_link(AVFilterLink *link)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
AVFilterContext * src
source filter
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.
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
FF_FILTER_FORWARD_WANTED(outlink, inlink)
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
int w
agreed upon image width
AVSampleFormat
Audio sample formats.
#define FILTER_QUERY_FUNC2(func)
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
const char * name
Pad name.
int ff_inlink_queued_samples(AVFilterLink *link)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
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
static float vdot(const float x[3], const float y[3])
int h
agreed upon image height
float projection_matrix[4][4]
@ AV_OPT_TYPE_INT
Underlying C type is int.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static void scale(int *out, const int *in, const int w, const int h, const int shift)
FF_FILTER_FORWARD_STATUS(inlink, outlink)
static double cr(void *priv, double x, double y)
static int activate(AVFilterContext *ctx)
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
const AVFilter ff_avf_a3dscope
AVFILTER_DEFINE_CLASS(a3dscope)
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.