avformat/mxfdec: Check edit unit for overflow in mxf_set_current_edit_unit()
[FFMpeg-mirror.git] / tests / checkasm / llauddsp.c
blob969166baca890d4e59ad3394db37cb14289184fd
1 /*
2 * Copyright (c) 2016 Alexandra Hájková
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <string.h>
23 #include "libavutil/common.h"
24 #include "libavutil/intreadwrite.h"
25 #include "libavutil/mem.h"
26 #include "libavutil/mem_internal.h"
28 #include "libavcodec/lossless_audiodsp.h"
30 #include "checkasm.h"
32 #define randomize_buf(buf, len) \
33 do { \
34 for (int i = 0; i < len; i++) \
35 buf[i] = rnd(); \
36 } while (0)
38 static void check_scalarproduct_and_madd_int16(LLAudDSPContext *c)
40 #define BUF_SIZE 1088 // multiple of 16
41 LOCAL_ALIGNED_16(int16_t, v1, [BUF_SIZE]);
42 LOCAL_ALIGNED_16(int16_t, v2, [BUF_SIZE]);
43 LOCAL_ALIGNED_16(int16_t, v3, [BUF_SIZE]);
44 int mul;
46 declare_func(int32_t, int16_t *, const int16_t *, const int16_t *,
47 int, int);
49 randomize_buf(v1, BUF_SIZE);
50 randomize_buf(v2, BUF_SIZE);
51 randomize_buf(v3, BUF_SIZE);
52 mul = (int16_t)rnd();
54 if (check_func(c->scalarproduct_and_madd_int16,
55 "scalarproduct_and_madd_int16")) {
56 LOCAL_ALIGNED_16(int16_t, dst0, [BUF_SIZE]);
57 LOCAL_ALIGNED_16(int16_t, dst1, [BUF_SIZE]);
58 int ref, val;
60 memcpy(dst0, v1, sizeof (*dst0) * BUF_SIZE);
61 memcpy(dst1, v1, sizeof (*dst1) * BUF_SIZE);
62 ref = call_ref(dst0, v2, v3, BUF_SIZE, mul);
63 val = call_new(dst1, v2, v3, BUF_SIZE, mul);
64 if (memcmp(dst0, dst1, sizeof (*dst0) * BUF_SIZE) != 0 || ref != val)
65 fail();
67 bench_new(v1, v2, v3, BUF_SIZE, mul);
70 report("scalarproduct_and_madd_int16");
73 static void check_scalarproduct_and_madd_int32(LLAudDSPContext *c)
75 #define BUF_SIZE 1088 // multiple of 16
76 LOCAL_ALIGNED_16(int16_t, v1, [BUF_SIZE]);
77 LOCAL_ALIGNED_16(int32_t, v2, [BUF_SIZE]);
78 LOCAL_ALIGNED_16(int16_t, v3, [BUF_SIZE]);
79 int mul;
81 declare_func(int32_t, int16_t *, const int32_t *, const int16_t *,
82 int, int);
84 randomize_buf(v1, BUF_SIZE);
85 randomize_buf(v2, BUF_SIZE);
86 randomize_buf(v3, BUF_SIZE);
87 mul = (int16_t)rnd();
89 if (check_func(c->scalarproduct_and_madd_int32,
90 "scalarproduct_and_madd_int32")) {
91 LOCAL_ALIGNED_16(int16_t, dst0, [BUF_SIZE]);
92 LOCAL_ALIGNED_16(int16_t, dst1, [BUF_SIZE]);
93 int ref, val;
95 memcpy(dst0, v1, sizeof (*dst0) * BUF_SIZE);
96 memcpy(dst1, v1, sizeof (*dst1) * BUF_SIZE);
97 ref = call_ref(dst0, v2, v3, BUF_SIZE, mul);
98 val = call_new(dst1, v2, v3, BUF_SIZE, mul);
99 if (memcmp(dst0, dst1, sizeof (*dst0) * BUF_SIZE) != 0 || ref != val)
100 fail();
102 bench_new(v1, v2, v3, BUF_SIZE, mul);
105 report("scalarproduct_and_madd_int32");
108 void checkasm_check_llauddsp(void)
110 LLAudDSPContext c;
112 ff_llauddsp_init(&c);
113 check_scalarproduct_and_madd_int16(&c);
114 check_scalarproduct_and_madd_int32(&c);