FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/x86/vc1dsp_init.c
Date: 2026-10-29 07:45:57
Exec Total Coverage
Lines: 42 42 100.0%
Functions: 6 6 100.0%
Branches: 15 18 83.3%

Line Branch Exec Source
1 /*
2 * VC-1 and WMV3 - DSP functions MMX-optimized
3 * Copyright (c) 2007 Christophe GISQUET <christophe.gisquet@free.fr>
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following
12 * conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27 #include "libavutil/attributes.h"
28 #include "libavutil/cpu.h"
29 #include "libavutil/x86/cpu.h"
30 #include "libavcodec/vc1dsp.h"
31 #include "vc1dsp.h"
32 #include "config.h"
33
34 #define LOOP_FILTER4(EXT) \
35 void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, ptrdiff_t stride, int pq); \
36 void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, ptrdiff_t stride, int pq);
37 #define LOOP_FILTER816(EXT) \
38 void ff_vc1_v_loop_filter8_ ## EXT(uint8_t *src, ptrdiff_t stride, int pq); \
39 void ff_vc1_h_loop_filter8_ ## EXT(uint8_t *src, ptrdiff_t stride, int pq); \
40 \
41 static void vc1_v_loop_filter16_ ## EXT(uint8_t *src, ptrdiff_t stride, int pq) \
42 { \
43 ff_vc1_v_loop_filter8_ ## EXT(src, stride, pq); \
44 ff_vc1_v_loop_filter8_ ## EXT(src+8, stride, pq); \
45 } \
46 \
47 static void vc1_h_loop_filter16_ ## EXT(uint8_t *src, ptrdiff_t stride, int pq) \
48 { \
49 ff_vc1_h_loop_filter8_ ## EXT(src, stride, pq); \
50 ff_vc1_h_loop_filter8_ ## EXT(src+8*stride, stride, pq); \
51 }
52
53 8008 LOOP_FILTER816(sse2)
54 LOOP_FILTER4(ssse3)
55 6008 LOOP_FILTER816(ssse3)
56
57 void ff_vc1_h_loop_filter8_sse4(uint8_t *src, ptrdiff_t stride, int pq);
58
59 1002 static void vc1_h_loop_filter16_sse4(uint8_t *src, ptrdiff_t stride, int pq)
60 {
61 1002 ff_vc1_h_loop_filter8_sse4(src, stride, pq);
62 1002 ff_vc1_h_loop_filter8_sse4(src+8*stride, stride, pq);
63 1002 }
64
65 void ff_put_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, const uint8_t *src,
66 ptrdiff_t stride, int h, int x, int y);
67 void ff_avg_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, const uint8_t *src,
68 ptrdiff_t stride, int h, int x, int y);
69 void ff_vc1_inv_trans_4x4_dc_sse2(uint8_t *dest, ptrdiff_t linesize,
70 int16_t *block);
71 void ff_vc1_inv_trans_4x8_dc_sse2(uint8_t *dest, ptrdiff_t linesize,
72 int16_t *block);
73 void ff_vc1_inv_trans_8x4_dc_sse2(uint8_t *dest, ptrdiff_t linesize,
74 int16_t *block);
75 void ff_vc1_inv_trans_8x8_dc_sse2(uint8_t *dest, ptrdiff_t linesize,
76 int16_t *block);
77 void ff_vc1_inv_trans_4x4_sse2(uint8_t *dest, ptrdiff_t linesize,
78 int16_t *block);
79 void ff_vc1_inv_trans_4x8_sse2(uint8_t *dest, ptrdiff_t linesize,
80 int16_t *block);
81 void ff_vc1_inv_trans_8x4_sse2(uint8_t *dest, ptrdiff_t linesize,
82 int16_t *block);
83 void ff_vc1_inv_trans_8x8_sse2(int16_t block[64]);
84 void ff_vc1_inv_trans_8x8_avx2(int16_t block[64]);
85
86 #define MSPEL_FUNC(OP, X, Y, SIZE, XMM) \
87 void ff_vc1_ ## OP ## _mspel_mc ## X ## Y ## _ ## SIZE ##_ ## XMM \
88 (uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int rnd); \
89 dsp->OP ## _vc1_mspel_pixels_tab[SIZE == 8][X + 4 * Y] = \
90 ff_vc1_ ## OP ## _mspel_mc ## X ## Y## _ ## SIZE ##_ ## XMM
91 #define MSPEL_FUNCS_SIZE(X, Y, SIZE, XMM) \
92 MSPEL_FUNC(put, X, Y, SIZE, XMM); \
93 MSPEL_FUNC(avg, X, Y, SIZE, XMM)
94 #define MSPEL_FUNCS(X, Y, XMM) \
95 MSPEL_FUNCS_SIZE(X, Y, 8, XMM); \
96 MSPEL_FUNCS_SIZE(X, Y, 16, XMM)
97
98 112 av_cold void ff_vc1dsp_init_x86(VC1DSPContext *dsp)
99 {
100 112 int cpu_flags = av_get_cpu_flags();
101
102 #if HAVE_X86_6REGS && HAVE_INLINE_ASM && HAVE_MMX_EXTERNAL
103
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 47 times.
112 if (HAVE_X86_6REGS && INLINE_MMX(cpu_flags))
104
1/2
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
65 if (EXTERNAL_MMX(cpu_flags))
105 65 ff_vc1dsp_init_mmx(dsp);
106
107
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 52 times.
112 if (HAVE_X86_6REGS && INLINE_MMXEXT(cpu_flags))
108
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if (EXTERNAL_MMXEXT(cpu_flags))
109 60 ff_vc1dsp_init_mmxext(dsp);
110 #endif /* HAVE_X86_6REGS && HAVE_INLINE_ASM && HAVE_MMX_EXTERNAL */
111
112 #define ASSIGN_LF4(EXT) \
113 dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \
114 dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_ ## EXT
115 #define ASSIGN_LF816(EXT) \
116 dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_ ## EXT; \
117 dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_ ## EXT; \
118 dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_ ## EXT; \
119 dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_ ## EXT
120
121
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 62 times.
112 if (EXTERNAL_SSE2(cpu_flags)) {
122 50 dsp->vc1_inv_trans_8x8_dc = ff_vc1_inv_trans_8x8_dc_sse2;
123 50 dsp->vc1_inv_trans_4x8_dc = ff_vc1_inv_trans_4x8_dc_sse2;
124 50 dsp->vc1_inv_trans_8x4_dc = ff_vc1_inv_trans_8x4_dc_sse2;
125 50 dsp->vc1_inv_trans_4x4_dc = ff_vc1_inv_trans_4x4_dc_sse2;
126 50 dsp->vc1_inv_trans_4x4 = ff_vc1_inv_trans_4x4_sse2;
127 50 dsp->vc1_inv_trans_4x8 = ff_vc1_inv_trans_4x8_sse2;
128 50 dsp->vc1_inv_trans_8x4 = ff_vc1_inv_trans_8x4_sse2;
129 #if ARCH_X86_64
130 50 dsp->vc1_inv_trans_8x8 = ff_vc1_inv_trans_8x8_sse2;
131 #endif
132
133 50 ASSIGN_LF816(sse2);
134
135 50 MSPEL_FUNCS(0, 0, sse2);
136 }
137
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 72 times.
112 if (EXTERNAL_SSSE3(cpu_flags)) {
138 40 ASSIGN_LF4(ssse3);
139 40 ASSIGN_LF816(ssse3);
140 40 dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_ssse3;
141 40 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_ssse3;
142
143 40 MSPEL_FUNCS(0, 1, ssse3);
144 40 MSPEL_FUNCS(0, 2, ssse3);
145 40 MSPEL_FUNCS(0, 3, ssse3);
146 40 MSPEL_FUNCS(1, 0, ssse3);
147 40 MSPEL_FUNCS(2, 0, ssse3);
148 40 MSPEL_FUNCS(3, 0, ssse3);
149 }
150
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if (EXTERNAL_SSE4(cpu_flags)) {
151 35 dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4;
152 35 dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse4;
153 }
154 #if ARCH_X86_64
155
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
112 if (EXTERNAL_AVX2_FAST(cpu_flags))
156 5 dsp->vc1_inv_trans_8x8 = ff_vc1_inv_trans_8x8_avx2;
157 #endif
158 112 }
159