FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/blockdsp.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 26 27 96.3%
Functions: 2 2 100.0%
Branches: 18 42 42.9%

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 #define randomize_buffers(size) \
33 do { \
34 int i; \
35 for (i = 0; i < size; i++) { \
36 uint16_t r = rnd(); \
37 AV_WN16A(buf0 + i, r); \
38 AV_WN16A(buf1 + i, r); \
39 } \
40 } while (0)
41
42 #define check_clear(func, size) \
43 do { \
44 if (check_func(h.func, "blockdsp." #func)) { \
45 declare_func(void, int16_t *block); \
46 randomize_buffers(size); \
47 call_ref(buf0); \
48 call_new(buf1); \
49 if (memcmp(buf0, buf1, sizeof(*buf0) * size)) \
50 fail(); \
51 bench_new(buf0); \
52 } \
53 } while (0)
54
55 13 static void check_fill(BlockDSPContext *h){
56 13 LOCAL_ALIGNED_16(uint8_t, buf0_16, [16 * 16]);
57 13 LOCAL_ALIGNED_16(uint8_t, buf1_16, [16 * 16]);
58
59
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 13 times.
39 for (int t = 0; t < 2; ++t) {
60 26 uint8_t *buf0 = buf0_16 + t * /* force 8 byte alignment */ 8;
61 26 uint8_t *buf1 = buf1_16 + t * /* force 8 byte alignment */ 8;
62 26 int n = 16 - 8 * t;
63 26 declare_func(void, uint8_t *block, uint8_t value,
64 ptrdiff_t line_size, int h);
65
2/2
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 20 times.
26 if (check_func(h->fill_block_tab[t], "blockdsp.fill_block_tab[%d]", t)) {
66 6 uint8_t value = rnd();
67 6 memset(buf0, 0, sizeof(*buf0) * n * n);
68 6 memset(buf1, 0, sizeof(*buf1) * n * n);
69 6 call_ref(buf0, value, n, n);
70 6 call_new(buf1, value, n, n);
71
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (memcmp(buf0, buf1, sizeof(*buf0) * n * n))
72 fail();
73
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(buf0, value, n, n);
74 }
75 }
76 13 }
77
78 13 void checkasm_check_blockdsp(void)
79 {
80 13 LOCAL_ALIGNED_32(uint16_t, buf0, [6 * 8 * 8]);
81 13 LOCAL_ALIGNED_32(uint16_t, buf1, [6 * 8 * 8]);
82
83 BlockDSPContext h;
84
85 13 ff_blockdsp_init(&h);
86
87
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);
88
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);
89
90 13 check_fill(&h);
91
92 13 report("blockdsp");
93 13 }
94