Go to the documentation of this file.
26 #include "config_components.h"
78 static double val(
void *priv,
double ch)
87 #define OFFSET(x) offsetof(EvalContext, x)
88 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
92 {
"nb_samples",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX,
FLAGS },
93 {
"n",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX,
FLAGS },
106 int expected_nb_channels)
110 char *expr, *last_expr =
NULL, *buf;
123 if (!strcmp(
ctx->filter->name,
"aeval")) {
128 #define ADD_EXPRESSION(expr_) do { \
129 ret = av_dynarray_add_nofree(&eval->expr, \
130 &eval->nb_channels, NULL); \
133 eval->expr[eval->nb_channels-1] = NULL; \
134 ret = av_expr_parse(&eval->expr[eval->nb_channels - 1], expr_, \
135 var_names, func1_names, func1, \
136 NULL, NULL, 0, ctx); \
150 while (expr =
av_strtok(buf,
"|", &buf)) {
159 if (expected_nb_channels > 0 && eval->
nb_channels != expected_nb_channels) {
161 "Mismatch between the specified number of channel expressions '%d' "
162 "and the number of expected output channels '%d' for the specified channel layout\n",
179 if (!strcmp(eval->
chlayout_str,
"same") && !strcmp(
ctx->filter->name,
"aeval")) {
240 "sample_rate:%d chlayout:%s duration:%"PRId64
"\n",
296 for (
i = 0;
i < nb_samples;
i++, eval->
n++) {
306 samplesref->
pts = eval->
pts;
308 eval->
pts += nb_samples;
313 #if CONFIG_AEVALSRC_FILTER
332 .priv_class = &aevalsrc_class,
337 #define OFFSET(x) offsetof(EvalContext, x)
338 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
431 for (
i = 0;
i < nb_samples;
i++, eval->
n++) {
435 for (j = 0; j <
inlink->ch_layout.nb_channels; j++)
440 *((
double *)
out->extended_data[j] +
i) =
449 #if CONFIG_AEVAL_FILTER
469 .description =
NULL_IF_CONFIG_SMALL(
"Filter audio signal according to a specified expression."),
476 .priv_class = &aeval_class,
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
A list of supported channel layouts.
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
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
#define AVERROR_EOF
End of file.
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
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_cold int init(AVFilterContext *ctx)
static int aeval_query_formats(AVFilterContext *ctx)
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).
#define ADD_EXPRESSION(expr_)
#define FILTER_QUERY_FUNC(func)
static const char *const aeval_func1_names[]
#define AV_LOG_VERBOSE
Detailed information.
const char * name
Filter name.
static int config_props(AVFilterLink *outlink)
int nb_channels
Number of channels in this layout.
A link between two filters.
static av_cold void uninit(AVFilterContext *ctx)
void * priv
private data for use by the filter
int same_chlayout
set output as input channel layout
static double val(void *priv, double ch)
static const char *const func1_names[]
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
A filter pad used for either input or output.
double var_values[VAR_VARS_NB]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
#define FILTER_INPUTS(array)
#define av_realloc_f(p, o, n)
static const AVOption aevalsrc_options[]
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static int aeval_config_output(AVFilterLink *outlink)
Rational number (pair of numerator and denominator).
const AVFilter ff_af_aeval
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 inputs
int nb_in_channels
number of input channels
static const AVOption aeval_options[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
An AVChannelLayout holds information about the channel layout of audio data.
int sample_rate
Sample rate of the audio data.
int nb_channels
number of output channels
AVFilterContext * src
source filter
static double(*const aeval_func1[])(void *, double)
AVFilterFormatsConfig incfg
Lists of supported formats / etc.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int sample_rate
samples per second
int nb_samples
number of audio samples (per channel) described by this frame
static double(*const func1[])(void *, double)
#define i(width, name, range_min, range_max)
#define AV_TIME_BASE
Internal time base represented as integer.
uint8_t ** extended_data
pointers to the data planes/channels.
AVSampleFormat
Audio sample formats.
const char * name
Pad name.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
AVFILTER_DEFINE_CLASS(aevalsrc)
static const char *const var_names[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
@ AV_SAMPLE_FMT_DBLP
double, planar
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static int activate(AVFilterContext *ctx)
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
char * av_strdup(const char *s)
Duplicate a string.
static int parse_channel_expressions(AVFilterContext *ctx, int expected_nb_channels)
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
#define FILTER_OUTPUTS(array)
static int query_formats(AVFilterContext *ctx)
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
const AVFilter ff_asrc_aevalsrc
int nb_samples
number of samples per requested frame