Mercurial > mplayer.hg
annotate libmpeg2/motion_comp.c @ 27078:7f6bec0700aa
sync w/r27107, patch by C¸«±dric Viou
author | gpoirier |
---|---|
date | Fri, 20 Jun 2008 20:11:57 +0000 |
parents | 5b89b42f6d50 |
children | 7cf315c4707f |
rev | line source |
---|---|
1 | 1 /* |
2 * motion_comp.c | |
10303 | 3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org> |
9852 | 4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> |
1 | 5 * |
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. | |
9852 | 7 * See http://libmpeg2.sourceforge.net/ for updates. |
1 | 8 * |
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. | |
13 * | |
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. | |
18 * | |
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 | |
14732
1385ec491ffb
Mark locally modified files as such to comply more closely with GPL 2a.
diego
parents:
13864
diff
changeset
|
22 * |
21526 | 23 * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes. |
18783 | 24 * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/ |
14732
1385ec491ffb
Mark locally modified files as such to comply more closely with GPL 2a.
diego
parents:
13864
diff
changeset
|
25 * $Id$ |
1 | 26 */ |
27 | |
28 #include "config.h" | |
29 | |
30 #include <inttypes.h> | |
31 | |
9852 | 32 #include "mpeg2.h" |
12932 | 33 #include "attributes.h" |
1 | 34 #include "mpeg2_internal.h" |
35 | |
9852 | 36 mpeg2_mc_t mpeg2_mc; |
1 | 37 |
9852 | 38 void mpeg2_mc_init (uint32_t accel) |
1 | 39 { |
26282
79ab4ecba54a
Revert local changes that pointlessly add #ifdefs all over libmpeg2 to disable
diego
parents:
26046
diff
changeset
|
40 #ifdef ARCH_X86 |
9852 | 41 if (accel & MPEG2_ACCEL_X86_MMXEXT) |
42 mpeg2_mc = mpeg2_mc_mmxext; | |
26282
79ab4ecba54a
Revert local changes that pointlessly add #ifdefs all over libmpeg2 to disable
diego
parents:
26046
diff
changeset
|
43 else if (accel & MPEG2_ACCEL_X86_3DNOW) |
9852 | 44 mpeg2_mc = mpeg2_mc_3dnow; |
26282
79ab4ecba54a
Revert local changes that pointlessly add #ifdefs all over libmpeg2 to disable
diego
parents:
26046
diff
changeset
|
45 else if (accel & MPEG2_ACCEL_X86_MMX) |
9852 | 46 mpeg2_mc = mpeg2_mc_mmx; |
47 else | |
48 #endif | |
26625
5b89b42f6d50
Only compile and use libmpeg2 AltiVec code when AltiVec is available. The
diego
parents:
26282
diff
changeset
|
49 #ifdef HAVE_ALTIVEC |
9852 | 50 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) |
51 mpeg2_mc = mpeg2_mc_altivec; | |
52 else | |
53 #endif | |
54 #ifdef ARCH_ALPHA | |
55 if (accel & MPEG2_ACCEL_ALPHA) | |
56 mpeg2_mc = mpeg2_mc_alpha; | |
57 else | |
1 | 58 #endif |
26282
79ab4ecba54a
Revert local changes that pointlessly add #ifdefs all over libmpeg2 to disable
diego
parents:
26046
diff
changeset
|
59 #ifdef ARCH_SPARC |
12932 | 60 if (accel & MPEG2_ACCEL_SPARC_VIS) |
61 mpeg2_mc = mpeg2_mc_vis; | |
9852 | 62 else |
1 | 63 #endif |
23236
f0ddd02aec27
iWMMXt-accelerated DCT and motion compensation for ARM processors
gpoirier
parents:
21526
diff
changeset
|
64 #ifdef ARCH_ARM |
26282
79ab4ecba54a
Revert local changes that pointlessly add #ifdefs all over libmpeg2 to disable
diego
parents:
26046
diff
changeset
|
65 if (accel & MPEG2_ACCEL_ARM_IWMMXT) |
79ab4ecba54a
Revert local changes that pointlessly add #ifdefs all over libmpeg2 to disable
diego
parents:
26046
diff
changeset
|
66 mpeg2_mc = mpeg2_mc_iwmmxt; |
79ab4ecba54a
Revert local changes that pointlessly add #ifdefs all over libmpeg2 to disable
diego
parents:
26046
diff
changeset
|
67 else if (accel & MPEG2_ACCEL_ARM) |
79ab4ecba54a
Revert local changes that pointlessly add #ifdefs all over libmpeg2 to disable
diego
parents:
26046
diff
changeset
|
68 mpeg2_mc = mpeg2_mc_arm; |
79ab4ecba54a
Revert local changes that pointlessly add #ifdefs all over libmpeg2 to disable
diego
parents:
26046
diff
changeset
|
69 else |
23236
f0ddd02aec27
iWMMXt-accelerated DCT and motion compensation for ARM processors
gpoirier
parents:
21526
diff
changeset
|
70 #endif |
9852 | 71 mpeg2_mc = mpeg2_mc_c; |
1 | 72 } |
73 | |
74 #define avg2(a,b) ((a+b+1)>>1) | |
75 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2) | |
76 | |
9852 | 77 #define predict_o(i) (ref[i]) |
1 | 78 #define predict_x(i) (avg2 (ref[i], ref[i+1])) |
79 #define predict_y(i) (avg2 (ref[i], (ref+stride)[i])) | |
9852 | 80 #define predict_xy(i) (avg4 (ref[i], ref[i+1], \ |
81 (ref+stride)[i], (ref+stride)[i+1])) | |
1 | 82 |
83 #define put(predictor,i) dest[i] = predictor (i) | |
84 #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i]) | |
85 | |
36 | 86 /* mc function template */ |
1 | 87 |
9852 | 88 #define MC_FUNC(op,xy) \ |
89 static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \ | |
90 const int stride, int height) \ | |
91 { \ | |
92 do { \ | |
93 op (predict_##xy, 0); \ | |
94 op (predict_##xy, 1); \ | |
95 op (predict_##xy, 2); \ | |
96 op (predict_##xy, 3); \ | |
97 op (predict_##xy, 4); \ | |
98 op (predict_##xy, 5); \ | |
99 op (predict_##xy, 6); \ | |
100 op (predict_##xy, 7); \ | |
101 op (predict_##xy, 8); \ | |
102 op (predict_##xy, 9); \ | |
103 op (predict_##xy, 10); \ | |
104 op (predict_##xy, 11); \ | |
105 op (predict_##xy, 12); \ | |
106 op (predict_##xy, 13); \ | |
107 op (predict_##xy, 14); \ | |
108 op (predict_##xy, 15); \ | |
109 ref += stride; \ | |
110 dest += stride; \ | |
111 } while (--height); \ | |
112 } \ | |
113 static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \ | |
114 const int stride, int height) \ | |
115 { \ | |
116 do { \ | |
117 op (predict_##xy, 0); \ | |
118 op (predict_##xy, 1); \ | |
119 op (predict_##xy, 2); \ | |
120 op (predict_##xy, 3); \ | |
121 op (predict_##xy, 4); \ | |
122 op (predict_##xy, 5); \ | |
123 op (predict_##xy, 6); \ | |
124 op (predict_##xy, 7); \ | |
125 ref += stride; \ | |
126 dest += stride; \ | |
127 } while (--height); \ | |
1 | 128 } |
129 | |
36 | 130 /* definitions of the actual mc functions */ |
1 | 131 |
9852 | 132 MC_FUNC (put,o) |
133 MC_FUNC (avg,o) | |
1 | 134 MC_FUNC (put,x) |
135 MC_FUNC (avg,x) | |
136 MC_FUNC (put,y) | |
137 MC_FUNC (avg,y) | |
138 MC_FUNC (put,xy) | |
139 MC_FUNC (avg,xy) | |
140 | |
9852 | 141 MPEG2_MC_EXTERN (c) |