Go to the documentation of this file.
41 for (p = 0; p <
a->planes; p++) {
43 while ((intptr_t)
a->data[p] % cur_align)
45 if (cur_align < min_align)
46 min_align = cur_align;
48 a->ptr_align = min_align;
80 memset(
a, 0,
sizeof(*
a));
89 if (!
a->sample_size) {
95 a->stride =
a->sample_size * (
a->is_planar ? 1 :
channels);
97 for (p = 0; p < (
a->is_planar ?
channels : 1); p++) {
104 a->allocated_samples = nb_samples * !read_only;
105 a->nb_samples = nb_samples;
106 a->sample_fmt = sample_fmt;
109 a->read_only = read_only;
110 a->allow_realloc = 0;
114 a->samples_align = plane_size /
a->stride;
133 if (!
a->sample_size) {
139 a->stride =
a->sample_size * (
a->is_planar ? 1 :
channels);
142 a->sample_fmt = sample_fmt;
146 a->allow_realloc = 1;
149 if (nb_samples > 0) {
164 int ret, new_buf_size, plane_size, p;
167 if (
a->allocated_samples >= nb_samples)
171 if (
a->read_only || !
a->allow_realloc)
175 a->allocated_channels, nb_samples,
177 if (new_buf_size < 0)
183 if (
a->nb_samples > 0 &&
a->is_planar) {
187 nb_samples,
a->sample_fmt, 0);
191 for (p = 0; p <
a->planes; p++)
192 memcpy(new_data[p],
a->data[p],
a->nb_samples *
a->stride);
195 memcpy(
a->data, new_data,
sizeof(new_data));
196 a->buffer =
a->data[0];
203 a->allocated_channels, nb_samples,
208 a->buffer_size = new_buf_size;
209 a->allocated_samples = nb_samples;
212 a->samples_align = plane_size /
a->stride;
233 if (
map && !
src->is_planar) {
239 if (!
src->nb_samples) {
252 for (p = 0; p <
src->planes; p++) {
253 if (
map->channel_map[p] >= 0)
254 memcpy(dst->
data[p],
src->data[
map->channel_map[p]],
255 src->nb_samples *
src->stride);
258 if (
map->do_copy ||
map->do_zero) {
259 for (p = 0; p <
src->planes; p++) {
260 if (
map->channel_copy[p])
261 memcpy(dst->
data[p], dst->
data[
map->channel_copy[p]],
262 src->nb_samples *
src->stride);
263 else if (
map->channel_zero[p])
269 for (p = 0; p <
src->planes; p++)
270 memcpy(dst->
data[p],
src->data[p],
src->nb_samples *
src->stride);
279 int src_offset,
int nb_samples)
281 int ret, p, dst_offset2, dst_move_size;
290 if (dst_offset < 0 || dst_offset > dst->
nb_samples ||
291 src_offset < 0 || src_offset >
src->nb_samples) {
293 src_offset, dst_offset);
298 if (nb_samples >
src->nb_samples - src_offset)
299 nb_samples =
src->nb_samples - src_offset;
316 dst_offset2 = dst_offset + nb_samples;
319 for (p = 0; p <
src->planes; p++) {
320 if (dst_move_size > 0) {
321 memmove(dst->
data[p] + dst_offset2 * dst->
stride,
323 dst_move_size * dst->
stride);
325 memcpy(dst->
data[p] + dst_offset * dst->
stride,
326 src->data[p] + src_offset *
src->stride,
327 nb_samples *
src->stride);
336 if (
a->nb_samples <= nb_samples) {
341 int move_offset =
a->stride * nb_samples;
342 int move_size =
a->stride * (
a->nb_samples - nb_samples);
344 for (p = 0; p <
a->planes; p++)
345 memmove(
a->data[p],
a->data[p] + move_offset, move_size);
347 a->nb_samples -= nb_samples;
359 offset_size =
offset *
a->stride;
360 for (p = 0; p <
a->planes; p++)
361 offset_data[p] =
a->data[p] + offset_size;
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
int ff_sample_fmt_is_planar(enum AVSampleFormat sample_fmt, int channels)
static void calc_ptr_alignment(AudioData *a)
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
AudioData * ff_audio_data_alloc(int channels, int nb_samples, enum AVSampleFormat sample_fmt, const char *name)
Allocate AudioData.
int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Fill plane data pointers and linesize for samples with sample format sample_fmt.
int ff_audio_data_set_channels(AudioData *a, int channels)
#define AVRESAMPLE_MAX_CHANNELS
int ff_audio_data_add_to_fifo(AVAudioFifo *af, AudioData *a, int offset, int nb_samples)
Add samples in AudioData to an AVAudioFifo.
uint8_t * data[AVRESAMPLE_MAX_CHANNELS]
data plane pointers
void ff_audio_data_free(AudioData **a)
Free AudioData.
int ff_audio_data_read_from_fifo(AVAudioFifo *af, AudioData *a, int nb_samples)
Read samples from an AVAudioFifo to AudioData.
static const AVClass audio_data_class
Audio buffer used for intermediate storage between conversion phases.
Context for an Audio FIFO Buffer.
int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Allocate a samples buffer for nb_samples samples, and fill data pointers and linesize accordingly.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
enum AVSampleFormat sample_fmt
sample format
const char * av_default_item_name(void *ptr)
Return the context name.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples)
Read data from an AVAudioFifo.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
AVSampleFormat
Audio sample formats.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Get the required buffer size for the given audio parameters.
int read_only
data is read-only
int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
int nb_samples
current number of samples
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int ff_audio_data_realloc(AudioData *a, int nb_samples)
Reallocate AudioData.
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.
const VDPAUPixFmtMap * map
int channels
channel count
int stride
sample byte offset within a plane
int ff_audio_data_init(AudioData *a, uint8_t *const *src, int plane_size, int channels, int nb_samples, enum AVSampleFormat sample_fmt, int read_only, const char *name)
Initialize AudioData using a given source.
int ff_audio_data_copy(AudioData *dst, AudioData *src, ChannelMapInfo *map)
Copy data from one AudioData to another.
void ff_audio_data_drain(AudioData *a, int nb_samples)
Drain samples from the start of the AudioData.