51 return sample_fmt_info[sample_fmt].
name;
59 if (!strcmp(sample_fmt_info[i].name, name))
68 if (sample_fmt_info[sample_fmt].planar == planar)
70 return sample_fmt_info[sample_fmt].
altform;
77 if (sample_fmt_info[sample_fmt].planar)
78 return sample_fmt_info[sample_fmt].
altform;
86 if (sample_fmt_info[sample_fmt].planar)
88 return sample_fmt_info[sample_fmt].
altform;
95 snprintf(buf, buf_size,
"name " " depth");
107 0 : sample_fmt_info[sample_fmt].
bits >> 3;
110 #if FF_API_GET_BITS_PER_SAMPLE_FMT
114 0 : sample_fmt_info[sample_fmt].
bits;
122 return sample_fmt_info[sample_fmt].
planar;
133 if (!sample_size || nb_samples <= 0 || nb_channels <= 0)
139 nb_samples =
FFALIGN(nb_samples, 32);
143 if (nb_channels > INT_MAX / align ||
144 (int64_t)nb_channels * nb_samples > (INT_MAX - (align * nb_channels)) / sample_size)
147 line_size = planar ?
FFALIGN(nb_samples * sample_size, align) :
148 FFALIGN(nb_samples * sample_size * nb_channels, align);
150 *linesize = line_size;
152 return planar ? line_size * nb_channels : line_size;
159 int ch, planar, buf_size, line_size;
167 audio_data[0] = (
uint8_t *)buf;
169 audio_data[ch] = audio_data[ch-1] + line_size;
172 *linesize = line_size;
174 #if FF_API_SAMPLES_UTILS_RETURN_ZERO
195 nb_samples, sample_fmt, align);
203 #if FF_API_SAMPLES_UTILS_RETURN_ZERO
215 *audio_data =
av_calloc(nb_planes,
sizeof(**audio_data));
219 nb_samples, sample_fmt, align);
230 int planes = planar ? nb_channels : 1;
232 int data_size = nb_samples * block_align;
235 dst_offset *= block_align;
236 src_offset *= block_align;
238 if((dst[0] < src[0] ? src[0] - dst[0] : dst[0] - src[0]) >= data_size) {
239 for (i = 0; i < planes; i++)
240 memcpy(dst[i] + dst_offset, src[i] + src_offset, data_size);
242 for (i = 0; i < planes; i++)
243 memmove(dst[i] + dst_offset, src[i] + src_offset, data_size);
253 int planes = planar ? nb_channels : 1;
255 int data_size = nb_samples * block_align;
260 offset *= block_align;
262 for (i = 0; i < planes; i++)
263 memset(audio_data[i] + offset, fill_char, data_size);
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...
void * av_calloc(size_t nmemb, size_t size) av_malloc_attrib
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
Number of sample formats. DO NOT USE if linking dynamically.
int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Allocate a data pointers array, samples buffer for nb_samples samples, and fill data pointers and lin...
enum AVSampleFormat altform
planar<->packed alternative form
enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt)
Get the planar alternative form of the given sample format.
enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar)
Return the planar<->packed alternative form of the given sample format, or AV_SAMPLE_FMT_NONE on erro...
static const SampleFmtInfo sample_fmt_info[AV_SAMPLE_FMT_NB]
this table gives more information about formats
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
enum AVSampleFormat av_get_sample_fmt(const char *name)
Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE on error.
static const uint8_t offset[511][2]
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 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.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int av_samples_copy(uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Copy samples from src to dst.
attribute_deprecated int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt)
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
const AVS_VideoInfo int align
AVSampleFormat
Audio Sample Formats.
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
char * av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt)
Generate a string corresponding to the sample format with sample_fmt, or a header if sample_fmt is ne...
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 av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
common internal and external API header
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.