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;
75 int read_only,
const char *
name)
79 memset(a, 0,
sizeof(*a));
96 for (p = 0; p < (a->
is_planar ? channels : 1); p++) {
110 a->
name = name ? name :
"{no name}";
146 a->
name = name ? name :
"{no name}";
148 if (nb_samples > 0) {
163 int ret, new_buf_size, plane_size, p;
176 if (new_buf_size < 0)
190 for (p = 0; p < a->
planes; p++)
194 memcpy(a->
data, new_data,
sizeof(new_data));
251 for (p = 0; p < src->
planes; p++) {
258 for (p = 0; p < src->
planes; p++) {
268 for (p = 0; p < src->
planes; p++)
278 int src_offset,
int nb_samples)
280 int ret, p, dst_offset2, dst_move_size;
289 if (dst_offset < 0 || dst_offset > dst->
nb_samples ||
290 src_offset < 0 || src_offset > src->
nb_samples) {
292 src_offset, dst_offset);
297 if (nb_samples > src->
nb_samples - src_offset)
315 dst_offset2 = dst_offset + nb_samples;
318 for (p = 0; p < src->
planes; p++) {
319 if (dst_move_size > 0) {
320 memmove(dst->
data[p] + dst_offset2 * dst->
stride,
322 dst_move_size * dst->
stride);
324 memcpy(dst->
data[p] + dst_offset * dst->
stride,
326 nb_samples * src->
stride);
340 int move_offset = a->
stride * nb_samples;
343 for (p = 0; p < a->
planes; p++)
344 memmove(a->
data[p], a->
data[p] + move_offset, move_size);
358 offset_size = offset * a->
stride;
359 for (p = 0; p < a->
planes; p++)
360 offset_data[p] = a->
data[p] + offset_size;
unsigned int buffer_size
allocated buffer size
static void calc_ptr_alignment(AudioData *a)
const char * name
name for debug logging
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples)
Read data from an AVAudioFifo.
int ff_audio_data_realloc(AudioData *a, int nb_samples)
Reallocate AudioData.
Audio buffer used for intermediate storage between conversion phases.
#define LIBAVUTIL_VERSION_INT
memory handling functions
int ff_audio_data_add_to_fifo(AVAudioFifo *af, AudioData *a, int offset, int nb_samples)
Add samples in AudioData to an AVAudioFifo.
int do_zero
zeroing needed
AudioData * ff_audio_data_alloc(int channels, int nb_samples, enum AVSampleFormat sample_fmt, const char *name)
Allocate AudioData.
int allow_realloc
realloc is allowed
int channel_zero[AVRESAMPLE_MAX_CHANNELS]
dest index to zero
int nb_samples
current number of samples
static const AVClass audio_data_class
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 sample_size
bytes per sample
int allocated_channels
allocated channel count
int read_only
data is read-only
int ff_sample_fmt_is_planar(enum AVSampleFormat sample_fmt, int channels)
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
int ff_audio_data_set_channels(AudioData *a, int channels)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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 stride
sample byte offset within a plane
int channels
channel count
static const uint8_t offset[127][2]
int ff_audio_data_read_from_fifo(AVAudioFifo *af, AudioData *a, int nb_samples)
Read samples from an AVAudioFifo to AudioData.
int is_planar
sample format is planar
uint8_t * buffer
data buffer
Context for an Audio FIFO Buffer.
const AVClass * class
AVClass for logging.
int channel_copy[AVRESAMPLE_MAX_CHANNELS]
dest index to copy from
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.
void ff_audio_data_drain(AudioData *a, int nb_samples)
Drain samples from the start of the AudioData.
int ff_audio_data_init(AudioData *a, uint8_t **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 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...
AVSampleFormat
Audio sample formats.
uint8_t * data[AVRESAMPLE_MAX_CHANNELS]
data plane pointers
#define AVRESAMPLE_MAX_CHANNELS
Describe the class of an AVClass context structure.
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 channel_map[AVRESAMPLE_MAX_CHANNELS]
source index of each output channel, -1 if not remapped
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
int samples_align
allocated samples alignment
int ff_audio_data_copy(AudioData *dst, AudioData *src, ChannelMapInfo *map)
Copy data from one AudioData to another.
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 allocated_samples
number of samples the buffer can hold
enum AVSampleFormat sample_fmt
sample format
void ff_audio_data_free(AudioData **a)
Free AudioData.
int ptr_align
minimum data pointer alignment
int planes
number of data planes
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...