52 int nb_samples,
int channels);
55 #define OFFSET(x) offsetof(AudioPhaserContext, x)
56 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
116 #define MOD(a, b) (((a) >= (b)) ? (a) - (b) : (a))
118 #define PHASER_PLANAR(name, type) \
119 static void phaser_## name ##p(AudioPhaserContext *p, \
120 uint8_t * const *src, uint8_t **dst, \
121 int nb_samples, int channels) \
123 int i, c, delay_pos, modulation_pos; \
125 av_assert0(channels > 0); \
126 for (c = 0; c < channels; c++) { \
127 type *s = (type *)src[c]; \
128 type *d = (type *)dst[c]; \
129 double *buffer = p->delay_buffer + \
130 c * p->delay_buffer_length; \
132 delay_pos = p->delay_pos; \
133 modulation_pos = p->modulation_pos; \
135 for (i = 0; i < nb_samples; i++, s++, d++) { \
136 double v = *s * p->in_gain + buffer[ \
137 MOD(delay_pos + p->modulation_buffer[ \
139 p->delay_buffer_length)] * p->decay; \
141 modulation_pos = MOD(modulation_pos + 1, \
142 p->modulation_buffer_length); \
143 delay_pos = MOD(delay_pos + 1, p->delay_buffer_length); \
144 buffer[delay_pos] = v; \
146 *d = v * p->out_gain; \
150 p->delay_pos = delay_pos; \
151 p->modulation_pos = modulation_pos; \
154 #define PHASER(name, type) \
155 static void phaser_## name (AudioPhaserContext *p, \
156 uint8_t * const *src, uint8_t **dst, \
157 int nb_samples, int channels) \
159 int i, c, delay_pos, modulation_pos; \
160 type *s = (type *)src[0]; \
161 type *d = (type *)dst[0]; \
162 double *buffer = p->delay_buffer; \
164 delay_pos = p->delay_pos; \
165 modulation_pos = p->modulation_pos; \
167 for (i = 0; i < nb_samples; i++) { \
168 int pos = MOD(delay_pos + p->modulation_buffer[modulation_pos], \
169 p->delay_buffer_length) * channels; \
172 delay_pos = MOD(delay_pos + 1, p->delay_buffer_length); \
173 npos = delay_pos * channels; \
174 for (c = 0; c < channels; c++, s++, d++) { \
175 double v = *s * p->in_gain + buffer[pos + c] * p->decay; \
177 buffer[npos + c] = v; \
179 *d = v * p->out_gain; \
182 modulation_pos = MOD(modulation_pos + 1, \
183 p->modulation_buffer_length); \
186 p->delay_pos = delay_pos; \
187 p->modulation_pos = modulation_pos; \
293 .priv_class = &aphaser_class,
static const AVOption aphaser_options[]
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
Main libavfilter public API header.
static enum AVSampleFormat formats[]
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
#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.
static const AVFilterPad aphaser_outputs[]
static av_cold void uninit(AVFilterContext *ctx)
A filter pad used for either input or output.
A link between two filters.
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.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define PHASER(name, type)
#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
simple assert() macros that are a bit more flexible than ISO C assert().
static int config_output(AVFilterLink *outlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *inbuf)
static av_cold int init(AVFilterContext *ctx)
AVFilterContext * src
source filter
int format
agreed upon media format
void ff_generate_wave_table(enum WaveType wave_type, enum AVSampleFormat sample_fmt, void *table, int table_size, double min, double max, double phase)
A list of supported channel layouts.
AVSampleFormat
Audio sample formats.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
AVFILTER_DEFINE_CLASS(aphaser)
Describe the class of an AVClass context structure.
int av_frame_get_channels(const AVFrame *frame)
static const AVFilterPad inputs[]
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
void * av_calloc(size_t nmemb, size_t size)
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
void(* phaser)(struct AudioPhaserContext *p, uint8_t *const *src, uint8_t **dst, int nb_samples, int channels)
int modulation_buffer_length
static int query_formats(AVFilterContext *ctx)
int channels
Number of channels.
AVFilterContext * dst
dest filter
int32_t * modulation_buffer
static enum AVSampleFormat sample_fmts[]
static const AVFilterPad aphaser_inputs[]
#define av_malloc_array(a, b)
uint8_t ** extended_data
pointers to the data planes/channels.
int nb_samples
number of audio samples (per channel) described by this frame
#define PHASER_PLANAR(name, type)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.