41 int src_x, src_y, motion_x, motion_y;
51 src_x = av_clip(src_x, -16, s->
width);
52 if (src_x == s->
width)
54 src_y = av_clip(src_y, -16, s->
height);
61 ptr = ref_picture[0] + src_y * linesize + src_x;
73 if ((motion_x | motion_y) & 7) {
74 s->
dsp.
gmc1(dest_y, ptr, linesize, 16,
75 motion_x & 15, motion_y & 15, 128 - s->
no_rounding);
76 s->
dsp.
gmc1(dest_y + 8, ptr + 8, linesize, 16,
77 motion_x & 15, motion_y & 15, 128 - s->
no_rounding);
81 dxy = ((motion_x >> 3) & 1) | ((motion_y >> 2) & 2);
98 src_x = av_clip(src_x, -8, s->
width >> 1);
99 if (src_x == s->
width >> 1)
101 src_y = av_clip(src_y, -8, s->
height >> 1);
102 if (src_y == s->
height >> 1)
106 ptr = ref_picture[1] +
offset;
110 uvlinesize, uvlinesize,
117 s->
dsp.
gmc1(dest_cb, ptr, uvlinesize, 8,
118 motion_x & 15, motion_y & 15, 128 - s->
no_rounding);
120 ptr = ref_picture[2] +
offset;
123 uvlinesize, uvlinesize,
129 s->
dsp.
gmc1(dest_cr, ptr, uvlinesize, 8,
130 motion_x & 15, motion_y & 15, 128 - s->
no_rounding);
145 ptr = ref_picture[0];
152 s->
dsp.
gmc(dest_y, ptr, linesize, 16,
158 s->
dsp.
gmc(dest_y + 8, ptr, linesize, 16,
174 ptr = ref_picture[1];
175 s->
dsp.
gmc(dest_cb, ptr, uvlinesize, 8,
182 ptr = ref_picture[2];
183 s->
dsp.
gmc(dest_cr, ptr, uvlinesize, 8,
193 int src_x,
int src_y,
195 int motion_x,
int motion_y)
200 src_x += motion_x >> 1;
201 src_y += motion_y >> 1;
204 src_x = av_clip(src_x, -16, s->
width);
205 if (src_x != s->
width)
207 src_y = av_clip(src_y, -16, s->
height);
209 dxy |= (motion_y & 1) << 1;
242 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
243 int dxy, uvdxy, mx, my, src_x, src_y,
258 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
259 src_x = s->
mb_x * 16 + (motion_x >> 1);
260 src_y = (mb_y << (4 - field_based)) + (motion_y >> 1);
264 mx = (motion_x >> 1) | (motion_x & 1);
266 uvdxy = ((my & 1) << 1) | (mx & 1);
267 uvsrc_x = s->
mb_x * 8 + (mx >> 1);
268 uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
270 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
271 uvsrc_x = src_x >> 1;
272 uvsrc_y = src_y >> 1;
279 uvsrc_x = s->
mb_x * 8 + mx;
280 uvsrc_y = mb_y * 8 + my;
285 uvdxy = ((my & 1) << 1) | (mx & 1);
286 uvsrc_x = s->
mb_x * 8 + (mx >> 1);
287 uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
292 uvdxy = ((motion_y & 1) << 1) | (mx & 1);
293 uvsrc_x = s->
mb_x * 8 + (mx >> 1);
304 ptr_y = ref_picture[0] + src_y * linesize + src_x;
305 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
306 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
309 (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y & 1) - h , 0)) {
314 "MPEG motion vector out of boundary (%d %d)\n", src_x,
320 17, 17 + field_based,
321 src_x, src_y << field_based,
329 uvsrc_x, uvsrc_y << field_based,
334 uvsrc_x, uvsrc_y << field_based,
355 pix_op[0][dxy](dest_y, ptr_y,
linesize, h);
363 if (!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
371 int field_select,
uint8_t **ref_picture,
373 int motion_x,
int motion_y,
int h,
int mb_y)
378 field_select, ref_picture, pix_op,
379 motion_x, motion_y, h, 1, mb_y);
383 field_select, ref_picture, pix_op,
384 motion_x, motion_y, h, 0, mb_y);
389 int bottom_field,
int field_select,
392 int motion_x,
int motion_y,
int h,
int mb_y)
397 bottom_field, field_select, ref_picture, pix_op,
398 motion_x, motion_y, h, 1, mb_y);
402 bottom_field, field_select, ref_picture, pix_op,
403 motion_x, motion_y, h, 0, mb_y);
414 uint8_t *
const bottom = src[4];
415 #define OBMC_FILTER(x, t, l, m, r, b)\
416 dst[x]= (t*top[x] + l*left[x] + m*mid[x] + r*right[x] + b*bottom[x] + 4)>>3
417 #define OBMC_FILTER4(x, t, l, m, r, b)\
418 OBMC_FILTER(x , t, l, m, r, b);\
419 OBMC_FILTER(x+1 , t, l, m, r, b);\
420 OBMC_FILTER(x +stride, t, l, m, r, b);\
421 OBMC_FILTER(x+1+stride, t, l, m, r, b);
462 int src_x,
int src_y,
472 for (i = 0; i < 5; i++) {
473 if (i && mv[i][0] == mv[
MID][0] && mv[i][1] == mv[
MID][1]) {
490 int field_based,
int bottom_field,
491 int field_select,
uint8_t **ref_picture,
494 int motion_x,
int motion_y,
int h)
496 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
497 int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y,
v_edge_pos;
500 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
502 src_x = s->
mb_x * 16 + (motion_x >> 2);
503 src_y = s->
mb_y * (16 >> field_based) + (motion_y >> 2);
506 linesize = s->
linesize << field_based;
513 static const int rtab[8] = { 0, 0, 1, 1, 0, 0, 0, 1 };
514 mx = (motion_x >> 1) + rtab[motion_x & 7];
515 my = (motion_y >> 1) + rtab[motion_y & 7];
517 mx = (motion_x >> 1) | (motion_x & 1);
518 my = (motion_y >> 1) | (motion_y & 1);
523 mx = (mx >> 1) | (mx & 1);
524 my = (my >> 1) | (my & 1);
526 uvdxy = (mx & 1) | ((my & 1) << 1);
530 uvsrc_x = s->
mb_x * 8 + mx;
531 uvsrc_y = s->
mb_y * (8 >> field_based) + my;
533 ptr_y = ref_picture[0] + src_y * linesize + src_x;
534 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
535 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
538 (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y & 3) - h, 0)) {
541 17, 17 + field_based,
542 src_x, src_y << field_based,
550 uvsrc_x, uvsrc_y << field_based,
555 uvsrc_x, uvsrc_y << field_based,
563 qpix_op[0][dxy](dest_y, ptr_y,
linesize);
578 qpix_op[1][dxy](dest_y, ptr_y,
linesize);
579 qpix_op[1][dxy](dest_y + 8, ptr_y + 8,
linesize);
582 pix_op[1][uvdxy](dest_cr, ptr_cr,
uvlinesize, h >> 1);
583 pix_op[1][uvdxy](dest_cb, ptr_cb,
uvlinesize, h >> 1);
597 int src_x, src_y, dxy, emu = 0;
605 dxy = ((my & 1) << 1) | (mx & 1);
609 src_x = s->
mb_x * 8 + mx;
610 src_y = s->
mb_y * 8 + my;
611 src_x = av_clip(src_x, -8, (s->
width >> 1));
612 if (src_x == (s->
width >> 1))
614 src_y = av_clip(src_y, -8, (s->
height >> 1));
615 if (src_y == (s->
height >> 1))
619 ptr = ref_picture[1] +
offset;
620 if ((
unsigned)src_x >
FFMAX((s->
h_edge_pos >> 1) - (dxy & 1) - 8, 0) ||
631 ptr = ref_picture[2] +
offset;
647 const int mx = (s->
mv[dir][0][0] >>
shift) + 16 * s->
mb_x + 8;
648 const int my = (s->
mv[dir][0][1] >> shift) + 16 * s->
mb_y;
652 off = (mx >> 1) + ((my >> 1) + (s->
mb_x & 7)) * s->
uvlinesize + 64;
667 const int xy = mb_x + mb_y * s->
mb_stride;
669 const int mot_xy = mb_x * 2 + mb_y * 2 * mot_stride;
678 cur_frame->
motion_val[0][mot_xy + mot_stride]);
680 cur_frame->
motion_val[0][mot_xy + mot_stride + 1]);
683 cur_frame->
motion_val[0][mot_xy + mot_stride]);
685 cur_frame->
motion_val[0][mot_xy + mot_stride + 1]);
688 AV_COPY32(mv_cache[0][1], mv_cache[1][1]);
689 AV_COPY32(mv_cache[0][2], mv_cache[1][2]);
692 cur_frame->
motion_val[0][mot_xy - mot_stride]);
694 cur_frame->
motion_val[0][mot_xy - mot_stride + 1]);
698 AV_COPY32(mv_cache[1][0], mv_cache[1][1]);
699 AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
703 cur_frame->
motion_val[0][mot_xy - 1 + mot_stride]);
707 AV_COPY32(mv_cache[1][3], mv_cache[1][2]);
708 AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
712 cur_frame->
motion_val[0][mot_xy + 2 + mot_stride]);
717 for (i = 0; i < 4; i++) {
718 const int x = (i & 1) + 1;
719 const int y = (i >> 1) + 1;
721 { mv_cache[
y][x][0], mv_cache[
y][x][1] },
722 { mv_cache[y - 1][x][0], mv_cache[y - 1][x][1] },
723 { mv_cache[
y][x - 1][0], mv_cache[
y][x - 1][1] },
724 { mv_cache[
y][x + 1][0], mv_cache[
y][x + 1][1] },
725 { mv_cache[y + 1][x][0], mv_cache[y + 1][x][1] }
730 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >> 1) * 8,
739 ref_picture, pix_op[1],
752 int dxy, mx, my, src_x, src_y;
761 for (i = 0; i < 4; i++) {
762 int motion_x = s->
mv[dir][i][0];
763 int motion_y = s->
mv[dir][i][1];
765 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
766 src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
767 src_y = mb_y * 16 + (motion_y >> 2) + (i >> 1) * 8;
770 src_x = av_clip(src_x, -16, s->
width);
771 if (src_x == s->
width)
773 src_y = av_clip(src_y, -16, s->
height);
777 ptr = ref_picture[0] + (src_y * s->
linesize) + (src_x);
788 dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->
linesize;
789 qpix_op[1][dxy](dest, ptr, s->
linesize);
791 mx += s->
mv[dir][i][0] / 2;
792 my += s->
mv[dir][i][1] / 2;
795 for (i = 0; i < 4; i++) {
797 dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->
linesize,
799 mb_x * 16 + (i & 1) * 8,
800 mb_y * 16 + (i >> 1) * 8,
805 mx += s->
mv[dir][i][0];
806 my += s->
mv[dir][i][1];
812 ref_picture, pix_op[1], mx, my);
843 apply_obmc(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op);
860 ref_picture, pix_op, qpix_op,
861 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
862 }
else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
866 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
870 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y);
876 dir, ref_picture, qpix_op, pix_op);
881 for (i = 0; i < 2; i++)
884 ref_picture, pix_op, qpix_op,
885 s->
mv[dir][i][0], s->
mv[dir][i][1], 8);
891 s->
mv[dir][0][0], s->
mv[dir][0][1], 8, mb_y);
896 s->
mv[dir][1][0], s->
mv[dir][1][1], 8, mb_y);
900 || !ref_picture[0]) {
907 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y >> 1);
911 for (i = 0; i < 2; i++) {
924 s->
mv[dir][i][0], s->
mv[dir][i][1] + 16 * i,
934 for (i = 0; i < 2; i++) {
936 for (j = 0; j < 2; j++)
938 j, j ^ i, ref_picture, pix_op,
939 s->
mv[dir][2 * i + j][0],
940 s->
mv[dir][2 * i + j][1], 8, mb_y);
944 if (!ref_picture[0]) {
947 for (i = 0; i < 2; i++) {
951 s->
mv[dir][2 * i][0], s->
mv[dir][2 * i][1],
979 ref_picture, pix_op, qpix_op, 1);
983 ref_picture, pix_op, qpix_op, 0);