26#include "config_components.h"
77static 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;
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",
298 for (
i = 0;
i < nb_samples;
i++, eval->
n++) {
308 samplesref->
pts = eval->
pts;
310 eval->
pts += nb_samples;
315#if CONFIG_AEVALSRC_FILTER
325 .p.name =
"aevalsrc",
327 .p.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++) {
438 *((
double *)
out->extended_data[j] +
i) =
447#if CONFIG_AEVAL_FILTER
467 .p.description =
NULL_IF_CONFIG_SMALL(
"Filter audio signal according to a specified expression."),
468 .p.priv_class = &aeval_class,
static enum AVSampleFormat sample_fmts[]
#define ADD_EXPRESSION(expr_)
static double val(void *priv, double ch)
static int config_props(AVFilterLink *outlink)
static const AVOption aeval_options[]
static double(*const aeval_func1[])(void *, double)
static int aeval_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int parse_channel_expressions(AVFilterContext *ctx, int expected_nb_channels)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int activate(AVFilterContext *ctx)
static const AVOption aevalsrc_options[]
static av_cold void uninit(AVFilterContext *ctx)
static const char *const aeval_func1_names[]
static int aeval_config_output(AVFilterLink *outlink)
const FFFilter ff_asrc_aevalsrc
const FFFilter ff_af_aeval
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
Parse a sample rate.
int ff_parse_channel_layout(AVChannelLayout *ret, int *nret, const char *arg, void *log_ctx)
Parse a channel layout or a corresponding integer representation.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
static const uint16_t channel_layouts[7]
static const int sample_rates[]
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
simple arithmetic expression evaluator
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ 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...
#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.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
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.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
#define AVERROR_EOF
End of file.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_DBLP
double, planar
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().
#define AV_TIME_BASE
Internal time base represented as integer.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Memory handling functions.
enum MovChannelLayoutTag * layouts
static const char *const var_names[]
static int config_props(AVBitStreamFilterLink *link)
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
A list of supported channel layouts.
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int sample_rate
samples per second
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int sample_rate
Sample rate of the audio data.
uint8_t ** extended_data
pointers to the data planes/channels.
Rational number (pair of numerator and denominator).
int nb_channels
number of output channels
int same_chlayout
set output as input channel layout
int nb_in_channels
number of input channels
int nb_samples
number of samples per requested frame
double var_values[VAR_VARS_NB]
#define av_realloc_f(p, o, n)
static AVFormatContext * ctx
static double(*const func1[])(void *, double)
static const char *const func1_names[]