FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/x86/hpeldsp_init.c
Date: 2026-07-21 08:37:06
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 195 static void hpeldsp_init_sse2(HpelDSPContext *c, int flags)
76 {
77 #if HAVE_SSE2_EXTERNAL
78 195 c->put_pixels_tab[0][0] = ff_put_pixels16_sse2;
79 195 c->put_pixels_tab[0][1] = ff_put_pixels16_x2_sse2;
80 195 c->put_pixels_tab[0][2] = ff_put_pixels16_y2_sse2;
81 195 c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_sse2;
82
83 195 c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_sse2;
84 195 c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_sse2;
85 195 c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_sse2;
86 195 c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_sse2;
87
88 195 c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_sse2;
89 195 c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_sse2;
90 195 c->put_no_rnd_pixels_tab[1][0] =
91 195 c->put_pixels_tab[1][0] = ff_put_pixels8_sse2;
92 195 c->put_pixels_tab[1][1] = ff_put_pixels8_x2_sse2;
93 195 c->put_pixels_tab[1][2] = ff_put_pixels8_y2_sse2;
94
95 195 c->avg_pixels_tab[0][0] = ff_avg_pixels16_sse2;
96 195 c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_sse2;
97 195 c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_sse2;
98 195 c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_sse2;
99 195 c->avg_pixels_tab[1][0] = ff_avg_pixels8_sse2;
100 195 c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_sse2;
101 195 c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_sse2;
102
103 195 c->avg_no_rnd_pixels_tab[0] = ff_avg_pixels16_sse2;
104 195 c->avg_no_rnd_pixels_tab[1] = ff_avg_no_rnd_pixels16_x2_sse2;
105 195 c->avg_no_rnd_pixels_tab[2] = ff_avg_no_rnd_pixels16_y2_sse2;
106 195 c->avg_no_rnd_pixels_tab[3] = ff_avg_no_rnd_pixels16_xy2_sse2;
107
108
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 33 times.
195 if (!(flags & AV_CODEC_FLAG_BITEXACT)) {
109 162 c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_approx_sse2;
110 162 c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_approx_sse2;
111 }
112 #endif /* HAVE_SSE2_EXTERNAL */
113 195 }
114
115 193 static void hpeldsp_init_ssse3(HpelDSPContext *c, int flags)
116 {
117 #if HAVE_SSSE3_EXTERNAL
118 193 c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_ssse3;
119 193 c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_ssse3;
120 193 c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_ssse3;
121 193 c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_ssse3;
122
123 193 c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_ssse3;
124 #endif
125 193 }
126
127 994 av_cold void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags)
128 {
129 994 int cpu_flags = av_get_cpu_flags();
130
131
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 799 times.
994 if (EXTERNAL_SSE2(cpu_flags))
132 195 hpeldsp_init_sse2(c, flags);
133
134
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 801 times.
994 if (EXTERNAL_SSSE3(cpu_flags))
135 193 hpeldsp_init_ssse3(c, flags);
136 994 }
137