FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/x86/hpeldsp_init.c
Date: 2026-01-16 07:34:38
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 171 static void hpeldsp_init_mmxext(HpelDSPContext *c, int flags)
78 {
79 #if HAVE_MMXEXT_EXTERNAL
80 171 c->put_pixels_tab[1][1] = ff_put_pixels8_x2_mmxext;
81 171 c->put_pixels_tab[1][2] = ff_put_pixels8_y2_mmxext;
82
83 171 c->avg_pixels_tab[1][0] = ff_avg_pixels8_mmxext;
84 171 c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_mmxext;
85 171 c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_mmxext;
86
87 171 c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_mmxext;
88 171 c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_mmxext;
89
90
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 29 times.
171 if (!(flags & AV_CODEC_FLAG_BITEXACT)) {
91 142 c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_mmxext;
92 142 c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_mmxext;
93 }
94 #endif /* HAVE_MMXEXT_EXTERNAL */
95 171 }
96
97 169 static void hpeldsp_init_sse2(HpelDSPContext *c, int flags)
98 {
99 #if HAVE_SSE2_EXTERNAL
100 169 c->put_pixels_tab[0][0] = ff_put_pixels16_sse2;
101 169 c->put_pixels_tab[0][1] = ff_put_pixels16_x2_sse2;
102 169 c->put_pixels_tab[0][2] = ff_put_pixels16_y2_sse2;
103 169 c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_sse2;
104
105 169 c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_sse2;
106 169 c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_sse2;
107 169 c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_sse2;
108 169 c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_sse2;
109
110 169 c->put_no_rnd_pixels_tab[1][0] =
111 169 c->put_pixels_tab[1][0] = ff_put_pixels8_sse2;
112
113 169 c->avg_pixels_tab[0][0] = ff_avg_pixels16_sse2;
114 169 c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_sse2;
115 169 c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_sse2;
116 169 c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_sse2;
117
118 169 c->avg_no_rnd_pixels_tab[0] = ff_avg_pixels16_sse2;
119 169 c->avg_no_rnd_pixels_tab[1] = ff_avg_no_rnd_pixels16_x2_sse2;
120 169 c->avg_no_rnd_pixels_tab[2] = ff_avg_no_rnd_pixels16_y2_sse2;
121 169 c->avg_no_rnd_pixels_tab[3] = ff_avg_no_rnd_pixels16_xy2_sse2;
122 #endif /* HAVE_SSE2_EXTERNAL */
123 169 }
124
125 167 static void hpeldsp_init_ssse3(HpelDSPContext *c, int flags)
126 {
127 #if HAVE_SSSE3_EXTERNAL
128 167 c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_ssse3;
129 167 c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_ssse3;
130 167 c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_ssse3;
131 167 c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_ssse3;
132
133 167 c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_ssse3;
134 #endif
135 167 }
136
137 945 av_cold void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags)
138 {
139 945 int cpu_flags = av_get_cpu_flags();
140
141
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 774 times.
945 if (EXTERNAL_MMXEXT(cpu_flags))
142 171 hpeldsp_init_mmxext(c, flags);
143
144
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 776 times.
945 if (EXTERNAL_SSE2(cpu_flags))
145 169 hpeldsp_init_sse2(c, flags);
146
147
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 778 times.
945 if (EXTERNAL_SSSE3(cpu_flags))
148 167 hpeldsp_init_ssse3(c, flags);
149 945 }
150