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;
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;
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;
244 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
245 int dxy, uvdxy, mx, my, src_x, src_y,
260 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
261 src_x = s->
mb_x * 16 + (motion_x >> 1);
262 src_y = (mb_y << (4 - field_based)) + (motion_y >> 1);
266 mx = (motion_x >> 1) | (motion_x & 1);
268 uvdxy = ((my & 1) << 1) | (mx & 1);
269 uvsrc_x = s->
mb_x * 8 + (mx >> 1);
270 uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
272 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
273 uvsrc_x = src_x >> 1;
274 uvsrc_y = src_y >> 1;
281 uvsrc_x = s->
mb_x * 8 + mx;
282 uvsrc_y = mb_y * 8 + my;
287 uvdxy = ((my & 1) << 1) | (mx & 1);
288 uvsrc_x = s->
mb_x * 8 + (mx >> 1);
289 uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
294 uvdxy = ((motion_y & 1) << 1) | (mx & 1);
295 uvsrc_x = s->
mb_x * 8 + (mx >> 1);
306 ptr_y = ref_picture[0] + src_y * linesize + src_x;
307 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
308 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
311 (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y & 1) - h , 0)) {
316 "MPEG motion vector out of boundary (%d %d)\n", src_x,
322 17, 17 + field_based,
323 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)) {
544 17, 17 + field_based,
545 src_x, src_y << field_based,
554 uvsrc_x, uvsrc_y << field_based,
560 uvsrc_x, uvsrc_y << field_based,
568 qpix_op[0][dxy](dest_y, ptr_y,
linesize);
583 qpix_op[1][dxy](dest_y, ptr_y,
linesize);
584 qpix_op[1][dxy](dest_y + 8, ptr_y + 8,
linesize);
587 pix_op[1][uvdxy](dest_cr, ptr_cr,
uvlinesize, h >> 1);
588 pix_op[1][uvdxy](dest_cb, ptr_cb,
uvlinesize, h >> 1);
602 int src_x, src_y, dxy, emu = 0;
610 dxy = ((my & 1) << 1) | (mx & 1);
614 src_x = s->
mb_x * 8 + mx;
615 src_y = s->
mb_y * 8 + my;
616 src_x = av_clip(src_x, -8, (s->
width >> 1));
617 if (src_x == (s->
width >> 1))
619 src_y = av_clip(src_y, -8, (s->
height >> 1));
620 if (src_y == (s->
height >> 1))
624 ptr = ref_picture[1] +
offset;
626 if ((
unsigned)src_x >
FFMAX((s->
h_edge_pos >> 1) - (dxy & 1) - 8, 0) ||
638 ptr = ref_picture[2] +
offset;
654 const int mx = (s->
mv[dir][0][0] >>
shift) + 16 * s->
mb_x + 8;
655 const int my = (s->
mv[dir][0][1] >> shift) + 16 * s->
mb_y;
659 off = (mx >> 1) + ((my >> 1) + (s->
mb_x & 7)) * s->
uvlinesize + 64;
674 const int xy = mb_x + mb_y * s->
mb_stride;
676 const int mot_xy = mb_x * 2 + mb_y * 2 * mot_stride;
685 cur_frame->
motion_val[0][mot_xy + mot_stride]);
687 cur_frame->
motion_val[0][mot_xy + mot_stride + 1]);
690 cur_frame->
motion_val[0][mot_xy + mot_stride]);
692 cur_frame->
motion_val[0][mot_xy + mot_stride + 1]);
695 AV_COPY32(mv_cache[0][1], mv_cache[1][1]);
696 AV_COPY32(mv_cache[0][2], mv_cache[1][2]);
699 cur_frame->
motion_val[0][mot_xy - mot_stride]);
701 cur_frame->
motion_val[0][mot_xy - mot_stride + 1]);
705 AV_COPY32(mv_cache[1][0], mv_cache[1][1]);
706 AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
710 cur_frame->
motion_val[0][mot_xy - 1 + mot_stride]);
714 AV_COPY32(mv_cache[1][3], mv_cache[1][2]);
715 AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
719 cur_frame->
motion_val[0][mot_xy + 2 + mot_stride]);
724 for (i = 0; i < 4; i++) {
725 const int x = (i & 1) + 1;
726 const int y = (i >> 1) + 1;
728 { mv_cache[
y][x][0], mv_cache[
y][x][1] },
729 { mv_cache[y - 1][x][0], mv_cache[y - 1][x][1] },
730 { mv_cache[
y][x - 1][0], mv_cache[
y][x - 1][1] },
731 { mv_cache[
y][x + 1][0], mv_cache[
y][x + 1][1] },
732 { mv_cache[y + 1][x][0], mv_cache[y + 1][x][1] }
737 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >> 1) * 8,
746 ref_picture, pix_op[1],
759 int dxy, mx, my, src_x, src_y;
768 for (i = 0; i < 4; i++) {
769 int motion_x = s->
mv[dir][i][0];
770 int motion_y = s->
mv[dir][i][1];
772 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
773 src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
774 src_y = mb_y * 16 + (motion_y >> 2) + (i >> 1) * 8;
777 src_x = av_clip(src_x, -16, s->
width);
778 if (src_x == s->
width)
780 src_y = av_clip(src_y, -16, s->
height);
784 ptr = ref_picture[0] + (src_y * s->
linesize) + (src_x);
798 dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->
linesize;
799 qpix_op[1][dxy](dest, ptr, s->
linesize);
801 mx += s->
mv[dir][i][0] / 2;
802 my += s->
mv[dir][i][1] / 2;
805 for (i = 0; i < 4; i++) {
807 dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->
linesize,
809 mb_x * 16 + (i & 1) * 8,
810 mb_y * 16 + (i >> 1) * 8,
815 mx += s->
mv[dir][i][0];
816 my += s->
mv[dir][i][1];
822 ref_picture, pix_op[1], mx, my);
853 apply_obmc(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op);
870 ref_picture, pix_op, qpix_op,
871 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
872 }
else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
876 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
880 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y);
886 dir, ref_picture, qpix_op, pix_op);
891 for (i = 0; i < 2; i++)
894 ref_picture, pix_op, qpix_op,
895 s->
mv[dir][i][0], s->
mv[dir][i][1], 8);
901 s->
mv[dir][0][0], s->
mv[dir][0][1], 8, mb_y);
906 s->
mv[dir][1][0], s->
mv[dir][1][1], 8, mb_y);
910 || !ref_picture[0]) {
917 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y >> 1);
921 for (i = 0; i < 2; i++) {
934 s->
mv[dir][i][0], s->
mv[dir][i][1] + 16 * i,
944 for (i = 0; i < 2; i++) {
946 for (j = 0; j < 2; j++)
948 j, j ^ i, ref_picture, pix_op,
949 s->
mv[dir][2 * i + j][0],
950 s->
mv[dir][2 * i + j][1], 8, mb_y);
954 if (!ref_picture[0]) {
957 for (i = 0; i < 2; i++) {
961 s->
mv[dir][2 * i][0], s->
mv[dir][2 * i][1],
989 ref_picture, pix_op, qpix_op, 1);
993 ref_picture, pix_op, qpix_op, 0);