annotate libmpeg2/motion_comp.c @ 3145:78e11396f431

runtime cpu detection
author michael
date Mon, 26 Nov 2001 21:55:22 +0000
parents 4059e05c480a
children 47984e3f54ce
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
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
3 * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 * mpeg2dec is free software; you can redistribute it and/or modify
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 * (at your option) any later version.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 * mpeg2dec is distributed in the hope that it will be useful,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 * GNU General Public License for more details.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 #include <inttypes.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 #include "mpeg2_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 #include "mm_accel.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 mc_functions_t mc_functions;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 void motion_comp_init (void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 #ifdef ARCH_X86
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 if (config.flags & MM_ACCEL_X86_MMXEXT) {
1216
4059e05c480a some info printfs moved stderr->stdout
arpi_esp
parents: 36
diff changeset
37 printf ("libmpeg2: Using MMXEXT for motion compensation\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 mc_functions = mc_functions_mmxext;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 } else if (config.flags & MM_ACCEL_X86_3DNOW) {
1216
4059e05c480a some info printfs moved stderr->stdout
arpi_esp
parents: 36
diff changeset
40 printf ("libmpeg2: Using 3DNOW for motion compensation\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 mc_functions = mc_functions_3dnow;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 } else if (config.flags & MM_ACCEL_X86_MMX) {
1216
4059e05c480a some info printfs moved stderr->stdout
arpi_esp
parents: 36
diff changeset
43 printf ("libmpeg2: Using MMX for motion compensation\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 mc_functions = mc_functions_mmx;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 #ifdef LIBMPEG2_MLIB
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 if (config.flags & MM_ACCEL_MLIB) {
1216
4059e05c480a some info printfs moved stderr->stdout
arpi_esp
parents: 36
diff changeset
49 printf ("libmpeg2: Using mlib for motion compensation\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 mc_functions = mc_functions_mlib;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 {
1216
4059e05c480a some info printfs moved stderr->stdout
arpi_esp
parents: 36
diff changeset
54 printf ("libmpeg2: No accelerated motion compensation found\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 mc_functions = mc_functions_c;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 #define avg2(a,b) ((a+b+1)>>1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 #define predict_(i) (ref[i])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 #define predict_x(i) (avg2 (ref[i], ref[i+1]))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 #define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 #define predict_xy(i) (avg4 (ref[i], ref[i+1], (ref+stride)[i], (ref+stride)[i+1]))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 #define put(predictor,i) dest[i] = predictor (i)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
70 /* mc function template */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 #define MC_FUNC(op,xy) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 static void MC_##op##_##xy##16_c (uint8_t * dest, uint8_t * ref,\
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 int stride, int height) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 { \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 do { \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 op (predict_##xy, 0); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 op (predict_##xy, 1); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 op (predict_##xy, 2); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 op (predict_##xy, 3); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 op (predict_##xy, 4); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 op (predict_##xy, 5); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 op (predict_##xy, 6); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 op (predict_##xy, 7); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 op (predict_##xy, 8); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 op (predict_##xy, 9); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 op (predict_##xy, 10); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 op (predict_##xy, 11); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 op (predict_##xy, 12); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 op (predict_##xy, 13); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 op (predict_##xy, 14); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 op (predict_##xy, 15); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 ref += stride; \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 dest += stride; \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 } while (--height); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 } \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 static void MC_##op##_##xy##8_c (uint8_t * dest, uint8_t * ref, \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 int stride, int height) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 { \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 do { \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 op (predict_##xy, 0); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 op (predict_##xy, 1); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 op (predict_##xy, 2); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 op (predict_##xy, 3); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 op (predict_##xy, 4); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 op (predict_##xy, 5); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 op (predict_##xy, 6); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 op (predict_##xy, 7); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 ref += stride; \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 dest += stride; \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 } while (--height); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
114 /* definitions of the actual mc functions */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 MC_FUNC (put,)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 MC_FUNC (avg,)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 MC_FUNC (put,x)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 MC_FUNC (avg,x)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 MC_FUNC (put,y)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 MC_FUNC (avg,y)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 MC_FUNC (put,xy)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 MC_FUNC (avg,xy)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 MOTION_COMP_EXTERN (c)