FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavutil/x86/pixelutils.h
Date: 2026-05-03 23:58:45
Exec Total Coverage
Lines: 16 16 100.0%
Functions: 1 1 100.0%
Branches: 13 16 81.2%

Line Branch Exec Source
1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (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 GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef AVUTIL_X86_PIXELUTILS_H
20 #define AVUTIL_X86_PIXELUTILS_H
21
22 #include <stddef.h>
23 #include <stdint.h>
24
25 #include "config.h"
26
27 #include "cpu.h"
28 #include "libavutil/attributes.h"
29 #include "libavutil/pixelutils.h"
30
31 int ff_pixelutils_sad_8x8_sse2(const uint8_t *src1, ptrdiff_t stride1,
32 const uint8_t *src2, ptrdiff_t stride2);
33
34 int ff_pixelutils_sad_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1,
35 const uint8_t *src2, ptrdiff_t stride2);
36 int ff_pixelutils_sad_a_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1,
37 const uint8_t *src2, ptrdiff_t stride2);
38 int ff_pixelutils_sad_u_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1,
39 const uint8_t *src2, ptrdiff_t stride2);
40
41 int ff_pixelutils_sad_32x32_sse2(const uint8_t *src1, ptrdiff_t stride1,
42 const uint8_t *src2, ptrdiff_t stride2);
43 int ff_pixelutils_sad_a_32x32_sse2(const uint8_t *src1, ptrdiff_t stride1,
44 const uint8_t *src2, ptrdiff_t stride2);
45 int ff_pixelutils_sad_u_32x32_sse2(const uint8_t *src1, ptrdiff_t stride1,
46 const uint8_t *src2, ptrdiff_t stride2);
47
48 int ff_pixelutils_sad_32x32_avx2(const uint8_t *src1, ptrdiff_t stride1,
49 const uint8_t *src2, ptrdiff_t stride2);
50
51 280 static inline av_cold void ff_pixelutils_sad_init_x86(av_pixelutils_sad_fn *sad, int aligned)
52 {
53 280 int cpu_flags = av_get_cpu_flags();
54
55
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 70 times.
280 if (EXTERNAL_SSE2(cpu_flags)) {
56 210 sad[2] = ff_pixelutils_sad_8x8_sse2;
57
3/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
210 switch (aligned) {
58 70 case 0: sad[3] = ff_pixelutils_sad_16x16_sse2; break; // src1 unaligned, src2 unaligned
59 70 case 1: sad[3] = ff_pixelutils_sad_u_16x16_sse2; break; // src1 aligned, src2 unaligned
60 70 case 2: sad[3] = ff_pixelutils_sad_a_16x16_sse2; break; // src1 aligned, src2 aligned
61 }
62 }
63
64
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 70 times.
280 if (EXTERNAL_SSE2(cpu_flags)) {
65
3/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
210 switch (aligned) {
66 70 case 0: sad[4] = ff_pixelutils_sad_32x32_sse2; break; // src1 unaligned, src2 unaligned
67 70 case 1: sad[4] = ff_pixelutils_sad_u_32x32_sse2; break; // src1 aligned, src2 unaligned
68 70 case 2: sad[4] = ff_pixelutils_sad_a_32x32_sse2; break; // src1 aligned, src2 aligned
69 }
70 }
71
72 #if HAVE_AVX2_EXTERNAL
73
3/4
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
280 if (EXTERNAL_AVX2_FAST(cpu_flags)) {
74 75 sad[4] = ff_pixelutils_sad_32x32_avx2;
75 }
76 #endif
77 280 }
78 #endif
79