On Thu, Dec 15, 2016 at 07:55:57PM -0800, Thomas Turner wrote: > Signed-off-by: Thomas Turner <[email protected]> > --- > libavutil/Makefile | 1 + > libavutil/tests/audio_fifo.c | 210 +++++++++++++++++++++++++++++++++++++++ > tests/fate/libavutil.mak | 4 + > tests/ref/fate/audio_fifo | 228 > +++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 443 insertions(+) > create mode 100644 libavutil/tests/audio_fifo.c > create mode 100644 tests/ref/fate/audio_fifo > > diff --git a/libavutil/Makefile b/libavutil/Makefile > index 9841645..2dd91b8 100644 > --- a/libavutil/Makefile > +++ b/libavutil/Makefile > @@ -182,6 +182,7 @@ SKIPHEADERS-$(CONFIG_OPENCL) += opencl.h > TESTPROGS = adler32 \ > aes \ > atomic \ > + audio_fifo \ > avstring \ > base64 \ > blowfish \ > diff --git a/libavutil/tests/audio_fifo.c b/libavutil/tests/audio_fifo.c > new file mode 100644 > index 0000000..e3a3484 > --- /dev/null > +++ b/libavutil/tests/audio_fifo.c > @@ -0,0 +1,210 @@ > +/* > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +#include <stdlib.h> > +#include <inttypes.h>
> +//#include "libavutil/audio_fifo.c"
> +#include "../audio_fifo.c"
is the ../ still needed ?
one of the 2 includes should be removed
> +#include "libavutil/audio_fifo.h"
> +#include "libavutil/error.h"
> +
> +#define MAX_CHANNELS 32
> +
> +
> +typedef struct TestStruct {
> + const char *message;
> + const enum AVSampleFormat format;
> + const int nb_ch;
> + void *data_planes[MAX_CHANNELS];
> + int nb_samples_pch;
> +} TestStruct;
> +
> +static uint8_t data_U8 [] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
> };
> +static int16_t data_S16[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
> };
> +static 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};
do this ever change ?
if not they could be static const
> +
> +
> +static const TestStruct test_struct[] = {
> + {.format = AV_SAMPLE_FMT_U8 , .nb_ch = 1, .data_planes = {data_U8 ,
> }, .nb_samples_pch = 12},
> + {.format = AV_SAMPLE_FMT_U8P , .nb_ch = 2, .data_planes = {data_U8 ,
> data_U8 +6, }, .nb_samples_pch = 6 },
> + {.format = AV_SAMPLE_FMT_S16 , .nb_ch = 1, .data_planes = {data_S16,
> }, .nb_samples_pch = 12},
> + {.format = AV_SAMPLE_FMT_S16P , .nb_ch = 2, .data_planes = {data_S16,
> data_S16+6, }, .nb_samples_pch = 6 },
> + {.format = AV_SAMPLE_FMT_FLT , .nb_ch = 1, .data_planes = {data_FLT,
> }, .nb_samples_pch = 12},
> + {.format = AV_SAMPLE_FMT_FLTP , .nb_ch = 2, .data_planes = {data_FLT,
> data_FLT+6, }, .nb_samples_pch = 6 }
> +};
> +
> +static int is_little_endian(void)
> +{
> + const unsigned int i = 1;
> + return *(uint8_t*)&i;
> +}
see HAVE_BIGENDIAN
[...]
> +static void test_function(TestStruct test_sample)
> +{
> + int ret, i;
> + void **output_data = NULL;
> + AVAudioFifo *afifo = av_audio_fifo_alloc(test_sample.format,
> test_sample.nb_ch,
> + test_sample.nb_samples_pch);
> + if (!afifo) {
> + fprintf(stderr, "ERROR: av_audio_fifo_alloc returned NULL!\n");
> + exit(1);
> + }
you can factorize fprintf + exit() into a function
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list [email protected] http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
