2 * VC-1 and WMV3 - DSP functions MMX-optimized
3 * Copyright (c) 2007 Christophe GISQUET <christophe.gisquet@free.fr>
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
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
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.
27 #include "libavutil/cpu.h"
28 #include "libavutil/x86/cpu.h"
29 #include "libavcodec/vc1dsp.h"
33 #define LOOP_FILTER(EXT) \
34 void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
35 void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
36 void ff_vc1_v_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
37 void ff_vc1_h_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
39 static void vc1_v_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \
41 ff_vc1_v_loop_filter8_ ## EXT(src, stride, pq); \
42 ff_vc1_v_loop_filter8_ ## EXT(src+8, stride, pq); \
45 static void vc1_h_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \
47 ff_vc1_h_loop_filter8_ ## EXT(src, stride, pq); \
48 ff_vc1_h_loop_filter8_ ## EXT(src+8*stride, stride, pq); \
56 void ff_vc1_h_loop_filter8_sse4(uint8_t *src, int stride, int pq);
58 static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq)
60 ff_vc1_h_loop_filter8_sse4(src, stride, pq);
61 ff_vc1_h_loop_filter8_sse4(src+8*stride, stride, pq);
63 #endif /* HAVE_YASM */
65 void ff_put_vc1_chroma_mc8_mmx_nornd (uint8_t *dst, uint8_t *src,
66 int stride, int h, int x, int y);
67 void ff_avg_vc1_chroma_mc8_mmx2_nornd (uint8_t *dst, uint8_t *src,
68 int stride, int h, int x, int y);
69 void ff_avg_vc1_chroma_mc8_3dnow_nornd(uint8_t *dst, uint8_t *src,
70 int stride, int h, int x, int y);
71 void ff_put_vc1_chroma_mc8_ssse3_nornd(uint8_t *dst, uint8_t *src,
72 int stride, int h, int x, int y);
73 void ff_avg_vc1_chroma_mc8_ssse3_nornd(uint8_t *dst, uint8_t *src,
74 int stride, int h, int x, int y);
77 av_cold void ff_vc1dsp_init_x86(VC1DSPContext *dsp)
79 int mm_flags = av_get_cpu_flags();
81 if (INLINE_MMX(mm_flags))
82 ff_vc1dsp_init_mmx(dsp);
84 if (INLINE_MMXEXT(mm_flags))
85 ff_vc1dsp_init_mmxext(dsp);
87 #define ASSIGN_LF(EXT) \
88 dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \
89 dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_ ## EXT; \
90 dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_ ## EXT; \
91 dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_ ## EXT; \
92 dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_ ## EXT; \
93 dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_ ## EXT
96 if (mm_flags & AV_CPU_FLAG_MMX) {
97 dsp->put_no_rnd_vc1_chroma_pixels_tab[0]= ff_put_vc1_chroma_mc8_mmx_nornd;
100 if (mm_flags & AV_CPU_FLAG_MMXEXT) {
102 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= ff_avg_vc1_chroma_mc8_mmx2_nornd;
103 } else if (mm_flags & AV_CPU_FLAG_3DNOW) {
104 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= ff_avg_vc1_chroma_mc8_3dnow_nornd;
107 if (mm_flags & AV_CPU_FLAG_SSE2) {
108 dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_sse2;
109 dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse2;
110 dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_sse2;
111 dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse2;
113 if (mm_flags & AV_CPU_FLAG_SSSE3) {
115 dsp->put_no_rnd_vc1_chroma_pixels_tab[0]= ff_put_vc1_chroma_mc8_ssse3_nornd;
116 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= ff_avg_vc1_chroma_mc8_ssse3_nornd;
118 if (mm_flags & AV_CPU_FLAG_SSE4) {
119 dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4;
120 dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse4;
122 #endif /* HAVE_YASM */