FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/blockdsp.c
Date: 2024-05-03 15:42:48
Exec Total Coverage
Lines: 24 25 96.0%
Functions: 2 2 100.0%
Branches: 20 44 45.5%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2015 Henrik Gramner
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/blockdsp.h"
26
27 #include "libavutil/common.h"
28 #include "libavutil/internal.h"
29 #include "libavutil/intreadwrite.h"
30 #include "libavutil/mem_internal.h"
31
32 typedef struct {
33 const char *name;
34 int size;
35 } test;
36
37 #define randomize_buffers(size) \
38 do { \
39 int i; \
40 for (i = 0; i < size; i++) { \
41 uint16_t r = rnd(); \
42 AV_WN16A(buf0 + i, r); \
43 AV_WN16A(buf1 + i, r); \
44 } \
45 } while (0)
46
47 #define check_clear(func, size) \
48 do { \
49 if (check_func(h.func, "blockdsp." #func)) { \
50 declare_func(void, int16_t *block); \
51 randomize_buffers(size); \
52 call_ref(buf0); \
53 call_new(buf1); \
54 if (memcmp(buf0, buf1, sizeof(*buf0) * size)) \
55 fail(); \
56 bench_new(buf0); \
57 } \
58 } while (0)
59
60 13 static void check_fill(BlockDSPContext *h){
61 13 const test tests[] = {
62 {"fill_block_tab[0]", 16},
63 {"fill_block_tab[1]", 8},
64 };
65 13 LOCAL_ALIGNED_32(uint8_t, buf0, [16 * 16]);
66 13 LOCAL_ALIGNED_32(uint8_t, buf1, [16 * 16]);
67
68
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 13 times.
39 for (size_t t = 0; t < FF_ARRAY_ELEMS(tests); ++t) {
69 26 int n = tests[t].size;
70 26 declare_func(void, uint8_t *block, uint8_t value,
71 ptrdiff_t line_size, int h);
72
2/2
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 24 times.
26 if (check_func(h->fill_block_tab[t], "blockdsp.%s", tests[t].name)) {
73 2 uint8_t value = rnd();
74
2/2
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 2 times.
26 randomize_buffers(tests[t].size);
75 2 call_ref(buf0, value, n, n);
76 2 call_new(buf1, value, n, n);
77
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (memcmp(buf0, buf1, sizeof(*buf0) * n * n))
78 fail();
79
1/8
✗ Branch 1 not taken.
✓ Branch 2 taken 2 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.
2 bench_new(buf0, value, n, n);
80 }
81 }
82 13 }
83
84 13 void checkasm_check_blockdsp(void)
85 {
86 13 LOCAL_ALIGNED_32(uint16_t, buf0, [6 * 8 * 8]);
87 13 LOCAL_ALIGNED_32(uint16_t, buf1, [6 * 8 * 8]);
88
89 BlockDSPContext h;
90
91 13 ff_blockdsp_init(&h);
92
93
6/14
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
✓ Branch 6 taken 192 times.
✓ Branch 7 taken 3 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 3 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 3 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
205 check_clear(clear_block, 8 * 8);
94
6/14
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
✓ Branch 6 taken 1152 times.
✓ Branch 7 taken 3 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 3 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 3 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
1165 check_clear(clear_blocks, 8 * 8 * 6);
95
96 13 check_fill(&h);
97
98 13 report("blockdsp");
99 13 }
100