Go to the documentation of this file.
51 uint8_t *
const *
src, uint8_t **dst,
55 #define OFFSET(x) offsetof(AudioPhaserContext, x)
56 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
78 if (
s->in_gain > (1 -
s->decay *
s->decay))
80 if (
s->in_gain / (1 -
s->decay) > 1 /
s->out_gain)
86 #define MOD(a, b) (((a) >= (b)) ? (a) - (b) : (a))
88 #define PHASER_PLANAR(name, type) \
89 static void phaser_## name ##p(AudioPhaserContext *s, \
90 uint8_t * const *ssrc, uint8_t **ddst, \
91 int nb_samples, int channels) \
93 int i, c, delay_pos, modulation_pos; \
95 av_assert0(channels > 0); \
96 for (c = 0; c < channels; c++) { \
97 type *src = (type *)ssrc[c]; \
98 type *dst = (type *)ddst[c]; \
99 double *buffer = s->delay_buffer + \
100 c * s->delay_buffer_length; \
102 delay_pos = s->delay_pos; \
103 modulation_pos = s->modulation_pos; \
105 for (i = 0; i < nb_samples; i++, src++, dst++) { \
106 double v = *src * s->in_gain + buffer[ \
107 MOD(delay_pos + s->modulation_buffer[ \
109 s->delay_buffer_length)] * s->decay; \
111 modulation_pos = MOD(modulation_pos + 1, \
112 s->modulation_buffer_length); \
113 delay_pos = MOD(delay_pos + 1, s->delay_buffer_length); \
114 buffer[delay_pos] = v; \
116 *dst = v * s->out_gain; \
120 s->delay_pos = delay_pos; \
121 s->modulation_pos = modulation_pos; \
124 #define PHASER(name, type) \
125 static void phaser_## name (AudioPhaserContext *s, \
126 uint8_t * const *ssrc, uint8_t **ddst, \
127 int nb_samples, int channels) \
129 int i, c, delay_pos, modulation_pos; \
130 type *src = (type *)ssrc[0]; \
131 type *dst = (type *)ddst[0]; \
132 double *buffer = s->delay_buffer; \
134 delay_pos = s->delay_pos; \
135 modulation_pos = s->modulation_pos; \
137 for (i = 0; i < nb_samples; i++) { \
138 int pos = MOD(delay_pos + s->modulation_buffer[modulation_pos], \
139 s->delay_buffer_length) * channels; \
142 delay_pos = MOD(delay_pos + 1, s->delay_buffer_length); \
143 npos = delay_pos * channels; \
144 for (c = 0; c < channels; c++, src++, dst++) { \
145 double v = *src * s->in_gain + buffer[pos + c] * s->decay; \
147 buffer[npos + c] = v; \
149 *dst = v * s->out_gain; \
152 modulation_pos = MOD(modulation_pos + 1, \
153 s->modulation_buffer_length); \
156 s->delay_pos = delay_pos; \
157 s->modulation_pos = modulation_pos; \
175 s->delay_buffer_length =
s->delay * 0.001 *
inlink->sample_rate + 0.5;
176 if (
s->delay_buffer_length <= 0) {
180 s->delay_buffer =
av_calloc(
s->delay_buffer_length,
sizeof(*
s->delay_buffer) *
inlink->channels);
181 s->modulation_buffer_length =
inlink->sample_rate /
s->speed + 0.5;
182 s->modulation_buffer =
av_malloc_array(
s->modulation_buffer_length,
sizeof(*
s->modulation_buffer));
184 if (!
s->modulation_buffer || !
s->delay_buffer)
188 s->modulation_buffer,
s->modulation_buffer_length,
189 1.,
s->delay_buffer_length,
M_PI / 2.0);
191 s->delay_pos =
s->modulation_pos = 0;
270 .priv_class = &aphaser_class,
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
@ AV_SAMPLE_FMT_FLTP
float, planar
#define AV_LOG_WARNING
Something somehow does not look correct.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void(* phaser)(struct AudioPhaserContext *s, uint8_t *const *src, uint8_t **dst, int nb_samples, int channels)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
static const AVOption aphaser_options[]
const char * name
Filter name.
A link between two filters.
static int filter_frame(AVFilterLink *inlink, AVFrame *inbuf)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int channels
number of audio channels, only used for audio.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define FILTER_INPUTS(array)
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define PHASER_PLANAR(name, type)
void ff_generate_wave_table(enum WaveType wave_type, enum AVSampleFormat sample_fmt, void *table, int table_size, double min, double max, double phase)
static const AVFilterPad aphaser_outputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold void uninit(AVFilterContext *ctx)
const AVFilter ff_af_aphaser
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
#define PHASER(name, type)
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t ** extended_data
pointers to the data planes/channels.
#define av_malloc_array(a, b)
AVFILTER_DEFINE_CLASS(aphaser)
@ AV_SAMPLE_FMT_S16
signed 16 bits
const char * name
Pad name.
void * av_calloc(size_t nmemb, size_t size)
int32_t * modulation_buffer
static const AVFilterPad aphaser_inputs[]
@ AV_SAMPLE_FMT_DBLP
double, planar
int modulation_buffer_length
#define FILTER_OUTPUTS(array)
static av_cold int init(AVFilterContext *ctx)
@ AV_SAMPLE_FMT_DBL
double
@ AV_SAMPLE_FMT_S32
signed 32 bits
static int config_output(AVFilterLink *outlink)
#define FILTER_SAMPLEFMTS(...)