FFmpeg: libswresample/swresample_frame.c Source File
Go to the documentation of this file. 1 /*
2 * Copyright (c) 2014 Luca Barbato <lu_zero@gentoo.org>
3 * Copyright (c) 2014 Michael Niedermayer <michaelni@gmx.at>
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
26
28 {
31
33
43 }
44
54 }
55
62 }
63
66 {
69
72 return err;
74 s->in_sample_rate !=
in->sample_rate ||
75 s->in_sample_fmt !=
in->format) {
77 }
78 }
79
82 return err;
84 s->out_sample_rate !=
out->sample_rate ||
85 s->out_sample_fmt !=
out->format) {
87 }
88 }
90
92 }
93
96 {
98 uint8_t **out_data =
NULL;
99 const uint8_t **in_data =
NULL;
100 int out_nb_samples = 0, in_nb_samples = 0;
101
103 out_data =
out->extended_data;
104 out_nb_samples =
out->nb_samples;
105 }
106
108 in_data = (
const uint8_t **)
in->extended_data;
109 in_nb_samples =
in->nb_samples;
110 }
111
112 ret =
swr_convert(
s, out_data, out_nb_samples, in_data, in_nb_samples);
113
118 }
119
122
123 return 0;
124 }
125
127 {
129 int samples =
out->linesize[0] / bytes_per_sample;
130
133 } else {
136 }
137 }
138
141 {
143
149 setup = 1;
150 } else {
151 // return as is or reconfigure for input changes?
154 }
155
157 if (!
out->linesize[0]) {
160 out->nb_samples +=
in->nb_samples*(
int64_t)
s->out_sample_rate /
s->in_sample_rate;
161 }
163 if (setup)
166 }
167 } else {
168 if (!
out->nb_samples)
170 }
171 }
172
174 }
175
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.
Generated on Thu Sep 26 2024 23:15:57 for FFmpeg by
doxygen
1.8.17