FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vc1dsp_init.c
Go to the documentation of this file.
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 "dsputil_x86.h"
32 #include "vc1dsp.h"
33 #include "config.h"
34 
35 #define LOOP_FILTER(EXT) \
36 void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
37 void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
38 void ff_vc1_v_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
39 void ff_vc1_h_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
40 \
41 static void vc1_v_loop_filter16_ ## EXT(uint8_t *src, int 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, int 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 #if HAVE_YASM
54 LOOP_FILTER(mmxext)
55 LOOP_FILTER(sse2)
56 LOOP_FILTER(ssse3)
57 
58 void ff_vc1_h_loop_filter8_sse4(uint8_t *src, int stride, int pq);
59 
60 static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq)
61 {
62  ff_vc1_h_loop_filter8_sse4(src, stride, pq);
63  ff_vc1_h_loop_filter8_sse4(src+8*stride, stride, pq);
64 }
65 
66 static void avg_vc1_mspel_mc00_mmxext(uint8_t *dst, const uint8_t *src,
67  ptrdiff_t stride, int rnd)
68 {
69  ff_avg_pixels8_mmxext(dst, src, stride, 8);
70 }
71 #endif /* HAVE_YASM */
72 
74  int stride, int h, int x, int y);
76  int stride, int h, int x, int y);
78  int stride, int h, int x, int y);
80  int stride, int h, int x, int y);
82  int stride, int h, int x, int y);
83 
84 
86 {
88 
89  if (INLINE_MMX(cpu_flags))
90  ff_vc1dsp_init_mmx(dsp);
91 
92  if (INLINE_MMXEXT(cpu_flags))
94 
95 #define ASSIGN_LF(EXT) \
96  dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \
97  dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_ ## EXT; \
98  dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_ ## EXT; \
99  dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_ ## EXT; \
100  dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_ ## EXT; \
101  dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_ ## EXT
102 
103 #if HAVE_YASM
104  if (EXTERNAL_MMX(cpu_flags)) {
106  }
107  if (EXTERNAL_AMD3DNOW(cpu_flags)) {
109  }
110  if (EXTERNAL_MMXEXT(cpu_flags)) {
111  ASSIGN_LF(mmxext);
113 
114  dsp->avg_vc1_mspel_pixels_tab[0] = avg_vc1_mspel_mc00_mmxext;
115  }
116  if (EXTERNAL_SSE2(cpu_flags)) {
117  dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_sse2;
118  dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse2;
119  dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_sse2;
120  dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse2;
121  }
122  if (EXTERNAL_SSSE3(cpu_flags)) {
123  ASSIGN_LF(ssse3);
126  }
127  if (EXTERNAL_SSE4(cpu_flags)) {
128  dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4;
129  dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse4;
130  }
131 #endif /* HAVE_YASM */
132 }