57#define OFFSET(x) offsetof(ANoiseSrcContext, x)
58#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
78 {
"nb_samples",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64 = 1024}, 1, INT_MAX,
FLAGS },
79 {
"n",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64 = 1024}, 1, INT_MAX,
FLAGS },
118 buf[0] = 0.99886 * buf[0] + white * 0.0555179;
119 buf[1] = 0.99332 * buf[1] + white * 0.0750759;
120 buf[2] = 0.96900 * buf[2] + white * 0.1538520;
121 buf[3] = 0.86650 * buf[3] + white * 0.3104856;
122 buf[4] = 0.55000 * buf[4] + white * 0.5329522;
123 buf[5] = -0.7616 * buf[5] - white * 0.0168980;
124 pink = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6] + white * 0.5362;
125 buf[6] = white * 0.115926;
134 buf[0] = 0.0555179 * white - 0.99886 * buf[0];
135 buf[1] = 0.0750759 * white - 0.99332 * buf[1];
136 buf[2] = 0.1538520 * white - 0.96900 * buf[2];
137 buf[3] = 0.3104856 * white - 0.86650 * buf[3];
138 buf[4] = 0.5329522 * white - 0.55000 * buf[4];
139 buf[5] = -0.016898 * white + 0.76160 * buf[5];
140 blue = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6] + white * 0.5362;
141 buf[6] = white * 0.115926;
149 brown = ((0.02 * white) + buf[0]) / 1.02;
158 violet = ((0.02 * white) - buf[0]) / 1.02;
165 double awhite =
fabs(white);
166 return FFDIFFSIGN(white, 0.0) * buf[1] * (awhite < buf[0]);
178 if (
s->duration == 0)
189 s->buf[1] =
s->amplitude;
207 if (!
s->infinite &&
s->duration <= 0) {
210 }
else if (!
s->infinite &&
s->duration <
s->nb_samples) {
211 nb_samples =
s->duration;
213 nb_samples =
s->nb_samples;
220 for (
i = 0;
i < nb_samples;
i++) {
223 dst[
i] =
s->filter(white,
s->buf);
227 s->duration -= nb_samples;
230 s->pts += nb_samples;
243 .p.name =
"anoisesrc",
245 .p.priv_class = &anoisesrc_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static enum AVSampleFormat sample_fmts[]
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
const FFFilter ff_asrc_anoisesrc
static double white_filter(double white, double *buf)
static double blue_filter(double white, double *buf)
static double pink_filter(double white, double *buf)
static double violet_filter(double white, double *buf)
static double velvet_filter(double white, double *buf)
static double brown_filter(double white, double *buf)
static const AVOption anoisesrc_options[]
static av_cold int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int activate(AVFilterContext *ctx)
static const AVFilterPad anoisesrc_outputs[]
static av_cold int config_props(AVFilterLink *outlink)
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 __device__ float fabs(float a)
static const int sample_rates[]
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
#define AV_CHANNEL_LAYOUT_MONO
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
#define AVERROR_EOF
End of file.
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_DBL
double
#define AV_TIME_BASE
Internal time base represented as integer.
static int activate(AVBitStreamFilterContext *ctx)
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
#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.
#define FFDIFFSIGN(x, y)
Comparator.
static int config_props(AVBitStreamFilterLink *link)
double(* filter)(double white, double *buf)
An AVChannelLayout holds information about the channel layout of audio data.
Describe the class of an AVClass context structure.
A link between two filters.
AVFilterContext * src
source filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
Context structure for the Lagged Fibonacci PRNG.
static AVFormatContext * ctx