FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/x86/vc1dsp_init.c
Date: 2026-04-24 10:13:59
Exec Total Coverage
Lines: 39 39 100.0%
Functions: 10 10 100.0%
Branches: 14 16 87.5%

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 "libavutil/x86/asm.h"
31 #include "libavcodec/vc1dsp.h"
32 #include "fpel.h"
33 #include "vc1dsp.h"
34 #include "config.h"
35
36 #define LOOP_FILTER4(EXT) \
37 void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, ptrdiff_t stride, int pq); \
38 void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, ptrdiff_t stride, int pq);
39 #define LOOP_FILTER816(EXT) \
40 void ff_vc1_v_loop_filter8_ ## EXT(uint8_t *src, ptrdiff_t stride, int pq); \
41 void ff_vc1_h_loop_filter8_ ## EXT(uint8_t *src, ptrdiff_t stride, int pq); \
42 \
43 static void vc1_v_loop_filter16_ ## EXT(uint8_t *src, ptrdiff_t stride, int pq) \
44 { \
45 ff_vc1_v_loop_filter8_ ## EXT(src, stride, pq); \
46 ff_vc1_v_loop_filter8_ ## EXT(src+8, stride, pq); \
47 } \
48 \
49 static void vc1_h_loop_filter16_ ## EXT(uint8_t *src, ptrdiff_t stride, int pq) \
50 { \
51 ff_vc1_h_loop_filter8_ ## EXT(src, stride, pq); \
52 ff_vc1_h_loop_filter8_ ## EXT(src+8*stride, stride, pq); \
53 }
54
55 LOOP_FILTER4(mmxext)
56 8000 LOOP_FILTER816(sse2)
57 LOOP_FILTER4(ssse3)
58 6000 LOOP_FILTER816(ssse3)
59
60 void ff_vc1_h_loop_filter8_sse4(uint8_t *src, ptrdiff_t stride, int pq);
61
62 1000 static void vc1_h_loop_filter16_sse4(uint8_t *src, ptrdiff_t stride, int pq)
63 {
64 1000 ff_vc1_h_loop_filter8_sse4(src, stride, pq);
65 1000 ff_vc1_h_loop_filter8_sse4(src+8*stride, stride, pq);
66 1000 }
67
68 #define DECLARE_FUNCTION(OP, DEPTH, INSN) \
69 static void OP##vc1_mspel_mc00_##DEPTH##INSN(uint8_t *dst, \
70 const uint8_t *src, ptrdiff_t stride, int rnd) \
71 { \
72 ff_ ## OP ## pixels ## DEPTH ## INSN(dst, src, stride, DEPTH); \
73 }
74
75 1 DECLARE_FUNCTION(put_, 8, _sse2)
76 1 DECLARE_FUNCTION(avg_, 8, _mmxext)
77 1 DECLARE_FUNCTION(put_, 16, _sse2)
78 1 DECLARE_FUNCTION(avg_, 16, _sse2)
79
80 void ff_put_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, const uint8_t *src,
81 ptrdiff_t stride, int h, int x, int y);
82 void ff_avg_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, const uint8_t *src,
83 ptrdiff_t stride, int h, int x, int y);
84 void ff_vc1_inv_trans_4x4_dc_mmxext(uint8_t *dest, ptrdiff_t linesize,
85 int16_t *block);
86 void ff_vc1_inv_trans_4x8_dc_mmxext(uint8_t *dest, ptrdiff_t linesize,
87 int16_t *block);
88 void ff_vc1_inv_trans_8x4_dc_mmxext(uint8_t *dest, ptrdiff_t linesize,
89 int16_t *block);
90 void ff_vc1_inv_trans_8x8_dc_mmxext(uint8_t *dest, ptrdiff_t linesize,
91 int16_t *block);
92
93
94 112 av_cold void ff_vc1dsp_init_x86(VC1DSPContext *dsp)
95 {
96 112 int cpu_flags = av_get_cpu_flags();
97
98 #if HAVE_6REGS && HAVE_INLINE_ASM && HAVE_MMX_EXTERNAL
99
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 47 times.
112 if (HAVE_6REGS && INLINE_MMX(cpu_flags))
100
1/2
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
65 if (EXTERNAL_MMX(cpu_flags))
101 65 ff_vc1dsp_init_mmx(dsp);
102
103
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 52 times.
112 if (HAVE_6REGS && INLINE_MMXEXT(cpu_flags))
104
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if (EXTERNAL_MMXEXT(cpu_flags))
105 60 ff_vc1dsp_init_mmxext(dsp);
106 #endif /* HAVE_6REGS && HAVE_INLINE_ASM && HAVE_MMX_EXTERNAL */
107
108 #define ASSIGN_LF4(EXT) \
109 dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \
110 dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_ ## EXT
111 #define ASSIGN_LF816(EXT) \
112 dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_ ## EXT; \
113 dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_ ## EXT; \
114 dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_ ## EXT; \
115 dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_ ## EXT
116
117
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 52 times.
112 if (EXTERNAL_MMXEXT(cpu_flags)) {
118 60 ASSIGN_LF4(mmxext);
119
120 60 dsp->avg_vc1_mspel_pixels_tab[1][0] = avg_vc1_mspel_mc00_8_mmxext;
121
122 60 dsp->vc1_inv_trans_8x8_dc = ff_vc1_inv_trans_8x8_dc_mmxext;
123 60 dsp->vc1_inv_trans_4x8_dc = ff_vc1_inv_trans_4x8_dc_mmxext;
124 60 dsp->vc1_inv_trans_8x4_dc = ff_vc1_inv_trans_8x4_dc_mmxext;
125 60 dsp->vc1_inv_trans_4x4_dc = ff_vc1_inv_trans_4x4_dc_mmxext;
126 }
127
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 62 times.
112 if (EXTERNAL_SSE2(cpu_flags)) {
128 50 ASSIGN_LF816(sse2);
129
130 50 dsp->put_vc1_mspel_pixels_tab[0][0] = put_vc1_mspel_mc00_16_sse2;
131 50 dsp->put_vc1_mspel_pixels_tab[1][0] = put_vc1_mspel_mc00_8_sse2;
132 50 dsp->avg_vc1_mspel_pixels_tab[0][0] = avg_vc1_mspel_mc00_16_sse2;
133 }
134
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 72 times.
112 if (EXTERNAL_SSSE3(cpu_flags)) {
135 40 ASSIGN_LF4(ssse3);
136 40 ASSIGN_LF816(ssse3);
137 40 dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_ssse3;
138 40 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_ssse3;
139 }
140
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if (EXTERNAL_SSE4(cpu_flags)) {
141 35 dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4;
142 35 dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse4;
143 }
144 112 }
145