26#define MAX_CHANNELS 32
36static const uint8_t
data_U8 [] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
37static const int16_t
data_S16[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
38static const float data_FLT[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0};
58static void ERROR(
const char *str)
60 fprintf(stderr,
"%s\n", str);
69 ? test_sample->
nb_ch : 1;
70 int line_size = (buffers > 1) ? nb_samples * byte_offset
71 : nb_samples * byte_offset * test_sample->
nb_ch;
72 for (p = 0; p < buffers; ++p){
73 for(
b = 0;
b < line_size;
b+=byte_offset){
74 for (
f = 0;
f < byte_offset;
f++){
75 int order = !HAVE_BIGENDIAN ? (byte_offset -
f - 1) :
f;
76 printf(
"%02x", *((uint8_t*)data_planes[p] +
b + order));
78 if (
b + byte_offset < line_size)
90 ? samples : afifo->
channels * samples;
93 ERROR(
"failed to allocate memory!");
96 *output = data_planes;
101 ERROR(
"failed to allocate memory!");
108 int nb_samples,
int offset)
122 data_planes[
i] = (uint8_t*)test_sample->
data_planes[
i] + offset_size;
135 ERROR(
"ERROR: av_audio_fifo_alloc returned NULL!");
139 ERROR(
"ERROR: av_audio_fifo_write failed!");
141 printf(
"written: %d\n", ret);
145 ERROR(
"ERROR: av_audio_fifo_write failed!");
147 printf(
"written: %d\n", ret);
152 ERROR(
"ERROR: av_audio_fifo_read failed!");
154 printf(
"read: %d\n", ret);
161 ERROR(
"ERROR: av_audio_fifo_peek failed!");
172 ERROR(
"ERROR: av_audio_fifo_peek_at failed!");
182 ERROR(
"ERROR: av_audio_fifo_drain failed!");
185 ERROR(
"drain failed to flush all samples in audio_fifo!");
197 for (t = 0; t <
tests; ++t){
198 printf(
"\nTEST: %d\n\n", t+1);
#define i(width, name, range_min, range_max)
__device__ int printf(const char *,...)
int av_audio_fifo_peek(const AVAudioFifo *af, void *const *data, int nb_samples)
Peek data from an AVAudioFifo.
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
int av_audio_fifo_peek_at(const AVAudioFifo *af, void *const *data, int nb_samples, int offset)
Peek data from an AVAudioFifo.
int av_audio_fifo_write(AVAudioFifo *af, void *const *data, int nb_samples)
Write data to an AVAudioFifo.
int av_audio_fifo_read(AVAudioFifo *af, void *const *data, int nb_samples)
Read data from an AVAudioFifo.
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
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.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_FLTP
float, planar
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
@ AV_SAMPLE_FMT_U8
unsigned 8 bits
@ AV_SAMPLE_FMT_S16
signed 16 bits
static int output_data(MLPDecodeContext *m, unsigned int substr, AVFrame *frame, int *got_frame_ptr)
Write the audio data into the output buffer.
Memory handling functions.
Context for an Audio FIFO Buffer.
enum AVSampleFormat sample_fmt
sample format
int nb_buffers
number of buffers
int nb_samples
number of samples currently in the FIFO
int sample_size
size, in bytes, of one sample in a buffer
int channels
number of channels
enum AVSampleFormat format
void const * data_planes[MAX_CHANNELS]
#define av_malloc_array(a, b)
static int read_samples_from_audio_fifo(AVAudioFifo *afifo, void ***output, int nb_samples)
static void ERROR(const char *str)
static void test_function(const TestStruct *test_sample)
static const int16_t data_S16[]
static int write_samples_to_audio_fifo(AVAudioFifo *afifo, const TestStruct *test_sample, int nb_samples, int offset)
static void print_audio_bytes(const TestStruct *test_sample, void **data_planes, int nb_samples)
static void free_data_planes(AVAudioFifo *afifo, void **output_data)
static const TestStruct test_struct[]
static const uint8_t data_U8[]
static const float data_FLT[]