52 uint8_t *
const *
src, uint8_t **
dst,
56#define OFFSET(x) offsetof(AudioPhaserContext, x)
57#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
79 if (
s->in_gain > (1 -
s->decay *
s->decay))
81 if (
s->in_gain / (1 -
s->decay) > 1 /
s->out_gain)
87#define MOD(a, b) (((a) >= (b)) ? (a) - (b) : (a))
89#define PHASER_PLANAR(name, type) \
90static void phaser_## name ##p(AudioPhaserContext *s, \
91 uint8_t * const *ssrc, uint8_t **ddst, \
92 int nb_samples, int channels) \
94 int i, c, delay_pos, modulation_pos; \
96 av_assert0(channels > 0); \
97 for (c = 0; c < channels; c++) { \
98 type *src = (type *)ssrc[c]; \
99 type *dst = (type *)ddst[c]; \
100 double *buffer = s->delay_buffer + \
101 c * s->delay_buffer_length; \
103 delay_pos = s->delay_pos; \
104 modulation_pos = s->modulation_pos; \
106 for (i = 0; i < nb_samples; i++, src++, dst++) { \
107 double v = *src * s->in_gain + buffer[ \
108 MOD(delay_pos + s->modulation_buffer[ \
110 s->delay_buffer_length)] * s->decay; \
112 modulation_pos = MOD(modulation_pos + 1, \
113 s->modulation_buffer_length); \
114 delay_pos = MOD(delay_pos + 1, s->delay_buffer_length); \
115 buffer[delay_pos] = v; \
117 *dst = v * s->out_gain; \
121 s->delay_pos = delay_pos; \
122 s->modulation_pos = modulation_pos; \
125#define PHASER(name, type) \
126static void phaser_## name (AudioPhaserContext *s, \
127 uint8_t * const *ssrc, uint8_t **ddst, \
128 int nb_samples, int channels) \
130 int i, c, delay_pos, modulation_pos; \
131 type *src = (type *)ssrc[0]; \
132 type *dst = (type *)ddst[0]; \
133 double *buffer = s->delay_buffer; \
135 delay_pos = s->delay_pos; \
136 modulation_pos = s->modulation_pos; \
138 for (i = 0; i < nb_samples; i++) { \
139 int pos = MOD(delay_pos + s->modulation_buffer[modulation_pos], \
140 s->delay_buffer_length) * channels; \
143 delay_pos = MOD(delay_pos + 1, s->delay_buffer_length); \
144 npos = delay_pos * channels; \
145 for (c = 0; c < channels; c++, src++, dst++) { \
146 double v = *src * s->in_gain + buffer[pos + c] * s->decay; \
148 buffer[npos + c] = v; \
150 *dst = v * s->out_gain; \
153 modulation_pos = MOD(modulation_pos + 1, \
154 s->modulation_buffer_length); \
157 s->delay_pos = delay_pos; \
158 s->modulation_pos = modulation_pos; \
176 s->delay_buffer_length =
s->delay * 0.001 * inlink->
sample_rate + 0.5;
177 if (
s->delay_buffer_length <= 0) {
178 av_log(outlink->src, AV_LOG_ERROR,
"delay is too small\n");
179 return AVERROR(EINVAL);
182 s->modulation_buffer_length = inlink->
sample_rate /
s->speed + 0.5;
183 s->modulation_buffer =
av_malloc_array(
s->modulation_buffer_length,
sizeof(*
s->modulation_buffer));
185 if (!
s->modulation_buffer || !
s->delay_buffer)
189 s->modulation_buffer,
s->modulation_buffer_length,
190 1.,
s->delay_buffer_length,
M_PI / 2.0);
192 s->delay_pos =
s->modulation_pos = 0;
262 .p.priv_class = &aphaser_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define PHASER_PLANAR(name, type)
static const AVFilterPad aphaser_inputs[]
static const AVFilterPad aphaser_outputs[]
#define PHASER(name, type)
static int filter_frame(AVFilterLink *inlink, AVFrame *inbuf)
const FFFilter ff_af_aphaser
static av_cold void uninit(AVFilterContext *ctx)
static const AVOption aphaser_options[]
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
void ff_generate_wave_table(enum WaveType wave_type, enum AVSampleFormat sample_fmt, void *table, int table_size, double min, double max, double phase)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_WARNING
Something somehow does not look correct.
@ AV_SAMPLE_FMT_FLTP
float, planar
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_SAMPLE_FMT_DBLP
double, planar
@ AV_SAMPLE_FMT_DBL
double
@ AV_SAMPLE_FMT_S16
signed 16 bits
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_SAMPLEFMTS(...)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
AVFilterLink ** inputs
array of pointers to input links
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
AVFilterContext * src
source filter
int sample_rate
samples per second
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
AVChannelLayout ch_layout
Channel layout of the audio data.
uint8_t ** extended_data
pointers to the data planes/channels.
void(* phaser)(struct AudioPhaserContext *s, uint8_t *const *src, uint8_t **dst, int nb_samples, int channels)
int32_t * modulation_buffer
int modulation_buffer_length
#define av_malloc_array(a, b)
static AVFormatContext * ctx