Add support for VDPAU video out, including hardware decoding.
[mplayer/glamo.git] / libmpeg2 / motion_comp.c
blobf056176e9210e357d99244f2a60cd1eddd86d422
1 /*
2 * motion_comp.c
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 libmpeg2_changes.diff for the exact changes.
24 * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
25 * $Id$
28 #include "config.h"
30 #include <inttypes.h>
32 #include "mpeg2.h"
33 #include "attributes.h"
34 #include "mpeg2_internal.h"
36 mpeg2_mc_t mpeg2_mc;
38 void mpeg2_mc_init (uint32_t accel)
40 #if HAVE_MMX2
41 if (accel & MPEG2_ACCEL_X86_MMXEXT)
42 mpeg2_mc = mpeg2_mc_mmxext;
43 else
44 #endif
45 #if HAVE_AMD3DNOW
46 if (accel & MPEG2_ACCEL_X86_3DNOW)
47 mpeg2_mc = mpeg2_mc_3dnow;
48 else
49 #endif
50 #if HAVE_MMX
51 if (accel & MPEG2_ACCEL_X86_MMX)
52 mpeg2_mc = mpeg2_mc_mmx;
53 else
54 #endif
55 #if HAVE_ALTIVEC
56 if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
57 mpeg2_mc = mpeg2_mc_altivec;
58 else
59 #endif
60 #if ARCH_ALPHA
61 if (accel & MPEG2_ACCEL_ALPHA)
62 mpeg2_mc = mpeg2_mc_alpha;
63 else
64 #endif
65 #if HAVE_VIS
66 if (accel & MPEG2_ACCEL_SPARC_VIS)
67 mpeg2_mc = mpeg2_mc_vis;
68 else
69 #endif
70 #if ARCH_ARM
71 if (accel & MPEG2_ACCEL_ARM)
72 mpeg2_mc = mpeg2_mc_arm;
73 else
74 #endif
75 mpeg2_mc = mpeg2_mc_c;
78 #define avg2(a,b) ((a+b+1)>>1)
79 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
81 #define predict_o(i) (ref[i])
82 #define predict_x(i) (avg2 (ref[i], ref[i+1]))
83 #define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
84 #define predict_xy(i) (avg4 (ref[i], ref[i+1], \
85 (ref+stride)[i], (ref+stride)[i+1]))
87 #define put(predictor,i) dest[i] = predictor (i)
88 #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
90 /* mc function template */
92 #define MC_FUNC(op,xy) \
93 static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \
94 const int stride, int height) \
95 { \
96 do { \
97 op (predict_##xy, 0); \
98 op (predict_##xy, 1); \
99 op (predict_##xy, 2); \
100 op (predict_##xy, 3); \
101 op (predict_##xy, 4); \
102 op (predict_##xy, 5); \
103 op (predict_##xy, 6); \
104 op (predict_##xy, 7); \
105 op (predict_##xy, 8); \
106 op (predict_##xy, 9); \
107 op (predict_##xy, 10); \
108 op (predict_##xy, 11); \
109 op (predict_##xy, 12); \
110 op (predict_##xy, 13); \
111 op (predict_##xy, 14); \
112 op (predict_##xy, 15); \
113 ref += stride; \
114 dest += stride; \
115 } while (--height); \
117 static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \
118 const int stride, int height) \
120 do { \
121 op (predict_##xy, 0); \
122 op (predict_##xy, 1); \
123 op (predict_##xy, 2); \
124 op (predict_##xy, 3); \
125 op (predict_##xy, 4); \
126 op (predict_##xy, 5); \
127 op (predict_##xy, 6); \
128 op (predict_##xy, 7); \
129 ref += stride; \
130 dest += stride; \
131 } while (--height); \
134 /* definitions of the actual mc functions */
136 MC_FUNC (put,o)
137 MC_FUNC (avg,o)
138 MC_FUNC (put,x)
139 MC_FUNC (avg,x)
140 MC_FUNC (put,y)
141 MC_FUNC (avg,y)
142 MC_FUNC (put,xy)
143 MC_FUNC (avg,xy)
145 MPEG2_MC_EXTERN (c)