Go to the documentation of this file.
74 s->in_sample_rate !=
in->sample_rate ||
75 s->in_sample_fmt !=
in->format) {
84 s->out_sample_rate !=
out->sample_rate ||
85 s->out_sample_fmt !=
out->format) {
98 uint8_t **out_data =
NULL;
99 const uint8_t **in_data =
NULL;
100 int out_nb_samples = 0, in_nb_samples = 0;
103 out_data =
out->extended_data;
104 out_nb_samples =
out->nb_samples;
108 in_data = (
const uint8_t **)
in->extended_data;
109 in_nb_samples =
in->nb_samples;
112 ret =
swr_convert(
s, out_data, out_nb_samples, in_data, in_nb_samples);
129 int samples =
out->linesize[0] / bytes_per_sample;
157 if (!
out->linesize[0]) {
160 out->nb_samples +=
in->nb_samples*(
int64_t)
s->out_sample_rate /
s->in_sample_rate;
168 if (!
out->nb_samples)
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
This structure describes decoded (raw) audio or video data.
static int convert_frame(SwrContext *s, AVFrame *out, const AVFrame *in)
int swr_is_initialized(struct SwrContext *s)
Check whether an swr context has been initialized or not.
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.
int64_t swr_get_delay(struct SwrContext *s, int64_t base)
Gets the delay the next input sample will experience relative to the next output sample.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
static int available_samples(AVFrame *out)
#define AVERROR_INPUT_CHANGED
Input changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_OUTPUT_CHANGED)
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
The libswresample context.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
int swr_convert_frame(SwrContext *s, AVFrame *out, const AVFrame *in)
Convert the samples in the input AVFrame and write them to the output AVFrame.
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 AVERROR_OUTPUT_CHANGED
Output changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_INPUT_CHANGED)
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
int swr_config_frame(SwrContext *s, const AVFrame *out, const AVFrame *in)
Configure or reconfigure the SwrContext using the information provided by the AVFrames.
static int config_changed(SwrContext *s, const AVFrame *out, const AVFrame *in)
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
Filter the word “frame” indicates either a video frame or a group of audio samples
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
AudioData in
input audio data
av_cold void swr_close(SwrContext *s)
Closes the context so that swr_is_initialized() returns 0.