FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/h264qpel.c
Date: 2024-09-07 18:49:03
Exec Total Coverage
Lines: 22 23 95.7%
Functions: 1 1 100.0%
Branches: 23 32 71.9%

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 #define src0 (buf0 + 3 * 2 * 16) /* h264qpel functions read data from negative src pointer offsets */
49 #define src1 (buf1 + 3 * 2 * 16)
50
51 13 void checkasm_check_h264qpel(void)
52 {
53 13 LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]);
54 13 LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]);
55 13 LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
56 13 LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
57 H264QpelContext h;
58 int op, bit_depth, i, j;
59
2/2
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 times.
13 declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, const uint8_t *src, ptrdiff_t stride);
60
61
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 13 times.
39 for (op = 0; op < 2; op++) {
62
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 qpel_mc_func (*tab)[16] = op ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab;
63
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 const char *op_name = op ? "avg" : "put";
64
65
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 26 times.
104 for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
66 78 ff_h264qpel_init(&h, bit_depth);
67
4/4
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 273 times.
✓ Branch 3 taken 78 times.
351 for (i = 0; i < (op ? 3 : 4); i++) {
68 273 int size = 16 >> i;
69
2/2
✓ Branch 0 taken 4368 times.
✓ Branch 1 taken 273 times.
4641 for (j = 0; j < 16; j++)
70
2/2
✓ Branch 3 taken 600 times.
✓ Branch 4 taken 3768 times.
4368 if (check_func(tab[i][j], "%s_h264_qpel_%d_mc%d%d_%d", op_name, size, j & 3, j >> 2, bit_depth)) {
71
2/2
✓ Branch 2 taken 110400 times.
✓ Branch 3 taken 600 times.
111000 randomize_buffers();
72 600 call_ref(dst0, src0, size * SIZEOF_PIXEL);
73 600 call_new(dst1, src1, size * SIZEOF_PIXEL);
74
2/4
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 600 times.
600 if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE))
75 fail();
76
1/8
✗ Branch 1 not taken.
✓ Branch 2 taken 600 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.
600 bench_new(dst1, src1, size * SIZEOF_PIXEL);
77 }
78 }
79 }
80 26 report("%s", op_name);
81 }
82 13 }
83