Go to the documentation of this file.
26 #include "config_components.h"
77 static double val(
void *priv,
double ch)
86 #define OFFSET(x) offsetof(EvalContext, x)
87 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
91 {
"nb_samples",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX,
FLAGS },
92 {
"n",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX,
FLAGS },
105 int expected_nb_channels)
109 char *expr, *last_expr =
NULL, *buf;
122 if (!strcmp(
ctx->filter->name,
"aeval")) {
127 #define ADD_EXPRESSION(expr_) do { \
128 ret = av_dynarray_add_nofree(&eval->expr, \
129 &eval->nb_channels, NULL); \
132 eval->expr[eval->nb_channels-1] = NULL; \
133 ret = av_expr_parse(&eval->expr[eval->nb_channels - 1], expr_, \
134 var_names, func1_names, func1, \
135 NULL, NULL, 0, ctx); \
149 while (expr =
av_strtok(buf,
"|", &buf)) {
158 if (expected_nb_channels > 0 && eval->
nb_channels != expected_nb_channels) {
160 "Mismatch between the specified number of channel expressions '%d' "
161 "and the number of expected output channels '%d' for the specified channel layout\n",
178 if (!strcmp(eval->
chlayout_str,
"same") && !strcmp(
ctx->filter->name,
"aeval")) {
239 "sample_rate:%d chlayout:%s duration:%"PRId64
"\n",
297 for (
i = 0;
i < nb_samples;
i++, eval->
n++) {
307 samplesref->
pts = eval->
pts;
309 eval->
pts += nb_samples;
314 #if CONFIG_AEVALSRC_FILTER
333 .priv_class = &aevalsrc_class,
338 #define OFFSET(x) offsetof(EvalContext, x)
339 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
429 for (
i = 0;
i < nb_samples;
i++, eval->
n++) {
433 for (j = 0; j <
inlink->ch_layout.nb_channels; j++)
438 *((
double *)
out->extended_data[j] +
i) =
447 #if CONFIG_AEVAL_FILTER
467 .description =
NULL_IF_CONFIG_SMALL(
"Filter audio signal according to a specified expression."),
474 .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.
static int aeval_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
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)
#define FILTER_INPUTS(array)
static const int sample_rates[]
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_)
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
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_OUTPUTS(array)
int ff_parse_channel_layout(AVChannelLayout *ret, int *nret, const char *arg, void *log_ctx)
Parse a channel layout or a corresponding integer representation.
#define av_realloc_f(p, o, n)
static const AVOption aevalsrc_options[]
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
Parse a sample rate.
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)
#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.
#define FILTER_QUERY_FUNC2(func)
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)
@ AV_OPT_TYPE_INT
Underlying C type is int.
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)
static const uint16_t channel_layouts[7]
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
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
const AVFilter ff_asrc_aevalsrc
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
int nb_samples
number of samples per requested frame