Go to the documentation of this file.
36 const int IN_RATE = 48000;
37 const int OUT_RATE = 16000;
39 const int N1_OUT = 160;
40 const int N2_OUT = 320;
41 const int N1_IN = N1_OUT * IN_RATE / OUT_RATE;
42 const int N2_IN = N2_OUT * IN_RATE / OUT_RATE;
49 fprintf(stderr,
"swr_alloc failed\n");
63 fprintf(stderr,
"swr_init failed: %d\n",
ret);
71 const uint8_t *in_planes[1];
72 uint8_t *out_planes[1];
76 fprintf(stderr,
"alloc failed\n");
84 for (
i = 0;
i < N2_IN; ++
i)
85 input[
i] = (int16_t)((
i * 7) & 0x3fff);
89 in_planes[0] = (
const uint8_t *)
input;
90 out_planes[0] = (uint8_t *)
out;
91 n =
swr_convert(swr, out_planes, N1_OUT, in_planes, N1_IN);
93 fprintf(stderr,
"swr_convert call#1 failed: %d\n", n);
102 in_planes[0] = (
const uint8_t *)
input;
103 out_planes[0] = (uint8_t *)
out;
104 n =
swr_convert(swr, out_planes, N2_OUT, in_planes, N2_IN);
106 fprintf(stderr,
"swr_convert call#2 failed: %d\n", n);
int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t *const *out_arg, int out_count, const uint8_t *const *in_arg, int in_count)
Convert audio.
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
av_cold struct SwrContext * swr_alloc(void)
Allocate SwrContext.
The libswresample context.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
An AVChannelLayout holds information about the channel layout of audio data.
int av_opt_set_chlayout(void *obj, const char *name, const AVChannelLayout *channel_layout, int search_flags)
#define i(width, name, range_min, range_max)
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_S16
signed 16 bits
void * av_calloc(size_t nmemb, size_t size)
#define AV_CHANNEL_LAYOUT_MONO
int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags)