FFmpeg
audio_data.h
1 /*
2  * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVRESAMPLE_AUDIO_DATA_H
22 #define AVRESAMPLE_AUDIO_DATA_H
23 
24 #include <stdint.h>
25 
26 #include "libavutil/audio_fifo.h"
27 #include "libavutil/log.h"
28 #include "libavutil/samplefmt.h"
29 #include "avresample.h"
30 #include "internal.h"
31 
32 int ff_sample_fmt_is_planar(enum AVSampleFormat sample_fmt, int channels);
33 
37 struct AudioData {
38  const AVClass *class;
39  uint8_t *data[AVRESAMPLE_MAX_CHANNELS];
40  uint8_t *buffer;
41  unsigned int buffer_size;
43  int nb_samples;
45  int channels;
47  int is_planar;
48  int planes;
50  int stride;
51  int read_only;
53  int ptr_align;
55  const char *name;
56 };
57 
58 int ff_audio_data_set_channels(AudioData *a, int channels);
59 
79 int ff_audio_data_init(AudioData *a, uint8_t * const *src, int plane_size,
80  int channels, int nb_samples,
82  const char *name);
83 
95 AudioData *ff_audio_data_alloc(int channels, int nb_samples,
97  const char *name);
98 
108 int ff_audio_data_realloc(AudioData *a, int nb_samples);
109 
117 void ff_audio_data_free(AudioData **a);
118 
127 int ff_audio_data_copy(AudioData *out, AudioData *in, ChannelMapInfo *map);
128 
141 int ff_audio_data_combine(AudioData *dst, int dst_offset, AudioData *src,
142  int src_offset, int nb_samples);
143 
152 void ff_audio_data_drain(AudioData *a, int nb_samples);
153 
164 int ff_audio_data_add_to_fifo(AVAudioFifo *af, AudioData *a, int offset,
165  int nb_samples);
166 
176 int ff_audio_data_read_from_fifo(AVAudioFifo *af, AudioData *a, int nb_samples);
177 
178 #endif /* AVRESAMPLE_AUDIO_DATA_H */
unsigned int buffer_size
allocated buffer size
Definition: audio_data.h:41
const char * name
name for debug logging
Definition: audio_data.h:55
Audio buffer used for intermediate storage between conversion phases.
Definition: audio_data.h:37
int allow_realloc
realloc is allowed
Definition: audio_data.h:52
int nb_samples
current number of samples
Definition: audio_data.h:43
int sample_size
bytes per sample
Definition: audio_data.h:49
int allocated_channels
allocated channel count
Definition: audio_data.h:46
int read_only
data is read-only
Definition: audio_data.h:51
Definition: internal.h:43
int stride
sample byte offset within a plane
Definition: audio_data.h:50
int channels
channel count
Definition: audio_data.h:45
int is_planar
sample format is planar
Definition: audio_data.h:47
uint8_t * buffer
data buffer
Definition: audio_data.h:40
Definition: audio_fifo.c:34
external API header
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
uint8_t * data[AVRESAMPLE_MAX_CHANNELS]
data plane pointers
Definition: audio_data.h:39
Describe the class of an AVClass context structure.
Definition: log.h:67
int samples_align
allocated samples alignment
Definition: audio_data.h:54
Audio FIFO Buffer.
int allocated_samples
number of samples the buffer can hold
Definition: audio_data.h:42
enum AVSampleFormat sample_fmt
sample format
Definition: audio_data.h:44
int ptr_align
minimum data pointer alignment
Definition: audio_data.h:53
int planes
number of data planes
Definition: audio_data.h:48