1 /*
2  * motion_comp_arm.c
3  * Copyright (C) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
4  *
5  * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
6  * See http://libmpeg2.sourceforge.net/ for updates.
7  *
8  * mpeg2dec is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * mpeg2dec is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with mpeg2dec; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22 
23 #include "config.h"
24 
25 #ifdef ARCH_ARM
26 
27 #include <inttypes.h>
28 
29 #include "mpeg2.h"
30 #include "attributes.h"
31 #include "mpeg2_internal.h"
32 
33 #define avg2(a,b)     ((a+b+1)>>1)
34 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
35 
36 #define predict_o(i)  (ref[i])
37 #define predict_x(i)  (avg2 (ref[i], ref[i+1]))
38 #define predict_y(i)  (avg2 (ref[i], (ref+stride)[i]))
39 #define predict_xy(i) (avg4 (ref[i], ref[i+1], \
40 			     (ref+stride)[i], (ref+stride)[i+1]))
41 
42 #define put(predictor,i) dest[i] = predictor (i)
43 #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
44 
45 /* mc function template */
46 
47 #define MC_FUNC(op,xy)							\
48 static void inline MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref,	\
49 				   const int stride, int height)	\
50 {									\
51     do {								\
52 	op (predict_##xy, 0);						\
53 	op (predict_##xy, 1);						\
54 	op (predict_##xy, 2);						\
55 	op (predict_##xy, 3);						\
56 	op (predict_##xy, 4);						\
57 	op (predict_##xy, 5);						\
58 	op (predict_##xy, 6);						\
59 	op (predict_##xy, 7);						\
60 	op (predict_##xy, 8);						\
61 	op (predict_##xy, 9);						\
62 	op (predict_##xy, 10);						\
63 	op (predict_##xy, 11);						\
64 	op (predict_##xy, 12);						\
65 	op (predict_##xy, 13);						\
66 	op (predict_##xy, 14);						\
67 	op (predict_##xy, 15);						\
68 	ref += stride;							\
69 	dest += stride;							\
70     } while (--height);						\
71 }									\
72 static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref,	\
73 				  const int stride, int height)		\
74 {									\
75     do {								\
76 	op (predict_##xy, 0);						\
77 	op (predict_##xy, 1);						\
78 	op (predict_##xy, 2);						\
79 	op (predict_##xy, 3);						\
80 	op (predict_##xy, 4);						\
81 	op (predict_##xy, 5);						\
82 	op (predict_##xy, 6);						\
83 	op (predict_##xy, 7);						\
84 	ref += stride;							\
85 	dest += stride;							\
86     } while (--height);						\
87 }									\
88 /* definitions of the actual mc functions */
89 
90 MC_FUNC (avg,o)
91 MC_FUNC (avg,x)
92 MC_FUNC (put,y)
93 MC_FUNC (avg,y)
94 MC_FUNC (put,xy)
95 MC_FUNC (avg,xy)
96 
97 
98 extern void MC_put_o_16_arm (uint8_t * dest, const uint8_t * ref,
99 			     int stride, int height);
100 
101 extern void MC_put_x_16_arm (uint8_t * dest, const uint8_t * ref,
102 			     int stride, int height);
103 
104 
MC_put_y_16_arm(uint8_t * dest,const uint8_t * ref,int stride,int height)105 static void MC_put_y_16_arm (uint8_t * dest, const uint8_t * ref,
106 			      int stride, int height)
107 {
108     MC_put_y_16_c(dest, ref, stride, height);
109 }
110 
MC_put_xy_16_arm(uint8_t * dest,const uint8_t * ref,int stride,int height)111 static void MC_put_xy_16_arm (uint8_t * dest, const uint8_t * ref,
112 			       int stride, int height)
113 {
114     MC_put_xy_16_c(dest, ref, stride, height);
115 }
116 
117 extern void MC_put_o_8_arm (uint8_t * dest, const uint8_t * ref,
118 			     int stride, int height);
119 
120 extern void MC_put_x_8_arm (uint8_t * dest, const uint8_t * ref,
121 			    int stride, int height);
122 
MC_put_y_8_arm(uint8_t * dest,const uint8_t * ref,int stride,int height)123 static void MC_put_y_8_arm (uint8_t * dest, const uint8_t * ref,
124 			     int stride, int height)
125 {
126     MC_put_y_8_c(dest, ref, stride, height);
127 }
128 
MC_put_xy_8_arm(uint8_t * dest,const uint8_t * ref,int stride,int height)129 static void MC_put_xy_8_arm (uint8_t * dest, const uint8_t * ref,
130 			      int stride, int height)
131 {
132     MC_put_xy_8_c(dest, ref, stride, height);
133 }
134 
MC_avg_o_16_arm(uint8_t * dest,const uint8_t * ref,int stride,int height)135 static void MC_avg_o_16_arm (uint8_t * dest, const uint8_t * ref,
136 			      int stride, int height)
137 {
138     MC_avg_o_16_c(dest, ref, stride, height);
139 }
140 
MC_avg_x_16_arm(uint8_t * dest,const uint8_t * ref,int stride,int height)141 static void MC_avg_x_16_arm (uint8_t * dest, const uint8_t * ref,
142 			      int stride, int height)
143 {
144     MC_avg_x_16_c(dest, ref, stride, height);
145 }
146 
MC_avg_y_16_arm(uint8_t * dest,const uint8_t * ref,int stride,int height)147 static void MC_avg_y_16_arm (uint8_t * dest, const uint8_t * ref,
148 			      int stride, int height)
149 {
150     MC_avg_y_16_c(dest, ref, stride, height);
151 }
152 
MC_avg_xy_16_arm(uint8_t * dest,const uint8_t * ref,int stride,int height)153 static void MC_avg_xy_16_arm (uint8_t * dest, const uint8_t * ref,
154 			       int stride, int height)
155 {
156     MC_avg_xy_16_c(dest, ref, stride, height);
157 }
158 
MC_avg_o_8_arm(uint8_t * dest,const uint8_t * ref,int stride,int height)159 static void MC_avg_o_8_arm (uint8_t * dest, const uint8_t * ref,
160 			     int stride, int height)
161 {
162     MC_avg_o_8_c(dest, ref, stride, height);
163 }
164 
MC_avg_x_8_arm(uint8_t * dest,const uint8_t * ref,int stride,int height)165 static void MC_avg_x_8_arm (uint8_t * dest, const uint8_t * ref,
166 			     int stride, int height)
167 {
168     MC_avg_x_8_c(dest, ref, stride, height);
169 }
170 
MC_avg_y_8_arm(uint8_t * dest,const uint8_t * ref,int stride,int height)171 static void MC_avg_y_8_arm (uint8_t * dest, const uint8_t * ref,
172 			     int stride, int height)
173 {
174     MC_avg_y_8_c(dest, ref, stride, height);
175 }
176 
MC_avg_xy_8_arm(uint8_t * dest,const uint8_t * ref,int stride,int height)177 static void MC_avg_xy_8_arm (uint8_t * dest, const uint8_t * ref,
178 			      int stride, int height)
179 {
180     MC_avg_xy_8_c(dest, ref, stride, height);
181 }
182 
183 MPEG2_MC_EXTERN (arm)
184 
185 #endif
186