FFmpeg
af_afreqshift.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) Paul B Mahol
3  * Copyright (c) Laurent de Soras, 2005
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
23 #include "libavutil/ffmath.h"
24 #include "libavutil/opt.h"
25 #include "avfilter.h"
26 #include "audio.h"
27 #include "formats.h"
28 
29 #define NB_COEFS 16
30 
31 typedef struct AFreqShift {
32  const AVClass *class;
33 
34  double shift;
35  double level;
36 
37  double cd[NB_COEFS];
38  float cf[NB_COEFS];
39 
40  int64_t in_samples;
41 
44 
46  int channel,
47  AVFrame *in, AVFrame *out);
48 } AFreqShift;
49 
51 {
54  static const enum AVSampleFormat sample_fmts[] = {
58  };
59  int ret;
60 
61  formats = ff_make_format_list(sample_fmts);
62  if (!formats)
63  return AVERROR(ENOMEM);
64  ret = ff_set_common_formats(ctx, formats);
65  if (ret < 0)
66  return ret;
67 
68  layouts = ff_all_channel_counts();
69  if (!layouts)
70  return AVERROR(ENOMEM);
71 
72  ret = ff_set_common_channel_layouts(ctx, layouts);
73  if (ret < 0)
74  return ret;
75 
76  formats = ff_all_samplerates();
77  return ff_set_common_samplerates(ctx, formats);
78 }
79 
80 #define PFILTER(name, type, sin, cos, cc) \
81 static void pfilter_channel_## name(AVFilterContext *ctx, \
82  int ch, \
83  AVFrame *in, AVFrame *out) \
84 { \
85  AFreqShift *s = ctx->priv; \
86  const int nb_samples = in->nb_samples; \
87  const type *src = (const type *)in->extended_data[ch]; \
88  type *dst = (type *)out->extended_data[ch]; \
89  type *i1 = (type *)s->i1->extended_data[ch]; \
90  type *o1 = (type *)s->o1->extended_data[ch]; \
91  type *i2 = (type *)s->i2->extended_data[ch]; \
92  type *o2 = (type *)s->o2->extended_data[ch]; \
93  const type *c = s->cc; \
94  const type level = s->level; \
95  type shift = s->shift * M_PI; \
96  type cos_theta = cos(shift); \
97  type sin_theta = sin(shift); \
98  \
99  for (int n = 0; n < nb_samples; n++) { \
100  type xn1 = src[n], xn2 = src[n]; \
101  type I, Q; \
102  \
103  for (int j = 0; j < NB_COEFS / 2; j++) { \
104  I = c[j] * (xn1 + o2[j]) - i2[j]; \
105  i2[j] = i1[j]; \
106  i1[j] = xn1; \
107  o2[j] = o1[j]; \
108  o1[j] = I; \
109  xn1 = I; \
110  } \
111  \
112  for (int j = NB_COEFS / 2; j < NB_COEFS; j++) { \
113  Q = c[j] * (xn2 + o2[j]) - i2[j]; \
114  i2[j] = i1[j]; \
115  i1[j] = xn2; \
116  o2[j] = o1[j]; \
117  o1[j] = Q; \
118  xn2 = Q; \
119  } \
120  Q = o2[NB_COEFS - 1]; \
121  \
122  dst[n] = (I * cos_theta - Q * sin_theta) * level; \
123  } \
124 }
125 
126 PFILTER(flt, float, sin, cos, cf)
127 PFILTER(dbl, double, sin, cos, cd)
128 
129 #define FFILTER(name, type, sin, cos, fmod, cc) \
130 static void ffilter_channel_## name(AVFilterContext *ctx, \
131  int ch, \
132  AVFrame *in, AVFrame *out) \
133 { \
134  AFreqShift *s = ctx->priv; \
135  const int nb_samples = in->nb_samples; \
136  const type *src = (const type *)in->extended_data[ch]; \
137  type *dst = (type *)out->extended_data[ch]; \
138  type *i1 = (type *)s->i1->extended_data[ch]; \
139  type *o1 = (type *)s->o1->extended_data[ch]; \
140  type *i2 = (type *)s->i2->extended_data[ch]; \
141  type *o2 = (type *)s->o2->extended_data[ch]; \
142  const type *c = s->cc; \
143  const type level = s->level; \
144  type ts = 1. / in->sample_rate; \
145  type shift = s->shift; \
146  int64_t N = s->in_samples; \
147  \
148  for (int n = 0; n < nb_samples; n++) { \
149  type xn1 = src[n], xn2 = src[n]; \
150  type I, Q, theta; \
151  \
152  for (int j = 0; j < NB_COEFS / 2; j++) { \
153  I = c[j] * (xn1 + o2[j]) - i2[j]; \
154  i2[j] = i1[j]; \
155  i1[j] = xn1; \
156  o2[j] = o1[j]; \
157  o1[j] = I; \
158  xn1 = I; \
159  } \
160  \
161  for (int j = NB_COEFS / 2; j < NB_COEFS; j++) { \
162  Q = c[j] * (xn2 + o2[j]) - i2[j]; \
163  i2[j] = i1[j]; \
164  i1[j] = xn2; \
165  o2[j] = o1[j]; \
166  o1[j] = Q; \
167  xn2 = Q; \
168  } \
169  Q = o2[NB_COEFS - 1]; \
170  \
171  theta = 2. * M_PI * fmod(shift * (N + n) * ts, 1.); \
172  dst[n] = (I * cos(theta) - Q * sin(theta)) * level; \
173  } \
174 }
175 
176 FFILTER(flt, float, sinf, cosf, fmodf, cf)
177 FFILTER(dbl, double, sin, cos, fmod, cd)
178 
179 static void compute_transition_param(double *K, double *Q, double transition)
180 {
181  double kksqrt, e, e2, e4, k, q;
182 
183  k = tan((1. - transition * 2.) * M_PI / 4.);
184  k *= k;
185  kksqrt = pow(1 - k * k, 0.25);
186  e = 0.5 * (1. - kksqrt) / (1. + kksqrt);
187  e2 = e * e;
188  e4 = e2 * e2;
189  q = e * (1. + e4 * (2. + e4 * (15. + 150. * e4)));
190 
191  *Q = q;
192  *K = k;
193 }
194 
195 static double ipowp(double x, int64_t n)
196 {
197  double z = 1.;
198 
199  while (n != 0) {
200  if (n & 1)
201  z *= x;
202  n >>= 1;
203  x *= x;
204  }
205 
206  return z;
207 }
208 
209 static double compute_acc_num(double q, int order, int c)
210 {
211  int64_t i = 0;
212  int j = 1;
213  double acc = 0.;
214  double q_ii1;
215 
216  do {
217  q_ii1 = ipowp(q, i * (i + 1));
218  q_ii1 *= sin((i * 2 + 1) * c * M_PI / order) * j;
219  acc += q_ii1;
220 
221  j = -j;
222  i++;
223  } while (fabs(q_ii1) > 1e-100);
224 
225  return acc;
226 }
227 
228 static double compute_acc_den(double q, int order, int c)
229 {
230  int64_t i = 1;
231  int j = -1;
232  double acc = 0.;
233  double q_i2;
234 
235  do {
236  q_i2 = ipowp(q, i * i);
237  q_i2 *= cos(i * 2 * c * M_PI / order) * j;
238  acc += q_i2;
239 
240  j = -j;
241  i++;
242  } while (fabs(q_i2) > 1e-100);
243 
244  return acc;
245 }
246 
247 static double compute_coef(int index, double k, double q, int order)
248 {
249  const int c = index + 1;
250  const double num = compute_acc_num(q, order, c) * pow(q, 0.25);
251  const double den = compute_acc_den(q, order, c) + 0.5;
252  const double ww = num / den;
253  const double wwsq = ww * ww;
254 
255  const double x = sqrt((1 - wwsq * k) * (1 - wwsq / k)) / (1 + wwsq);
256  const double coef = (1 - x) / (1 + x);
257 
258  return coef;
259 }
260 
261 static void compute_coefs(double *coef_arrd, float *coef_arrf, int nbr_coefs, double transition)
262 {
263  const int order = nbr_coefs * 2 + 1;
264  double k, q;
265 
266  compute_transition_param(&k, &q, transition);
267 
268  for (int n = 0; n < nbr_coefs; n++) {
269  const int idx = (n / 2) + (n & 1) * nbr_coefs / 2;
270 
271  coef_arrd[idx] = compute_coef(n, k, q, order);
272  coef_arrf[idx] = coef_arrd[idx];
273  }
274 }
275 
277 {
278  AVFilterContext *ctx = inlink->dst;
279  AFreqShift *s = ctx->priv;
280 
281  compute_coefs(s->cd, s->cf, NB_COEFS, 2. * 20. / inlink->sample_rate);
282 
283  s->i1 = ff_get_audio_buffer(inlink, NB_COEFS);
284  s->o1 = ff_get_audio_buffer(inlink, NB_COEFS);
285  s->i2 = ff_get_audio_buffer(inlink, NB_COEFS);
286  s->o2 = ff_get_audio_buffer(inlink, NB_COEFS);
287  if (!s->i1 || !s->o1 || !s->i2 || !s->o2)
288  return AVERROR(ENOMEM);
289 
290  if (inlink->format == AV_SAMPLE_FMT_DBLP) {
291  if (!strcmp(ctx->filter->name, "afreqshift"))
292  s->filter_channel = ffilter_channel_dbl;
293  else
294  s->filter_channel = pfilter_channel_dbl;
295  } else {
296  if (!strcmp(ctx->filter->name, "afreqshift"))
297  s->filter_channel = ffilter_channel_flt;
298  else
299  s->filter_channel = pfilter_channel_flt;
300  }
301 
302  return 0;
303 }
304 
305 typedef struct ThreadData {
306  AVFrame *in, *out;
307 } ThreadData;
308 
309 static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
310 {
311  AFreqShift *s = ctx->priv;
312  ThreadData *td = arg;
313  AVFrame *out = td->out;
314  AVFrame *in = td->in;
315  const int start = (in->channels * jobnr) / nb_jobs;
316  const int end = (in->channels * (jobnr+1)) / nb_jobs;
317 
318  for (int ch = start; ch < end; ch++)
319  s->filter_channel(ctx, ch, in, out);
320 
321  return 0;
322 }
323 
325 {
326  AVFilterContext *ctx = inlink->dst;
327  AVFilterLink *outlink = ctx->outputs[0];
328  AFreqShift *s = ctx->priv;
329  AVFrame *out;
330  ThreadData td;
331 
332  if (av_frame_is_writable(in)) {
333  out = in;
334  } else {
335  out = ff_get_audio_buffer(outlink, in->nb_samples);
336  if (!out) {
337  av_frame_free(&in);
338  return AVERROR(ENOMEM);
339  }
340  av_frame_copy_props(out, in);
341  }
342 
343  td.in = in; td.out = out;
344  ctx->internal->execute(ctx, filter_channels, &td, NULL, FFMIN(inlink->channels,
346 
347  s->in_samples += in->nb_samples;
348 
349  if (out != in)
350  av_frame_free(&in);
351  return ff_filter_frame(outlink, out);
352 }
353 
355 {
356  AFreqShift *s = ctx->priv;
357 
358  av_frame_free(&s->i1);
359  av_frame_free(&s->o1);
360  av_frame_free(&s->i2);
361  av_frame_free(&s->o2);
362 }
363 
364 #define OFFSET(x) offsetof(AFreqShift, x)
365 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
366 
367 static const AVOption afreqshift_options[] = {
368  { "shift", "set frequency shift", OFFSET(shift), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -INT_MAX, INT_MAX, FLAGS },
369  { "level", "set output level", OFFSET(level), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.0, 1.0, FLAGS },
370  { NULL }
371 };
372 
373 AVFILTER_DEFINE_CLASS(afreqshift);
374 
375 static const AVFilterPad inputs[] = {
376  {
377  .name = "default",
378  .type = AVMEDIA_TYPE_AUDIO,
379  .filter_frame = filter_frame,
380  .config_props = config_input,
381  },
382  { NULL }
383 };
384 
385 static const AVFilterPad outputs[] = {
386  {
387  .name = "default",
388  .type = AVMEDIA_TYPE_AUDIO,
389  },
390  { NULL }
391 };
392 
394  .name = "afreqshift",
395  .description = NULL_IF_CONFIG_SMALL("Apply frequency shifting to input audio."),
396  .query_formats = query_formats,
397  .priv_size = sizeof(AFreqShift),
398  .priv_class = &afreqshift_class,
399  .uninit = uninit,
400  .inputs = inputs,
401  .outputs = outputs,
405 };
406 
407 static const AVOption aphaseshift_options[] = {
408  { "shift", "set phase shift", OFFSET(shift), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -1.0, 1.0, FLAGS },
409  { "level", "set output level",OFFSET(level), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.0, 1.0, FLAGS },
410  { NULL }
411 };
412 
413 AVFILTER_DEFINE_CLASS(aphaseshift);
414 
416  .name = "aphaseshift",
417  .description = NULL_IF_CONFIG_SMALL("Apply phase shifting to input audio."),
418  .query_formats = query_formats,
419  .priv_size = sizeof(AFreqShift),
420  .priv_class = &aphaseshift_class,
421  .uninit = uninit,
422  .inputs = inputs,
423  .outputs = outputs,
427 };
static int query_formats(AVFilterContext *ctx)
Definition: af_afreqshift.c:50
float, planar
Definition: samplefmt.h:69
#define NULL
Definition: coverity.c:32
AVFrame * i1
Definition: af_afreqshift.c:42
AVFrame * out
Definition: af_adeclick.c:502
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
AVOption.
Definition: opt.h:248
AVFILTER_DEFINE_CLASS(afreqshift)
Main libavfilter public API header.
int acc
Definition: yuv2rgb.c:555
AVFilter ff_af_afreqshift
static double compute_acc_num(double q, int order, int c)
double, planar
Definition: samplefmt.h:70
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *channel_layouts)
A helper for query_formats() which sets all links to the same list of channel layouts/sample rates...
Definition: formats.c:569
double cd[NB_COEFS]
Definition: af_afreqshift.c:37
fg index
static const AVOption aphaseshift_options[]
static const AVOption afreqshift_options[]
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:287
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:126
const char * name
Pad name.
Definition: internal.h:60
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1094
#define av_cold
Definition: attributes.h:88
AVOptions.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
#define NB_COEFS
Definition: af_afreqshift.c:29
#define PFILTER(name, type, sin, cos, cc)
Definition: af_afreqshift.c:80
float cf[NB_COEFS]
Definition: af_afreqshift.c:38
#define cosf(x)
Definition: libm.h:78
static const AVFilterPad outputs[]
static double ipowp(double x, int64_t n)
#define FLAGS
A filter pad used for either input or output.
Definition: internal.h:54
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:588
#define td
Definition: regdef.h:70
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:86
static double compute_acc_den(double q, int order, int c)
static __device__ float fabs(float a)
Definition: cuda_runtime.h:182
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:204
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:117
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options...
Definition: avfilter.c:882
void * priv
private data for use by the filter
Definition: avfilter.h:356
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
const char * arg
Definition: jacosubdec.c:66
static double compute_coef(int index, double k, double q, int order)
AVFrame * i2
Definition: af_afreqshift.c:43
#define FFILTER(name, type, sin, cos, fmod, cc)
static int config_input(AVFilterLink *inlink)
static void compute_transition_param(double *K, double *Q, double transition)
int channels
number of audio channels, only used for audio.
Definition: frame.h:624
audio channel layout utility functions
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:802
#define FFMIN(a, b)
Definition: common.h:105
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_acrusher.c:336
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
AVFormatContext * ctx
Definition: movenc.c:48
static const AVFilterPad inputs[]
#define OFFSET(x)
#define s(width, name)
Definition: cbs_vp9.c:257
double shift
Definition: af_afreqshift.c:34
static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static av_cold void uninit(AVFilterContext *ctx)
A list of supported channel layouts.
Definition: formats.h:86
void(* filter_channel)(AVFilterContext *ctx, int channel, AVFrame *in, AVFrame *out)
Definition: af_afreqshift.c:45
#define sinf(x)
Definition: libm.h:419
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:595
Used for passing data between threads.
Definition: dsddec.c:67
double level
Definition: af_afreqshift.c:35
static void compute_coefs(double *coef_arrd, float *coef_arrf, int nbr_coefs, double transition)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;}return ac;}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;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:145
const char * name
Filter name.
Definition: avfilter.h:149
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:353
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:422
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:381
AVFrame * o1
Definition: af_afreqshift.c:42
int64_t in_samples
Definition: af_afreqshift.c:40
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
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
internal math functions header
AVFrame * o2
Definition: af_afreqshift.c:43
channel
Use these values when setting the channel map with ebur128_set_channel().
Definition: ebur128.h:39
avfilter_execute_func * execute
Definition: internal.h:136
A list of supported formats for one end of a filter link.
Definition: formats.h:65
An instance of a filter.
Definition: avfilter.h:341
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:941
FILE * out
Definition: movenc.c:54
#define M_PI
Definition: mathematics.h:52
AVFrame * in
Definition: af_adenorm.c:223
formats
Definition: signature.h:48
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
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition...
Definition: formats.c:437
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:384
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:344
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:576
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:659
int i
Definition: input.c:407
AVFilter ff_af_aphaseshift