Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2015 Janne Grunau | ||
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 <math.h> | ||
22 | #include <stdint.h> | ||
23 | #include <string.h> | ||
24 | |||
25 | #include "libavutil/internal.h" | ||
26 | #include "libavutil/common.h" | ||
27 | #include "libavutil/mem_internal.h" | ||
28 | |||
29 | #include "libavcodec/fmtconvert.h" | ||
30 | |||
31 | #include "checkasm.h" | ||
32 | |||
33 | #define BUF_SIZE 1024 | ||
34 | |||
35 | #define randomize_input(len) \ | ||
36 | do { \ | ||
37 | int k; \ | ||
38 | for (k = 0; k < len; k++) { \ | ||
39 | in[k] = rnd() - INT32_MAX; \ | ||
40 | } \ | ||
41 | for ( ; k < BUF_SIZE; k++) { \ | ||
42 | in[k] = INT32_MAX; \ | ||
43 | } \ | ||
44 | } while (0) | ||
45 | |||
46 | 13 | void checkasm_check_fmtconvert(void) | |
47 | { | ||
48 | FmtConvertContext c; | ||
49 | 13 | LOCAL_ALIGNED(32, float, dst0, [BUF_SIZE]); | |
50 | 13 | LOCAL_ALIGNED(32, float, dst1, [BUF_SIZE]); | |
51 | 13 | LOCAL_ALIGNED(32, int32_t, in, [BUF_SIZE]); | |
52 | float scale_arr[128]; | ||
53 | 13 | int length[] = {8, 16, 24, 56, 72, 128, 512, 520, 656, 768, 992}; | |
54 | int i, j; | ||
55 | |||
56 |
2/2✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 13 times.
|
1677 | for (i = 0; i < FF_ARRAY_ELEMS(scale_arr); i++) |
57 | 1664 | scale_arr[i] = (FF_ARRAY_ELEMS(scale_arr) - FF_ARRAY_ELEMS(scale_arr) / 2) / 13; | |
58 | |||
59 | 13 | ff_fmt_convert_init(&c); | |
60 | |||
61 | 13 | memset(dst0, 0, sizeof(*dst0) * BUF_SIZE); | |
62 | 13 | memset(dst1, 0, sizeof(*dst1) * BUF_SIZE); | |
63 | |||
64 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
|
13 | if (check_func(c.int32_to_float_fmul_scalar, "int32_to_float_fmul_scalar")) { |
65 | 2 | declare_func(void, float *, const int32_t *, float, int); | |
66 | |||
67 |
2/2✓ Branch 0 taken 256 times.
✓ Branch 1 taken 2 times.
|
258 | for (i = 0; i < FF_ARRAY_ELEMS(scale_arr); i++) { |
68 |
2/2✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 256 times.
|
3072 | for (j = 0; j < FF_ARRAY_ELEMS(length); j++) { |
69 | |||
70 |
4/4✓ Branch 1 taken 960512 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 1923072 times.
✓ Branch 4 taken 2816 times.
|
2886400 | randomize_input(length[j]); |
71 | |||
72 | 2816 | call_ref(dst0, in, scale_arr[i], length[j]); | |
73 | 2816 | call_new(dst1, in, scale_arr[i], length[j]); | |
74 | |||
75 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2816 times.
|
2816 | if (!float_near_ulp_array(dst0, dst1, 3, length[j])) { |
76 | ✗ | fail(); | |
77 | ✗ | break; | |
78 | } | ||
79 | |||
80 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 2816 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.
|
2816 | bench_new(dst1, in, scale_arr[i], length[j]); |
81 | } | ||
82 | } | ||
83 | } | ||
84 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
|
13 | if (check_func(c.int32_to_float_fmul_array8, "int32_to_float_fmul_array8")) { |
85 | 2 | declare_func(void, FmtConvertContext *, float *, const int32_t *, | |
86 | const float *, int); | ||
87 | |||
88 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
|
10 | for (i = 0; i < 4; i++) { |
89 |
2/2✓ Branch 0 taken 88 times.
✓ Branch 1 taken 8 times.
|
96 | for (j = 0; j < FF_ARRAY_ELEMS(length); j++) { |
90 | |||
91 |
4/4✓ Branch 1 taken 30016 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 60096 times.
✓ Branch 4 taken 88 times.
|
90200 | randomize_input(length[j]); |
92 | |||
93 | 88 | call_ref(&c, dst0, in, scale_arr, length[j]); | |
94 | 88 | call_new(&c, dst1, in, scale_arr, length[j]); | |
95 | |||
96 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
|
88 | if (!float_near_ulp_array(dst0, dst1, 3, length[j])) { |
97 | ✗ | fail(); | |
98 | ✗ | fprintf(stderr, "int32_to_float_fmul_array8: len: %d\n", length[j]); | |
99 | ✗ | break; | |
100 | } | ||
101 | |||
102 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 88 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.
|
88 | bench_new(&c, dst1, in, scale_arr, length[j]); |
103 | } | ||
104 | } | ||
105 | } | ||
106 | 13 | report("fmtconvert"); | |
107 | 13 | } | |
108 |