annotate libmpeg2/motion_comp.c @ 33389:2672587086ad

Add MNG output support. Patch by Stefan Schuermans, stefan blinkenarea dot org.
author cboesch
date Sat, 21 May 2011 15:04:50 +0000
parents 31287e75b5d8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 * motion_comp.c
10303
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 10269
diff changeset
3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
7 * See http://libmpeg2.sourceforge.net/ for updates.
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * mpeg2dec is free software; you can redistribute it and/or modify
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 * (at your option) any later version.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 * mpeg2dec is distributed in the hope that it will be useful,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 * GNU General Public License for more details.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
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 *
27571
fd18fa10de53 libmpeg-0.4.1.diff was renamed to libmpeg2_changes.diff.
diego
parents: 27522
diff changeset
23 * Modified for use with MPlayer, see libmpeg2_changes.diff for the exact changes.
18783
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 14732
diff changeset
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
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 #include <inttypes.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
32 #include "mpeg2.h"
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10303
diff changeset
33 #include "attributes.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 #include "mpeg2_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
36 mpeg2_mc_t mpeg2_mc;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
38 void mpeg2_mc_init (uint32_t accel)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 {
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27645
diff changeset
40 #if HAVE_MMX2
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
41 if (accel & MPEG2_ACCEL_X86_MMXEXT)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
42 mpeg2_mc = mpeg2_mc_mmxext;
27522
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 27361
diff changeset
43 else
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 27361
diff changeset
44 #endif
28335
31287e75b5d8 HAVE_3DNOW --> HAVE_AMD3DNOW
diego
parents: 28290
diff changeset
45 #if HAVE_AMD3DNOW
27522
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 27361
diff changeset
46 if (accel & MPEG2_ACCEL_X86_3DNOW)
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
47 mpeg2_mc = mpeg2_mc_3dnow;
27522
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 27361
diff changeset
48 else
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 27361
diff changeset
49 #endif
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27645
diff changeset
50 #if HAVE_MMX
27522
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 27361
diff changeset
51 if (accel & MPEG2_ACCEL_X86_MMX)
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
52 mpeg2_mc = mpeg2_mc_mmx;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
53 else
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
54 #endif
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27645
diff changeset
55 #if HAVE_ALTIVEC
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
56 if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
57 mpeg2_mc = mpeg2_mc_altivec;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
58 else
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
59 #endif
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27645
diff changeset
60 #if ARCH_ALPHA
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
61 if (accel & MPEG2_ACCEL_ALPHA)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
62 mpeg2_mc = mpeg2_mc_alpha;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
63 else
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 #endif
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27645
diff changeset
65 #if HAVE_VIS
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10303
diff changeset
66 if (accel & MPEG2_ACCEL_SPARC_VIS)
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10303
diff changeset
67 mpeg2_mc = mpeg2_mc_vis;
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
68 else
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 #endif
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27645
diff changeset
70 #if ARCH_ARM
27361
7cf315c4707f Fix ARM linking failure when IWMMXT support is disabled.
diego
parents: 26625
diff changeset
71 if (accel & MPEG2_ACCEL_ARM)
26282
79ab4ecba54a Revert local changes that pointlessly add #ifdefs all over libmpeg2 to disable
diego
parents: 26046
diff changeset
72 mpeg2_mc = mpeg2_mc_arm;
79ab4ecba54a Revert local changes that pointlessly add #ifdefs all over libmpeg2 to disable
diego
parents: 26046
diff changeset
73 else
23236
f0ddd02aec27 iWMMXt-accelerated DCT and motion compensation for ARM processors
gpoirier
parents: 21526
diff changeset
74 #endif
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
75 mpeg2_mc = mpeg2_mc_c;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 #define avg2(a,b) ((a+b+1)>>1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
81 #define predict_o(i) (ref[i])
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 #define predict_x(i) (avg2 (ref[i], ref[i+1]))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 #define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
84 #define predict_xy(i) (avg4 (ref[i], ref[i+1], \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
85 (ref+stride)[i], (ref+stride)[i+1]))
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 #define put(predictor,i) dest[i] = predictor (i)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
90 /* mc function template */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
92 #define MC_FUNC(op,xy) \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
93 static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
94 const int stride, int height) \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
95 { \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
96 do { \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
97 op (predict_##xy, 0); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
98 op (predict_##xy, 1); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
99 op (predict_##xy, 2); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
100 op (predict_##xy, 3); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
101 op (predict_##xy, 4); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
102 op (predict_##xy, 5); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
103 op (predict_##xy, 6); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
104 op (predict_##xy, 7); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
105 op (predict_##xy, 8); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
106 op (predict_##xy, 9); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
107 op (predict_##xy, 10); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
108 op (predict_##xy, 11); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
109 op (predict_##xy, 12); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
110 op (predict_##xy, 13); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
111 op (predict_##xy, 14); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
112 op (predict_##xy, 15); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
113 ref += stride; \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
114 dest += stride; \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
115 } while (--height); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
116 } \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
117 static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
118 const int stride, int height) \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
119 { \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
120 do { \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
121 op (predict_##xy, 0); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
122 op (predict_##xy, 1); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
123 op (predict_##xy, 2); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
124 op (predict_##xy, 3); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
125 op (predict_##xy, 4); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
126 op (predict_##xy, 5); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
127 op (predict_##xy, 6); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
128 op (predict_##xy, 7); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
129 ref += stride; \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
130 dest += stride; \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
131 } while (--height); \
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
134 /* definitions of the actual mc functions */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
136 MC_FUNC (put,o)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
137 MC_FUNC (avg,o)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 MC_FUNC (put,x)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 MC_FUNC (avg,x)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 MC_FUNC (put,y)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 MC_FUNC (avg,y)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 MC_FUNC (put,xy)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 MC_FUNC (avg,xy)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 1216
diff changeset
145 MPEG2_MC_EXTERN (c)