FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
af_flanger.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006 Rob Sykes <robs@users.sourceforge.net>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/avstring.h"
22 #include "libavutil/opt.h"
23 #include "libavutil/samplefmt.h"
24 #include "avfilter.h"
25 #include "audio.h"
26 #include "internal.h"
27 #include "generate_wave_table.h"
28 
29 #define INTERPOLATION_LINEAR 0
30 #define INTERPOLATION_QUADRATIC 1
31 
32 typedef struct FlangerContext {
33  const AVClass *class;
34  double delay_min;
35  double delay_depth;
36  double feedback_gain;
37  double delay_gain;
38  double speed;
40  double channel_phase;
42  double in_gain;
46  double *delay_last;
47  float *lfo;
49  int lfo_pos;
51 
52 #define OFFSET(x) offsetof(FlangerContext, x)
53 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
54 
55 static const AVOption flanger_options[] = {
56  { "delay", "base delay in milliseconds", OFFSET(delay_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 30, A },
57  { "depth", "added swept delay in milliseconds", OFFSET(delay_depth), AV_OPT_TYPE_DOUBLE, {.dbl=2}, 0, 10, A },
58  { "regen", "percentage regeneration (delayed signal feedback)", OFFSET(feedback_gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -95, 95, A },
59  { "width", "percentage of delayed signal mixed with original", OFFSET(delay_gain), AV_OPT_TYPE_DOUBLE, {.dbl=71}, 0, 100, A },
60  { "speed", "sweeps per second (Hz)", OFFSET(speed), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0.1, 10, A },
61  { "shape", "swept wave shape", OFFSET(wave_shape), AV_OPT_TYPE_INT, {.i64=WAVE_SIN}, WAVE_SIN, WAVE_NB-1, A, "type" },
62  { "triangular", NULL, 0, AV_OPT_TYPE_CONST, {.i64=WAVE_TRI}, 0, 0, A, "type" },
63  { "t", NULL, 0, AV_OPT_TYPE_CONST, {.i64=WAVE_TRI}, 0, 0, A, "type" },
64  { "sinusoidal", NULL, 0, AV_OPT_TYPE_CONST, {.i64=WAVE_SIN}, 0, 0, A, "type" },
65  { "s", NULL, 0, AV_OPT_TYPE_CONST, {.i64=WAVE_SIN}, 0, 0, A, "type" },
66  { "phase", "swept wave percentage phase-shift for multi-channel", OFFSET(channel_phase), AV_OPT_TYPE_DOUBLE, {.dbl=25}, 0, 100, A },
67  { "interp", "delay-line interpolation", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, A, "itype" },
68  { "linear", NULL, 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATION_LINEAR}, 0, 0, A, "itype" },
69  { "quadratic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATION_QUADRATIC}, 0, 0, A, "itype" },
70  { NULL }
71 };
72 
73 AVFILTER_DEFINE_CLASS(flanger);
74 
75 static int init(AVFilterContext *ctx)
76 {
77  FlangerContext *s = ctx->priv;
78 
79  s->feedback_gain /= 100;
80  s->delay_gain /= 100;
81  s->channel_phase /= 100;
82  s->delay_min /= 1000;
83  s->delay_depth /= 1000;
84  s->in_gain = 1 / (1 + s->delay_gain);
85  s->delay_gain /= 1 + s->delay_gain;
86  s->delay_gain *= 1 - fabs(s->feedback_gain);
87 
88  return 0;
89 }
90 
92 {
95  static const enum AVSampleFormat sample_fmts[] = {
97  };
98  int ret;
99 
100  layouts = ff_all_channel_layouts();
101  if (!layouts)
102  return AVERROR(ENOMEM);
103  ret = ff_set_common_channel_layouts(ctx, layouts);
104  if (ret < 0)
105  return ret;
106 
107  formats = ff_make_format_list(sample_fmts);
108  if (!formats)
109  return AVERROR(ENOMEM);
110  ret = ff_set_common_formats(ctx, formats);
111  if (ret < 0)
112  return ret;
113 
114  formats = ff_all_samplerates();
115  if (!formats)
116  return AVERROR(ENOMEM);
117  return ff_set_common_samplerates(ctx, formats);
118 }
119 
120 static int config_input(AVFilterLink *inlink)
121 {
122  AVFilterContext *ctx = inlink->dst;
123  FlangerContext *s = ctx->priv;
124 
125  s->max_samples = (s->delay_min + s->delay_depth) * inlink->sample_rate + 2.5;
126  s->lfo_length = inlink->sample_rate / s->speed;
127  s->delay_last = av_calloc(inlink->channels, sizeof(*s->delay_last));
128  s->lfo = av_calloc(s->lfo_length, sizeof(*s->lfo));
129  if (!s->lfo || !s->delay_last)
130  return AVERROR(ENOMEM);
131 
133  floor(s->delay_min * inlink->sample_rate + 0.5),
134  s->max_samples - 2., 3 * M_PI_2);
135 
137  inlink->channels, s->max_samples,
138  inlink->format, 0);
139 }
140 
141 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
142 {
143  AVFilterContext *ctx = inlink->dst;
144  FlangerContext *s = ctx->priv;
145  AVFrame *out_frame;
146  int chan, i;
147 
148  if (av_frame_is_writable(frame)) {
149  out_frame = frame;
150  } else {
151  out_frame = ff_get_audio_buffer(inlink, frame->nb_samples);
152  if (!out_frame)
153  return AVERROR(ENOMEM);
154  av_frame_copy_props(out_frame, frame);
155  }
156 
157  for (i = 0; i < frame->nb_samples; i++) {
158 
159  s->delay_buf_pos = (s->delay_buf_pos + s->max_samples - 1) % s->max_samples;
160 
161  for (chan = 0; chan < inlink->channels; chan++) {
162  double *src = (double *)frame->extended_data[chan];
163  double *dst = (double *)out_frame->extended_data[chan];
164  double delayed_0, delayed_1;
165  double delayed;
166  double in, out;
167  int channel_phase = chan * s->lfo_length * s->channel_phase + .5;
168  double delay = s->lfo[(s->lfo_pos + channel_phase) % s->lfo_length];
169  int int_delay = (int)delay;
170  double frac_delay = modf(delay, &delay);
171  double *delay_buffer = (double *)s->delay_buffer[chan];
172 
173  in = src[i];
174  delay_buffer[s->delay_buf_pos] = in + s->delay_last[chan] *
175  s->feedback_gain;
176  delayed_0 = delay_buffer[(s->delay_buf_pos + int_delay++) % s->max_samples];
177  delayed_1 = delay_buffer[(s->delay_buf_pos + int_delay++) % s->max_samples];
178 
180  delayed = delayed_0 + (delayed_1 - delayed_0) * frac_delay;
181  } else {
182  double a, b;
183  double delayed_2 = delay_buffer[(s->delay_buf_pos + int_delay++) % s->max_samples];
184  delayed_2 -= delayed_0;
185  delayed_1 -= delayed_0;
186  a = delayed_2 * .5 - delayed_1;
187  b = delayed_1 * 2 - delayed_2 *.5;
188  delayed = delayed_0 + (a * frac_delay + b) * frac_delay;
189  }
190 
191  s->delay_last[chan] = delayed;
192  out = in * s->in_gain + delayed * s->delay_gain;
193  dst[i] = out;
194  }
195  s->lfo_pos = (s->lfo_pos + 1) % s->lfo_length;
196  }
197 
198  if (frame != out_frame)
199  av_frame_free(&frame);
200 
201  return ff_filter_frame(ctx->outputs[0], out_frame);
202 }
203 
204 static av_cold void uninit(AVFilterContext *ctx)
205 {
206  FlangerContext *s = ctx->priv;
207 
208  av_freep(&s->lfo);
209  av_freep(&s->delay_last);
210 
211  if (s->delay_buffer)
212  av_freep(&s->delay_buffer[0]);
213  av_freep(&s->delay_buffer);
214 }
215 
216 static const AVFilterPad flanger_inputs[] = {
217  {
218  .name = "default",
219  .type = AVMEDIA_TYPE_AUDIO,
220  .config_props = config_input,
221  .filter_frame = filter_frame,
222  },
223  { NULL }
224 };
225 
226 static const AVFilterPad flanger_outputs[] = {
227  {
228  .name = "default",
229  .type = AVMEDIA_TYPE_AUDIO,
230  },
231  { NULL }
232 };
233 
235  .name = "flanger",
236  .description = NULL_IF_CONFIG_SMALL("Apply a flanging effect to the audio."),
237  .query_formats = query_formats,
238  .priv_size = sizeof(FlangerContext),
239  .priv_class = &flanger_class,
240  .init = init,
241  .uninit = uninit,
242  .inputs = flanger_inputs,
243  .outputs = flanger_outputs,
244 };
#define NULL
Definition: coverity.c:32
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *layouts)
A helper for query_formats() which sets all links to the same list of channel layouts/sample rates...
Definition: formats.c:523
const char * s
Definition: avisynth_c.h:631
This structure describes decoded (raw) audio or video data.
Definition: frame.h:171
AVOption.
Definition: opt.h:255
double * delay_last
Definition: af_flanger.c:46
double feedback_gain
Definition: af_flanger.c:36
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:248
Main libavfilter public API header.
float * lfo
Definition: af_flanger.c:47
const char * b
Definition: vf_curves.c:109
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: af_flanger.c:141
double, planar
Definition: samplefmt.h:71
uint8_t ** delay_buffer
Definition: af_flanger.c:44
AVFilter ff_af_flanger
Definition: af_flanger.c:234
static enum AVSampleFormat formats[]
int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Allocate a data pointers array, samples buffer for nb_samples samples, and fill data pointers and lin...
Definition: samplefmt.c:196
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
const char * name
Pad name.
Definition: internal.h:69
static int query_formats(AVFilterContext *ctx)
Definition: af_flanger.c:91
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1158
#define A
Definition: af_flanger.c:53
uint8_t
#define av_cold
Definition: attributes.h:74
AVOptions.
static AVFrame * frame
A filter pad used for either input or output.
Definition: internal.h:63
double channel_phase
Definition: af_flanger.c:40
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:542
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:74
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:148
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
void * priv
private data for use by the filter
Definition: avfilter.h:654
static const AVFilterPad flanger_outputs[]
Definition: af_flanger.c:226
double delay_depth
Definition: af_flanger.c:35
#define M_PI_2
Definition: mathematics.h:49
double in_gain
Definition: af_flanger.c:42
AVFILTER_DEFINE_CLASS(flanger)
AVFilterChannelLayouts * ff_all_channel_layouts(void)
Construct an empty AVFilterChannelLayouts/AVFilterFormats struct – representing any channel layout (w...
Definition: formats.c:385
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 av_cold void uninit(AVFilterContext *ctx)
Definition: af_flanger.c:204
#define INTERPOLATION_LINEAR
Definition: af_flanger.c:29
A list of supported channel layouts.
Definition: formats.h:85
AVS_Value src
Definition: avisynth_c.h:482
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:59
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:493
double speed
Definition: af_flanger.c:38
static const AVOption flanger_options[]
Definition: af_flanger.c:55
#define INTERPOLATION_QUADRATIC
Definition: af_flanger.c:30
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
#define OFFSET(x)
Definition: af_flanger.c:52
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:470
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:239
double delay_gain
Definition: af_flanger.c:37
static const AVFilterPad flanger_inputs[]
Definition: af_flanger.c:216
const char * name
Filter name.
Definition: avfilter.h:474
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:648
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:379
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...
Definition: mem.c:260
static int config_input(AVFilterLink *inlink)
Definition: af_flanger.c:120
double delay_min
Definition: af_flanger.c:34
static int init(AVFilterContext *ctx)
Definition: af_flanger.c:75
if(ret< 0)
Definition: vf_mcdeint.c:280
A list of supported formats for one end of a filter link.
Definition: formats.h:64
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
An instance of a filter.
Definition: avfilter.h:633
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701
#define av_freep(p)
internal API functions
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:215
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:225
for(j=16;j >0;--j)
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:530
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:553