33 printf(
"Testing name/format round-trip\n");
37 printf(
"%2d: name=%-5s roundtrip=%s\n",
i,
name, fmt ==
i ?
"OK" :
"FAIL");
46 printf(
"\nTesting av_get_bytes_per_sample()\n");
52 printf(
"\nTesting av_sample_fmt_is_planar()\n");
58 printf(
"\nTesting packed/planar conversions\n");
62 printf(
"%s: packed=%-4s planar=%s\n",
69 printf(
"\nTesting av_get_alt_sample_fmt()\n");
73 printf(
"%s: alt_packed=%-4s alt_planar=%s\n",
80 printf(
"\nTesting av_get_sample_fmt_string()\n");
82 printf(
"header: %s\n", buf);
89 printf(
"\nTesting av_samples_get_buffer_size()\n");
92 printf(
"2ch 1024smp s16: %d\n",
94 printf(
"2ch 1024smp s16p: %d\n",
96 printf(
"6ch 512smp s32: %d\n",
99 printf(
"linesize (2ch 1024smp s16 align=0): %d\n", linesize);
105 printf(
"\nTesting av_samples_alloc()\n");
107 uint8_t *
data[8] = { 0 };
111 printf(
"alloc 2ch s16: ret=%d linesize=%d data[0]=%s\n",
112 ret > 0, linesize,
data[0] ?
"set" :
"null");
116 printf(
"alloc 2ch s16p: ret=%d linesize=%d data[0]=%s data[1]=%s\n",
118 data[0] ?
"set" :
"null",
data[1] ?
"set" :
"null");
123 printf(
"\nTesting av_samples_alloc_array_and_samples()\n");
130 printf(
"alloc_array 2ch s16p: ret=%d linesize=%d data[0]=%s data[1]=%s\n",
132 data[0] ?
"set" :
"null",
data[1] ?
"set" :
"null");
139 printf(
"\nTesting av_samples_copy()\n");
141 uint8_t *
src[1] = { 0 }, *
dst[1] = { 0 };
147 memset(
src[0], 0xAB, 8);
149 printf(
"copy: %s\n", memcmp(
src[0],
dst[0], 8) == 0 ?
"OK" :
"FAIL");
156 printf(
"\nTesting OOM paths\n");
158 uint8_t *
data[8] = { 0 };
159 uint8_t **array_data =
NULL;
165 printf(
"alloc OOM: ret=%d data[0]=%s\n",
170 printf(
"alloc_array OOM: ret=%d data=%s\n",
171 ret ==
AVERROR(ENOMEM), array_data ?
"set" :
"null");
177 printf(
"\nTesting av_samples_set_silence()\n");
179 uint8_t *
data[1] = { 0 };
184 memset(
data[0], 0xFF, 8);
188 for (
int i = 0;
i < 8;
i++)
189 if (
data[0][
i] != 0) silent = 0;
190 printf(
"silence s16: %s\n", silent ?
"OK" :
"FAIL");
196 memset(
data[0], 0xFF, 4);
200 for (
int i = 0;
i < 4;
i++)
201 if (
data[0][
i] != 0x80) silent = 0;
202 printf(
"silence u8: %s\n", silent ?
"OK" :
"FAIL");
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define i(width, name, range_min, range_max)
__device__ int printf(const char *,...)
void av_max_alloc(size_t max)
Set the maximum size that may be allocated in one block.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
enum AVSampleFormat av_get_sample_fmt(const char *name)
Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE on error.
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
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...
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.
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...
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.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_NB
Number of sample formats. DO NOT USE if linking dynamically.
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_SAMPLE_FMT_U8
unsigned 8 bits
@ AV_SAMPLE_FMT_S16
signed 16 bits
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.
int av_samples_set_silence(uint8_t *const *audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
int av_samples_copy(uint8_t *const *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.
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...
Memory handling functions.