FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/bswapdsp.c
Date: 2024-05-03 15:42:48
Exec Total Coverage
Lines: 12 12 100.0%
Functions: 1 1 100.0%
Branches: 18 36 50.0%

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 #include "checkasm.h"
23 #include "libavcodec/bswapdsp.h"
24 #include "libavutil/common.h"
25 #include "libavutil/internal.h"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/mem_internal.h"
28
29 #define BUF_SIZE 512
30
31 #define randomize_buffers() \
32 do { \
33 int i; \
34 for (i = 0; i < BUF_SIZE; i += 4) { \
35 uint32_t r = rnd(); \
36 AV_WN32A(src0 + i, r); \
37 AV_WN32A(src1 + i, r); \
38 r = rnd(); \
39 AV_WN32A(dst0 + i, r); \
40 AV_WN32A(dst1 + i, r); \
41 } \
42 } while (0)
43
44 #define check_bswap(type) \
45 do { \
46 int w; \
47 declare_func(void, type *dst, const type *src, int w); \
48 \
49 for (w = 0; w < BUF_SIZE / sizeof(type); w++) { \
50 int offset = (BUF_SIZE / sizeof(type) - w) & 15; /* Test various alignments */ \
51 randomize_buffers(); \
52 call_ref((type *)dst0 + offset, (type *)src0 + offset, w); \
53 call_new((type *)dst1 + offset, (type *)src1 + offset, w); \
54 if (memcmp(src0, src1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE)) \
55 fail(); \
56 bench_new((type *)dst1 + offset, (type *)src1 + offset, w); \
57 } \
58 } while (0)
59
60 13 void checkasm_check_bswapdsp(void)
61 {
62 13 LOCAL_ALIGNED_16(uint8_t, src0, [BUF_SIZE]);
63 13 LOCAL_ALIGNED_16(uint8_t, src1, [BUF_SIZE]);
64 13 LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
65 13 LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
66 BswapDSPContext h;
67
68 13 ff_bswapdsp_init(&h);
69
70
2/2
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 9 times.
13 if (check_func(h.bswap_buf, "bswap_buf"))
71
7/16
✓ Branch 2 taken 65536 times.
✓ Branch 3 taken 512 times.
✓ Branch 11 taken 512 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 512 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 512 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✓ Branch 36 taken 512 times.
✓ Branch 37 taken 4 times.
66052 check_bswap(uint32_t);
72
73
2/2
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 12 times.
13 if (check_func(h.bswap16_buf, "bswap16_buf"))
74
7/16
✓ Branch 2 taken 32768 times.
✓ Branch 3 taken 256 times.
✓ Branch 11 taken 256 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 256 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 256 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✓ Branch 36 taken 256 times.
✓ Branch 37 taken 1 times.
33025 check_bswap(uint16_t);
75
76 13 report("bswap");
77 13 }
78