FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
resample.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
3  * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
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 
22 #include "libavutil/common.h"
23 #include "libavutil/libm.h"
24 #include "libavutil/log.h"
25 #include "internal.h"
26 #include "resample.h"
27 #include "audio_data.h"
28 
29 
30 /* double template */
31 #define CONFIG_RESAMPLE_DBL
32 #include "resample_template.c"
33 #undef CONFIG_RESAMPLE_DBL
34 
35 /* float template */
36 #define CONFIG_RESAMPLE_FLT
37 #include "resample_template.c"
38 #undef CONFIG_RESAMPLE_FLT
39 
40 /* s32 template */
41 #define CONFIG_RESAMPLE_S32
42 #include "resample_template.c"
43 #undef CONFIG_RESAMPLE_S32
44 
45 /* s16 template */
46 #include "resample_template.c"
47 
48 
49 /* 0th order modified bessel function of the first kind. */
50 static double bessel(double x)
51 {
52  double v = 1;
53  double lastv = 0;
54  double t = 1;
55  int i;
56 
57  x = x * x / 4;
58  for (i = 1; v != lastv; i++) {
59  lastv = v;
60  t *= x / (i * i);
61  v += t;
62  }
63  return v;
64 }
65 
66 /* Build a polyphase filterbank. */
67 static int build_filter(ResampleContext *c, double factor)
68 {
69  int ph, i;
70  double x, y, w;
71  double *tab;
72  int tap_count = c->filter_length;
73  int phase_count = 1 << c->phase_shift;
74  const int center = (tap_count - 1) / 2;
75 
76  tab = av_malloc(tap_count * sizeof(*tab));
77  if (!tab)
78  return AVERROR(ENOMEM);
79 
80  for (ph = 0; ph < phase_count; ph++) {
81  double norm = 0;
82  for (i = 0; i < tap_count; i++) {
83  x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;
84  if (x == 0) y = 1.0;
85  else y = sin(x) / x;
86  switch (c->filter_type) {
88  const float d = -0.5; //first order derivative = -0.5
89  x = fabs(((double)(i - center) - (double)ph / phase_count) * factor);
90  if (x < 1.0) y = 1 - 3 * x*x + 2 * x*x*x + d * ( -x*x + x*x*x);
91  else y = d * (-4 + 8 * x - 5 * x*x + x*x*x);
92  break;
93  }
95  w = 2.0 * x / (factor * tap_count) + M_PI;
96  y *= 0.3635819 - 0.4891775 * cos( w) +
97  0.1365995 * cos(2 * w) -
98  0.0106411 * cos(3 * w);
99  break;
101  w = 2.0 * x / (factor * tap_count * M_PI);
102  y *= bessel(c->kaiser_beta * sqrt(FFMAX(1 - w * w, 0)));
103  break;
104  }
105 
106  tab[i] = y;
107  norm += y;
108  }
109  /* normalize so that an uniform color remains the same */
110  for (i = 0; i < tap_count; i++)
111  tab[i] = tab[i] / norm;
112 
113  c->set_filter(c->filter_bank, tab, ph, tap_count);
114  }
115 
116  av_free(tab);
117  return 0;
118 }
119 
121 {
123  int out_rate = avr->out_sample_rate;
124  int in_rate = avr->in_sample_rate;
125  double factor = FFMIN(out_rate * avr->cutoff / in_rate, 1.0);
126  int phase_count = 1 << avr->phase_shift;
127  int felem_size;
128 
133  av_log(avr, AV_LOG_ERROR, "Unsupported internal format for "
134  "resampling: %s\n",
136  return NULL;
137  }
138  c = av_mallocz(sizeof(*c));
139  if (!c)
140  return NULL;
141 
142  c->avr = avr;
143  c->phase_shift = avr->phase_shift;
144  c->phase_mask = phase_count - 1;
145  c->linear = avr->linear_interp;
146  c->filter_length = FFMAX((int)ceil(avr->filter_size / factor), 1);
147  c->filter_type = avr->filter_type;
148  c->kaiser_beta = avr->kaiser_beta;
149 
150  switch (avr->internal_sample_fmt) {
151  case AV_SAMPLE_FMT_DBLP:
152  c->resample_one = c->linear ? resample_linear_dbl : resample_one_dbl;
153  c->resample_nearest = resample_nearest_dbl;
154  c->set_filter = set_filter_dbl;
155  break;
156  case AV_SAMPLE_FMT_FLTP:
157  c->resample_one = c->linear ? resample_linear_flt : resample_one_flt;
158  c->resample_nearest = resample_nearest_flt;
159  c->set_filter = set_filter_flt;
160  break;
161  case AV_SAMPLE_FMT_S32P:
162  c->resample_one = c->linear ? resample_linear_s32 : resample_one_s32;
163  c->resample_nearest = resample_nearest_s32;
164  c->set_filter = set_filter_s32;
165  break;
166  case AV_SAMPLE_FMT_S16P:
167  c->resample_one = c->linear ? resample_linear_s16 : resample_one_s16;
168  c->resample_nearest = resample_nearest_s16;
169  c->set_filter = set_filter_s16;
170  break;
171  }
172 
173  if (ARCH_AARCH64)
175  if (ARCH_ARM)
177 
178  felem_size = av_get_bytes_per_sample(avr->internal_sample_fmt);
179  c->filter_bank = av_mallocz(c->filter_length * (phase_count + 1) * felem_size);
180  if (!c->filter_bank)
181  goto error;
182 
183  if (build_filter(c, factor) < 0)
184  goto error;
185 
186  memcpy(&c->filter_bank[(c->filter_length * phase_count + 1) * felem_size],
187  c->filter_bank, (c->filter_length - 1) * felem_size);
188  memcpy(&c->filter_bank[c->filter_length * phase_count * felem_size],
189  &c->filter_bank[(c->filter_length - 1) * felem_size], felem_size);
190 
191  c->compensation_distance = 0;
192  if (!av_reduce(&c->src_incr, &c->dst_incr, out_rate,
193  in_rate * (int64_t)phase_count, INT32_MAX / 2))
194  goto error;
195  c->ideal_dst_incr = c->dst_incr;
196 
197  c->padding_size = (c->filter_length - 1) / 2;
198  c->initial_padding_filled = 0;
199  c->index = 0;
200  c->frac = 0;
201 
202  /* allocate internal buffer */
204  avr->internal_sample_fmt,
205  "resample buffer");
206  if (!c->buffer)
207  goto error;
208  c->buffer->nb_samples = c->padding_size;
210 
211  av_log(avr, AV_LOG_DEBUG, "resample: %s from %d Hz to %d Hz\n",
213  avr->in_sample_rate, avr->out_sample_rate);
214 
215  return c;
216 
217 error:
219  av_free(c->filter_bank);
220  av_free(c);
221  return NULL;
222 }
223 
225 {
226  if (!*c)
227  return;
228  ff_audio_data_free(&(*c)->buffer);
229  av_free((*c)->filter_bank);
230  av_freep(c);
231 }
232 
235 {
237  AudioData *fifo_buf = NULL;
238  int ret = 0;
239 
240  if (compensation_distance < 0)
241  return AVERROR(EINVAL);
242  if (!compensation_distance && sample_delta)
243  return AVERROR(EINVAL);
244 
245  if (!avr->resample_needed) {
246 #if FF_API_RESAMPLE_CLOSE_OPEN
247  /* if resampling was not enabled previously, re-initialize the
248  AVAudioResampleContext and force resampling */
249  int fifo_samples;
250  int restore_matrix = 0;
251  double matrix[AVRESAMPLE_MAX_CHANNELS * AVRESAMPLE_MAX_CHANNELS] = { 0 };
252 
253  /* buffer any remaining samples in the output FIFO before closing */
254  fifo_samples = av_audio_fifo_size(avr->out_fifo);
255  if (fifo_samples > 0) {
256  fifo_buf = ff_audio_data_alloc(avr->out_channels, fifo_samples,
257  avr->out_sample_fmt, NULL);
258  if (!fifo_buf)
259  return AVERROR(EINVAL);
260  ret = ff_audio_data_read_from_fifo(avr->out_fifo, fifo_buf,
261  fifo_samples);
262  if (ret < 0)
263  goto reinit_fail;
264  }
265  /* save the channel mixing matrix */
266  if (avr->am) {
268  if (ret < 0)
269  goto reinit_fail;
270  restore_matrix = 1;
271  }
272 
273  /* close the AVAudioResampleContext */
274  avresample_close(avr);
275 
276  avr->force_resampling = 1;
277 
278  /* restore the channel mixing matrix */
279  if (restore_matrix) {
281  if (ret < 0)
282  goto reinit_fail;
283  }
284 
285  /* re-open the AVAudioResampleContext */
286  ret = avresample_open(avr);
287  if (ret < 0)
288  goto reinit_fail;
289 
290  /* restore buffered samples to the output FIFO */
291  if (fifo_samples > 0) {
292  ret = ff_audio_data_add_to_fifo(avr->out_fifo, fifo_buf, 0,
293  fifo_samples);
294  if (ret < 0)
295  goto reinit_fail;
296  ff_audio_data_free(&fifo_buf);
297  }
298 #else
299  av_log(avr, AV_LOG_ERROR, "Unable to set resampling compensation\n");
300  return AVERROR(EINVAL);
301 #endif
302  }
303  c = avr->resample;
305  if (compensation_distance) {
306  c->dst_incr = c->ideal_dst_incr - c->ideal_dst_incr *
307  (int64_t)sample_delta / compensation_distance;
308  } else {
309  c->dst_incr = c->ideal_dst_incr;
310  }
311  return 0;
312 
313 reinit_fail:
314  ff_audio_data_free(&fifo_buf);
315  return ret;
316 }
317 
318 static int resample(ResampleContext *c, void *dst, const void *src,
319  int *consumed, int src_size, int dst_size, int update_ctx,
320  int nearest_neighbour)
321 {
322  int dst_index;
323  unsigned int index = c->index;
324  int frac = c->frac;
325  int dst_incr_frac = c->dst_incr % c->src_incr;
326  int dst_incr = c->dst_incr / c->src_incr;
328 
329  if (!dst != !src)
330  return AVERROR(EINVAL);
331 
332  if (nearest_neighbour) {
333  uint64_t index2 = ((uint64_t)index) << 32;
334  int64_t incr = (1LL << 32) * c->dst_incr / c->src_incr;
335  dst_size = FFMIN(dst_size,
336  (src_size-1-index) * (int64_t)c->src_incr /
337  c->dst_incr);
338 
339  if (dst) {
340  for(dst_index = 0; dst_index < dst_size; dst_index++) {
341  c->resample_nearest(dst, dst_index, src, index2 >> 32);
342  index2 += incr;
343  }
344  } else {
345  dst_index = dst_size;
346  }
347  index += dst_index * dst_incr;
348  index += (frac + dst_index * (int64_t)dst_incr_frac) / c->src_incr;
349  frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->src_incr;
350  } else {
351  for (dst_index = 0; dst_index < dst_size; dst_index++) {
352  int sample_index = index >> c->phase_shift;
353 
354  if (sample_index + c->filter_length > src_size)
355  break;
356 
357  if (dst)
358  c->resample_one(c, dst, dst_index, src, index, frac);
359 
360  frac += dst_incr_frac;
361  index += dst_incr;
362  if (frac >= c->src_incr) {
363  frac -= c->src_incr;
364  index++;
365  }
366  if (dst_index + 1 == compensation_distance) {
367  compensation_distance = 0;
368  dst_incr_frac = c->ideal_dst_incr % c->src_incr;
369  dst_incr = c->ideal_dst_incr / c->src_incr;
370  }
371  }
372  }
373  if (consumed)
374  *consumed = index >> c->phase_shift;
375 
376  if (update_ctx) {
377  index &= c->phase_mask;
378 
379  if (compensation_distance) {
380  compensation_distance -= dst_index;
381  if (compensation_distance <= 0)
382  return AVERROR_BUG;
383  }
384  c->frac = frac;
385  c->index = index;
386  c->dst_incr = dst_incr_frac + c->src_incr*dst_incr;
388  }
389 
390  return dst_index;
391 }
392 
394 {
395  int ch, in_samples, in_leftover, consumed = 0, out_samples = 0;
396  int ret = AVERROR(EINVAL);
397  int nearest_neighbour = (c->compensation_distance == 0 &&
398  c->filter_length == 1 &&
399  c->phase_shift == 0);
400 
401  in_samples = src ? src->nb_samples : 0;
402  in_leftover = c->buffer->nb_samples;
403 
404  /* add input samples to the internal buffer */
405  if (src) {
406  ret = ff_audio_data_combine(c->buffer, in_leftover, src, 0, in_samples);
407  if (ret < 0)
408  return ret;
409  } else if (in_leftover <= c->final_padding_samples) {
410  /* no remaining samples to flush */
411  return 0;
412  }
413 
414  if (!c->initial_padding_filled) {
416  int i;
417 
418  if (src && c->buffer->nb_samples < 2 * c->padding_size)
419  return 0;
420 
421  for (i = 0; i < c->padding_size; i++)
422  for (ch = 0; ch < c->buffer->channels; ch++) {
423  if (c->buffer->nb_samples > 2 * c->padding_size - i) {
424  memcpy(c->buffer->data[ch] + bps * i,
425  c->buffer->data[ch] + bps * (2 * c->padding_size - i), bps);
426  } else {
427  memset(c->buffer->data[ch] + bps * i, 0, bps);
428  }
429  }
430  c->initial_padding_filled = 1;
431  }
432 
433  if (!src && !c->final_padding_filled) {
435  int i;
436 
437  ret = ff_audio_data_realloc(c->buffer,
438  FFMAX(in_samples, in_leftover) +
439  c->padding_size);
440  if (ret < 0) {
441  av_log(c->avr, AV_LOG_ERROR, "Error reallocating resampling buffer\n");
442  return AVERROR(ENOMEM);
443  }
444 
445  for (i = 0; i < c->padding_size; i++)
446  for (ch = 0; ch < c->buffer->channels; ch++) {
447  if (in_leftover > i) {
448  memcpy(c->buffer->data[ch] + bps * (in_leftover + i),
449  c->buffer->data[ch] + bps * (in_leftover - i - 1),
450  bps);
451  } else {
452  memset(c->buffer->data[ch] + bps * (in_leftover + i),
453  0, bps);
454  }
455  }
456  c->buffer->nb_samples += c->padding_size;
458  c->final_padding_filled = 1;
459  }
460 
461 
462  /* calculate output size and reallocate output buffer if needed */
463  /* TODO: try to calculate this without the dummy resample() run */
464  if (!dst->read_only && dst->allow_realloc) {
465  out_samples = resample(c, NULL, NULL, NULL, c->buffer->nb_samples,
466  INT_MAX, 0, nearest_neighbour);
467  ret = ff_audio_data_realloc(dst, out_samples);
468  if (ret < 0) {
469  av_log(c->avr, AV_LOG_ERROR, "error reallocating output\n");
470  return ret;
471  }
472  }
473 
474  /* resample each channel plane */
475  for (ch = 0; ch < c->buffer->channels; ch++) {
476  out_samples = resample(c, (void *)dst->data[ch],
477  (const void *)c->buffer->data[ch], &consumed,
479  ch + 1 == c->buffer->channels, nearest_neighbour);
480  }
481  if (out_samples < 0) {
482  av_log(c->avr, AV_LOG_ERROR, "error during resampling\n");
483  return out_samples;
484  }
485 
486  /* drain consumed samples from the internal buffer */
487  ff_audio_data_drain(c->buffer, consumed);
489 
490  av_log(c->avr, AV_LOG_TRACE, "resampled %d in + %d leftover to %d out + %d leftover\n",
491  in_samples, in_leftover, out_samples, c->buffer->nb_samples);
492 
493  dst->nb_samples = out_samples;
494  return 0;
495 }
496 
498 {
499  ResampleContext *c = avr->resample;
500 
501  if (!avr->resample_needed || !avr->resample)
502  return 0;
503 
504  return FFMAX(c->buffer->nb_samples - c->padding_size, 0);
505 }
float, planar
Definition: samplefmt.h:70
#define NULL
Definition: coverity.c:32
int initial_padding_filled
Definition: resample.h:51
int initial_padding_samples
Definition: resample.h:52
int padding_size
Definition: resample.h:50
float v
int ff_audio_data_realloc(AudioData *a, int nb_samples)
Reallocate AudioData.
Definition: audio_data.c:161
Kaiser Windowed Sinc.
Definition: avresample.h:120
Audio buffer used for intermediate storage between conversion phases.
Definition: audio_data.h:37
void(* set_filter)(void *filter, double *tab, int phase, int tap_count)
Definition: resample.h:44
int ff_audio_data_add_to_fifo(AVAudioFifo *af, AudioData *a, int offset, int nb_samples)
Add samples in AudioData to an AVAudioFifo.
Definition: audio_data.c:350
AudioData * ff_audio_data_alloc(int channels, int nb_samples, enum AVSampleFormat sample_fmt, const char *name)
Allocate AudioData.
Definition: audio_data.c:118
int allow_realloc
realloc is allowed
Definition: audio_data.h:52
double, planar
Definition: samplefmt.h:71
int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta, int compensation_distance)
Set compensation for resampling.
Definition: resample.c:233
double cutoff
resampling cutoff frequency.
Definition: internal.h:72
int nb_samples
current number of samples
Definition: audio_data.h:43
static int resample(ResampleContext *c, void *dst, const void *src, int *consumed, int src_size, int dst_size, int update_ctx, int nearest_neighbour)
Definition: resample.c:318
AudioData * buffer
Definition: resample.h:30
#define av_malloc(s)
AVAudioResampleContext * avr
Definition: af_resample.c:40
int out_channels
number of output channels
Definition: internal.h:78
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:204
int read_only
data is read-only
Definition: audio_data.h:51
int compensation_distance
Definition: resample.h:38
enum AVResampleFilterType filter_type
Definition: resample.h:42
#define av_log(a,...)
void avresample_close(AVAudioResampleContext *avr)
Close AVAudioResampleContext.
Definition: utils.c:262
AudioMix * am
channel mixing context
Definition: internal.h:96
int ff_audio_resample(ResampleContext *c, AudioData *dst, AudioData *src)
Resample audio data.
Definition: resample.c:393
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define AVERROR(e)
Definition: error.h:43
int channels
channel count
Definition: audio_data.h:45
unsigned int index
Definition: resample.h:35
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
Definition: samplefmt.c:47
#define FFMAX(a, b)
Definition: common.h:64
int ff_audio_data_read_from_fifo(AVAudioFifo *af, AudioData *a, int nb_samples)
Read samples from an AVAudioFifo to AudioData.
Definition: audio_data.c:365
int compensation_distance
Definition: resample2.c:71
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
ResampleContext * resample
resampling context
Definition: internal.h:95
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
Definition: audio_fifo.c:186
av_cold void ff_audio_resample_init_arm(ResampleContext *c, enum AVSampleFormat sample_fmt)
Definition: resample_init.c:52
#define FFMIN(a, b)
Definition: common.h:66
float y
signed 32 bits, planar
Definition: samplefmt.h:69
ret
Definition: avfilter.c:974
int phase_shift
log2 of the number of entries in the resampling polyphase filterbank
Definition: internal.h:70
int ff_audio_data_combine(AudioData *dst, int dst_offset, AudioData *src, int src_offset, int nb_samples)
Append data from one AudioData to the end of another.
Definition: audio_data.c:277
void ff_audio_data_drain(AudioData *a, int nb_samples)
Drain samples from the start of the AudioData.
Definition: audio_data.c:333
int linear_interp
if 1 then the resampling FIR filter will be linearly interpolated
Definition: internal.h:71
int kaiser_beta
beta value for Kaiser window (only applicable if filter_type == AV_FILTER_TYPE_KAISER) ...
Definition: internal.h:74
int avresample_set_matrix(AVAudioResampleContext *avr, const double *matrix, int stride)
Set channel mixing matrix.
Definition: utils.c:665
int in_sample_rate
input sample rate
Definition: internal.h:58
int avresample_get_delay(AVAudioResampleContext *avr)
Return the number of samples currently in the resampling delay buffer.
Definition: resample.c:497
int avresample_get_matrix(AVAudioResampleContext *avr, double *matrix, int stride)
Get the current channel mixing matrix.
Definition: utils.c:636
void ff_audio_resample_free(ResampleContext **c)
Free a ResampleContext.
Definition: resample.c:224
static int build_filter(ResampleContext *c, double factor)
Definition: resample.c:67
AVS_Value src
Definition: avisynth_c.h:482
AVAudioFifo * out_fifo
FIFO for output samples.
Definition: internal.h:91
uint8_t * data[AVRESAMPLE_MAX_CHANNELS]
data plane pointers
Definition: audio_data.h:39
enum AVResampleFilterType filter_type
resampling filter type
Definition: internal.h:73
#define AVRESAMPLE_MAX_CHANNELS
Definition: avresample.h:104
enum AVSampleFormat internal_sample_fmt
internal sample format
Definition: internal.h:62
int force_resampling
force resampling
Definition: internal.h:68
Replacements for frequently missing libm functions.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:50
int filter_length
Definition: resample.h:32
ResampleContext * ff_audio_resample_init(AVAudioResampleContext *avr)
Allocate and initialize a ResampleContext.
Definition: resample.c:120
int index
Definition: gxfenc.c:89
int filter_size
length of each FIR filter in the resampling filterbank relative to the cutoff frequency ...
Definition: internal.h:69
Blackman Nuttall Windowed Sinc.
Definition: avresample.h:119
static const int factor[16]
Definition: vf_pp7.c:75
int final_padding_filled
Definition: resample.h:53
void(* resample_one)(struct ResampleContext *c, void *dst0, int dst_index, const void *src0, unsigned int index, int frac)
Definition: resample.h:45
int ideal_dst_incr
Definition: resample.h:33
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition: samplefmt.c:104
enum AVSampleFormat out_sample_fmt
output sample format
Definition: internal.h:60
common internal and external API header
int resample_channels
number of channels used for resampling
Definition: internal.h:79
static double c[64]
int resample_needed
resampling is needed
Definition: internal.h:83
unsigned bps
Definition: movenc.c:1334
#define av_free(p)
int final_padding_samples
Definition: resample.h:54
int allocated_samples
number of samples the buffer can hold
Definition: audio_data.h:42
uint8_t * filter_bank
Definition: resample.h:31
static const struct twinvq_data tab
#define av_freep(p)
int out_sample_rate
output sample rate
Definition: internal.h:61
void ff_audio_data_free(AudioData **a)
Free AudioData.
Definition: audio_data.c:216
signed 16 bits, planar
Definition: samplefmt.h:68
#define M_PI
Definition: mathematics.h:46
void(* resample_nearest)(void *dst0, int dst_index, const void *src0, unsigned int index)
Definition: resample.h:48
static double bessel(double x)
Definition: resample.c:50
int avresample_open(AVAudioResampleContext *avr)
Initialize AVAudioResampleContext.
Definition: utils.c:36
av_cold void ff_audio_resample_init_aarch64(ResampleContext *c, enum AVSampleFormat sample_fmt)
Definition: resample_init.c:48
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:250