1 #include "mpeg3private.h"
2 #include "mpeg3protos.h"
6 static inline void rec(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
9 for(j
= 0; j
< h
; j
++, s
+= lx2
, d
+= lx2
)
11 d
[0] = s
[0]; d
[1] = s
[1]; d
[2] = s
[2]; d
[3] = s
[3];
12 d
[4] = s
[4]; d
[5] = s
[5]; d
[6] = s
[6]; d
[7] = s
[7];
13 d
[8] = s
[8]; d
[9] = s
[9]; d
[10] = s
[10]; d
[11] = s
[11];
14 d
[12] = s
[12]; d
[13] = s
[13]; d
[14] = s
[14]; d
[15] = s
[15];
20 static inline void recc(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
23 for(j
= 0; j
< h
; j
++, s
+= lx2
, d
+= lx2
)
25 d
[0] = s
[0]; d
[1] = s
[1]; d
[2] = s
[2]; d
[3] = s
[3];
26 d
[4] = s
[4]; d
[5] = s
[5]; d
[6] = s
[6]; d
[7] = s
[7];
30 static inline void reca(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
33 for(j
= 0; j
< h
; j
++, s
+=lx2
, d
+=lx2
)
35 d
[0] = (unsigned int)(d
[0] + s
[0] + 1) >> 1;
36 d
[1] = (unsigned int)(d
[1] + s
[1] + 1) >> 1;
37 d
[2] = (unsigned int)(d
[2] + s
[2] + 1) >> 1;
38 d
[3] = (unsigned int)(d
[3] + s
[3] + 1) >> 1;
39 d
[4] = (unsigned int)(d
[4] + s
[4] + 1) >> 1;
40 d
[5] = (unsigned int)(d
[5] + s
[5] + 1) >> 1;
41 d
[6] = (unsigned int)(d
[6] + s
[6] + 1) >> 1;
42 d
[7] = (unsigned int)(d
[7] + s
[7] + 1) >> 1;
43 d
[8] = (unsigned int)(d
[8] + s
[8] + 1) >> 1;
44 d
[9] = (unsigned int)(d
[9] + s
[9] + 1) >> 1;
45 d
[10] = (unsigned int)(d
[10] + s
[10] + 1) >> 1;
46 d
[11] = (unsigned int)(d
[11] + s
[11] + 1) >> 1;
47 d
[12] = (unsigned int)(d
[12] + s
[12] + 1) >> 1;
48 d
[13] = (unsigned int)(d
[13] + s
[13] + 1) >> 1;
49 d
[14] = (unsigned int)(d
[14] + s
[14] + 1) >> 1;
50 d
[15] = (unsigned int)(d
[15] + s
[15] + 1) >> 1;
54 static inline void recac(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
57 for(j
= 0; j
< h
; j
++, s
+= lx2
, d
+= lx2
)
59 d
[0] = (unsigned int)(d
[0] + s
[0] + 1)>>1;
60 d
[1] = (unsigned int)(d
[1] + s
[1] + 1)>>1;
61 d
[2] = (unsigned int)(d
[2] + s
[2] + 1)>>1;
62 d
[3] = (unsigned int)(d
[3] + s
[3] + 1)>>1;
63 d
[4] = (unsigned int)(d
[4] + s
[4] + 1)>>1;
64 d
[5] = (unsigned int)(d
[5] + s
[5] + 1)>>1;
65 d
[6] = (unsigned int)(d
[6] + s
[6] + 1)>>1;
66 d
[7] = (unsigned int)(d
[7] + s
[7] + 1)>>1;
70 static inline void recv(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
72 unsigned char *dp
,*sp
,*sp2
;
77 for(j
= 0; j
< h
; j
++)
79 dp
[0] = (unsigned int)(sp
[0] + sp2
[0] + 1) >> 1;
80 dp
[1] = (unsigned int)(sp
[1] + sp2
[1] + 1) >> 1;
81 dp
[2] = (unsigned int)(sp
[2] + sp2
[2] + 1) >> 1;
82 dp
[3] = (unsigned int)(sp
[3] + sp2
[3] + 1) >> 1;
83 dp
[4] = (unsigned int)(sp
[4] + sp2
[4] + 1) >> 1;
84 dp
[5] = (unsigned int)(sp
[5] + sp2
[5] + 1) >> 1;
85 dp
[6] = (unsigned int)(sp
[6] + sp2
[6] + 1) >> 1;
86 dp
[7] = (unsigned int)(sp
[7] + sp2
[7] + 1) >> 1;
87 dp
[8] = (unsigned int)(sp
[8] + sp2
[8] + 1) >> 1;
88 dp
[9] = (unsigned int)(sp
[9] + sp2
[9] + 1) >> 1;
89 dp
[10] = (unsigned int)(sp
[10] + sp2
[10] + 1) >> 1;
90 dp
[11] = (unsigned int)(sp
[11] + sp2
[11] + 1) >> 1;
91 dp
[12] = (unsigned int)(sp
[12] + sp2
[12] + 1) >> 1;
92 dp
[13] = (unsigned int)(sp
[13] + sp2
[13] + 1) >> 1;
93 dp
[14] = (unsigned int)(sp
[14] + sp2
[14] + 1) >> 1;
94 dp
[15] = (unsigned int)(sp
[15] + sp2
[15] + 1) >> 1;
101 static inline void recvc(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
103 unsigned char *dp
,*sp
,*sp2
;
109 for(j
= 0; j
< h
; j
++)
111 dp
[0] = (unsigned int)(sp
[0]+sp2
[0]+1)>>1;
112 dp
[1] = (unsigned int)(sp
[1]+sp2
[1]+1)>>1;
113 dp
[2] = (unsigned int)(sp
[2]+sp2
[2]+1)>>1;
114 dp
[3] = (unsigned int)(sp
[3]+sp2
[3]+1)>>1;
115 dp
[4] = (unsigned int)(sp
[4]+sp2
[4]+1)>>1;
116 dp
[5] = (unsigned int)(sp
[5]+sp2
[5]+1)>>1;
117 dp
[6] = (unsigned int)(sp
[6]+sp2
[6]+1)>>1;
118 dp
[7] = (unsigned int)(sp
[7]+sp2
[7]+1)>>1;
126 static inline void recva(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
128 unsigned char *dp
,*sp
,*sp2
;
135 dp
[0] = (dp
[0] + ((unsigned int)(sp
[0]+sp2
[0]+1)>>1) + 1)>>1;
136 dp
[1] = (dp
[1] + ((unsigned int)(sp
[1]+sp2
[1]+1)>>1) + 1)>>1;
137 dp
[2] = (dp
[2] + ((unsigned int)(sp
[2]+sp2
[2]+1)>>1) + 1)>>1;
138 dp
[3] = (dp
[3] + ((unsigned int)(sp
[3]+sp2
[3]+1)>>1) + 1)>>1;
139 dp
[4] = (dp
[4] + ((unsigned int)(sp
[4]+sp2
[4]+1)>>1) + 1)>>1;
140 dp
[5] = (dp
[5] + ((unsigned int)(sp
[5]+sp2
[5]+1)>>1) + 1)>>1;
141 dp
[6] = (dp
[6] + ((unsigned int)(sp
[6]+sp2
[6]+1)>>1) + 1)>>1;
142 dp
[7] = (dp
[7] + ((unsigned int)(sp
[7]+sp2
[7]+1)>>1) + 1)>>1;
143 dp
[8] = (dp
[8] + ((unsigned int)(sp
[8]+sp2
[8]+1)>>1) + 1)>>1;
144 dp
[9] = (dp
[9] + ((unsigned int)(sp
[9]+sp2
[9]+1)>>1) + 1)>>1;
145 dp
[10] = (dp
[10] + ((unsigned int)(sp
[10]+sp2
[10]+1)>>1) + 1)>>1;
146 dp
[11] = (dp
[11] + ((unsigned int)(sp
[11]+sp2
[11]+1)>>1) + 1)>>1;
147 dp
[12] = (dp
[12] + ((unsigned int)(sp
[12]+sp2
[12]+1)>>1) + 1)>>1;
148 dp
[13] = (dp
[13] + ((unsigned int)(sp
[13]+sp2
[13]+1)>>1) + 1)>>1;
149 dp
[14] = (dp
[14] + ((unsigned int)(sp
[14]+sp2
[14]+1)>>1) + 1)>>1;
150 dp
[15] = (dp
[15] + ((unsigned int)(sp
[15]+sp2
[15]+1)>>1) + 1)>>1;
158 static inline void recvac(unsigned char *s
, unsigned char *d
, int lx
,int lx2
, int h
){
159 unsigned char *dp
,*sp
,*sp2
;
166 dp
[0] = (dp
[0] + ((unsigned int)(sp
[0]+sp2
[0]+1)>>1) + 1)>>1;
167 dp
[1] = (dp
[1] + ((unsigned int)(sp
[1]+sp2
[1]+1)>>1) + 1)>>1;
168 dp
[2] = (dp
[2] + ((unsigned int)(sp
[2]+sp2
[2]+1)>>1) + 1)>>1;
169 dp
[3] = (dp
[3] + ((unsigned int)(sp
[3]+sp2
[3]+1)>>1) + 1)>>1;
170 dp
[4] = (dp
[4] + ((unsigned int)(sp
[4]+sp2
[4]+1)>>1) + 1)>>1;
171 dp
[5] = (dp
[5] + ((unsigned int)(sp
[5]+sp2
[5]+1)>>1) + 1)>>1;
172 dp
[6] = (dp
[6] + ((unsigned int)(sp
[6]+sp2
[6]+1)>>1) + 1)>>1;
173 dp
[7] = (dp
[7] + ((unsigned int)(sp
[7]+sp2
[7]+1)>>1) + 1)>>1;
181 static inline void rech(unsigned char *s
, unsigned char *d
, int lx2
, int h
){
182 unsigned char *dp
,*sp
;
190 dp
[0] = (unsigned int)(s1
+(s2
=sp
[1])+1)>>1;
191 dp
[1] = (unsigned int)(s2
+(s1
=sp
[2])+1)>>1;
192 dp
[2] = (unsigned int)(s1
+(s2
=sp
[3])+1)>>1;
193 dp
[3] = (unsigned int)(s2
+(s1
=sp
[4])+1)>>1;
194 dp
[4] = (unsigned int)(s1
+(s2
=sp
[5])+1)>>1;
195 dp
[5] = (unsigned int)(s2
+(s1
=sp
[6])+1)>>1;
196 dp
[6] = (unsigned int)(s1
+(s2
=sp
[7])+1)>>1;
197 dp
[7] = (unsigned int)(s2
+(s1
=sp
[8])+1)>>1;
198 dp
[8] = (unsigned int)(s1
+(s2
=sp
[9])+1)>>1;
199 dp
[9] = (unsigned int)(s2
+(s1
=sp
[10])+1)>>1;
200 dp
[10] = (unsigned int)(s1
+(s2
=sp
[11])+1)>>1;
201 dp
[11] = (unsigned int)(s2
+(s1
=sp
[12])+1)>>1;
202 dp
[12] = (unsigned int)(s1
+(s2
=sp
[13])+1)>>1;
203 dp
[13] = (unsigned int)(s2
+(s1
=sp
[14])+1)>>1;
204 dp
[14] = (unsigned int)(s1
+(s2
=sp
[15])+1)>>1;
205 dp
[15] = (unsigned int)(s2
+sp
[16]+1)>>1;
212 static inline void rechc(unsigned char *s
,unsigned char *d
, int lx2
, int h
){
213 unsigned char *dp
,*sp
;
221 dp
[0] = (unsigned int)(s1
+(s2
=sp
[1])+1)>>1;
222 dp
[1] = (unsigned int)(s2
+(s1
=sp
[2])+1)>>1;
223 dp
[2] = (unsigned int)(s1
+(s2
=sp
[3])+1)>>1;
224 dp
[3] = (unsigned int)(s2
+(s1
=sp
[4])+1)>>1;
225 dp
[4] = (unsigned int)(s1
+(s2
=sp
[5])+1)>>1;
226 dp
[5] = (unsigned int)(s2
+(s1
=sp
[6])+1)>>1;
227 dp
[6] = (unsigned int)(s1
+(s2
=sp
[7])+1)>>1;
228 dp
[7] = (unsigned int)(s2
+sp
[8]+1)>>1;
234 static inline void recha(unsigned char *s
, unsigned char *d
,int lx2
, int h
)
236 unsigned char *dp
,*sp
;
242 for (j
= 0; j
< h
; j
++)
245 dp
[0] = (dp
[0] + ((unsigned int)(s1
+ (s2
= sp
[1]) + 1) >> 1) + 1) >> 1;
246 dp
[1] = (dp
[1] + ((unsigned int)(s2
+ (s1
= sp
[2]) + 1) >> 1) + 1) >> 1;
247 dp
[2] = (dp
[2] + ((unsigned int)(s1
+ (s2
= sp
[3]) + 1) >> 1) + 1) >> 1;
248 dp
[3] = (dp
[3] + ((unsigned int)(s2
+ (s1
= sp
[4]) + 1) >> 1) + 1) >> 1;
249 dp
[4] = (dp
[4] + ((unsigned int)(s1
+ (s2
= sp
[5]) + 1) >> 1) + 1) >> 1;
250 dp
[5] = (dp
[5] + ((unsigned int)(s2
+ (s1
= sp
[6]) + 1) >> 1) + 1) >> 1;
251 dp
[6] = (dp
[6] + ((unsigned int)(s1
+ (s2
= sp
[7]) + 1) >> 1) + 1) >> 1;
252 dp
[7] = (dp
[7] + ((unsigned int)(s2
+ (s1
= sp
[8]) + 1) >> 1) + 1) >> 1;
253 dp
[8] = (dp
[8] + ((unsigned int)(s1
+ (s2
= sp
[9]) + 1) >> 1) + 1) >> 1;
254 dp
[9] = (dp
[9] + ((unsigned int)(s2
+ (s1
= sp
[10]) + 1) >> 1) + 1) >> 1;
255 dp
[10] = (dp
[10] + ((unsigned int)(s1
+ (s2
= sp
[11]) + 1) >> 1) + 1) >> 1;
256 dp
[11] = (dp
[11] + ((unsigned int)(s2
+ (s1
= sp
[12]) + 1) >> 1) + 1) >> 1;
257 dp
[12] = (dp
[12] + ((unsigned int)(s1
+ (s2
= sp
[13]) + 1) >> 1) + 1) >> 1;
258 dp
[13] = (dp
[13] + ((unsigned int)(s2
+ (s1
= sp
[14]) + 1) >> 1) + 1) >> 1;
259 dp
[14] = (dp
[14] + ((unsigned int)(s1
+ (s2
= sp
[15]) + 1) >> 1) + 1) >> 1;
260 dp
[15] = (dp
[15] + ((unsigned int)(s2
+ sp
[16] + 1) >> 1) + 1) >> 1;
267 static inline void rechac(unsigned char *s
,unsigned char *d
, int lx2
, int h
)
269 unsigned char *dp
,*sp
;
275 for(j
= 0; j
< h
; j
++)
278 dp
[0] = (dp
[0] + ((unsigned int)(s1
+ (s2
= sp
[1]) + 1) >> 1) + 1) >> 1;
279 dp
[1] = (dp
[1] + ((unsigned int)(s2
+ (s1
= sp
[2]) + 1) >> 1) + 1) >> 1;
280 dp
[2] = (dp
[2] + ((unsigned int)(s1
+ (s2
= sp
[3]) + 1) >> 1) + 1) >> 1;
281 dp
[3] = (dp
[3] + ((unsigned int)(s2
+ (s1
= sp
[4]) + 1) >> 1) + 1) >> 1;
282 dp
[4] = (dp
[4] + ((unsigned int)(s1
+ (s2
= sp
[5]) + 1) >> 1) + 1) >> 1;
283 dp
[5] = (dp
[5] + ((unsigned int)(s2
+ (s1
= sp
[6]) + 1) >> 1) + 1) >> 1;
284 dp
[6] = (dp
[6] + ((unsigned int)(s1
+ (s2
= sp
[7]) + 1) >> 1) + 1) >> 1;
285 dp
[7] = (dp
[7] + ((unsigned int)(s2
+ sp
[8] + 1) >> 1) + 1) >> 1;
292 static inline void rec4(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
294 unsigned char *dp
,*sp
,*sp2
;
295 unsigned int s1
,s2
,s3
,s4
;
303 dp
[0] = (unsigned int)(s1
+(s2
=sp
[1])+s3
+(s4
=sp2
[1])+2)>>2;
304 dp
[1] = (unsigned int)(s2
+(s1
=sp
[2])+s4
+(s3
=sp2
[2])+2)>>2;
305 dp
[2] = (unsigned int)(s1
+(s2
=sp
[3])+s3
+(s4
=sp2
[3])+2)>>2;
306 dp
[3] = (unsigned int)(s2
+(s1
=sp
[4])+s4
+(s3
=sp2
[4])+2)>>2;
307 dp
[4] = (unsigned int)(s1
+(s2
=sp
[5])+s3
+(s4
=sp2
[5])+2)>>2;
308 dp
[5] = (unsigned int)(s2
+(s1
=sp
[6])+s4
+(s3
=sp2
[6])+2)>>2;
309 dp
[6] = (unsigned int)(s1
+(s2
=sp
[7])+s3
+(s4
=sp2
[7])+2)>>2;
310 dp
[7] = (unsigned int)(s2
+(s1
=sp
[8])+s4
+(s3
=sp2
[8])+2)>>2;
311 dp
[8] = (unsigned int)(s1
+(s2
=sp
[9])+s3
+(s4
=sp2
[9])+2)>>2;
312 dp
[9] = (unsigned int)(s2
+(s1
=sp
[10])+s4
+(s3
=sp2
[10])+2)>>2;
313 dp
[10] = (unsigned int)(s1
+(s2
=sp
[11])+s3
+(s4
=sp2
[11])+2)>>2;
314 dp
[11] = (unsigned int)(s2
+(s1
=sp
[12])+s4
+(s3
=sp2
[12])+2)>>2;
315 dp
[12] = (unsigned int)(s1
+(s2
=sp
[13])+s3
+(s4
=sp2
[13])+2)>>2;
316 dp
[13] = (unsigned int)(s2
+(s1
=sp
[14])+s4
+(s3
=sp2
[14])+2)>>2;
317 dp
[14] = (unsigned int)(s1
+(s2
=sp
[15])+s3
+(s4
=sp2
[15])+2)>>2;
318 dp
[15] = (unsigned int)(s2
+sp
[16]+s4
+sp2
[16]+2)>>2;
326 static inline void rec4c(unsigned char *s
,unsigned char *d
, int lx
, int lx2
, int h
)
328 unsigned char *dp
,*sp
,*sp2
;
329 unsigned int s1
,s2
,s3
,s4
;
337 dp
[0] = (unsigned int)(s1
+(s2
=sp
[1])+s3
+(s4
=sp2
[1])+2)>>2;
338 dp
[1] = (unsigned int)(s2
+(s1
=sp
[2])+s4
+(s3
=sp2
[2])+2)>>2;
339 dp
[2] = (unsigned int)(s1
+(s2
=sp
[3])+s3
+(s4
=sp2
[3])+2)>>2;
340 dp
[3] = (unsigned int)(s2
+(s1
=sp
[4])+s4
+(s3
=sp2
[4])+2)>>2;
341 dp
[4] = (unsigned int)(s1
+(s2
=sp
[5])+s3
+(s4
=sp2
[5])+2)>>2;
342 dp
[5] = (unsigned int)(s2
+(s1
=sp
[6])+s4
+(s3
=sp2
[6])+2)>>2;
343 dp
[6] = (unsigned int)(s1
+(s2
=sp
[7])+s3
+(s4
=sp2
[7])+2)>>2;
344 dp
[7] = (unsigned int)(s2
+sp
[8]+s4
+sp2
[8]+2)>>2;
352 static inline void rec4a(unsigned char *s
,unsigned char *d
, int lx
, int lx2
, int h
)
354 unsigned char *dp
=d
, *sp
=s
, *sp2
=s
+lx
;
355 unsigned int s1
, s2
, s3
, s4
;
365 dp
[0] = (dp
[0] + ((unsigned int)(s1
+(s2
=sp
[1])+s3
+(s4
=sp2
[1])+2)>>2) + 1)>>1;
366 dp
[1] = (dp
[1] + ((unsigned int)(s2
+(s1
=sp
[2])+s4
+(s3
=sp2
[2])+2)>>2) + 1)>>1;
367 dp
[2] = (dp
[2] + ((unsigned int)(s1
+(s2
=sp
[3])+s3
+(s4
=sp2
[3])+2)>>2) + 1)>>1;
368 dp
[3] = (dp
[3] + ((unsigned int)(s2
+(s1
=sp
[4])+s4
+(s3
=sp2
[4])+2)>>2) + 1)>>1;
369 dp
[4] = (dp
[4] + ((unsigned int)(s1
+(s2
=sp
[5])+s3
+(s4
=sp2
[5])+2)>>2) + 1)>>1;
370 dp
[5] = (dp
[5] + ((unsigned int)(s2
+(s1
=sp
[6])+s4
+(s3
=sp2
[6])+2)>>2) + 1)>>1;
371 dp
[6] = (dp
[6] + ((unsigned int)(s1
+(s2
=sp
[7])+s3
+(s4
=sp2
[7])+2)>>2) + 1)>>1;
372 dp
[7] = (dp
[7] + ((unsigned int)(s2
+(s1
=sp
[8])+s4
+(s3
=sp2
[8])+2)>>2) + 1)>>1;
373 dp
[8] = (dp
[8] + ((unsigned int)(s1
+(s2
=sp
[9])+s3
+(s4
=sp2
[9])+2)>>2) + 1)>>1;
374 dp
[9] = (dp
[9] + ((unsigned int)(s2
+(s1
=sp
[10])+s4
+(s3
=sp2
[10])+2)>>2) + 1)>>1;
375 dp
[10] = (dp
[10] + ((unsigned int)(s1
+(s2
=sp
[11])+s3
+(s4
=sp2
[11])+2)>>2) + 1)>>1;
376 dp
[11] = (dp
[11] + ((unsigned int)(s2
+(s1
=sp
[12])+s4
+(s3
=sp2
[12])+2)>>2) + 1)>>1;
377 dp
[12] = (dp
[12] + ((unsigned int)(s1
+(s2
=sp
[13])+s3
+(s4
=sp2
[13])+2)>>2) + 1)>>1;
378 dp
[13] = (dp
[13] + ((unsigned int)(s2
+(s1
=sp
[14])+s4
+(s3
=sp2
[14])+2)>>2) + 1)>>1;
379 dp
[14] = (dp
[14] + ((unsigned int)(s1
+(s2
=sp
[15])+s3
+(s4
=sp2
[15])+2)>>2) + 1)>>1;
380 dp
[15] = (dp
[15] + ((unsigned int)(s2
+sp
[16]+s4
+sp2
[16]+2)>>2) + 1)>>1;
388 static inline void rec4ac(unsigned char *s
,unsigned char *d
, int lx
, int lx2
, int h
)
390 unsigned char *dp
=d
, *sp
=s
, *sp2
=s
+lx
;
391 unsigned int s1
,s2
,s3
,s4
;
402 dp
[0] = (dp
[0] + ((unsigned int)(s1
+(s2
=sp
[1])+s3
+(s4
=sp2
[1])+2)>>2) + 1)>>1;
403 dp
[1] = (dp
[1] + ((unsigned int)(s2
+(s1
=sp
[2])+s4
+(s3
=sp2
[2])+2)>>2) + 1)>>1;
404 dp
[2] = (dp
[2] + ((unsigned int)(s1
+(s2
=sp
[3])+s3
+(s4
=sp2
[3])+2)>>2) + 1)>>1;
405 dp
[3] = (dp
[3] + ((unsigned int)(s2
+(s1
=sp
[4])+s4
+(s3
=sp2
[4])+2)>>2) + 1)>>1;
406 dp
[4] = (dp
[4] + ((unsigned int)(s1
+(s2
=sp
[5])+s3
+(s4
=sp2
[5])+2)>>2) + 1)>>1;
407 dp
[5] = (dp
[5] + ((unsigned int)(s2
+(s1
=sp
[6])+s4
+(s3
=sp2
[6])+2)>>2) + 1)>>1;
408 dp
[6] = (dp
[6] + ((unsigned int)(s1
+(s2
=sp
[7])+s3
+(s4
=sp2
[7])+2)>>2) + 1)>>1;
409 dp
[7] = (dp
[7] + ((unsigned int)(s2
+sp
[8]+s4
+sp2
[8]+2)>>2) + 1)>>1;
417 void recon_comp(mpeg3video_t
*video
,
431 unsigned char *s
, *d
;
433 /* half pel scaling */
434 switcher
= (dx
& 1) << 3 | (dy
& 1) << 2 | w
;
435 if(addflag
) switcher
|= 2;
437 s
= src
+ lx
* (y
+ (dy
>> 1)) + x
+ (dx
>> 1);
438 d
= dst
+ lx
* y
+ x
;
440 // Accelerated functions
443 case 0x3: reca(s
, d
, lx2
, h
); break;
444 case 0x2: recac(s
, d
, lx2
, h
); break;
445 case 0x1: rec(s
, d
, lx2
, h
); break;
446 case 0x0: recc(s
, d
, lx2
, h
); break;
447 case 0x7: recva(s
, d
, lx
, lx2
, h
); break;
448 case 0x6: recvac(s
, d
, lx
, lx2
, h
); break;
449 case 0x5: recv(s
, d
, lx
, lx2
, h
); break;
450 case 0x4: recvc(s
, d
, lx
, lx2
, h
); break;
451 case 0x9: rech(s
, d
, lx2
, h
); break;
452 case 0x8: rechc(s
, d
, lx2
, h
); break;
455 // Unaccelerated functions
458 case 0xb: recha(s
, d
, lx2
, h
); break;
459 case 0xa: rechac(s
, d
, lx2
, h
); break;
460 case 0xf: rec4a(s
, d
, lx
, lx2
, h
); break;
461 case 0xe: rec4ac(s
, d
, lx
, lx2
, h
); break;
462 case 0xd: rec4(s
, d
, lx
, lx2
, h
); break;
463 case 0xc: rec4c(s
, d
, lx
, lx2
, h
); break;
468 unsigned char *src[]; * prediction source buffer *
469 int sfield; * prediction source field number (0 or 1) *
470 unsigned char *dst[]; * prediction destination buffer *
471 int dfield; * prediction destination field number (0 or 1)*
472 int lx,lx2; * horizontal offsets *
473 int w,h; * prediction block/sub-block width, height *
474 int x,y; * pixel co-ordinates of top-left sample in current MB *
475 int dx,dy; * horizontal, vertical motion vector *
476 int addflag; * add prediction error to prediction ? *
478 static void recon(mpeg3video_t
*video
,
479 unsigned char *src
[],
481 unsigned char *dst
[],
495 recon_comp(video
, (src
[0] + (sfield
? (lx2
>> 1) : 0)),
496 dst
[0] + (dfield
? (lx2
>> 1) : 0),
497 lx
, lx2
, w
, h
, x
, y
, dx
, dy
, addflag
);
499 if(video
->chroma_format
!= CHROMA444
)
508 if(video
->chroma_format
== CHROMA420
)
516 recon_comp(video
, (src
[1] + (sfield
? (lx2
>> 1) : 0)),
517 dst
[1] + (dfield
? (lx2
>> 1) : 0),
518 lx
, lx2
, w
, h
, x
, y
, dx
, dy
, addflag
);
521 recon_comp(video
, (src
[2] + (sfield
? (lx2
>> 1) : 0)),
522 dst
[2] + (dfield
? (lx2
>> 1) : 0),
523 lx
, lx2
, w
, h
, x
, y
, dx
, dy
, addflag
);
528 int mpeg3video_reconstruct(mpeg3video_t
*video
,
534 int mv_field_sel
[2][2],
539 unsigned char **predframe
;
543 stwtop
= stwtype
% 3; /* 0:temporal, 1 : (spat+temp) / 2, 2 : spatial */
544 stwbot
= stwtype
/ 3;
546 if((mb_type
& MB_FORWARD
) || (video
->pict_type
== P_TYPE
))
548 if(video
->pict_struct
== FRAME_PICTURE
)
550 if((motion_type
== MC_FRAME
) || !(mb_type
& MB_FORWARD
))
552 /* frame-based prediction */
555 recon(video
, video
->oldrefframe
, 0, video
->newframe
, 0,
556 video
->coded_picture_width
, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
,
557 PMV
[0][0][0], PMV
[0][0][1], stwtop
);
560 recon(video
, video
->oldrefframe
, 1, video
->newframe
, 1,
561 video
->coded_picture_width
, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
,
562 PMV
[0][0][0], PMV
[0][0][1], stwbot
);
565 else if(motion_type
== MC_FIELD
) /* field-based prediction */
567 /* top field prediction */
569 recon(video
, video
->oldrefframe
, mv_field_sel
[0][0], video
->newframe
, 0,
570 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
>> 1,
571 PMV
[0][0][0], PMV
[0][0][1] >> 1, stwtop
);
573 /* bottom field prediction */
575 recon(video
, video
->oldrefframe
, mv_field_sel
[1][0], video
->newframe
, 1,
576 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
>> 1,
577 PMV
[1][0][0], PMV
[1][0][1] >> 1, stwbot
);
579 else if(motion_type
== MC_DMV
)
581 /* dual prime prediction */
582 /* calculate derived motion vectors */
583 mpeg3video_calc_dmv(video
,
591 /* predict top field from top field */
592 recon(video
, video
->oldrefframe
, 0, video
->newframe
, 0,
593 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
>>1,
594 PMV
[0][0][0], PMV
[0][0][1] >> 1, 0);
596 /* predict and add to top field from bottom field */
597 recon(video
, video
->oldrefframe
, 1, video
->newframe
, 0,
598 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
>>1,
599 DMV
[0][0], DMV
[0][1], 1);
604 /* predict bottom field from bottom field */
605 recon(video
, video
->oldrefframe
, 1, video
->newframe
, 1,
606 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
>>1,
607 PMV
[0][0][0], PMV
[0][0][1]>>1, 0);
609 /* predict and add to bottom field from top field */
610 recon(video
, video
->oldrefframe
, 0, video
->newframe
, 1,
611 video
->coded_picture_width
<< 1, video
->coded_picture_width
<<1, WIDTH
, 8, bx
, by
>>1,
612 DMV
[1][0], DMV
[1][1], 1);
616 /* invalid motion_type */
617 /* fprintf(stderr, "reconstruct: invalid motion_type\n"); */
622 /* TOP_FIELD or BOTTOM_FIELD */
624 currentfield
= (video
->pict_struct
== BOTTOM_FIELD
);
626 /* determine which frame to use for prediction */
627 if((video
->pict_type
== P_TYPE
) && video
->secondfield
628 && (currentfield
!= mv_field_sel
[0][0]))
629 predframe
= video
->refframe
; /* same frame */
631 predframe
= video
->oldrefframe
; /* previous frame */
633 if((motion_type
== MC_FIELD
) || !(mb_type
& MB_FORWARD
))
635 /* field-based prediction */
637 recon(video
, predframe
,mv_field_sel
[0][0],video
->newframe
,0,
638 video
->coded_picture_width
<< 1,video
->coded_picture_width
<< 1,WIDTH
,16,bx
,by
,
639 PMV
[0][0][0],PMV
[0][0][1],stwtop
);
642 if(motion_type
== MC_16X8
)
646 recon(video
, predframe
, mv_field_sel
[0][0], video
->newframe
, 0,
647 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
,
648 PMV
[0][0][0], PMV
[0][0][1], stwtop
);
650 /* determine which frame to use for lower half prediction */
651 if((video
->pict_type
==P_TYPE
) && video
->secondfield
652 && (currentfield
!=mv_field_sel
[1][0]))
653 predframe
= video
->refframe
; /* same frame */
655 predframe
= video
->oldrefframe
; /* previous frame */
657 recon(video
, predframe
, mv_field_sel
[1][0], video
->newframe
, 0,
658 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
+8,
659 PMV
[1][0][0], PMV
[1][0][1], stwtop
);
663 if(motion_type
== MC_DMV
) /* dual prime prediction */
665 if(video
->secondfield
)
666 predframe
= video
->refframe
; /* same frame */
668 predframe
= video
->oldrefframe
; /* previous frame */
670 /* calculate derived motion vectors */
671 mpeg3video_calc_dmv(video
,
677 /* predict from field of same parity */
678 recon(video
, video
->oldrefframe
, currentfield
, video
->newframe
, 0,
679 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 16, bx
, by
,
680 PMV
[0][0][0], PMV
[0][0][1], 0);
682 /* predict from field of opposite parity */
683 recon(video
, predframe
, !currentfield
, video
->newframe
, 0,
684 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 16, bx
, by
,
685 DMV
[0][0], DMV
[0][1], 1);
688 /* invalid motion_type */
689 /* fprintf(stderr, "reconstruct: invalid motion_type\n"); */
695 if(mb_type
& MB_BACKWARD
)
697 if(video
->pict_struct
== FRAME_PICTURE
)
699 if(motion_type
== MC_FRAME
)
701 /* frame-based prediction */
703 recon(video
, video
->refframe
, 0, video
->newframe
, 0,
704 video
->coded_picture_width
, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
,
705 PMV
[0][1][0], PMV
[0][1][1], stwtop
);
708 recon(video
, video
->refframe
, 1, video
->newframe
, 1,
709 video
->coded_picture_width
, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
,
710 PMV
[0][1][0], PMV
[0][1][1], stwbot
);
714 /* field-based prediction */
715 /* top field prediction */
718 recon(video
, video
->refframe
, mv_field_sel
[0][1], video
->newframe
, 0,
719 (video
->coded_picture_width
<< 1), (video
->coded_picture_width
<<1), WIDTH
, 8, bx
, (by
>> 1),
720 PMV
[0][1][0], (PMV
[0][1][1] >> 1), stwtop
);
723 /* bottom field prediction */
726 recon(video
, video
->refframe
, mv_field_sel
[1][1], video
->newframe
, 1, (video
->coded_picture_width
<< 1),
727 (video
->coded_picture_width
<< 1), WIDTH
, 8, bx
, (by
>>1),
728 PMV
[1][1][0], (PMV
[1][1][1]>>1), stwbot
);
734 /* TOP_FIELD or BOTTOM_FIELD */
736 if(motion_type
== MC_FIELD
)
738 /* field-based prediction */
739 recon(video
, video
->refframe
, mv_field_sel
[0][1], video
->newframe
, 0,
740 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 16, bx
, by
,
741 PMV
[0][1][0], PMV
[0][1][1], stwtop
);
743 else if(motion_type
==MC_16X8
)
745 recon(video
, video
->refframe
, mv_field_sel
[0][1], video
->newframe
, 0,
746 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
,
747 PMV
[0][1][0], PMV
[0][1][1], stwtop
);
749 recon(video
, video
->refframe
, mv_field_sel
[1][1], video
->newframe
, 0,
750 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
+8,
751 PMV
[1][1][0], PMV
[1][1][1], stwtop
);
754 /* invalid motion_type */
755 /* fprintf(stderr, "reconstruct: invalid motion_type\n"); */
758 } /* mb_type & MB_BACKWARD */