74 #define OFFSET(x) offsetof(AudioVectorScopeContext, x)
75 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
121 if (y >= s->
h || x >= s->
w)
137 int dx =
FFABS(x1-x0), sx = x0 < x1 ? 1 : -1;
138 int dy =
FFABS(y1-y0), sy = y0 < y1 ? 1 : -1;
139 int err = (dx>dy ? dx : -dy) / 2, e2;
144 if (x0 == x1 && y0 == y1)
168 for (i = 0; i < s->
h; i++) {
169 for (j = 0; j < s->
w*4; j+=4) {
241 const int hw = s->
hw;
242 const int hh = s->
hh;
245 double zoom = s->
zoom;
258 for (i = 0; i < outlink->
h; i++)
268 switch (insamples->
format) {
270 int16_t *samples = (int16_t *)insamples->
data[0];
273 float sample = samples[i] / (float)INT16_MAX;
280 float *samples = (
float *)insamples->
data[0];
295 int16_t *samples = (int16_t *)insamples->
data[0] + i * 2;
296 float *samplesf = (
float *)insamples->
data[0] + i * 2;
299 switch (insamples->
format) {
301 src[0] = samples[0] / (float)INT16_MAX;
302 src[1] = samples[1] / (float)INT16_MAX;
305 src[0] = samplesf[0];
306 src[1] = samplesf[1];
322 src[0] =
FFSIGN(src[0]) * logf(1 +
FFABS(src[0])) / logf(2);
323 src[1] =
FFSIGN(src[1]) * logf(1 +
FFABS(src[1])) / logf(2);
334 FFSWAP(
float, src[0], src[1]);
337 x = ((src[1] - src[0]) * zoom / 2 + 1) * hw;
338 y = (1.0 - (src[0] + src[1]) * zoom / 2) * hh;
340 x = (src[1] * zoom + 1) * hw;
341 y = (src[0] * zoom + 1) * hh;
343 float sx, sy, cx, cy;
347 cx = sx * sqrtf(1 - 0.5 * sy * sy);
348 cy = sy * sqrtf(1 - 0.5 * sx * sx);
349 x = hw + hw *
FFSIGN(cx + cy) * (cx - cy) * .7;
350 y = s->
h - s->
h * fabsf(cx + cy) * .7;
395 .
name =
"avectorscope",
400 .
inputs = audiovectorscope_inputs,
401 .
outputs = audiovectorscope_outputs,
402 .priv_class = &avectorscope_class,
This structure describes decoded (raw) audio or video data.
Main libavfilter public API header.
int max_samples
Maximum number of samples to filter at once.
static void draw_line(AudioVectorScopeContext *s, int x0, int y0, int x1, int y1)
static av_cold void uninit(AVFilterContext *ctx)
int h
agreed upon image height
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_CH_LAYOUT_STEREO
AVFilter ff_avf_avectorscope
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static const AVFilterPad audiovectorscope_outputs[]
static double av_q2d(AVRational a)
Convert an AVRational to a double.
A filter pad used for either input or output.
A link between two filters.
int min_samples
Minimum number of samples to filter at once.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
int sample_rate
samples per second
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static int config_input(AVFilterLink *inlink)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
simple assert() macros that are a bit more flexible than ISO C assert().
struct AVFilterChannelLayouts * out_channel_layouts
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
static const AVOption avectorscope_options[]
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int w
agreed upon image width
audio channel layout utility functions
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static const AVFilterPad audiovectorscope_inputs[]
AVFilterContext * src
source filter
int partial_buf_size
Size of the partial buffer to allocate.
static void draw_dot(AudioVectorScopeContext *s, unsigned x, unsigned y)
static const AVFilterPad inputs[]
AVFilterFormats * out_samplerates
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
static const AVFilterPad outputs[]
AVFILTER_DEFINE_CLASS(avectorscope)
static int config_output(AVFilterLink *outlink)
A list of supported channel layouts.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
AVSampleFormat
Audio sample formats.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
static av_always_inline float cbrtf(float x)
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
offset must point to AVRational
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
offset must point to two consecutive integers
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int query_formats(AVFilterContext *ctx)
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
AVFilterContext * dst
dest filter
static enum AVSampleFormat sample_fmts[]
#define FFSWAP(type, a, b)
static void fade(AudioVectorScopeContext *s)
AVPixelFormat
Pixel format.
mode
Use these values in ebur128_init (or'ed).
int nb_samples
number of audio samples (per channel) described by this frame
AVFilterFormats * out_formats