76 static double val(
void *priv, 
double ch)
 
   85 #define OFFSET(x) offsetof(EvalContext, x) 
   86 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 
   90     { 
"nb_samples",  
"set the number of samples per requested frame", 
OFFSET(nb_samples),      
AV_OPT_TYPE_INT,    {.i64 = 1024},    0,        INT_MAX, 
FLAGS },
 
   91     { 
"n",           
"set the number of samples per requested frame", 
OFFSET(nb_samples),      
AV_OPT_TYPE_INT,    {.i64 = 1024},    0,        INT_MAX, 
FLAGS },
 
  104                                      int expected_nb_channels)
 
  108     char *expr, *last_expr = 
NULL, *
buf;
 
  109     double (* 
const *
func1)(
void *, double) = 
NULL;
 
  126 #define ADD_EXPRESSION(expr_) do {                                      \ 
  127         if (!av_dynarray2_add((void **)&eval->expr, &eval->nb_channels, \ 
  128                               sizeof(*eval->expr), NULL)) {             \ 
  129             ret = AVERROR(ENOMEM);                                      \ 
  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)) {
 
  155         for (i = eval->
nb_channels; i < expected_nb_channels; i++)
 
  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",
 
  238            "sample_rate:%d chlayout:%s duration:%"PRId64
"\n",
 
  289     for (i = 0; i < eval->
nb_samples; i++, eval->
n++) {
 
  299     samplesref->
pts = eval->
pts;
 
  306 #if CONFIG_AEVALSRC_FILTER 
  326     .priv_class    = &aevalsrc_class,
 
  331 #define OFFSET(x) offsetof(EvalContext, x) 
  332 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 
  411 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb)) 
  431     for (i = 0; i < nb_samples; i++, eval->
n++) {
 
  438         for (j = 0; j < outlink->
channels; j++) {
 
  449 #if CONFIG_AEVAL_FILTER 
  471     .description   = 
NULL_IF_CONFIG_SMALL(
"Filter audio signal according to a specified expression."),
 
  478     .priv_class    = &aeval_class,
 
static const char *const func1_names[]
static int aeval_config_output(AVFilterLink *outlink)
#define av_realloc_f(p, o, n)
This structure describes decoded (raw) audio or video data. 
static int aeval_query_formats(AVFilterContext *ctx)
Main libavfilter public API header. 
static enum AVSampleFormat formats[]
static const char *const aeval_func1_names[]
static av_cold void uninit(AVFilterContext *ctx)
struct AVFilterChannelLayouts * in_channel_layouts
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout. 
const char * name
Pad name. 
AVFilterLink ** inputs
array of pointers to input links 
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter. 
int64_t out_channel_layout
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). 
static double(*const aeval_func1[])(void *, double)
#define AVERROR_EOF
End of file. 
#define AV_LOG_VERBOSE
Detailed information. 
static const char *const var_names[]
static const AVOption aeval_options[]
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. 
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 double(*const func1[])(void *, double)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g. 
#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 
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert(). 
struct AVFilterChannelLayouts * out_channel_layouts
static const int sample_rates[]
audio channel layout utility functions 
static int request_frame(AVFilterLink *outlink)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest. 
#define AV_TIME_BASE
Internal time base represented as integer. 
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
AVFilterContext * src
source filter 
static const AVFilterPad outputs[]
A list of supported channel layouts. 
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. 
static const AVFilterPad inputs[]
AVSampleFormat
Audio sample formats. 
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse(). 
int same_chlayout
set output as input channel layout 
char * av_strdup(const char *s)
Duplicate the string s. 
static int config_props(AVFilterLink *outlink)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
Describe the class of an AVClass context structure. 
int sample_rate
Sample rate of the audio data. 
rational number numerator/denominator 
AVFILTER_DEFINE_CLASS(aevalsrc)
const char * name
Filter name. 
AVFilterLink ** outputs
array of pointers to output links 
enum MovChannelLayoutTag * layouts
int nb_in_channels
number of input channels 
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 query_formats(AVFilterContext *ctx)
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h) 
int channels
Number of channels. 
int nb_channels
number of output channels 
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression. 
AVFilterContext * dst
dest filter 
#define ADD_EXPRESSION(expr_)
int64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels. 
static enum AVSampleFormat sample_fmts[]
static av_cold int init(AVFilterContext *ctx)
static int parse_channel_expressions(AVFilterContext *ctx, int expected_nb_channels)
uint8_t ** extended_data
pointers to the data planes/channels. 
double var_values[VAR_VARS_NB]
static double val(void *priv, double ch)
int nb_samples
number of audio samples (per channel) described by this frame 
const AVFilter * filter
the AVFilter of which this is an instance 
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst. 
simple arithmetic expression evaluator