avformat/mxfdec: Check edit unit for overflow in mxf_set_current_edit_unit()
[FFMpeg-mirror.git] / tests / checkasm / fdctdsp.c
blobc640a00656da14bc6bfd642a53890d104f82d292
1 /*
2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <string.h>
21 #include "checkasm.h"
23 #include "libavcodec/avcodec.h"
24 #include "libavcodec/fdctdsp.h"
26 #include "libavutil/common.h"
27 #include "libavutil/internal.h"
28 #include "libavutil/mem_internal.h"
30 static int int16_cmp_off_by_n(const int16_t *ref, const int16_t *test, size_t n, int accuracy)
32 for (size_t i = 0; i < n; i++) {
33 if (abs(ref[i] - test[i]) > accuracy)
34 return 1;
36 return 0;
39 static void check_fdct(void)
41 LOCAL_ALIGNED_16(int16_t, block0, [64]);
42 LOCAL_ALIGNED_16(int16_t, block1, [64]);
44 AVCodecContext avctx = {
45 .bits_per_raw_sample = 8,
46 .dct_algo = FF_DCT_AUTO,
48 FDCTDSPContext h;
50 ff_fdctdsp_init(&h, &avctx);
52 if (check_func(h.fdct, "fdct")) {
53 declare_func(void, int16_t *);
54 for (int i = 0; i < 64; i++) {
55 uint8_t r = rnd();
56 block0[i] = r;
57 block1[i] = r;
59 call_ref(block0);
60 call_new(block1);
61 if (int16_cmp_off_by_n(block0, block1, 64, 2))
62 fail();
63 bench_new(block1);
67 void checkasm_check_fdctdsp(void)
69 check_fdct();
70 report("fdctdsp");