FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/x86/hpeldsp_init.c
Date: 2026-08-28 22:32:55
Exec Total Coverage
Lines: 44 44 100.0%
Functions: 3 3 100.0%
Branches: 6 6 100.0%

Line Branch Exec Source
1 /*
2 * SIMD-optimized halfpel functions
3 * Copyright (c) 2000, 2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
23 */
24
25 #include <stddef.h>
26 #include <stdint.h>
27
28 #include "libavutil/attributes.h"
29 #include "libavutil/cpu.h"
30 #include "libavutil/x86/cpu.h"
31 #include "libavcodec/avcodec.h"
32 #include "libavcodec/hpeldsp.h"
33 #include "fpel.h"
34 #include "hpeldsp.h"
35
36 void ff_put_pixels8_x2_sse2(uint8_t *block, const uint8_t *pixels,
37 ptrdiff_t line_size, int h);
38 void ff_put_pixels16_x2_sse2(uint8_t *block, const uint8_t *pixels,
39 ptrdiff_t line_size, int h);
40 void ff_avg_pixels16_x2_sse2(uint8_t *block, const uint8_t *pixels,
41 ptrdiff_t line_size, int h);
42 void ff_put_pixels16_y2_sse2(uint8_t *block, const uint8_t *pixels,
43 ptrdiff_t line_size, int h);
44 void ff_avg_pixels16_y2_sse2(uint8_t *block, const uint8_t *pixels,
45 ptrdiff_t line_size, int h);
46 void ff_put_no_rnd_pixels8_x2_approx_sse2(uint8_t *block, const uint8_t *pixels,
47 ptrdiff_t line_size, int h);
48 void ff_put_no_rnd_pixels8_x2_sse2(uint8_t *block, const uint8_t *pixels,
49 ptrdiff_t line_size, int h);
50 void ff_put_no_rnd_pixels16_x2_sse2(uint8_t *block, const uint8_t *pixels,
51 ptrdiff_t line_size, int h);
52 void ff_avg_no_rnd_pixels16_x2_sse2(uint8_t *block, const uint8_t *pixels,
53 ptrdiff_t line_size, int h);
54 void ff_put_pixels8_y2_sse2(uint8_t *block, const uint8_t *pixels,
55 ptrdiff_t line_size, int h);
56 void ff_put_no_rnd_pixels8_y2_approx_sse2(uint8_t *block, const uint8_t *pixels,
57 ptrdiff_t line_size, int h);
58 void ff_put_no_rnd_pixels8_y2_sse2(uint8_t *block, const uint8_t *pixels,
59 ptrdiff_t line_size, int h);
60 void ff_put_no_rnd_pixels16_y2_sse2(uint8_t *block, const uint8_t *pixels,
61 ptrdiff_t line_size, int h);
62 void ff_avg_no_rnd_pixels16_y2_sse2(uint8_t *block, const uint8_t *pixels,
63 ptrdiff_t line_size, int h);
64 void ff_put_no_rnd_pixels8_xy2_ssse3(uint8_t *block, const uint8_t *pixels,
65 ptrdiff_t line_size, int h);
66 void ff_put_no_rnd_pixels16_xy2_sse2(uint8_t *block, const uint8_t *pixels,
67 ptrdiff_t line_size, int h);
68 void ff_avg_no_rnd_pixels16_xy2_sse2(uint8_t *block, const uint8_t *pixels,
69 ptrdiff_t line_size, int h);
70 void ff_avg_pixels8_x2_sse2(uint8_t *block, const uint8_t *pixels,
71 ptrdiff_t line_size, int h);
72 void ff_avg_pixels8_y2_sse2(uint8_t *block, const uint8_t *pixels,
73 ptrdiff_t line_size, int h);
74
75 197 static void hpeldsp_init_sse2(HpelDSPContext *c, int flags)
76 {
77 #if HAVE_SSE2_EXTERNAL
78 197 c->put_pixels_tab[0][0] = ff_put_pixels16_sse2;
79 197 c->put_pixels_tab[0][1] = ff_put_pixels16_x2_sse2;
80 197 c->put_pixels_tab[0][2] = ff_put_pixels16_y2_sse2;
81 197 c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_sse2;
82
83 197 c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_sse2;
84 197 c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_sse2;
85 197 c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_sse2;
86 197 c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_sse2;
87
88 197 c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_sse2;
89 197 c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_sse2;
90 197 c->put_no_rnd_pixels_tab[1][0] =
91 197 c->put_pixels_tab[1][0] = ff_put_pixels8_sse2;
92 197 c->put_pixels_tab[1][1] = ff_put_pixels8_x2_sse2;
93 197 c->put_pixels_tab[1][2] = ff_put_pixels8_y2_sse2;
94
95 197 c->avg_pixels_tab[0][0] = ff_avg_pixels16_sse2;
96 197 c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_sse2;
97 197 c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_sse2;
98 197 c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_sse2;
99 197 c->avg_pixels_tab[1][0] = ff_avg_pixels8_sse2;
100 197 c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_sse2;
101 197 c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_sse2;
102
103 197 c->avg_no_rnd_pixels_tab[0] = ff_avg_pixels16_sse2;
104 197 c->avg_no_rnd_pixels_tab[1] = ff_avg_no_rnd_pixels16_x2_sse2;
105 197 c->avg_no_rnd_pixels_tab[2] = ff_avg_no_rnd_pixels16_y2_sse2;
106 197 c->avg_no_rnd_pixels_tab[3] = ff_avg_no_rnd_pixels16_xy2_sse2;
107
108
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 34 times.
197 if (!(flags & AV_CODEC_FLAG_BITEXACT)) {
109 163 c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_approx_sse2;
110 163 c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_approx_sse2;
111 }
112 #endif /* HAVE_SSE2_EXTERNAL */
113 197 }
114
115 195 static void hpeldsp_init_ssse3(HpelDSPContext *c, int flags)
116 {
117 #if HAVE_SSSE3_EXTERNAL
118 195 c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_ssse3;
119 195 c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_ssse3;
120 195 c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_ssse3;
121 195 c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_ssse3;
122
123 195 c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_ssse3;
124 #endif
125 195 }
126
127 996 av_cold void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags)
128 {
129 996 int cpu_flags = av_get_cpu_flags();
130
131
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 799 times.
996 if (EXTERNAL_SSE2(cpu_flags))
132 197 hpeldsp_init_sse2(c, flags);
133
134
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 801 times.
996 if (EXTERNAL_SSSE3(cpu_flags))
135 195 hpeldsp_init_ssse3(c, flags);
136 996 }
137