50 #define CONTEXT SineContext
51 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
53 #define OPT_GENERIC(name, field, def, min, max, descr, type, deffield, ...) \
54 { name, descr, offsetof(CONTEXT, field), AV_OPT_TYPE_ ## type, \
55 { .deffield = def }, min, max, FLAGS, __VA_ARGS__ }
57 #define OPT_INT(name, field, def, min, max, descr, ...) \
58 OPT_GENERIC(name, field, def, min, max, descr, INT, i64, __VA_ARGS__)
60 #define OPT_DBL(name, field, def, min, max, descr, ...) \
61 OPT_GENERIC(name, field, def, min, max, descr, DOUBLE, dbl, __VA_ARGS__)
63 #define OPT_DUR(name, field, def, min, max, descr, ...) \
64 OPT_GENERIC(name, field, def, min, max, descr, DURATION, str, __VA_ARGS__)
66 #define OPT_STR(name, field, def, min, max, descr, ...) \
67 OPT_GENERIC(name, field, def, min, max, descr, STRING, str, __VA_ARGS__)
70 OPT_DBL(
"frequency", frequency, 440, 0, DBL_MAX,
"set the sine frequency",),
71 OPT_DBL(
"f", frequency, 440, 0, DBL_MAX,
"set the sine frequency",),
72 OPT_DBL(
"beep_factor", beep_factor, 0, 0, DBL_MAX,
"set the beep frequency factor",),
73 OPT_DBL(
"b", beep_factor, 0, 0, DBL_MAX,
"set the beep frequency factor",),
76 OPT_DUR(
"duration",
duration, 0, 0, INT64_MAX,
"set the audio duration",),
78 OPT_STR(
"samples_per_frame", samples_per_frame,
"1024", 0, 0,
"set the number of samples per frame",),
85 #define AMPLITUDE 4095
86 #define AMPLITUDE_SHIFT 3
92 uint64_t unit2 = (uint64_t)(ampls * ampls) << 32;
93 unsigned step, i,
c,
s, k, new_k, n2;
99 for (step = half_pi; step > 1; step /= 2) {
103 for (i = 0; i < half_pi / 2; i += step) {
104 s = sin[i] + sin[i + step];
105 c = sin[half_pi - i] + sin[half_pi - i - step];
109 new_k = (k + unit2 / ((uint64_t)k * n2) + 1) >> 1;
114 sin[i + step / 2] = (k * s + 0x7FFF) >> 16;
115 sin[half_pi - i - step / 2] = (k * c + 0x8000) >> 16;
119 for (i = 0; i <= half_pi; i++)
122 for (i = 0; i < half_pi; i++)
123 sin[half_pi * 2 - i] = sin[i];
124 for (i = 0; i < 2 * half_pi; i++)
125 sin[i + 2 * half_pi] = -sin[i];
230 if (nb_samples <= 0) {
232 "defaulting to 1024\n", nb_samples);
244 samples = (int16_t *)frame->
data[0];
246 for (i = 0; i < nb_samples; i++) {
258 sine->
pts += nb_samples;
281 .priv_class = &sine_class,
int64_t frame_count_in
Number of past frames sent through the link.
This structure describes decoded (raw) audio or video data.
#define OPT_INT(name, field, def, min, max, descr,...)
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
uint32_t dphi_beep
phase increment of the beep
static const AVOption sine_options[]
uint32_t phi_beep
current phase of the beep
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.
const char * name
Pad name.
AVFILTER_DEFINE_CLASS(sine)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define AVERROR_EOF
End of file.
static av_cold int init(AVFilterContext *ctx)
A filter pad used for either input or output.
A link between two filters.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
AVExpr * samples_per_frame_expr
#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().
audio channel layout utility functions
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
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.
AVFilterContext * src
source filter
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
A list of supported channel layouts.
static int request_frame(AVFilterLink *outlink)
static const AVFilterPad sine_outputs[]
AVSampleFormat
Audio sample formats.
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
#define OPT_DBL(name, field, def, min, max, descr,...)
static const char *const var_names[]
Describe the class of an AVClass context structure.
const char * name
Filter name.
static void make_sin_table(int16_t *sin)
enum MovChannelLayoutTag * layouts
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold void uninit(AVFilterContext *ctx)
static av_cold int config_props(AVFilterLink *outlink)
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
uint32_t phi
current phase of the sine (2pi = 1<<32)
uint32_t dphi
phase increment between two samples
static av_cold int query_formats(AVFilterContext *ctx)
static enum AVSampleFormat sample_fmts[]
#define OPT_STR(name, field, def, min, max, descr,...)
#define AV_CH_LAYOUT_MONO
simple arithmetic expression evaluator
#define OPT_DUR(name, field, def, min, max, descr,...)