FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/x86/hpeldsp_init.c
Date: 2026-04-23 02:20:26
Exec Total Coverage
Lines: 48 48 100.0%
Functions: 4 4 100.0%
Branches: 8 8 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_mmxext(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_mmxext(uint8_t *block, const uint8_t *pixels,
47 ptrdiff_t line_size, int h);
48 void ff_put_no_rnd_pixels8_x2_exact_mmxext(uint8_t *block,
49 const uint8_t *pixels,
50 ptrdiff_t line_size, int h);
51 void ff_put_no_rnd_pixels16_x2_sse2(uint8_t *block, const uint8_t *pixels,
52 ptrdiff_t line_size, int h);
53 void ff_avg_no_rnd_pixels16_x2_sse2(uint8_t *block, const uint8_t *pixels,
54 ptrdiff_t line_size, int h);
55 void ff_put_pixels8_y2_mmxext(uint8_t *block, const uint8_t *pixels,
56 ptrdiff_t line_size, int h);
57 void ff_put_no_rnd_pixels8_y2_mmxext(uint8_t *block, const uint8_t *pixels,
58 ptrdiff_t line_size, int h);
59 void ff_put_no_rnd_pixels8_y2_exact_mmxext(uint8_t *block,
60 const uint8_t *pixels,
61 ptrdiff_t line_size, int h);
62 void ff_put_no_rnd_pixels16_y2_sse2(uint8_t *block, const uint8_t *pixels,
63 ptrdiff_t line_size, int h);
64 void ff_avg_no_rnd_pixels16_y2_sse2(uint8_t *block, const uint8_t *pixels,
65 ptrdiff_t line_size, int h);
66 void ff_put_no_rnd_pixels8_xy2_ssse3(uint8_t *block, const uint8_t *pixels,
67 ptrdiff_t line_size, int h);
68 void ff_put_no_rnd_pixels16_xy2_sse2(uint8_t *block, const uint8_t *pixels,
69 ptrdiff_t line_size, int h);
70 void ff_avg_no_rnd_pixels16_xy2_sse2(uint8_t *block, const uint8_t *pixels,
71 ptrdiff_t line_size, int h);
72 void ff_avg_pixels8_x2_mmxext(uint8_t *block, const uint8_t *pixels,
73 ptrdiff_t line_size, int h);
74 void ff_avg_pixels8_y2_mmxext(uint8_t *block, const uint8_t *pixels,
75 ptrdiff_t line_size, int h);
76
77 180 static void hpeldsp_init_mmxext(HpelDSPContext *c, int flags)
78 {
79 #if HAVE_MMXEXT_EXTERNAL
80 180 c->put_pixels_tab[1][1] = ff_put_pixels8_x2_mmxext;
81 180 c->put_pixels_tab[1][2] = ff_put_pixels8_y2_mmxext;
82
83 180 c->avg_pixels_tab[1][0] = ff_avg_pixels8_mmxext;
84 180 c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_mmxext;
85 180 c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_mmxext;
86
87 180 c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_mmxext;
88 180 c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_mmxext;
89
90
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 30 times.
180 if (!(flags & AV_CODEC_FLAG_BITEXACT)) {
91 150 c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_mmxext;
92 150 c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_mmxext;
93 }
94 #endif /* HAVE_MMXEXT_EXTERNAL */
95 180 }
96
97 178 static void hpeldsp_init_sse2(HpelDSPContext *c, int flags)
98 {
99 #if HAVE_SSE2_EXTERNAL
100 178 c->put_pixels_tab[0][0] = ff_put_pixels16_sse2;
101 178 c->put_pixels_tab[0][1] = ff_put_pixels16_x2_sse2;
102 178 c->put_pixels_tab[0][2] = ff_put_pixels16_y2_sse2;
103 178 c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_sse2;
104
105 178 c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_sse2;
106 178 c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_sse2;
107 178 c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_sse2;
108 178 c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_sse2;
109
110 178 c->put_no_rnd_pixels_tab[1][0] =
111 178 c->put_pixels_tab[1][0] = ff_put_pixels8_sse2;
112
113 178 c->avg_pixels_tab[0][0] = ff_avg_pixels16_sse2;
114 178 c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_sse2;
115 178 c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_sse2;
116 178 c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_sse2;
117
118 178 c->avg_no_rnd_pixels_tab[0] = ff_avg_pixels16_sse2;
119 178 c->avg_no_rnd_pixels_tab[1] = ff_avg_no_rnd_pixels16_x2_sse2;
120 178 c->avg_no_rnd_pixels_tab[2] = ff_avg_no_rnd_pixels16_y2_sse2;
121 178 c->avg_no_rnd_pixels_tab[3] = ff_avg_no_rnd_pixels16_xy2_sse2;
122 #endif /* HAVE_SSE2_EXTERNAL */
123 178 }
124
125 176 static void hpeldsp_init_ssse3(HpelDSPContext *c, int flags)
126 {
127 #if HAVE_SSSE3_EXTERNAL
128 176 c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_ssse3;
129 176 c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_ssse3;
130 176 c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_ssse3;
131 176 c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_ssse3;
132
133 176 c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_ssse3;
134 #endif
135 176 }
136
137 955 av_cold void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags)
138 {
139 955 int cpu_flags = av_get_cpu_flags();
140
141
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 775 times.
955 if (EXTERNAL_MMXEXT(cpu_flags))
142 180 hpeldsp_init_mmxext(c, flags);
143
144
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 777 times.
955 if (EXTERNAL_SSE2(cpu_flags))
145 178 hpeldsp_init_sse2(c, flags);
146
147
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 779 times.
955 if (EXTERNAL_SSSE3(cpu_flags))
148 176 hpeldsp_init_ssse3(c, flags);
149 955 }
150