On Mon, Dec 19, 2016 at 06:39:03PM -0800, Thomas Turner wrote: > Signed-off-by: Thomas Turner <thomas...@googlemail.com> > --- > libavutil/Makefile | 1 + > libavutil/tests/audio_fifo.c | 195 ++++++++++++++++++++++++++++++++++++ > tests/fate/libavutil.mak | 4 + > tests/ref/fate/audio_fifo | 228 > +++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 428 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..7e166b1 > --- /dev/null > +++ b/libavutil/tests/audio_fifo.c > @@ -0,0 +1,195 @@ > +/* > + * 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 <stdio.h> > +#include <inttypes.h> > +#include "libavutil/audio_fifo.c" > + > +#define MAX_CHANNELS 32 > +
> +#define ERROR(str) \ > + fprintf(stderr, "%s\n", str); \ > + exit(1); this should use do{}while; like other multiline macros see for example: tests/tiny_ssim.c:#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) or it should use a function instead of a macro a function is probably a better idea anyway > + > +typedef struct TestStruct { > + const enum AVSampleFormat format; > + const int nb_ch; > + void const *data_planes[MAX_CHANNELS]; > + int nb_samples_pch; > +} TestStruct; > + > +static const uint8_t data_U8 [] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 > }; > +static const int16_t data_S16[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 > }; > +static 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}; > + > + > +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 void* allocate_memory(size_t size) > +{ > + void *ptr = malloc(size); > + if (ptr == NULL){ > + fprintf(stderr, "failed to allocate memory!\n"); > + exit(1); this could use ERROR() too thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam"
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel