FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/exrdsp.c
Date: 2024-05-03 15:42:48
Exec Total Coverage
Lines: 37 39 94.9%
Functions: 3 3 100.0%
Branches: 12 28 42.9%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2017 James Almer
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 #include "libavcodec/defs.h"
25 #include "libavcodec/exrdsp.h"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/mem_internal.h"
28
29 #define BUF_SIZE 5120
30 #define PADDED_BUF_SIZE BUF_SIZE+AV_INPUT_BUFFER_PADDING_SIZE*2
31
32 #define randomize_buffers() \
33 do { \
34 int i; \
35 for (i = 0; i < BUF_SIZE; i += 4) { \
36 uint32_t r = rnd(); \
37 AV_WN32A(src + i, r); \
38 } \
39 } while (0)
40
41 3 static void check_reorder_pixels(void) {
42 3 LOCAL_ALIGNED_32(uint8_t, src, [PADDED_BUF_SIZE]);
43 3 LOCAL_ALIGNED_32(uint8_t, dst_ref, [PADDED_BUF_SIZE]);
44 3 LOCAL_ALIGNED_32(uint8_t, dst_new, [PADDED_BUF_SIZE]);
45
46 3 declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t size);
47
48 3 memset(src, 0, PADDED_BUF_SIZE);
49 3 memset(dst_ref, 0, PADDED_BUF_SIZE);
50 3 memset(dst_new, 0, PADDED_BUF_SIZE);
51
2/2
✓ Branch 1 taken 3840 times.
✓ Branch 2 taken 3 times.
3843 randomize_buffers();
52 3 call_ref(dst_ref, src, BUF_SIZE);
53 3 call_new(dst_new, src, BUF_SIZE);
54
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (memcmp(dst_ref, dst_new, BUF_SIZE))
55 fail();
56
1/8
✗ Branch 1 not taken.
✓ Branch 2 taken 3 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.
3 bench_new(dst_new, src, BUF_SIZE);
57 3 }
58
59 4 static void check_predictor(void) {
60 4 LOCAL_ALIGNED_32(uint8_t, src, [PADDED_BUF_SIZE]);
61 4 LOCAL_ALIGNED_32(uint8_t, dst_ref, [PADDED_BUF_SIZE]);
62 4 LOCAL_ALIGNED_32(uint8_t, dst_new, [PADDED_BUF_SIZE]);
63
64 4 declare_func(void, uint8_t *src, ptrdiff_t size);
65
66 4 memset(src, 0, PADDED_BUF_SIZE);
67
2/2
✓ Branch 1 taken 5120 times.
✓ Branch 2 taken 4 times.
5124 randomize_buffers();
68 4 memcpy(dst_ref, src, PADDED_BUF_SIZE);
69 4 memcpy(dst_new, src, PADDED_BUF_SIZE);
70 4 call_ref(dst_ref, BUF_SIZE);
71 4 call_new(dst_new, BUF_SIZE);
72
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (memcmp(dst_ref, dst_new, BUF_SIZE))
73 fail();
74
1/8
✗ Branch 1 not taken.
✓ Branch 2 taken 4 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.
4 bench_new(dst_new, BUF_SIZE);
75 4 }
76
77 13 void checkasm_check_exrdsp(void)
78 {
79 ExrDSPContext h;
80
81 13 ff_exrdsp_init(&h);
82
83
2/2
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
13 if (check_func(h.reorder_pixels, "reorder_pixels"))
84 3 check_reorder_pixels();
85
86 13 report("reorder_pixels");
87
88
2/2
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 9 times.
13 if (check_func(h.predictor, "predictor"))
89 4 check_predictor();
90
91 13 report("predictor");
92 13 }
93