FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/diracdsp.c
Date: 2026-08-29 16:27:19
Exec Total Coverage
Lines: 25 26 96.2%
Functions: 2 2 100.0%
Branches: 11 30 36.7%

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