Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2024 Kyosuke Kawakami | ||
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 | |||
23 | #include "libavcodec/diracdsp.h" | ||
24 | |||
25 | #include "libavutil/intreadwrite.h" | ||
26 | #include "libavutil/mem_internal.h" | ||
27 | |||
28 | #define RANDOMIZE_DESTS(name, size) \ | ||
29 | do { \ | ||
30 | int i; \ | ||
31 | for (i = 0; i < size; ++i) { \ | ||
32 | uint16_t r = rnd(); \ | ||
33 | AV_WN16A(name##0 + i, r); \ | ||
34 | AV_WN16A(name##1 + i, r); \ | ||
35 | } \ | ||
36 | } while (0) | ||
37 | |||
38 | #define RANDOMIZE_BUFFER8(name, size) \ | ||
39 | do { \ | ||
40 | int i; \ | ||
41 | for (i = 0; i < size; ++i) { \ | ||
42 | uint8_t r = rnd(); \ | ||
43 | name[i] = r; \ | ||
44 | } \ | ||
45 | } while (0) | ||
46 | |||
47 | #define OBMC_STRIDE 32 | ||
48 | #define XBLEN_MAX 32 | ||
49 | #define YBLEN_MAX 64 | ||
50 | |||
51 | 39 | static void check_add_obmc(size_t func_index, int xblen) | |
52 | { | ||
53 | 39 | LOCAL_ALIGNED_16(uint8_t, src, [XBLEN_MAX * YBLEN_MAX]); | |
54 | 39 | LOCAL_ALIGNED_16(uint16_t, _dst0, [XBLEN_MAX * YBLEN_MAX + 4]); | |
55 | 39 | LOCAL_ALIGNED_16(uint16_t, _dst1, [XBLEN_MAX * YBLEN_MAX + 4]); | |
56 | 39 | LOCAL_ALIGNED_16(uint8_t, obmc_weight, [XBLEN_MAX * YBLEN_MAX]); | |
57 | |||
58 | // Ensure that they accept unaligned buffer. | ||
59 | // Not using LOCAL_ALIGNED_8 because it might make 16 byte aligned buffer. | ||
60 | 39 | uint16_t *dst0 = _dst0 + 4; | |
61 | 39 | uint16_t *dst1 = _dst1 + 4; | |
62 | |||
63 | int yblen; | ||
64 | DiracDSPContext h; | ||
65 | |||
66 | 39 | ff_diracdsp_init(&h); | |
67 | |||
68 |
2/2✓ Branch 3 taken 6 times.
✓ Branch 4 taken 33 times.
|
39 | if (check_func(h.add_dirac_obmc[func_index], "diracdsp.add_dirac_obmc_%d", xblen)) { |
69 | 6 | declare_func(void, uint16_t*, const uint8_t*, int, const uint8_t *, int); | |
70 | |||
71 |
2/2✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 6 times.
|
7174 | RANDOMIZE_BUFFER8(src, YBLEN_MAX * xblen); |
72 |
2/2✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 6 times.
|
7174 | RANDOMIZE_DESTS(dst, YBLEN_MAX * xblen); |
73 |
2/2✓ Branch 1 taken 12288 times.
✓ Branch 2 taken 6 times.
|
12294 | RANDOMIZE_BUFFER8(obmc_weight, YBLEN_MAX * OBMC_STRIDE); |
74 | |||
75 | 6 | yblen = 1 + (rnd() % YBLEN_MAX); | |
76 | 6 | call_ref(dst0, src, xblen, obmc_weight, yblen); | |
77 | 6 | call_new(dst1, src, xblen, obmc_weight, yblen); | |
78 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (memcmp(dst0, dst1, yblen * xblen)) |
79 | ✗ | fail(); | |
80 | |||
81 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 6 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.
|
6 | bench_new(dst1, src, xblen, obmc_weight, YBLEN_MAX); |
82 | } | ||
83 | 39 | } | |
84 | |||
85 | 13 | void checkasm_check_diracdsp(void) | |
86 | { | ||
87 | 13 | check_add_obmc(0, 8); | |
88 | 13 | check_add_obmc(1, 16); | |
89 | 13 | check_add_obmc(2, 32); | |
90 | 13 | report("diracdsp"); | |
91 | 13 | } | |
92 |