yading@10
|
1 /*
|
yading@10
|
2 * VC-1 and WMV3 - DSP functions MMX-optimized
|
yading@10
|
3 * Copyright (c) 2007 Christophe GISQUET <christophe.gisquet@free.fr>
|
yading@10
|
4 *
|
yading@10
|
5 * Permission is hereby granted, free of charge, to any person
|
yading@10
|
6 * obtaining a copy of this software and associated documentation
|
yading@10
|
7 * files (the "Software"), to deal in the Software without
|
yading@10
|
8 * restriction, including without limitation the rights to use,
|
yading@10
|
9 * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
yading@10
|
10 * copies of the Software, and to permit persons to whom the
|
yading@10
|
11 * Software is furnished to do so, subject to the following
|
yading@10
|
12 * conditions:
|
yading@10
|
13 *
|
yading@10
|
14 * The above copyright notice and this permission notice shall be
|
yading@10
|
15 * included in all copies or substantial portions of the Software.
|
yading@10
|
16 *
|
yading@10
|
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
yading@10
|
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
yading@10
|
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
yading@10
|
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
yading@10
|
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
yading@10
|
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
yading@10
|
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
yading@10
|
24 * OTHER DEALINGS IN THE SOFTWARE.
|
yading@10
|
25 */
|
yading@10
|
26
|
yading@10
|
27 #include "libavutil/cpu.h"
|
yading@10
|
28 #include "libavutil/x86/cpu.h"
|
yading@10
|
29 #include "libavcodec/vc1dsp.h"
|
yading@10
|
30 #include "dsputil_mmx.h"
|
yading@10
|
31 #include "vc1dsp.h"
|
yading@10
|
32 #include "config.h"
|
yading@10
|
33
|
yading@10
|
34 #define LOOP_FILTER(EXT) \
|
yading@10
|
35 void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
|
yading@10
|
36 void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
|
yading@10
|
37 void ff_vc1_v_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
|
yading@10
|
38 void ff_vc1_h_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
|
yading@10
|
39 \
|
yading@10
|
40 static void vc1_v_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \
|
yading@10
|
41 { \
|
yading@10
|
42 ff_vc1_v_loop_filter8_ ## EXT(src, stride, pq); \
|
yading@10
|
43 ff_vc1_v_loop_filter8_ ## EXT(src+8, stride, pq); \
|
yading@10
|
44 } \
|
yading@10
|
45 \
|
yading@10
|
46 static void vc1_h_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \
|
yading@10
|
47 { \
|
yading@10
|
48 ff_vc1_h_loop_filter8_ ## EXT(src, stride, pq); \
|
yading@10
|
49 ff_vc1_h_loop_filter8_ ## EXT(src+8*stride, stride, pq); \
|
yading@10
|
50 }
|
yading@10
|
51
|
yading@10
|
52 #if HAVE_YASM
|
yading@10
|
53 LOOP_FILTER(mmxext)
|
yading@10
|
54 LOOP_FILTER(sse2)
|
yading@10
|
55 LOOP_FILTER(ssse3)
|
yading@10
|
56
|
yading@10
|
57 void ff_vc1_h_loop_filter8_sse4(uint8_t *src, int stride, int pq);
|
yading@10
|
58
|
yading@10
|
59 static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq)
|
yading@10
|
60 {
|
yading@10
|
61 ff_vc1_h_loop_filter8_sse4(src, stride, pq);
|
yading@10
|
62 ff_vc1_h_loop_filter8_sse4(src+8*stride, stride, pq);
|
yading@10
|
63 }
|
yading@10
|
64
|
yading@10
|
65 static void avg_vc1_mspel_mc00_mmxext(uint8_t *dst, const uint8_t *src,
|
yading@10
|
66 ptrdiff_t stride, int rnd)
|
yading@10
|
67 {
|
yading@10
|
68 ff_avg_pixels8_mmxext(dst, src, stride, 8);
|
yading@10
|
69 }
|
yading@10
|
70 #endif /* HAVE_YASM */
|
yading@10
|
71
|
yading@10
|
72 void ff_put_vc1_chroma_mc8_nornd_mmx (uint8_t *dst, uint8_t *src,
|
yading@10
|
73 int stride, int h, int x, int y);
|
yading@10
|
74 void ff_avg_vc1_chroma_mc8_nornd_mmxext(uint8_t *dst, uint8_t *src,
|
yading@10
|
75 int stride, int h, int x, int y);
|
yading@10
|
76 void ff_avg_vc1_chroma_mc8_nornd_3dnow(uint8_t *dst, uint8_t *src,
|
yading@10
|
77 int stride, int h, int x, int y);
|
yading@10
|
78 void ff_put_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src,
|
yading@10
|
79 int stride, int h, int x, int y);
|
yading@10
|
80 void ff_avg_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src,
|
yading@10
|
81 int stride, int h, int x, int y);
|
yading@10
|
82
|
yading@10
|
83
|
yading@10
|
84 av_cold void ff_vc1dsp_init_x86(VC1DSPContext *dsp)
|
yading@10
|
85 {
|
yading@10
|
86 int mm_flags = av_get_cpu_flags();
|
yading@10
|
87
|
yading@10
|
88 if (INLINE_MMX(mm_flags))
|
yading@10
|
89 ff_vc1dsp_init_mmx(dsp);
|
yading@10
|
90
|
yading@10
|
91 if (INLINE_MMXEXT(mm_flags))
|
yading@10
|
92 ff_vc1dsp_init_mmxext(dsp);
|
yading@10
|
93
|
yading@10
|
94 #define ASSIGN_LF(EXT) \
|
yading@10
|
95 dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \
|
yading@10
|
96 dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_ ## EXT; \
|
yading@10
|
97 dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_ ## EXT; \
|
yading@10
|
98 dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_ ## EXT; \
|
yading@10
|
99 dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_ ## EXT; \
|
yading@10
|
100 dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_ ## EXT
|
yading@10
|
101
|
yading@10
|
102 #if HAVE_YASM
|
yading@10
|
103 if (mm_flags & AV_CPU_FLAG_MMX) {
|
yading@10
|
104 dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_mmx;
|
yading@10
|
105 }
|
yading@10
|
106
|
yading@10
|
107 if (mm_flags & AV_CPU_FLAG_MMXEXT) {
|
yading@10
|
108 ASSIGN_LF(mmxext);
|
yading@10
|
109 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_mmxext;
|
yading@10
|
110
|
yading@10
|
111 dsp->avg_vc1_mspel_pixels_tab[0] = avg_vc1_mspel_mc00_mmxext;
|
yading@10
|
112 } else if (mm_flags & AV_CPU_FLAG_3DNOW) {
|
yading@10
|
113 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_3dnow;
|
yading@10
|
114 }
|
yading@10
|
115
|
yading@10
|
116 if (mm_flags & AV_CPU_FLAG_SSE2) {
|
yading@10
|
117 dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_sse2;
|
yading@10
|
118 dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse2;
|
yading@10
|
119 dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_sse2;
|
yading@10
|
120 dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse2;
|
yading@10
|
121 }
|
yading@10
|
122 if (mm_flags & AV_CPU_FLAG_SSSE3) {
|
yading@10
|
123 ASSIGN_LF(ssse3);
|
yading@10
|
124 dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_ssse3;
|
yading@10
|
125 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_ssse3;
|
yading@10
|
126 }
|
yading@10
|
127 if (mm_flags & AV_CPU_FLAG_SSE4) {
|
yading@10
|
128 dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4;
|
yading@10
|
129 dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse4;
|
yading@10
|
130 }
|
yading@10
|
131 #endif /* HAVE_YASM */
|
yading@10
|
132 }
|