FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/pixblockdsp.c
Date: 2024-05-04 02:01:39
Exec Total Coverage
Lines: 22 22 100.0%
Functions: 1 1 100.0%
Branches: 38 76 50.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2015 Tiancheng "Timothy" Gu
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/pixblockdsp.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_UNITS 8
30 #define BUF_SIZE (BUF_UNITS * 128 + 8 * BUF_UNITS)
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(src10 + i, r); \
38 AV_WN32A(src11 + i, r); \
39 r = rnd(); \
40 AV_WN32A(src20 + i, r); \
41 AV_WN32A(src21 + i, r); \
42 r = rnd(); \
43 AV_WN32A(dst0_ + i, r); \
44 AV_WN32A(dst1_ + i, r); \
45 } \
46 } while (0)
47
48 #define check_get_pixels(type, aligned) \
49 do { \
50 int i; \
51 declare_func(void, int16_t *block, const uint8_t *pixels, ptrdiff_t line_size); \
52 \
53 for (i = 0; i < BUF_UNITS; i++) { \
54 int src_offset = i * 64 * sizeof(type) + (aligned ? 8 : 1) * i; \
55 int dst_offset = i * 64; /* dst must be aligned */ \
56 randomize_buffers(); \
57 call_ref(dst0 + dst_offset, src10 + src_offset, 8); \
58 call_new(dst1 + dst_offset, src11 + src_offset, 8); \
59 if (memcmp(src10, src11, BUF_SIZE)|| memcmp(dst0, dst1, BUF_SIZE)) \
60 fail(); \
61 bench_new(dst1 + dst_offset, src11 + src_offset, 8); \
62 } \
63 } while (0)
64
65 #define check_diff_pixels(type, aligned) \
66 do { \
67 int i; \
68 declare_func(void, int16_t *restrict block, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride); \
69 \
70 for (i = 0; i < BUF_UNITS; i++) { \
71 int src_offset = i * 64 * sizeof(type) + (aligned ? 8 : 1) * i; \
72 int dst_offset = i * 64; /* dst must be aligned */ \
73 randomize_buffers(); \
74 call_ref(dst0 + dst_offset, src10 + src_offset, src20 + src_offset, 8); \
75 call_new(dst1 + dst_offset, src11 + src_offset, src21 + src_offset, 8); \
76 if (memcmp(src10, src11, BUF_SIZE) || memcmp(src20, src21, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE)) \
77 fail(); \
78 bench_new(dst1 + dst_offset, src11 + src_offset, src21 + src_offset, 8); \
79 } \
80 } while (0)
81
82 13 void checkasm_check_pixblockdsp(void)
83 {
84 13 LOCAL_ALIGNED_16(uint8_t, src10, [BUF_SIZE]);
85 13 LOCAL_ALIGNED_16(uint8_t, src11, [BUF_SIZE]);
86 13 LOCAL_ALIGNED_16(uint8_t, src20, [BUF_SIZE]);
87 13 LOCAL_ALIGNED_16(uint8_t, src21, [BUF_SIZE]);
88 13 LOCAL_ALIGNED_16(uint8_t, dst0_, [BUF_SIZE]);
89 13 LOCAL_ALIGNED_16(uint8_t, dst1_, [BUF_SIZE]);
90 13 uint16_t *dst0 = (uint16_t *)dst0_;
91 13 uint16_t *dst1 = (uint16_t *)dst1_;
92 PixblockDSPContext h;
93 13 AVCodecContext avctx = {
94 .bits_per_raw_sample = 8,
95 };
96
97 13 ff_pixblockdsp_init(&h, &avctx);
98
99
2/2
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
13 if (check_func(h.get_pixels, "get_pixels"))
100
7/16
✓ Branch 3 taken 4352 times.
✓ Branch 4 taken 16 times.
✓ Branch 12 taken 16 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 16 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 16 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 2 times.
4370 check_get_pixels(uint8_t, 1);
101
2/2
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
13 if (check_func(h.get_pixels_unaligned, "get_pixels_unaligned"))
102
7/16
✓ Branch 3 taken 4352 times.
✓ Branch 4 taken 16 times.
✓ Branch 12 taken 16 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 16 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 16 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 2 times.
4370 check_get_pixels(uint8_t, 0);
103
104 13 report("get_pixels");
105
106
2/2
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
13 if (check_func(h.diff_pixels, "diff_pixels"))
107
8/18
✓ Branch 3 taken 4352 times.
✓ Branch 4 taken 16 times.
✓ Branch 12 taken 16 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 16 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 16 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 16 times.
✓ Branch 40 taken 2 times.
4370 check_diff_pixels(uint8_t, 1);
108
2/2
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
13 if (check_func(h.diff_pixels_unaligned, "diff_pixels_unaligned"))
109
8/18
✓ Branch 3 taken 4352 times.
✓ Branch 4 taken 16 times.
✓ Branch 12 taken 16 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 16 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 16 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 16 times.
✓ Branch 40 taken 2 times.
4370 check_diff_pixels(uint8_t, 0);
110
111 13 report("diff_pixels");
112 13 }
113