Go to the documentation of this file.
52 #define OFFSET(x) offsetof(Audio3dScopeContext, x)
53 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
54 #define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
136 f = 1.0f / tanf(fov * 0.5
f *
M_PI / 180.
f);
139 matrix[2][2] = -(far + near) / (far - near);
141 matrix[3][2] = -(near * far) / (far - near);
144 static inline void vmultiply(
const float v[4],
const float m[4][4],
float d[4])
146 d[0] = v[0] * m[0][0] + v[1] * m[1][0] + v[2] * m[2][0] + v[3] * m[3][0];
147 d[1] = v[0] * m[0][1] + v[1] * m[1][1] + v[2] * m[2][1] + v[3] * m[3][1];
148 d[2] = v[0] * m[0][2] + v[1] * m[1][2] + v[2] * m[2][2] + v[3] * m[3][2];
149 d[3] = v[0] * m[0][3] + v[1] * m[1][3] + v[2] * m[2][3] + v[3] * m[3][3];
152 static void mmultiply(
const float m2[4][4],
const float m1[4][4],
float m[4][4])
160 static float vdot(
const float x[3],
const float y[3])
162 return x[0] * y[0] + x[1] * y[1] + x[2] * y[2];
169 const float yaw,
float m[4][4])
179 {z[0], 0.f, 0.f, 0.f },
180 { 0.f, cy, -sy, 0.f },
181 { 0.f, sy, cy, 0.f },
182 { 0.f, 0.f, 0.f, 1.f },
186 { cp, 0.f,
sp, 0.f },
187 { 0.f,z[1], 0.f, 0.f },
188 {-
sp, 0.f, cp, 0.f },
189 { 0.f, 0.f, 0.f, 1.f },
193 {
cr, -sr, 0.f, 0.f },
194 { sr,
cr, 0.f, 0.f },
195 { 0.f, 0.f,z[2], 0.f },
196 { 0.f, 0.f, 0.f, 1.f },
199 memset(m, 0,
sizeof(*m));
204 m[3][0] = -
vdot(m[0], eye);
205 m[3][1] = -
vdot(m[1], eye);
206 m[3][2] = -
vdot(m[2], eye);
212 const ptrdiff_t linesize =
out->linesize[0];
215 dst =
out->data[0] + y * linesize + x * 4;
227 const float half_height = (
s->h - 1) * 0.5
f;
228 const float half_width = (
s->w - 1) * 0.5
f;
243 for (
int y = 0; y < outlink->
h; y++)
244 memset(
out->data[0] + y *
out->linesize[0], 0, outlink->
w * 4);
248 projection_matrix(
s->fov, half_width / half_height, 0.1f, 1000000.f,
s->projection_matrix);
252 for (
int nb_frame =
s->size - 1; nb_frame >= 0; nb_frame--) {
253 const float scale = 1.f /
s->nb_samples;
261 for (
int ch = 0; ch <
channels; ch++) {
262 const float *
src = (
float *)
frame->extended_data[ch];
264 const int g = 128.f + 127.f * ch / (
channels - 1);
267 for (
int n =
frame->nb_samples - 1, nn =
s->nb_samples * nb_frame; n >= 0; n--, nn++) {
277 x =
d[0] * half_width + half_width;
278 y =
d[1] * half_height + half_height;
280 if (x >=
w || y >=
h || x < 0 || y < 0)
290 memmove(&
s->frames[1], &
s->frames[0], 59 *
sizeof(
AVFrame *));
327 for (
int n = 0; n < 60; n++)
356 .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
A list of supported channel layouts.
AVPixelFormat
Pixel format.
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[]
enum MovChannelLayoutTag * layouts
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to 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.
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[]
#define FILTER_QUERY_FUNC(func)
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.
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 query_formats(AVFilterContext *ctx)
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])
static av_always_inline float scale(float x, float s)
A filter pad used for either input or output.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
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_INPUTS(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
offset must point to two consecutive integers
static const AVOption a3dscope_options[]
static void vmultiply(const float v[4], const float m[4][4], float d[4])
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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.
AVFilterFormatsConfig incfg
Lists of supported formats / etc.
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)
int w
agreed upon image width
AVSampleFormat
Audio sample formats.
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]
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
FF_FILTER_FORWARD_STATUS(inlink, outlink)
static double cr(void *priv, double x, double y)
#define FILTER_OUTPUTS(array)
static int activate(AVFilterContext *ctx)
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.