FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/jpeg2000dsp.c
Date: 2024-05-04 02:01:39
Exec Total Coverage
Lines: 46 48 95.8%
Functions: 3 3 100.0%
Branches: 16 36 44.4%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2015 James Almer
3 *
4 * This file is part of FFmpeg.
5 *
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.
10 *
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.
15 *
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.
19 */
20
21 #include "checkasm.h"
22 #include "libavcodec/jpeg2000dsp.h"
23 #include "libavutil/common.h"
24 #include "libavutil/internal.h"
25 #include "libavutil/intreadwrite.h"
26 #include "libavutil/mem_internal.h"
27
28 #define BUF_SIZE 512
29
30 #define randomize_buffers() \
31 do { \
32 int i; \
33 for (i = 0; i < BUF_SIZE*3; i++) \
34 src[i] = rnd(); \
35 } while (0)
36
37 #define randomize_buffers_float() \
38 do { \
39 int i; \
40 for (i = 0; i < BUF_SIZE*3; i++) \
41 src[i] = (float)rnd() / (UINT_MAX >> 5); \
42 } while (0)
43
44 3 static void check_rct_int(void)
45 {
46 3 LOCAL_ALIGNED_32(int32_t, src, [BUF_SIZE*3]);
47 3 LOCAL_ALIGNED_32(int32_t, ref, [BUF_SIZE*3]);
48 3 LOCAL_ALIGNED_32(int32_t, new, [BUF_SIZE*3]);
49 3 int32_t *ref0 = &ref[BUF_SIZE*0], *new0 = &new[BUF_SIZE*0];
50 3 int32_t *ref1 = &ref[BUF_SIZE*1], *new1 = &new[BUF_SIZE*1];
51 3 int32_t *ref2 = &ref[BUF_SIZE*2], *new2 = &new[BUF_SIZE*2];
52
53 3 declare_func(void, void *src0, void *src1, void *src2, int csize);
54
55
2/2
✓ Branch 1 taken 4608 times.
✓ Branch 2 taken 3 times.
4611 randomize_buffers();
56 3 memcpy(ref, src, BUF_SIZE * 3 * sizeof(*src));
57 3 memcpy(new, src, BUF_SIZE * 3 * sizeof(*src));
58 3 call_ref(ref0, ref1, ref2, BUF_SIZE);
59 3 call_new(new0, new1, new2, BUF_SIZE);
60
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (memcmp(ref0, new0, BUF_SIZE * sizeof(*src)) ||
61
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 memcmp(ref1, new1, BUF_SIZE * sizeof(*src)) ||
62
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 memcmp(ref2, new2, BUF_SIZE * sizeof(*src)))
63 fail();
64 3 memcpy(new, src, BUF_SIZE * 3 * sizeof(*src));
65
1/8
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
3 bench_new(new0, new1, new2, BUF_SIZE);
66 3 }
67
68 4 static void check_ict_float(void)
69 {
70 4 LOCAL_ALIGNED_32(float, src, [BUF_SIZE*3]);
71 4 LOCAL_ALIGNED_32(float, ref, [BUF_SIZE*3]);
72 4 LOCAL_ALIGNED_32(float, new, [BUF_SIZE*3]);
73 4 float *ref0 = &ref[BUF_SIZE*0], *new0 = &new[BUF_SIZE*0];
74 4 float *ref1 = &ref[BUF_SIZE*1], *new1 = &new[BUF_SIZE*1];
75 4 float *ref2 = &ref[BUF_SIZE*2], *new2 = &new[BUF_SIZE*2];
76
77 4 declare_func(void, void *src0, void *src1, void *src2, int csize);
78
79
2/2
✓ Branch 1 taken 6144 times.
✓ Branch 2 taken 4 times.
6148 randomize_buffers_float();
80 4 memcpy(ref, src, BUF_SIZE * 3 * sizeof(*src));
81 4 memcpy(new, src, BUF_SIZE * 3 * sizeof(*src));
82 4 call_ref(ref0, ref1, ref2, BUF_SIZE);
83 4 call_new(new0, new1, new2, BUF_SIZE);
84
2/4
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
8 if (!float_near_abs_eps_array(ref0, new0, 1.0e-5, BUF_SIZE) ||
85
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 !float_near_abs_eps_array(ref1, new1, 1.0e-5, BUF_SIZE) ||
86 4 !float_near_abs_eps_array(ref2, new2, 1.0e-5, BUF_SIZE))
87 fail();
88 4 memcpy(new, src, BUF_SIZE * 3 * sizeof(*src));
89
1/8
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
4 bench_new(new0, new1, new2, BUF_SIZE);
90 4 }
91
92 13 void checkasm_check_jpeg2000dsp(void)
93 {
94 Jpeg2000DSPContext h;
95
96 13 ff_jpeg2000dsp_init(&h);
97
98
2/2
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
13 if (check_func(h.mct_decode[FF_DWT53], "jpeg2000_rct_int"))
99 3 check_rct_int();
100
2/2
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 9 times.
13 if (check_func(h.mct_decode[FF_DWT97], "jpeg2000_ict_float"))
101 4 check_ict_float();
102
103 13 report("mct_decode");
104 13 }
105