1 #include "mpeg3private.h"
2 #include "mpeg3protos.h"
6 #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3)
7 #define USED __attribute__((used))
13 static inline void recva_mmx(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
18 "movq (%1), %%mm0\n" /* 8 s */
19 "movq 8(%1), %%mm1\n" /* 8 s */
20 "movq (%4), %%mm2\n" /* 8 s +lx */
21 "movq 8(%4), %%mm3\n" /* 8 s +lx **/
23 "pavgusb %%mm2, %%mm0\n"
25 "pavgusb %%mm3, %%mm1\n"
27 "movq (%2), %%mm2\n" /* 8 d */
28 "movq 8(%2), %%mm3\n" /* 8 d */
29 "pavgusb %%mm2, %%mm0\n"
31 "pavgusb %%mm3, %%mm1\n"
38 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
), "r" (s
+lx
)
42 static inline void recvac_mmx(unsigned char *s
, unsigned char *d
, int lx
,int lx2
, int h
)
47 "movq (%1), %%mm0\n" /* 8 s */
48 "movq (%4), %%mm2\n" /* 8 s +lx */
50 "pavgusb %%mm2, %%mm0\n"
51 "movq (%2), %%mm3\n" /* 8 d */
53 "pavgusb %%mm3, %%mm0\n"
58 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
), "r" (s
+lx
)
62 static inline void rech_mmx(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
67 "movq (%1), %%mm0\n" /* 8 s */
68 "movq 8(%1), %%mm1\n" /* 8 s */
69 "movq 1(%1), %%mm2\n" /* 8 s */
70 "movq 9(%1), %%mm3\n" /* 8 s */
72 "pavgusb %%mm2, %%mm0\n"
74 "pavgusb %%mm3, %%mm1\n"
81 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
)
85 static inline void rechc_mmx(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
90 "movq (%1), %%mm0\n" /* 8 s */
91 "movq 1(%1), %%mm2\n" /* 8 s +1 */
93 "pavgusb %%mm2, %%mm0\n"
98 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
)
102 static inline void recha_mmx(unsigned char *s
, unsigned char *d
,int lx2
, int h
)
107 "movq (%1), %%mm0\n" /* 8 s */
108 "movq 8(%1), %%mm1\n" /* 8 s */
109 "movq 1(%1), %%mm2\n" /* 8 s */
110 "movq 9(%1), %%mm3\n" /* 8 s */
112 "pavgusb %%mm2, %%mm0\n"
114 "pavgusb %%mm3, %%mm1\n"
116 "movq (%2), %%mm2\n" /* 8 d */
117 "movq 8(%2), %%mm3\n" /* 8 d */
118 "pavgusb %%mm2, %%mm0\n"
119 "pavgusb %%mm3, %%mm1\n"
122 "movq %%mm1, 8(%2)\n"
126 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
)
130 static inline void rechac_mmx(unsigned char *s
,unsigned char *d
, int lx2
, int h
)
135 "movq (%1), %%mm0\n" /* 8 s */
136 "movq 1(%1), %%mm2\n" /* 8 s */
139 "pavgusb %%mm2, %%mm0\n"
141 "movq (%2), %%mm1\n" /* 8 d */
142 "pavgusb %%mm1, %%mm0\n"
148 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
)
152 static inline void rec4_mmx(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
154 __asm__
__volatile__(
155 "movq (%1), %%mm0\n" /* 8 s */
156 "movq 8(%1), %%mm1\n" /* 8 s */
157 "movq 1(%1), %%mm2\n" /* 8 s +1*/
158 "movq 9(%1), %%mm3\n" /* 8 s +1*/
161 "movq (%4), %%mm4\n" /* 8 s+lx */
162 "pavgusb %%mm2, %%mm0\n"
163 "movq 8(%4), %%mm5\n" /* 8 s+lx */
164 "pavgusb %%mm3, %%mm1\n"
166 "movq 1(%4), %%mm6\n" /* 8 s+lx +1*/
167 "pavgusb %%mm4, %%mm0\n"
168 "movq 9(%4), %%mm7\n" /* 8 s+lx +1*/
169 "pavgusb %%mm5, %%mm1\n"
171 "pavgusb %%mm6, %%mm0\n"
173 "pavgusb %%mm7, %%mm1\n"
175 "movq %%mm6, %%mm2\n"
176 "movq %%mm7, %%mm3\n"
177 "movq %%mm1, 8(%2)\n"
178 "movq %%mm4, %%mm0\n"
179 "movq %%mm5, %%mm1\n"
183 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
), "r" (s
+lx
)
187 static inline void rec4c_mmx(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
189 __asm__
__volatile__(
190 "movq (%1), %%mm0\n" /* 8 s */
191 "movq 1(%1), %%mm2\n" /* 8 s +1*/
194 "movq (%4), %%mm4\n" /* 8 s+lx */
195 "pavgusb %%mm2, %%mm0\n"
197 "movq 1(%4), %%mm6\n" /* 8 s+lx +1*/
198 "pavgusb %%mm4, %%mm0\n"
201 "pavgusb %%mm6, %%mm0\n"
203 "movq %%mm6, %%mm2\n"
204 "movq %%mm4, %%mm0\n"
208 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
), "r" (s
+lx
)
212 static inline void rec4a_mmx(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
214 __asm__
__volatile__(
215 "movq (%1), %%mm0\n" /* 8 s */
216 "movq 8(%1), %%mm1\n" /* 8 s */
217 "movq 1(%1), %%mm2\n" /* 8 s +1*/
218 "movq 9(%1), %%mm3\n" /* 8 s +1*/
221 "movq (%4), %%mm4\n" /* 8 s+lx */
222 "pavgusb %%mm2, %%mm0\n"
223 "movq 8(%4), %%mm5\n" /* 8 s+lx */
224 "pavgusb %%mm3, %%mm1\n"
226 "movq 1(%4), %%mm6\n" /* 8 s+lx +1*/
227 "pavgusb %%mm4, %%mm0\n"
228 "movq 9(%4), %%mm7\n" /* 8 s+lx +1*/
229 "pavgusb %%mm5, %%mm1\n"
231 "pavgusb %%mm6, %%mm0\n"
232 "movq 8(%2), %%mm3\n"
234 "pavgusb %%mm2, %%mm0\n"
236 "pavgusb %%mm3, %%mm1\n"
239 "pavgusb %%mm7, %%mm1\n"
240 "movq %%mm6, %%mm2\n"
241 "movq %%mm7, %%mm3\n"
242 "movq %%mm1, 8(%2)\n"
243 "movq %%mm4, %%mm0\n"
244 "movq %%mm5, %%mm1\n"
248 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
), "r" (s
+lx
)
252 static inline void rec4ac_mmx(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
254 __asm__
__volatile__(
255 "movq (%1), %%mm0\n" /* 8 s */
256 "movq 1(%1), %%mm2\n" /* 8 s +1*/
259 "movq (%4), %%mm4\n" /* 8 s+lx */
260 "pavgusb %%mm2, %%mm0\n"
262 "movq 1(%4), %%mm6\n" /* 8 s+lx +1*/
263 "pavgusb %%mm4, %%mm0\n"
264 "movq (%2), %%mm1\n" /* 8 d */
265 "pavgusb %%mm6, %%mm0\n"
267 "pavgusb %%mm1, %%mm0\n"
268 "movq %%mm6, %%mm2\n"
270 "movq %%mm4, %%mm0\n"
274 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
), "r" (s
+lx
)
279 static long long ADD_1 USED
= 0x0101010101010101LL
;
280 static long long MASK_AND USED
= 0x7f7f7f7f7f7f7f7fLL
;
283 static inline void rec_mmx(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
285 __asm__
__volatile__(
288 "movq ( %1 ), %%mm0\n" /* 8 s */
289 "movq 8( %1 ), %%mm2\n" /* 16 s */
290 "movq %%mm0, ( %2 )\n"
292 "movq %%mm2, 8( %2 )\n"
294 "leal (%2, %3), %2\n"
297 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
)
302 static inline void recc_mmx(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
304 __asm__
__volatile__(
307 "movq ( %1 ), %%mm0\n"
309 "movq %%mm0, ( %2 )\n"
311 "leal (%2, %3), %2\n"
314 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
)
319 static inline void reca_mmx(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
325 "movq (%1), %%mm0\n" /* 8 s */
326 "movq (%2), %%mm2\n" /* 8 d */
327 "movq 8(%1), %%mm1\n" /* 8 s */
328 "movq 8(%2), %%mm3\n" /* 8 d */
329 "pavgusb %%mm2, %%mm0\n"
331 "pavgusb %%mm3, %%mm1\n"
334 "movq %%mm1, 8(%2)\n"
338 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
)
342 "movq MASK_AND, %%mm5\n"
343 "movq ADD_1, %%mm6\n"
345 "movq (%1),%%mm0\n" /* Load 16 pixels from each row */
349 "psrlw $1,%%mm0\n" /* Shift pixels down */
351 "pand %%mm5,%%mm0\n" /* Zero out significant bit */
356 "paddusb %%mm1,%%mm0\n" /* Add pixels */
358 "paddusb %%mm3,%%mm2\n"
359 "paddusb %%mm6,%%mm0\n" /* Add 1 to results */
360 "paddusb %%mm6,%%mm2\n"
363 "movq %%mm2, 8(%2)\n"
365 "leal (%2, %3), %2\n"
368 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
)
374 static inline void recac_mmx(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
380 "movq (%1), %%mm0\n" /* 8 s */
381 "movq (%2), %%mm2\n" /* 8 d */
382 "pavgusb %%mm2, %%mm0\n"
388 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
)
392 "movq MASK_AND, %%mm5\n"
393 "movq ADD_1, %%mm6\n"
401 "paddusb %%mm1,%%mm0\n"
402 "paddusb %%mm6,%%mm0\n"
406 "leal (%2, %3), %2\n"
409 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
)
415 static inline void recv_mmx(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
421 "movq (%1), %%mm0\n" /* 8 s */
422 "movq (%4), %%mm2\n" /* 8 s +lx */
423 "movq 8(%1), %%mm1\n" /* 8 s */
424 "movq 8(%4), %%mm3\n" /* 8 s +lx **/
426 "pavgusb %%mm2, %%mm0\n"
428 "pavgusb %%mm3, %%mm1\n"
432 "movq %%mm1, 8(%2)\n"
436 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
), "r" (s
+lx
)
440 "movq MASK_AND, %%mm5\n"
441 "movq ADD_1, %%mm6\n"
443 "movq (%1), %%mm0\n" /* 8 s */
444 "movq (%4), %%mm1\n" /* 8 s +lx */
445 "movq 8(%1), %%mm2\n" /* 8 s */
446 "movq 8(%4), %%mm3\n" /* 8 s +lx **/
454 "paddusb %%mm1,%%mm0\n"
456 "paddusb %%mm3,%%mm2\n"
457 "paddusb %%mm6,%%mm0\n"
458 "paddusb %%mm6,%%mm2\n"
461 "movq %%mm2, 8(%2)\n"
464 "leal (%2, %3), %2\n"
467 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
), "r" (s
+lx
)
473 static inline void recvc_mmx(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
479 "movq (%1), %%mm0\n" /* 8 s */
480 "movq (%4), %%mm2\n" /* 8 s +lx */
482 "pavgusb %%mm2, %%mm0\n"
488 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
), "r" (s
+lx
)
492 "movq MASK_AND, %%mm5\n"
493 "movq ADD_1, %%mm6\n"
495 "movq (%1), %%mm0\n" /* 8 s */
496 "movq (%4), %%mm1\n" /* 8 s +lx */
501 "paddusb %%mm1,%%mm0\n"
503 "paddusb %%mm6,%%mm0\n"
507 "leal (%2, %3), %2\n"
510 : "c" (h
), "r" (s
), "r" (d
), "r" (lx2
), "r" (s
+lx
)
517 static inline void rec(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
520 for(j
= 0; j
< h
; j
++, s
+= lx2
, d
+= lx2
)
522 d
[0] = s
[0]; d
[1] = s
[1]; d
[2] = s
[2]; d
[3] = s
[3];
523 d
[4] = s
[4]; d
[5] = s
[5]; d
[6] = s
[6]; d
[7] = s
[7];
524 d
[8] = s
[8]; d
[9] = s
[9]; d
[10] = s
[10]; d
[11] = s
[11];
525 d
[12] = s
[12]; d
[13] = s
[13]; d
[14] = s
[14]; d
[15] = s
[15];
531 static inline void recc(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
534 for(j
= 0; j
< h
; j
++, s
+= lx2
, d
+= lx2
)
536 d
[0] = s
[0]; d
[1] = s
[1]; d
[2] = s
[2]; d
[3] = s
[3];
537 d
[4] = s
[4]; d
[5] = s
[5]; d
[6] = s
[6]; d
[7] = s
[7];
541 static inline void reca(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
544 for(j
= 0; j
< h
; j
++, s
+=lx2
, d
+=lx2
)
546 d
[0] = (unsigned int)(d
[0] + s
[0] + 1) >> 1;
547 d
[1] = (unsigned int)(d
[1] + s
[1] + 1) >> 1;
548 d
[2] = (unsigned int)(d
[2] + s
[2] + 1) >> 1;
549 d
[3] = (unsigned int)(d
[3] + s
[3] + 1) >> 1;
550 d
[4] = (unsigned int)(d
[4] + s
[4] + 1) >> 1;
551 d
[5] = (unsigned int)(d
[5] + s
[5] + 1) >> 1;
552 d
[6] = (unsigned int)(d
[6] + s
[6] + 1) >> 1;
553 d
[7] = (unsigned int)(d
[7] + s
[7] + 1) >> 1;
554 d
[8] = (unsigned int)(d
[8] + s
[8] + 1) >> 1;
555 d
[9] = (unsigned int)(d
[9] + s
[9] + 1) >> 1;
556 d
[10] = (unsigned int)(d
[10] + s
[10] + 1) >> 1;
557 d
[11] = (unsigned int)(d
[11] + s
[11] + 1) >> 1;
558 d
[12] = (unsigned int)(d
[12] + s
[12] + 1) >> 1;
559 d
[13] = (unsigned int)(d
[13] + s
[13] + 1) >> 1;
560 d
[14] = (unsigned int)(d
[14] + s
[14] + 1) >> 1;
561 d
[15] = (unsigned int)(d
[15] + s
[15] + 1) >> 1;
565 static inline void recac(unsigned char *s
, unsigned char *d
, int lx2
, int h
)
568 for(j
= 0; j
< h
; j
++, s
+= lx2
, d
+= lx2
)
570 d
[0] = (unsigned int)(d
[0] + s
[0] + 1)>>1;
571 d
[1] = (unsigned int)(d
[1] + s
[1] + 1)>>1;
572 d
[2] = (unsigned int)(d
[2] + s
[2] + 1)>>1;
573 d
[3] = (unsigned int)(d
[3] + s
[3] + 1)>>1;
574 d
[4] = (unsigned int)(d
[4] + s
[4] + 1)>>1;
575 d
[5] = (unsigned int)(d
[5] + s
[5] + 1)>>1;
576 d
[6] = (unsigned int)(d
[6] + s
[6] + 1)>>1;
577 d
[7] = (unsigned int)(d
[7] + s
[7] + 1)>>1;
581 static inline void recv(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
583 unsigned char *dp
,*sp
,*sp2
;
588 for(j
= 0; j
< h
; j
++)
590 dp
[0] = (unsigned int)(sp
[0] + sp2
[0] + 1) >> 1;
591 dp
[1] = (unsigned int)(sp
[1] + sp2
[1] + 1) >> 1;
592 dp
[2] = (unsigned int)(sp
[2] + sp2
[2] + 1) >> 1;
593 dp
[3] = (unsigned int)(sp
[3] + sp2
[3] + 1) >> 1;
594 dp
[4] = (unsigned int)(sp
[4] + sp2
[4] + 1) >> 1;
595 dp
[5] = (unsigned int)(sp
[5] + sp2
[5] + 1) >> 1;
596 dp
[6] = (unsigned int)(sp
[6] + sp2
[6] + 1) >> 1;
597 dp
[7] = (unsigned int)(sp
[7] + sp2
[7] + 1) >> 1;
598 dp
[8] = (unsigned int)(sp
[8] + sp2
[8] + 1) >> 1;
599 dp
[9] = (unsigned int)(sp
[9] + sp2
[9] + 1) >> 1;
600 dp
[10] = (unsigned int)(sp
[10] + sp2
[10] + 1) >> 1;
601 dp
[11] = (unsigned int)(sp
[11] + sp2
[11] + 1) >> 1;
602 dp
[12] = (unsigned int)(sp
[12] + sp2
[12] + 1) >> 1;
603 dp
[13] = (unsigned int)(sp
[13] + sp2
[13] + 1) >> 1;
604 dp
[14] = (unsigned int)(sp
[14] + sp2
[14] + 1) >> 1;
605 dp
[15] = (unsigned int)(sp
[15] + sp2
[15] + 1) >> 1;
612 static inline void recvc(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
614 unsigned char *dp
,*sp
,*sp2
;
620 for(j
= 0; j
< h
; j
++)
622 dp
[0] = (unsigned int)(sp
[0]+sp2
[0]+1)>>1;
623 dp
[1] = (unsigned int)(sp
[1]+sp2
[1]+1)>>1;
624 dp
[2] = (unsigned int)(sp
[2]+sp2
[2]+1)>>1;
625 dp
[3] = (unsigned int)(sp
[3]+sp2
[3]+1)>>1;
626 dp
[4] = (unsigned int)(sp
[4]+sp2
[4]+1)>>1;
627 dp
[5] = (unsigned int)(sp
[5]+sp2
[5]+1)>>1;
628 dp
[6] = (unsigned int)(sp
[6]+sp2
[6]+1)>>1;
629 dp
[7] = (unsigned int)(sp
[7]+sp2
[7]+1)>>1;
637 static inline void recva(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
639 unsigned char *dp
,*sp
,*sp2
;
646 dp
[0] = (dp
[0] + ((unsigned int)(sp
[0]+sp2
[0]+1)>>1) + 1)>>1;
647 dp
[1] = (dp
[1] + ((unsigned int)(sp
[1]+sp2
[1]+1)>>1) + 1)>>1;
648 dp
[2] = (dp
[2] + ((unsigned int)(sp
[2]+sp2
[2]+1)>>1) + 1)>>1;
649 dp
[3] = (dp
[3] + ((unsigned int)(sp
[3]+sp2
[3]+1)>>1) + 1)>>1;
650 dp
[4] = (dp
[4] + ((unsigned int)(sp
[4]+sp2
[4]+1)>>1) + 1)>>1;
651 dp
[5] = (dp
[5] + ((unsigned int)(sp
[5]+sp2
[5]+1)>>1) + 1)>>1;
652 dp
[6] = (dp
[6] + ((unsigned int)(sp
[6]+sp2
[6]+1)>>1) + 1)>>1;
653 dp
[7] = (dp
[7] + ((unsigned int)(sp
[7]+sp2
[7]+1)>>1) + 1)>>1;
654 dp
[8] = (dp
[8] + ((unsigned int)(sp
[8]+sp2
[8]+1)>>1) + 1)>>1;
655 dp
[9] = (dp
[9] + ((unsigned int)(sp
[9]+sp2
[9]+1)>>1) + 1)>>1;
656 dp
[10] = (dp
[10] + ((unsigned int)(sp
[10]+sp2
[10]+1)>>1) + 1)>>1;
657 dp
[11] = (dp
[11] + ((unsigned int)(sp
[11]+sp2
[11]+1)>>1) + 1)>>1;
658 dp
[12] = (dp
[12] + ((unsigned int)(sp
[12]+sp2
[12]+1)>>1) + 1)>>1;
659 dp
[13] = (dp
[13] + ((unsigned int)(sp
[13]+sp2
[13]+1)>>1) + 1)>>1;
660 dp
[14] = (dp
[14] + ((unsigned int)(sp
[14]+sp2
[14]+1)>>1) + 1)>>1;
661 dp
[15] = (dp
[15] + ((unsigned int)(sp
[15]+sp2
[15]+1)>>1) + 1)>>1;
669 static inline void recvac(unsigned char *s
, unsigned char *d
, int lx
,int lx2
, int h
){
670 unsigned char *dp
,*sp
,*sp2
;
677 dp
[0] = (dp
[0] + ((unsigned int)(sp
[0]+sp2
[0]+1)>>1) + 1)>>1;
678 dp
[1] = (dp
[1] + ((unsigned int)(sp
[1]+sp2
[1]+1)>>1) + 1)>>1;
679 dp
[2] = (dp
[2] + ((unsigned int)(sp
[2]+sp2
[2]+1)>>1) + 1)>>1;
680 dp
[3] = (dp
[3] + ((unsigned int)(sp
[3]+sp2
[3]+1)>>1) + 1)>>1;
681 dp
[4] = (dp
[4] + ((unsigned int)(sp
[4]+sp2
[4]+1)>>1) + 1)>>1;
682 dp
[5] = (dp
[5] + ((unsigned int)(sp
[5]+sp2
[5]+1)>>1) + 1)>>1;
683 dp
[6] = (dp
[6] + ((unsigned int)(sp
[6]+sp2
[6]+1)>>1) + 1)>>1;
684 dp
[7] = (dp
[7] + ((unsigned int)(sp
[7]+sp2
[7]+1)>>1) + 1)>>1;
692 static inline void rech(unsigned char *s
, unsigned char *d
, int lx2
, int h
){
693 unsigned char *dp
,*sp
;
701 dp
[0] = (unsigned int)(s1
+(s2
=sp
[1])+1)>>1;
702 dp
[1] = (unsigned int)(s2
+(s1
=sp
[2])+1)>>1;
703 dp
[2] = (unsigned int)(s1
+(s2
=sp
[3])+1)>>1;
704 dp
[3] = (unsigned int)(s2
+(s1
=sp
[4])+1)>>1;
705 dp
[4] = (unsigned int)(s1
+(s2
=sp
[5])+1)>>1;
706 dp
[5] = (unsigned int)(s2
+(s1
=sp
[6])+1)>>1;
707 dp
[6] = (unsigned int)(s1
+(s2
=sp
[7])+1)>>1;
708 dp
[7] = (unsigned int)(s2
+(s1
=sp
[8])+1)>>1;
709 dp
[8] = (unsigned int)(s1
+(s2
=sp
[9])+1)>>1;
710 dp
[9] = (unsigned int)(s2
+(s1
=sp
[10])+1)>>1;
711 dp
[10] = (unsigned int)(s1
+(s2
=sp
[11])+1)>>1;
712 dp
[11] = (unsigned int)(s2
+(s1
=sp
[12])+1)>>1;
713 dp
[12] = (unsigned int)(s1
+(s2
=sp
[13])+1)>>1;
714 dp
[13] = (unsigned int)(s2
+(s1
=sp
[14])+1)>>1;
715 dp
[14] = (unsigned int)(s1
+(s2
=sp
[15])+1)>>1;
716 dp
[15] = (unsigned int)(s2
+sp
[16]+1)>>1;
723 static inline void rechc(unsigned char *s
,unsigned char *d
, int lx2
, int h
){
724 unsigned char *dp
,*sp
;
732 dp
[0] = (unsigned int)(s1
+(s2
=sp
[1])+1)>>1;
733 dp
[1] = (unsigned int)(s2
+(s1
=sp
[2])+1)>>1;
734 dp
[2] = (unsigned int)(s1
+(s2
=sp
[3])+1)>>1;
735 dp
[3] = (unsigned int)(s2
+(s1
=sp
[4])+1)>>1;
736 dp
[4] = (unsigned int)(s1
+(s2
=sp
[5])+1)>>1;
737 dp
[5] = (unsigned int)(s2
+(s1
=sp
[6])+1)>>1;
738 dp
[6] = (unsigned int)(s1
+(s2
=sp
[7])+1)>>1;
739 dp
[7] = (unsigned int)(s2
+sp
[8]+1)>>1;
745 static inline void recha(unsigned char *s
, unsigned char *d
,int lx2
, int h
)
747 unsigned char *dp
,*sp
;
753 for (j
= 0; j
< h
; j
++)
756 dp
[0] = (dp
[0] + ((unsigned int)(s1
+ (s2
= sp
[1]) + 1) >> 1) + 1) >> 1;
757 dp
[1] = (dp
[1] + ((unsigned int)(s2
+ (s1
= sp
[2]) + 1) >> 1) + 1) >> 1;
758 dp
[2] = (dp
[2] + ((unsigned int)(s1
+ (s2
= sp
[3]) + 1) >> 1) + 1) >> 1;
759 dp
[3] = (dp
[3] + ((unsigned int)(s2
+ (s1
= sp
[4]) + 1) >> 1) + 1) >> 1;
760 dp
[4] = (dp
[4] + ((unsigned int)(s1
+ (s2
= sp
[5]) + 1) >> 1) + 1) >> 1;
761 dp
[5] = (dp
[5] + ((unsigned int)(s2
+ (s1
= sp
[6]) + 1) >> 1) + 1) >> 1;
762 dp
[6] = (dp
[6] + ((unsigned int)(s1
+ (s2
= sp
[7]) + 1) >> 1) + 1) >> 1;
763 dp
[7] = (dp
[7] + ((unsigned int)(s2
+ (s1
= sp
[8]) + 1) >> 1) + 1) >> 1;
764 dp
[8] = (dp
[8] + ((unsigned int)(s1
+ (s2
= sp
[9]) + 1) >> 1) + 1) >> 1;
765 dp
[9] = (dp
[9] + ((unsigned int)(s2
+ (s1
= sp
[10]) + 1) >> 1) + 1) >> 1;
766 dp
[10] = (dp
[10] + ((unsigned int)(s1
+ (s2
= sp
[11]) + 1) >> 1) + 1) >> 1;
767 dp
[11] = (dp
[11] + ((unsigned int)(s2
+ (s1
= sp
[12]) + 1) >> 1) + 1) >> 1;
768 dp
[12] = (dp
[12] + ((unsigned int)(s1
+ (s2
= sp
[13]) + 1) >> 1) + 1) >> 1;
769 dp
[13] = (dp
[13] + ((unsigned int)(s2
+ (s1
= sp
[14]) + 1) >> 1) + 1) >> 1;
770 dp
[14] = (dp
[14] + ((unsigned int)(s1
+ (s2
= sp
[15]) + 1) >> 1) + 1) >> 1;
771 dp
[15] = (dp
[15] + ((unsigned int)(s2
+ sp
[16] + 1) >> 1) + 1) >> 1;
778 static inline void rechac(unsigned char *s
,unsigned char *d
, int lx2
, int h
)
780 unsigned char *dp
,*sp
;
786 for(j
= 0; j
< h
; j
++)
789 dp
[0] = (dp
[0] + ((unsigned int)(s1
+ (s2
= sp
[1]) + 1) >> 1) + 1) >> 1;
790 dp
[1] = (dp
[1] + ((unsigned int)(s2
+ (s1
= sp
[2]) + 1) >> 1) + 1) >> 1;
791 dp
[2] = (dp
[2] + ((unsigned int)(s1
+ (s2
= sp
[3]) + 1) >> 1) + 1) >> 1;
792 dp
[3] = (dp
[3] + ((unsigned int)(s2
+ (s1
= sp
[4]) + 1) >> 1) + 1) >> 1;
793 dp
[4] = (dp
[4] + ((unsigned int)(s1
+ (s2
= sp
[5]) + 1) >> 1) + 1) >> 1;
794 dp
[5] = (dp
[5] + ((unsigned int)(s2
+ (s1
= sp
[6]) + 1) >> 1) + 1) >> 1;
795 dp
[6] = (dp
[6] + ((unsigned int)(s1
+ (s2
= sp
[7]) + 1) >> 1) + 1) >> 1;
796 dp
[7] = (dp
[7] + ((unsigned int)(s2
+ sp
[8] + 1) >> 1) + 1) >> 1;
803 static inline void rec4(unsigned char *s
, unsigned char *d
, int lx
, int lx2
, int h
)
805 unsigned char *dp
,*sp
,*sp2
;
806 unsigned int s1
,s2
,s3
,s4
;
814 dp
[0] = (unsigned int)(s1
+(s2
=sp
[1])+s3
+(s4
=sp2
[1])+2)>>2;
815 dp
[1] = (unsigned int)(s2
+(s1
=sp
[2])+s4
+(s3
=sp2
[2])+2)>>2;
816 dp
[2] = (unsigned int)(s1
+(s2
=sp
[3])+s3
+(s4
=sp2
[3])+2)>>2;
817 dp
[3] = (unsigned int)(s2
+(s1
=sp
[4])+s4
+(s3
=sp2
[4])+2)>>2;
818 dp
[4] = (unsigned int)(s1
+(s2
=sp
[5])+s3
+(s4
=sp2
[5])+2)>>2;
819 dp
[5] = (unsigned int)(s2
+(s1
=sp
[6])+s4
+(s3
=sp2
[6])+2)>>2;
820 dp
[6] = (unsigned int)(s1
+(s2
=sp
[7])+s3
+(s4
=sp2
[7])+2)>>2;
821 dp
[7] = (unsigned int)(s2
+(s1
=sp
[8])+s4
+(s3
=sp2
[8])+2)>>2;
822 dp
[8] = (unsigned int)(s1
+(s2
=sp
[9])+s3
+(s4
=sp2
[9])+2)>>2;
823 dp
[9] = (unsigned int)(s2
+(s1
=sp
[10])+s4
+(s3
=sp2
[10])+2)>>2;
824 dp
[10] = (unsigned int)(s1
+(s2
=sp
[11])+s3
+(s4
=sp2
[11])+2)>>2;
825 dp
[11] = (unsigned int)(s2
+(s1
=sp
[12])+s4
+(s3
=sp2
[12])+2)>>2;
826 dp
[12] = (unsigned int)(s1
+(s2
=sp
[13])+s3
+(s4
=sp2
[13])+2)>>2;
827 dp
[13] = (unsigned int)(s2
+(s1
=sp
[14])+s4
+(s3
=sp2
[14])+2)>>2;
828 dp
[14] = (unsigned int)(s1
+(s2
=sp
[15])+s3
+(s4
=sp2
[15])+2)>>2;
829 dp
[15] = (unsigned int)(s2
+sp
[16]+s4
+sp2
[16]+2)>>2;
837 static inline void rec4c(unsigned char *s
,unsigned char *d
, int lx
, int lx2
, int h
)
839 unsigned char *dp
,*sp
,*sp2
;
840 unsigned int s1
,s2
,s3
,s4
;
848 dp
[0] = (unsigned int)(s1
+(s2
=sp
[1])+s3
+(s4
=sp2
[1])+2)>>2;
849 dp
[1] = (unsigned int)(s2
+(s1
=sp
[2])+s4
+(s3
=sp2
[2])+2)>>2;
850 dp
[2] = (unsigned int)(s1
+(s2
=sp
[3])+s3
+(s4
=sp2
[3])+2)>>2;
851 dp
[3] = (unsigned int)(s2
+(s1
=sp
[4])+s4
+(s3
=sp2
[4])+2)>>2;
852 dp
[4] = (unsigned int)(s1
+(s2
=sp
[5])+s3
+(s4
=sp2
[5])+2)>>2;
853 dp
[5] = (unsigned int)(s2
+(s1
=sp
[6])+s4
+(s3
=sp2
[6])+2)>>2;
854 dp
[6] = (unsigned int)(s1
+(s2
=sp
[7])+s3
+(s4
=sp2
[7])+2)>>2;
855 dp
[7] = (unsigned int)(s2
+sp
[8]+s4
+sp2
[8]+2)>>2;
863 static inline void rec4a(unsigned char *s
,unsigned char *d
, int lx
, int lx2
, int h
)
865 unsigned char *dp
=d
, *sp
=s
, *sp2
=s
+lx
;
866 unsigned int s1
, s2
, s3
, s4
;
876 dp
[0] = (dp
[0] + ((unsigned int)(s1
+(s2
=sp
[1])+s3
+(s4
=sp2
[1])+2)>>2) + 1)>>1;
877 dp
[1] = (dp
[1] + ((unsigned int)(s2
+(s1
=sp
[2])+s4
+(s3
=sp2
[2])+2)>>2) + 1)>>1;
878 dp
[2] = (dp
[2] + ((unsigned int)(s1
+(s2
=sp
[3])+s3
+(s4
=sp2
[3])+2)>>2) + 1)>>1;
879 dp
[3] = (dp
[3] + ((unsigned int)(s2
+(s1
=sp
[4])+s4
+(s3
=sp2
[4])+2)>>2) + 1)>>1;
880 dp
[4] = (dp
[4] + ((unsigned int)(s1
+(s2
=sp
[5])+s3
+(s4
=sp2
[5])+2)>>2) + 1)>>1;
881 dp
[5] = (dp
[5] + ((unsigned int)(s2
+(s1
=sp
[6])+s4
+(s3
=sp2
[6])+2)>>2) + 1)>>1;
882 dp
[6] = (dp
[6] + ((unsigned int)(s1
+(s2
=sp
[7])+s3
+(s4
=sp2
[7])+2)>>2) + 1)>>1;
883 dp
[7] = (dp
[7] + ((unsigned int)(s2
+(s1
=sp
[8])+s4
+(s3
=sp2
[8])+2)>>2) + 1)>>1;
884 dp
[8] = (dp
[8] + ((unsigned int)(s1
+(s2
=sp
[9])+s3
+(s4
=sp2
[9])+2)>>2) + 1)>>1;
885 dp
[9] = (dp
[9] + ((unsigned int)(s2
+(s1
=sp
[10])+s4
+(s3
=sp2
[10])+2)>>2) + 1)>>1;
886 dp
[10] = (dp
[10] + ((unsigned int)(s1
+(s2
=sp
[11])+s3
+(s4
=sp2
[11])+2)>>2) + 1)>>1;
887 dp
[11] = (dp
[11] + ((unsigned int)(s2
+(s1
=sp
[12])+s4
+(s3
=sp2
[12])+2)>>2) + 1)>>1;
888 dp
[12] = (dp
[12] + ((unsigned int)(s1
+(s2
=sp
[13])+s3
+(s4
=sp2
[13])+2)>>2) + 1)>>1;
889 dp
[13] = (dp
[13] + ((unsigned int)(s2
+(s1
=sp
[14])+s4
+(s3
=sp2
[14])+2)>>2) + 1)>>1;
890 dp
[14] = (dp
[14] + ((unsigned int)(s1
+(s2
=sp
[15])+s3
+(s4
=sp2
[15])+2)>>2) + 1)>>1;
891 dp
[15] = (dp
[15] + ((unsigned int)(s2
+sp
[16]+s4
+sp2
[16]+2)>>2) + 1)>>1;
899 static inline void rec4ac(unsigned char *s
,unsigned char *d
, int lx
, int lx2
, int h
)
901 unsigned char *dp
=d
, *sp
=s
, *sp2
=s
+lx
;
902 unsigned int s1
,s2
,s3
,s4
;
913 dp
[0] = (dp
[0] + ((unsigned int)(s1
+(s2
=sp
[1])+s3
+(s4
=sp2
[1])+2)>>2) + 1)>>1;
914 dp
[1] = (dp
[1] + ((unsigned int)(s2
+(s1
=sp
[2])+s4
+(s3
=sp2
[2])+2)>>2) + 1)>>1;
915 dp
[2] = (dp
[2] + ((unsigned int)(s1
+(s2
=sp
[3])+s3
+(s4
=sp2
[3])+2)>>2) + 1)>>1;
916 dp
[3] = (dp
[3] + ((unsigned int)(s2
+(s1
=sp
[4])+s4
+(s3
=sp2
[4])+2)>>2) + 1)>>1;
917 dp
[4] = (dp
[4] + ((unsigned int)(s1
+(s2
=sp
[5])+s3
+(s4
=sp2
[5])+2)>>2) + 1)>>1;
918 dp
[5] = (dp
[5] + ((unsigned int)(s2
+(s1
=sp
[6])+s4
+(s3
=sp2
[6])+2)>>2) + 1)>>1;
919 dp
[6] = (dp
[6] + ((unsigned int)(s1
+(s2
=sp
[7])+s3
+(s4
=sp2
[7])+2)>>2) + 1)>>1;
920 dp
[7] = (dp
[7] + ((unsigned int)(s2
+sp
[8]+s4
+sp2
[8]+2)>>2) + 1)>>1;
928 void recon_comp(mpeg3video_t
*video
,
942 unsigned char *s
, *d
;
944 /* half pel scaling */
945 switcher
= (dx
& 1) << 3 | (dy
& 1) << 2 | w
;
946 if(addflag
) switcher
|= 2;
948 s
= src
+ lx
* (y
+ (dy
>> 1)) + x
+ (dx
>> 1);
949 d
= dst
+ lx
* y
+ x
;
951 // Accelerated functions
957 case 0x3: reca_mmx(s
, d
, lx2
, h
); break;
958 case 0x2: recac_mmx(s
, d
, lx2
, h
); break;
959 case 0x1: rec_mmx(s
, d
, lx2
, h
); break;
960 case 0x0: recc_mmx(s
, d
, lx2
, h
); break;
961 case 0x7: recva_mmx(s
, d
, lx
, lx2
, h
); break;
962 case 0x6: recvac_mmx(s
, d
, lx
, lx2
, h
); break;
963 case 0x5: recv_mmx(s
, d
, lx
, lx2
, h
); break;
964 case 0x4: recvc_mmx(s
, d
, lx
, lx2
, h
); break;
965 case 0x9: rech_mmx(s
, d
, lx2
, h
); break;
966 case 0x8: rechc_mmx(s
, d
, lx2
, h
); break;
974 case 0x3: reca(s
, d
, lx2
, h
); break;
975 case 0x2: recac(s
, d
, lx2
, h
); break;
976 case 0x1: rec(s
, d
, lx2
, h
); break;
977 case 0x0: recc(s
, d
, lx2
, h
); break;
978 case 0x7: recva(s
, d
, lx
, lx2
, h
); break;
979 case 0x6: recvac(s
, d
, lx
, lx2
, h
); break;
980 case 0x5: recv(s
, d
, lx
, lx2
, h
); break;
981 case 0x4: recvc(s
, d
, lx
, lx2
, h
); break;
982 case 0x9: rech(s
, d
, lx2
, h
); break;
983 case 0x8: rechc(s
, d
, lx2
, h
); break;
987 // Unaccelerated functions
990 case 0xb: recha(s
, d
, lx2
, h
); break;
991 case 0xa: rechac(s
, d
, lx2
, h
); break;
992 case 0xf: rec4a(s
, d
, lx
, lx2
, h
); break;
993 case 0xe: rec4ac(s
, d
, lx
, lx2
, h
); break;
994 case 0xd: rec4(s
, d
, lx
, lx2
, h
); break;
995 case 0xc: rec4c(s
, d
, lx
, lx2
, h
); break;
1000 unsigned char *src[]; * prediction source buffer *
1001 int sfield; * prediction source field number (0 or 1) *
1002 unsigned char *dst[]; * prediction destination buffer *
1003 int dfield; * prediction destination field number (0 or 1)*
1004 int lx,lx2; * horizontal offsets *
1005 int w,h; * prediction block/sub-block width, height *
1006 int x,y; * pixel co-ordinates of top-left sample in current MB *
1007 int dx,dy; * horizontal, vertical motion vector *
1008 int addflag; * add prediction error to prediction ? *
1010 static void recon(mpeg3video_t
*video
,
1011 unsigned char *src
[],
1013 unsigned char *dst
[],
1027 recon_comp(video
, (src
[0] + (sfield
? (lx2
>> 1) : 0)),
1028 dst
[0] + (dfield
? (lx2
>> 1) : 0),
1029 lx
, lx2
, w
, h
, x
, y
, dx
, dy
, addflag
);
1031 if(video
->chroma_format
!= CHROMA444
)
1040 if(video
->chroma_format
== CHROMA420
)
1048 recon_comp(video
, (src
[1] + (sfield
? (lx2
>> 1) : 0)),
1049 dst
[1] + (dfield
? (lx2
>> 1) : 0),
1050 lx
, lx2
, w
, h
, x
, y
, dx
, dy
, addflag
);
1053 recon_comp(video
, (src
[2] + (sfield
? (lx2
>> 1) : 0)),
1054 dst
[2] + (dfield
? (lx2
>> 1) : 0),
1055 lx
, lx2
, w
, h
, x
, y
, dx
, dy
, addflag
);
1060 int mpeg3video_reconstruct(mpeg3video_t
*video
,
1066 int mv_field_sel
[2][2],
1071 unsigned char **predframe
;
1075 stwtop
= stwtype
% 3; /* 0:temporal, 1 : (spat+temp) / 2, 2 : spatial */
1076 stwbot
= stwtype
/ 3;
1078 if((mb_type
& MB_FORWARD
) || (video
->pict_type
== P_TYPE
))
1080 if(video
->pict_struct
== FRAME_PICTURE
)
1082 if((motion_type
== MC_FRAME
) || !(mb_type
& MB_FORWARD
))
1084 /* frame-based prediction */
1087 recon(video
, video
->oldrefframe
, 0, video
->newframe
, 0,
1088 video
->coded_picture_width
, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
,
1089 PMV
[0][0][0], PMV
[0][0][1], stwtop
);
1092 recon(video
, video
->oldrefframe
, 1, video
->newframe
, 1,
1093 video
->coded_picture_width
, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
,
1094 PMV
[0][0][0], PMV
[0][0][1], stwbot
);
1097 else if(motion_type
== MC_FIELD
) /* field-based prediction */
1099 /* top field prediction */
1101 recon(video
, video
->oldrefframe
, mv_field_sel
[0][0], video
->newframe
, 0,
1102 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
>> 1,
1103 PMV
[0][0][0], PMV
[0][0][1] >> 1, stwtop
);
1105 /* bottom field prediction */
1107 recon(video
, video
->oldrefframe
, mv_field_sel
[1][0], video
->newframe
, 1,
1108 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
>> 1,
1109 PMV
[1][0][0], PMV
[1][0][1] >> 1, stwbot
);
1111 else if(motion_type
== MC_DMV
)
1113 /* dual prime prediction */
1114 /* calculate derived motion vectors */
1115 mpeg3video_calc_dmv(video
,
1123 /* predict top field from top field */
1124 recon(video
, video
->oldrefframe
, 0, video
->newframe
, 0,
1125 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
>>1,
1126 PMV
[0][0][0], PMV
[0][0][1] >> 1, 0);
1128 /* predict and add to top field from bottom field */
1129 recon(video
, video
->oldrefframe
, 1, video
->newframe
, 0,
1130 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
>>1,
1131 DMV
[0][0], DMV
[0][1], 1);
1136 /* predict bottom field from bottom field */
1137 recon(video
, video
->oldrefframe
, 1, video
->newframe
, 1,
1138 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
>>1,
1139 PMV
[0][0][0], PMV
[0][0][1]>>1, 0);
1141 /* predict and add to bottom field from top field */
1142 recon(video
, video
->oldrefframe
, 0, video
->newframe
, 1,
1143 video
->coded_picture_width
<< 1, video
->coded_picture_width
<<1, WIDTH
, 8, bx
, by
>>1,
1144 DMV
[1][0], DMV
[1][1], 1);
1148 /* invalid motion_type */
1149 /* fprintf(stderr, "reconstruct: invalid motion_type\n"); */
1154 /* TOP_FIELD or BOTTOM_FIELD */
1156 currentfield
= (video
->pict_struct
== BOTTOM_FIELD
);
1158 /* determine which frame to use for prediction */
1159 if((video
->pict_type
== P_TYPE
) && video
->secondfield
1160 && (currentfield
!= mv_field_sel
[0][0]))
1161 predframe
= video
->refframe
; /* same frame */
1163 predframe
= video
->oldrefframe
; /* previous frame */
1165 if((motion_type
== MC_FIELD
) || !(mb_type
& MB_FORWARD
))
1167 /* field-based prediction */
1169 recon(video
, predframe
,mv_field_sel
[0][0],video
->newframe
,0,
1170 video
->coded_picture_width
<< 1,video
->coded_picture_width
<< 1,WIDTH
,16,bx
,by
,
1171 PMV
[0][0][0],PMV
[0][0][1],stwtop
);
1174 if(motion_type
== MC_16X8
)
1178 recon(video
, predframe
, mv_field_sel
[0][0], video
->newframe
, 0,
1179 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
,
1180 PMV
[0][0][0], PMV
[0][0][1], stwtop
);
1182 /* determine which frame to use for lower half prediction */
1183 if((video
->pict_type
==P_TYPE
) && video
->secondfield
1184 && (currentfield
!=mv_field_sel
[1][0]))
1185 predframe
= video
->refframe
; /* same frame */
1187 predframe
= video
->oldrefframe
; /* previous frame */
1189 recon(video
, predframe
, mv_field_sel
[1][0], video
->newframe
, 0,
1190 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
+8,
1191 PMV
[1][0][0], PMV
[1][0][1], stwtop
);
1195 if(motion_type
== MC_DMV
) /* dual prime prediction */
1197 if(video
->secondfield
)
1198 predframe
= video
->refframe
; /* same frame */
1200 predframe
= video
->oldrefframe
; /* previous frame */
1202 /* calculate derived motion vectors */
1203 mpeg3video_calc_dmv(video
,
1209 /* predict from field of same parity */
1210 recon(video
, video
->oldrefframe
, currentfield
, video
->newframe
, 0,
1211 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 16, bx
, by
,
1212 PMV
[0][0][0], PMV
[0][0][1], 0);
1214 /* predict from field of opposite parity */
1215 recon(video
, predframe
, !currentfield
, video
->newframe
, 0,
1216 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 16, bx
, by
,
1217 DMV
[0][0], DMV
[0][1], 1);
1220 /* invalid motion_type */
1221 /* fprintf(stderr, "reconstruct: invalid motion_type\n"); */
1224 stwtop
= stwbot
= 1;
1227 if(mb_type
& MB_BACKWARD
)
1229 if(video
->pict_struct
== FRAME_PICTURE
)
1231 if(motion_type
== MC_FRAME
)
1233 /* frame-based prediction */
1235 recon(video
, video
->refframe
, 0, video
->newframe
, 0,
1236 video
->coded_picture_width
, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
,
1237 PMV
[0][1][0], PMV
[0][1][1], stwtop
);
1240 recon(video
, video
->refframe
, 1, video
->newframe
, 1,
1241 video
->coded_picture_width
, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
,
1242 PMV
[0][1][0], PMV
[0][1][1], stwbot
);
1246 /* field-based prediction */
1247 /* top field prediction */
1250 recon(video
, video
->refframe
, mv_field_sel
[0][1], video
->newframe
, 0,
1251 (video
->coded_picture_width
<< 1), (video
->coded_picture_width
<<1), WIDTH
, 8, bx
, (by
>> 1),
1252 PMV
[0][1][0], (PMV
[0][1][1] >> 1), stwtop
);
1255 /* bottom field prediction */
1258 recon(video
, video
->refframe
, mv_field_sel
[1][1], video
->newframe
, 1, (video
->coded_picture_width
<< 1),
1259 (video
->coded_picture_width
<< 1), WIDTH
, 8, bx
, (by
>>1),
1260 PMV
[1][1][0], (PMV
[1][1][1]>>1), stwbot
);
1266 /* TOP_FIELD or BOTTOM_FIELD */
1268 if(motion_type
== MC_FIELD
)
1270 /* field-based prediction */
1271 recon(video
, video
->refframe
, mv_field_sel
[0][1], video
->newframe
, 0,
1272 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 16, bx
, by
,
1273 PMV
[0][1][0], PMV
[0][1][1], stwtop
);
1275 else if(motion_type
==MC_16X8
)
1277 recon(video
, video
->refframe
, mv_field_sel
[0][1], video
->newframe
, 0,
1278 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
,
1279 PMV
[0][1][0], PMV
[0][1][1], stwtop
);
1281 recon(video
, video
->refframe
, mv_field_sel
[1][1], video
->newframe
, 0,
1282 video
->coded_picture_width
<< 1, video
->coded_picture_width
<< 1, WIDTH
, 8, bx
, by
+8,
1283 PMV
[1][1][0], PMV
[1][1][1], stwtop
);
1286 /* invalid motion_type */
1287 /* fprintf(stderr, "reconstruct: invalid motion_type\n"); */
1290 } /* mb_type & MB_BACKWARD */