FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/h264qpel.c
Date: 2026-10-31 18:41:55
Exec Total Coverage
Lines: 37 40 92.5%
Functions: 2 2 100.0%
Branches: 31 54 57.4%

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/h264qpel.h"
24 #include "libavutil/common.h"
25 #include "libavutil/internal.h"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/mem_internal.h"
28
29 static const uint32_t pixel_mask[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff };
30
31 #define SIZEOF_PIXEL ((bit_depth + 7) / 8)
32 #define BUF_SIZE (2 * 16 * (16 + 3 + 4))
33
34 #define randomize_buffers() \
35 do { \
36 uint32_t mask = pixel_mask[bit_depth - 8]; \
37 int k; \
38 for (k = 0; k < BUF_SIZE; k += 4) { \
39 uint32_t r = rnd() & mask; \
40 AV_WN32A(buf0 + k, r); \
41 AV_WN32A(buf1 + k, r); \
42 r = rnd(); \
43 AV_WN32A(dst0 + k, r); \
44 AV_WN32A(dst1 + k, r); \
45 } \
46 } while (0)
47
48 /* 0/max stripes with period 3 in both directions take the centre filter's
49 * intermediate sums to their extremes; phase covers every column offset
50 * and both polarities */
51 6312 static void fill_stripes(uint8_t *buf0, uint8_t *buf1, int width, int bit_depth, int phase)
52 {
53 6312 int max = (1 << bit_depth) - 1;
54
2/2
✓ Branch 0 taken 3320832 times.
✓ Branch 1 taken 6312 times.
3327144 for (int k = 0; k < BUF_SIZE / SIZEOF_PIXEL; k++) {
55 3320832 int x = k % width, y = k / width;
56
2/2
✓ Branch 0 taken 1660416 times.
✓ Branch 1 taken 1660416 times.
3320832 int v = ((y % 3 == 1) ^ ("010010"[(x + phase) % 6] - '0') ^ (phase >= 6)) ? max : 0;
57
2/2
✓ Branch 0 taken 1996032 times.
✓ Branch 1 taken 1324800 times.
3320832 if (bit_depth == 8) {
58 1996032 buf0[k] = buf1[k] = v;
59 } else {
60 1324800 AV_WN16A(buf0 + 2 * k, v);
61 1324800 AV_WN16A(buf1 + 2 * k, v);
62 }
63 }
64 6312 }
65
66 #define src0 (buf0 + 3 * 2 * 16) /* h264qpel functions read data from negative src pointer offsets */
67 #define src1 (buf1 + 3 * 2 * 16)
68
69 14 void checkasm_check_h264qpel(void)
70 {
71 14 LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]);
72 14 LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]);
73 14 LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
74 14 LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
75 H264QpelContext h;
76 int op, bit_depth, i, j;
77 14 declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t stride);
78
79
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 14 times.
42 for (op = 0; op < 2; op++) {
80
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 qpel_mc_func (*tab)[16] = op ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab;
81
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 const char *op_name = op ? "avg" : "put";
82
83
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
84 84 ff_h264qpel_init(&h, bit_depth);
85
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 84 times.
336 for (i = 0; i < 3; i++) {
86 252 int size = 16 >> i;
87
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 252 times.
4284 for (j = 0; j < 16; j++)
88
2/2
✓ Branch 1 taken 526 times.
✓ Branch 2 taken 3506 times.
4032 if (check_func(tab[i][j], "%s_h264_qpel_%d_mc%d%d_%d", op_name, size, j & 3, j >> 2, bit_depth)) {
89
2/2
✓ Branch 2 taken 96784 times.
✓ Branch 3 taken 526 times.
97310 randomize_buffers();
90
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 526 times.
526 call_ref(dst0, src0, size * SIZEOF_PIXEL);
91 526 call_new(dst1, src1, size * SIZEOF_PIXEL);
92
2/4
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 526 times.
526 if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE))
93 ✗ fail();
94
2/2
✓ Branch 0 taken 6312 times.
✓ Branch 1 taken 526 times.
6838 for (int phase = 0; phase < 12; phase++) {
95 6312 fill_stripes(buf0, buf1, size, bit_depth, phase);
96
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 6312 times.
6312 call_ref(dst0, src0, size * SIZEOF_PIXEL);
97 6312 call_new(dst1, src1, size * SIZEOF_PIXEL);
98
2/4
✓ Branch 0 taken 6312 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6312 times.
6312 if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE)) {
99 ✗ fail();
100 ✗ break;
101 }
102 }
103
1/18
✗ Branch 1 not taken.
✓ Branch 2 taken 526 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
526 bench_new(dst1, src1, size * SIZEOF_PIXEL);
104 }
105 }
106 }
107 28 report("%s", op_name);
108 }
109 14 }
110