48 #define CONTEXT SineContext
49 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
51 #define OPT_GENERIC(name, field, def, min, max, descr, type, deffield, ...) \
52 { name, descr, offsetof(CONTEXT, field), AV_OPT_TYPE_ ## type, \
53 { .deffield = def }, min, max, FLAGS, __VA_ARGS__ }
55 #define OPT_INT(name, field, def, min, max, descr, ...) \
56 OPT_GENERIC(name, field, def, min, max, descr, INT, i64, __VA_ARGS__)
58 #define OPT_DBL(name, field, def, min, max, descr, ...) \
59 OPT_GENERIC(name, field, def, min, max, descr, DOUBLE, dbl, __VA_ARGS__)
61 #define OPT_DUR(name, field, def, min, max, descr, ...) \
62 OPT_GENERIC(name, field, def, min, max, descr, DURATION, str, __VA_ARGS__)
65 OPT_DBL(
"frequency", frequency, 440, 0, DBL_MAX,
"set the sine frequency"),
66 OPT_DBL(
"f", frequency, 440, 0, DBL_MAX,
"set the sine frequency"),
67 OPT_DBL(
"beep_factor", beep_factor, 0, 0, DBL_MAX,
"set the beep fequency factor"),
68 OPT_DBL(
"b", beep_factor, 0, 0, DBL_MAX,
"set the beep fequency factor"),
71 OPT_DUR(
"duration",
duration, 0, 0, INT64_MAX,
"set the audio duration"),
73 OPT_INT(
"samples_per_frame", samples_per_frame, 1024, 0, INT_MAX,
"set the number of samples per frame"),
80 #define AMPLITUDE 4095
81 #define AMPLITUDE_SHIFT 3
87 uint64_t unit2 = (uint64_t)(ampls * ampls) << 32;
88 unsigned step, i,
c,
s, k, new_k, n2;
94 for (step = half_pi; step > 1; step /= 2) {
98 for (i = 0; i < half_pi / 2; i += step) {
99 s = sin[i] + sin[i + step];
100 c = sin[half_pi - i] + sin[half_pi - i - step];
104 new_k = (k + unit2 / ((uint64_t)k * n2) + 1) >> 1;
109 sin[i + step / 2] = (k * s + 0x7FFF) >> 16;
110 sin[half_pi - i - step / 2] = (k * c + 0x8000) >> 16;
114 for (i = 0; i <= half_pi; i++)
117 for (i = 0; i < half_pi; i++)
118 sin[half_pi * 2 - i] = sin[i];
119 for (i = 0; i < 2 * half_pi; i++)
120 sin[i + 2 * half_pi] = -sin[i];
185 samples = (int16_t *)frame->
data[0];
187 for (i = 0; i < nb_samples; i++) {
199 sine->
pts += nb_samples;
222 .priv_class = &sine_class,