26 #include "libavutil/avassert.h"
27 #include "libavutil/avstring.h"
28 #include "libavutil/channel_layout.h"
29 #include "libavutil/eval.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/parseutils.h"
66 #define OFFSET(x) offsetof(EvalContext, x)
67 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
71 {
"nb_samples",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX,
FLAGS },
72 {
"n",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX,
FLAGS },
99 while (expr =
av_strtok(buf,
"|", &buf)) {
105 NULL, NULL, NULL, NULL, 0, ctx);
119 "Mismatch between the specified number of channels '%d' "
120 "and the number of channels '%d' in the specified channel layout '%s'\n",
152 eval->
expr[i] = NULL;
170 "sample_rate:%d chlayout:%s duration:%"PRId64
"\n",
205 for (i = 0; i < eval->
nb_samples; i++, eval->
n++) {
215 samplesref->
pts = eval->
pts;
241 .priv_class = &aevalsrc_class,
static const AVFilterPad aevalsrc_outputs[]
This structure describes decoded (raw) audio or video data.
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
const char * name
Filter name.
void * priv
private data for use by the filter
static const AVFilterPad outputs[]
char * av_strdup(const char *s) av_malloc_attrib
Duplicate the string s.
uint8_t ** extended_data
pointers to the data planes/channels.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static av_cold int end(AVCodecContext *avctx)
int nb_samples
number of samples per requested frame
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_LOG_VERBOSE
Detailed information.
A filter pad used for either input or output.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
static av_cold int init(AVFilterContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
AVFilterContext * src
source filter
static const int sample_rates[]
int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
void * av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size, const uint8_t *elem_data)
Add an element of size elem_size to a dynamic array.
static int request_frame(AVFilterLink *outlink)
Main libavfilter public API header.
AVSampleFormat
Audio Sample Formats.
static int query_formats(AVFilterContext *ctx)
Describe the class of an AVClass context structure.
int sample_rate
Sample rate of the audio data.
static const AVFilterPad inputs[]
rational number numerator/denominator
static const char *const var_names[]
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()...
static const AVOption aevalsrc_options[]
static int config_props(AVFilterLink *outlink)
#define AVFILTER_DEFINE_CLASS(fname)
AVFilter avfilter_asrc_aevalsrc
static enum AVSampleFormat sample_fmts[]
double var_values[VAR_VARS_NB]
static av_cold void uninit(AVFilterContext *ctx)
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
int64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.