55 #define OFFSET(x) offsetof(AudioPhaserContext, x) 56 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 119 #define MOD(a, b) (((a) >= (b)) ? (a) - (b) : (a)) 121 #define PHASER_PLANAR(name, type) \ 122 static void phaser_## name ##p(AudioPhaserContext *s, \ 123 uint8_t * const *ssrc, uint8_t **ddst, \ 124 int nb_samples, int channels) \ 126 int i, c, delay_pos, modulation_pos; \ 128 av_assert0(channels > 0); \ 129 for (c = 0; c < channels; c++) { \ 130 type *src = (type *)ssrc[c]; \ 131 type *dst = (type *)ddst[c]; \ 132 double *buffer = s->delay_buffer + \ 133 c * s->delay_buffer_length; \ 135 delay_pos = s->delay_pos; \ 136 modulation_pos = s->modulation_pos; \ 138 for (i = 0; i < nb_samples; i++, src++, dst++) { \ 139 double v = *src * s->in_gain + buffer[ \ 140 MOD(delay_pos + s->modulation_buffer[ \ 142 s->delay_buffer_length)] * s->decay; \ 144 modulation_pos = MOD(modulation_pos + 1, \ 145 s->modulation_buffer_length); \ 146 delay_pos = MOD(delay_pos + 1, s->delay_buffer_length); \ 147 buffer[delay_pos] = v; \ 149 *dst = v * s->out_gain; \ 153 s->delay_pos = delay_pos; \ 154 s->modulation_pos = modulation_pos; \ 157 #define PHASER(name, type) \ 158 static void phaser_## name (AudioPhaserContext *s, \ 159 uint8_t * const *ssrc, uint8_t **ddst, \ 160 int nb_samples, int channels) \ 162 int i, c, delay_pos, modulation_pos; \ 163 type *src = (type *)ssrc[0]; \ 164 type *dst = (type *)ddst[0]; \ 165 double *buffer = s->delay_buffer; \ 167 delay_pos = s->delay_pos; \ 168 modulation_pos = s->modulation_pos; \ 170 for (i = 0; i < nb_samples; i++) { \ 171 int pos = MOD(delay_pos + s->modulation_buffer[modulation_pos], \ 172 s->delay_buffer_length) * channels; \ 175 delay_pos = MOD(delay_pos + 1, s->delay_buffer_length); \ 176 npos = delay_pos * channels; \ 177 for (c = 0; c < channels; c++, src++, dst++) { \ 178 double v = *src * s->in_gain + buffer[pos + c] * s->decay; \ 180 buffer[npos + c] = v; \ 182 *dst = v * s->out_gain; \ 185 modulation_pos = MOD(modulation_pos + 1, \ 186 s->modulation_buffer_length); \ 189 s->delay_pos = delay_pos; \ 190 s->modulation_pos = modulation_pos; \ 302 .priv_class = &aphaser_class,
void(* phaser)(struct AudioPhaserContext *s, uint8_t *const *src, uint8_t **dst, int nb_samples, int channels)
static const AVOption aphaser_options[]
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
const char * name
Pad name.
#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.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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)
int channels
number of audio channels, only used for audio.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
static av_cold int init(AVFilterContext *ctx)
static const AVFilterPad outputs[]
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.
AVFILTER_DEFINE_CLASS(aphaser)
Describe the class of an AVClass context structure.
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
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
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)
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
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.