3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
7 * See http://libmpeg2.sourceforge.net/ for updates.
9 * mpeg2dec is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * mpeg2dec is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * Modified for use with MPlayer, see libmpeg-0.4.0.diff for the exact changes.
24 * detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
33 #include "attributes.h"
34 #include "mpeg2_internal.h"
38 void mpeg2_mc_init (uint32_t accel
)
40 #if defined(ARCH_X86) || defined(ARCH_X86_64)
41 if (accel
& MPEG2_ACCEL_X86_MMXEXT
)
42 mpeg2_mc
= mpeg2_mc_mmxext
;
43 else if (accel
& MPEG2_ACCEL_X86_3DNOW
)
44 mpeg2_mc
= mpeg2_mc_3dnow
;
45 else if (accel
& MPEG2_ACCEL_X86_MMX
)
46 mpeg2_mc
= mpeg2_mc_mmx
;
49 #if defined(ARCH_PPC) && defined(HAVE_ALTIVEC)
50 if (accel
& MPEG2_ACCEL_PPC_ALTIVEC
)
51 mpeg2_mc
= mpeg2_mc_altivec
;
55 if (accel
& MPEG2_ACCEL_ALPHA
)
56 mpeg2_mc
= mpeg2_mc_alpha
;
59 #if defined(ARCH_SPARC) && defined(HAVE_VIS)
60 if (accel
& MPEG2_ACCEL_SPARC_VIS
)
61 mpeg2_mc
= mpeg2_mc_vis
;
64 mpeg2_mc
= mpeg2_mc_c
;
67 #define avg2(a,b) ((a+b+1)>>1)
68 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
70 #define predict_o(i) (ref[i])
71 #define predict_x(i) (avg2 (ref[i], ref[i+1]))
72 #define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
73 #define predict_xy(i) (avg4 (ref[i], ref[i+1], \
74 (ref+stride)[i], (ref+stride)[i+1]))
76 #define put(predictor,i) dest[i] = predictor (i)
77 #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
79 /* mc function template */
81 #define MC_FUNC(op,xy) \
82 static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \
83 const int stride, int height) \
86 op (predict_##xy, 0); \
87 op (predict_##xy, 1); \
88 op (predict_##xy, 2); \
89 op (predict_##xy, 3); \
90 op (predict_##xy, 4); \
91 op (predict_##xy, 5); \
92 op (predict_##xy, 6); \
93 op (predict_##xy, 7); \
94 op (predict_##xy, 8); \
95 op (predict_##xy, 9); \
96 op (predict_##xy, 10); \
97 op (predict_##xy, 11); \
98 op (predict_##xy, 12); \
99 op (predict_##xy, 13); \
100 op (predict_##xy, 14); \
101 op (predict_##xy, 15); \
104 } while (--height); \
106 static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \
107 const int stride, int height) \
110 op (predict_##xy, 0); \
111 op (predict_##xy, 1); \
112 op (predict_##xy, 2); \
113 op (predict_##xy, 3); \
114 op (predict_##xy, 4); \
115 op (predict_##xy, 5); \
116 op (predict_##xy, 6); \
117 op (predict_##xy, 7); \
120 } while (--height); \
123 /* definitions of the actual mc functions */