FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/scene_sad.c
Date: 2025-07-28 20:30:09
Exec Total Coverage
Lines: 24 26 92.3%
Functions: 2 2 100.0%
Branches: 19 28 67.9%

Line Branch Exec Source
1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #include "checkasm.h"
20 #include "libavfilter/scene_sad.h"
21 #include "libavutil/mem_internal.h"
22
23 #define WIDTH 256
24 #define HEIGHT 256
25 #define STRIDE WIDTH
26
27 #define randomize_buffers(type, buf, size, mask) \
28 do { \
29 int j; \
30 type *tmp_buf = (type *) buf; \
31 for (j = 0; j < size; j++) \
32 tmp_buf[j] = rnd() & mask; \
33 } while (0)
34
35 78 static void check_scene_sad(int depth)
36 {
37 78 LOCAL_ALIGNED_32(uint8_t, src1, [WIDTH * HEIGHT * 2]);
38 78 LOCAL_ALIGNED_32(uint8_t, src2, [WIDTH * HEIGHT * 2]);
39 78 declare_func(void, const uint8_t *src1, ptrdiff_t stride1,
40 const uint8_t *src2, ptrdiff_t stride2,
41 ptrdiff_t width, ptrdiff_t height, uint64_t *sum);
42
43
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 13 times.
78 const int width = WIDTH >> (depth > 8);
44 78 int mask = (1 << depth) - 1;
45
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 65 times.
78 if (depth <= 8) {
46
2/2
✓ Branch 1 taken 851968 times.
✓ Branch 2 taken 13 times.
851981 randomize_buffers(uint8_t, src1, width * HEIGHT, mask);
47
2/2
✓ Branch 1 taken 851968 times.
✓ Branch 2 taken 13 times.
851981 randomize_buffers(uint8_t, src2, width * HEIGHT, mask);
48
1/2
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
65 } else if (depth <= 16) {
49
2/2
✓ Branch 1 taken 2129920 times.
✓ Branch 2 taken 65 times.
2129985 randomize_buffers(uint16_t, src1, width * HEIGHT, mask);
50
2/2
✓ Branch 1 taken 2129920 times.
✓ Branch 2 taken 65 times.
2129985 randomize_buffers(uint16_t, src2, width * HEIGHT, mask);
51 }
52
53
2/2
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 66 times.
78 if (check_func(ff_scene_sad_get_fn(depth), "scene_sad%d", depth)) {
54 uint64_t sum1, sum2;
55 12 call_ref(src1, STRIDE, src2, STRIDE, width, HEIGHT, &sum1);
56 12 call_new(src1, STRIDE, src2, STRIDE, width, HEIGHT, &sum2);
57
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (sum1 != sum2) {
58 fprintf(stderr, "scene_sad%d: sum mismatch: %llu != %llu\n",
59 depth, (unsigned long long) sum1, (unsigned long long) sum2);
60 fail();
61 }
62
1/8
✗ Branch 1 not taken.
✓ Branch 2 taken 12 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.
12 bench_new(src1, STRIDE, src2, STRIDE, WIDTH, HEIGHT, &sum2);
63 }
64 78 }
65
66 13 void checkasm_check_scene_sad(void)
67 {
68 13 const int depths[] = { 8, 10, 12, 14, 15, 16 };
69
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 13 times.
91 for (int i = 0; i < FF_ARRAY_ELEMS(depths); i++) {
70 78 check_scene_sad(depths[i]);
71 78 report("scene_sad%d", depths[i]);
72 }
73 13 }
74