42 int src_x, src_y, motion_x, motion_y;
52 src_x = av_clip(src_x, -16, s->
width);
53 if (src_x == s->
width)
55 src_y = av_clip(src_y, -16, s->
height);
62 ptr = ref_picture[0] + src_y * linesize + src_x;
74 if ((motion_x | motion_y) & 7) {
75 s->
mdsp.
gmc1(dest_y, ptr, linesize, 16,
76 motion_x & 15, motion_y & 15, 128 - s->
no_rounding);
77 s->
mdsp.
gmc1(dest_y + 8, ptr + 8, linesize, 16,
78 motion_x & 15, motion_y & 15, 128 - s->
no_rounding);
82 dxy = ((motion_x >> 3) & 1) | ((motion_y >> 2) & 2);
99 src_x = av_clip(src_x, -8, s->
width >> 1);
100 if (src_x == s->
width >> 1)
102 src_y = av_clip(src_y, -8, s->
height >> 1);
103 if (src_y == s->
height >> 1)
107 ptr = ref_picture[1] +
offset;
111 uvlinesize, uvlinesize,
118 s->
mdsp.
gmc1(dest_cb, ptr, uvlinesize, 8,
119 motion_x & 15, motion_y & 15, 128 - s->
no_rounding);
121 ptr = ref_picture[2] +
offset;
124 uvlinesize, uvlinesize,
130 s->
mdsp.
gmc1(dest_cr, ptr, uvlinesize, 8,
131 motion_x & 15, motion_y & 15, 128 - s->
no_rounding);
146 ptr = ref_picture[0];
153 s->
mdsp.
gmc(dest_y, ptr, linesize, 16,
159 s->
mdsp.
gmc(dest_y + 8, ptr, linesize, 16,
175 ptr = ref_picture[1];
176 s->
mdsp.
gmc(dest_cb, ptr, uvlinesize, 8,
183 ptr = ref_picture[2];
184 s->
mdsp.
gmc(dest_cr, ptr, uvlinesize, 8,
194 int src_x,
int src_y,
196 int motion_x,
int motion_y)
201 src_x += motion_x >> 1;
202 src_y += motion_y >> 1;
205 src_x = av_clip(src_x, -16, s->
width);
206 if (src_x != s->
width)
208 src_y = av_clip(src_y, -16, s->
height);
210 dxy |= (motion_y & 1) << 1;
243 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
244 int dxy, uvdxy, mx, my, src_x, src_y,
259 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
260 src_x = s->
mb_x * 16 + (motion_x >> 1);
261 src_y = (mb_y << (4 - field_based)) + (motion_y >> 1);
265 mx = (motion_x >> 1) | (motion_x & 1);
267 uvdxy = ((my & 1) << 1) | (mx & 1);
268 uvsrc_x = s->
mb_x * 8 + (mx >> 1);
269 uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
271 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
272 uvsrc_x = src_x >> 1;
273 uvsrc_y = src_y >> 1;
280 uvsrc_x = s->
mb_x * 8 + mx;
281 uvsrc_y = mb_y * 8 + my;
286 uvdxy = ((my & 1) << 1) | (mx & 1);
287 uvsrc_x = s->
mb_x * 8 + (mx >> 1);
288 uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
293 uvdxy = ((motion_y & 1) << 1) | (mx & 1);
294 uvsrc_x = s->
mb_x * 8 + (mx >> 1);
305 ptr_y = ref_picture[0] + src_y * linesize + src_x;
306 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
307 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
310 (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y & 1) - h , 0)) {
315 "MPEG motion vector out of boundary (%d %d)\n", src_x,
321 17, 17 + field_based,
322 src_x, src_y << field_based,
331 uvsrc_x, uvsrc_y << field_based,
336 uvsrc_x, uvsrc_y << field_based,
357 pix_op[0][dxy](dest_y, ptr_y,
linesize, h);
365 if (!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
373 int field_select,
uint8_t **ref_picture,
375 int motion_x,
int motion_y,
int h,
int mb_y)
380 field_select, ref_picture, pix_op,
381 motion_x, motion_y, h, 1, mb_y);
385 field_select, ref_picture, pix_op,
386 motion_x, motion_y, h, 0, mb_y);
391 int bottom_field,
int field_select,
394 int motion_x,
int motion_y,
int h,
int mb_y)
399 bottom_field, field_select, ref_picture, pix_op,
400 motion_x, motion_y, h, 1, mb_y);
404 bottom_field, field_select, ref_picture, pix_op,
405 motion_x, motion_y, h, 0, mb_y);
416 uint8_t *
const bottom = src[4];
417 #define OBMC_FILTER(x, t, l, m, r, b)\
418 dst[x]= (t*top[x] + l*left[x] + m*mid[x] + r*right[x] + b*bottom[x] + 4)>>3
419 #define OBMC_FILTER4(x, t, l, m, r, b)\
420 OBMC_FILTER(x , t, l, m, r, b);\
421 OBMC_FILTER(x+1 , t, l, m, r, b);\
422 OBMC_FILTER(x +stride, t, l, m, r, b);\
423 OBMC_FILTER(x+1+stride, t, l, m, r, b);
464 int src_x,
int src_y,
474 for (i = 0; i < 5; i++) {
475 if (i && mv[i][0] == mv[
MID][0] && mv[i][1] == mv[
MID][1]) {
492 int field_based,
int bottom_field,
493 int field_select,
uint8_t **ref_picture,
496 int motion_x,
int motion_y,
int h)
498 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
499 int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y,
v_edge_pos;
502 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
504 src_x = s->
mb_x * 16 + (motion_x >> 2);
505 src_y = s->
mb_y * (16 >> field_based) + (motion_y >> 2);
508 linesize = s->
linesize << field_based;
515 static const int rtab[8] = { 0, 0, 1, 1, 0, 0, 0, 1 };
516 mx = (motion_x >> 1) + rtab[motion_x & 7];
517 my = (motion_y >> 1) + rtab[motion_y & 7];
519 mx = (motion_x >> 1) | (motion_x & 1);
520 my = (motion_y >> 1) | (motion_y & 1);
525 mx = (mx >> 1) | (mx & 1);
526 my = (my >> 1) | (my & 1);
528 uvdxy = (mx & 1) | ((my & 1) << 1);
532 uvsrc_x = s->
mb_x * 8 + mx;
533 uvsrc_y = s->
mb_y * (8 >> field_based) + my;
535 ptr_y = ref_picture[0] + src_y * linesize + src_x;
536 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
537 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
540 (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y & 3) - h, 0)) {
543 17, 17 + field_based,
544 src_x, src_y << field_based,
553 uvsrc_x, uvsrc_y << field_based,
558 uvsrc_x, uvsrc_y << field_based,
566 qpix_op[0][dxy](dest_y, ptr_y,
linesize);
581 qpix_op[1][dxy](dest_y, ptr_y,
linesize);
582 qpix_op[1][dxy](dest_y + 8, ptr_y + 8,
linesize);
585 pix_op[1][uvdxy](dest_cr, ptr_cr,
uvlinesize, h >> 1);
586 pix_op[1][uvdxy](dest_cb, ptr_cb,
uvlinesize, h >> 1);
600 int src_x, src_y, dxy, emu = 0;
608 dxy = ((my & 1) << 1) | (mx & 1);
612 src_x = s->
mb_x * 8 + mx;
613 src_y = s->
mb_y * 8 + my;
614 src_x = av_clip(src_x, -8, (s->
width >> 1));
615 if (src_x == (s->
width >> 1))
617 src_y = av_clip(src_y, -8, (s->
height >> 1));
618 if (src_y == (s->
height >> 1))
622 ptr = ref_picture[1] +
offset;
623 if ((
unsigned)src_x >
FFMAX((s->
h_edge_pos >> 1) - (dxy & 1) - 8, 0) ||
634 ptr = ref_picture[2] +
offset;
650 const int mx = (s->
mv[dir][0][0] >>
shift) + 16 * s->
mb_x + 8;
651 const int my = (s->
mv[dir][0][1] >> shift) + 16 * s->
mb_y;
652 int off = mx + (my + (s->
mb_x & 3) * 4) * s->
linesize + 64;
655 off = (mx >> 1) + ((my >> 1) + (s->
mb_x & 7)) * s->
uvlinesize + 64;
670 const int xy = mb_x + mb_y * s->
mb_stride;
672 const int mot_xy = mb_x * 2 + mb_y * 2 * mot_stride;
681 cur_frame->
motion_val[0][mot_xy + mot_stride]);
683 cur_frame->
motion_val[0][mot_xy + mot_stride + 1]);
686 cur_frame->
motion_val[0][mot_xy + mot_stride]);
688 cur_frame->
motion_val[0][mot_xy + mot_stride + 1]);
691 AV_COPY32(mv_cache[0][1], mv_cache[1][1]);
692 AV_COPY32(mv_cache[0][2], mv_cache[1][2]);
695 cur_frame->
motion_val[0][mot_xy - mot_stride]);
697 cur_frame->
motion_val[0][mot_xy - mot_stride + 1]);
701 AV_COPY32(mv_cache[1][0], mv_cache[1][1]);
702 AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
706 cur_frame->
motion_val[0][mot_xy - 1 + mot_stride]);
710 AV_COPY32(mv_cache[1][3], mv_cache[1][2]);
711 AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
715 cur_frame->
motion_val[0][mot_xy + 2 + mot_stride]);
720 for (i = 0; i < 4; i++) {
721 const int x = (i & 1) + 1;
722 const int y = (i >> 1) + 1;
724 { mv_cache[
y][x][0], mv_cache[
y][x][1] },
725 { mv_cache[y - 1][x][0], mv_cache[y - 1][x][1] },
726 { mv_cache[
y][x - 1][0], mv_cache[
y][x - 1][1] },
727 { mv_cache[
y][x + 1][0], mv_cache[
y][x + 1][1] },
728 { mv_cache[y + 1][x][0], mv_cache[y + 1][x][1] }
733 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >> 1) * 8,
742 ref_picture, pix_op[1],
755 int dxy, mx, my, src_x, src_y;
764 for (i = 0; i < 4; i++) {
765 int motion_x = s->
mv[dir][i][0];
766 int motion_y = s->
mv[dir][i][1];
768 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
769 src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
770 src_y = mb_y * 16 + (motion_y >> 2) + (i >> 1) * 8;
773 src_x = av_clip(src_x, -16, s->
width);
774 if (src_x == s->
width)
776 src_y = av_clip(src_y, -16, s->
height);
780 ptr = ref_picture[0] + (src_y * s->
linesize) + (src_x);
791 dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->
linesize;
792 qpix_op[1][dxy](dest, ptr, s->
linesize);
794 mx += s->
mv[dir][i][0] / 2;
795 my += s->
mv[dir][i][1] / 2;
798 for (i = 0; i < 4; i++) {
800 dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->
linesize,
802 mb_x * 16 + (i & 1) * 8,
803 mb_y * 16 + (i >> 1) * 8,
808 mx += s->
mv[dir][i][0];
809 my += s->
mv[dir][i][1];
815 ref_picture, pix_op[1], mx, my);
846 apply_obmc(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op);
863 ref_picture, pix_op, qpix_op,
864 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
865 }
else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
869 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
873 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y);
879 dir, ref_picture, qpix_op, pix_op);
884 for (i = 0; i < 2; i++)
887 ref_picture, pix_op, qpix_op,
888 s->
mv[dir][i][0], s->
mv[dir][i][1], 8);
894 s->
mv[dir][0][0], s->
mv[dir][0][1], 8, mb_y);
899 s->
mv[dir][1][0], s->
mv[dir][1][1], 8, mb_y);
903 || !ref_picture[0]) {
910 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y >> 1);
914 for (i = 0; i < 2; i++) {
919 ref2picture = ref_picture;
927 s->
mv[dir][i][0], s->
mv[dir][i][1] + 16 * i,
937 for (i = 0; i < 2; i++) {
939 for (j = 0; j < 2; j++)
941 j, j ^ i, ref_picture, pix_op,
942 s->
mv[dir][2 * i + j][0],
943 s->
mv[dir][2 * i + j][1], 8, mb_y);
947 if (!ref_picture[0]) {
950 for (i = 0; i < 2; i++) {
954 s->
mv[dir][2 * i][0], s->
mv[dir][2 * i][1],
982 ref_picture, pix_op, qpix_op, 1);
986 ref_picture, pix_op, qpix_op, 0);