63 #define OFFSET(x) offsetof(AudioVectorScopeContext, x)
64 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
99 if (y >= s->
h || x >= s->
w)
115 int dx =
FFABS(x1-x0), sx = x0 < x1 ? 1 : -1;
116 int dy =
FFABS(y1-y0), sy = y0 < y1 ? 1 : -1;
117 int err = (dx>dy ? dx : -dy) / 2, e2;
122 if (x0 == x1 && y0 == y1)
146 for (i = 0; i < s->
h; i++) {
147 for (j = 0; j < s->
w*4; j+=4) {
219 const int hw = s->
hw;
220 const int hh = s->
hh;
223 const double zoom = s->
zoom;
235 for (i = 0; i < outlink->
h; i++)
242 switch (insamples->
format) {
245 int16_t *
src = (int16_t *)insamples->
data[0] + i * 2;
248 x = ((src[1] - src[0]) * zoom / (
float)(UINT16_MAX) + 1) * hw;
249 y = (1.0 - (src[0] + src[1]) * zoom / (
float)UINT16_MAX) * hh;
251 x = (src[1] * zoom / (float)INT16_MAX + 1) * hw;
252 y = (src[0] * zoom / (float)INT16_MAX + 1) * hh;
254 float sx, sy, cx, cy;
256 sx = src[1] * zoom / (float)INT16_MAX;
257 sy = src[0] * zoom / (float)INT16_MAX;
258 cx = sx * sqrtf(1 - 0.5*sy*sy);
259 cy = sy * sqrtf(1 - 0.5*sx*sx);
260 x = hw + hw *
FFSIGN(cx + cy) * (cx - cy) * .7;
261 y = s->
h - s->
h * fabsf(cx + cy) * .7;
275 float *
src = (
float *)insamples->
data[0] + i * 2;
278 x = ((src[1] - src[0]) * zoom / 2 + 1) * hw;
279 y = (1.0 - (src[0] + src[1]) * zoom / 2) * hh;
281 x = (src[1] * zoom + 1) * hw;
282 y = (src[0] * zoom + 1) * hh;
284 float sx, sy, cx, cy;
288 cx = sx * sqrtf(1 - 0.5 * sy * sy);
289 cy = sy * sqrtf(1 - 0.5 * sx * sx);
290 x = hw + hw *
FFSIGN(cx + cy) * (cx - cy) * .7;
291 y = s->
h - s->
h * fabsf(cx + cy) * .7;
340 .
name =
"avectorscope",
345 .
inputs = audiovectorscope_inputs,
346 .
outputs = audiovectorscope_outputs,
347 .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
static enum AVSampleFormat formats[]
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
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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 rational to double.
A filter pad used for either input or output.
A link between two filters.
int width
width and height of the video frame
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 const AVFilterPad outputs[]
static void draw_dot(AudioVectorScopeContext *s, unsigned x, unsigned y)
AVFilterFormats * out_samplerates
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
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...
static const AVFilterPad inputs[]
AVSampleFormat
Audio sample formats.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Describe the class of an AVClass context structure.
rational number numerator/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[]
static void fade(AudioVectorScopeContext *s)
AVPixelFormat
Pixel format.
int nb_samples
number of audio samples (per channel) described by this frame
AVFilterFormats * out_formats