42 int 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;
69 if((motion_x|motion_y)&7){
70 s->
dsp.
gmc1(dest_y , ptr , linesize, 16, motion_x&15, motion_y&15, 128 - s->
no_rounding);
71 s->
dsp.
gmc1(dest_y+8, ptr+8, linesize, 16, motion_x&15, motion_y&15, 128 - s->
no_rounding);
75 dxy= ((motion_x>>3)&1) | ((motion_y>>2)&2);
91 src_x = av_clip(src_x, -8, s->
width>>1);
92 if (src_x == s->
width>>1)
94 src_y = av_clip(src_y, -8, s->
height>>1);
99 ptr = ref_picture[1] +
offset;
106 s->
dsp.
gmc1(dest_cb, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->
no_rounding);
108 ptr = ref_picture[2] +
offset;
113 s->
dsp.
gmc1(dest_cr, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->
no_rounding);
130 ptr = ref_picture[0];
135 s->
dsp.
gmc(dest_y, ptr, linesize, 16,
142 s->
dsp.
gmc(dest_y+8, ptr, linesize, 16,
155 ptr = ref_picture[1];
156 s->
dsp.
gmc(dest_cb, ptr, uvlinesize, 8,
164 ptr = ref_picture[2];
165 s->
dsp.
gmc(dest_cr, ptr, uvlinesize, 8,
176 int src_x,
int src_y,
178 int motion_x,
int motion_y)
183 src_x += motion_x >> 1;
184 src_y += motion_y >> 1;
187 src_x = av_clip(src_x, -16, s->
width);
188 if (src_x != s->
width)
190 src_y = av_clip(src_y, -16, s->
height);
192 dxy |= (motion_y & 1) << 1;
213 int motion_x,
int motion_y,
int h,
int is_mpeg12,
int mb_y)
215 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
216 int dxy, uvdxy, mx, my, src_x, src_y,
231 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
232 src_x = s->
mb_x* 16 + (motion_x >> 1);
233 src_y =( mb_y<<(4-field_based)) + (motion_y >> 1);
237 mx = (motion_x>>1)|(motion_x&1);
239 uvdxy = ((my & 1) << 1) | (mx & 1);
240 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
241 uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
243 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
251 uvsrc_x = s->
mb_x*8 + mx;
252 uvsrc_y = mb_y*8 + my;
257 uvdxy = ((my & 1) << 1) | (mx & 1);
258 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
259 uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
264 uvdxy = ((motion_y & 1) << 1) | (mx & 1);
265 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
276 ptr_y = ref_picture[0] + src_y * linesize + src_x;
277 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
278 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
281 || (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y&1) - h , 0)){
285 "MPEG motion vector out of boundary (%d %d)\n", src_x, src_y);
290 src_x, src_y<<field_based,
298 uvsrc_x, uvsrc_y<<field_based,
303 uvsrc_x, uvsrc_y<<field_based,
322 pix_op[0][dxy](dest_y, ptr_y,
linesize, h);
330 if(!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
338 int field_select,
uint8_t **ref_picture,
340 int motion_x,
int motion_y,
int h,
int mb_y)
345 field_select, ref_picture, pix_op,
346 motion_x, motion_y, h, 1, mb_y);
350 field_select, ref_picture, pix_op,
351 motion_x, motion_y, h, 0, mb_y);
356 int bottom_field,
int field_select,
359 int motion_x,
int motion_y,
int h,
int mb_y)
364 bottom_field, field_select, ref_picture, pix_op,
365 motion_x, motion_y, h, 1, mb_y);
369 bottom_field, field_select, ref_picture, pix_op,
370 motion_x, motion_y, h, 0, mb_y);
379 uint8_t *
const right = src[3];
380 uint8_t *
const bottom= src[4];
381 #define OBMC_FILTER(x, t, l, m, r, b)\
382 dst[x]= (t*top[x] + l*left[x] + m*mid[x] + r*right[x] + b*bottom[x] + 4)>>3
383 #define OBMC_FILTER4(x, t, l, m, r, b)\
384 OBMC_FILTER(x , t, l, m, r, b);\
385 OBMC_FILTER(x+1 , t, l, m, r, b);\
386 OBMC_FILTER(x +stride, t, l, m, r, b);\
387 OBMC_FILTER(x+1+stride, t, l, m, r, b);
428 int src_x,
int src_y,
439 if(i && mv[i][0]==mv[
MID][0] && mv[i][1]==mv[
MID][1]){
455 int field_based,
int bottom_field,
int field_select,
458 int motion_x,
int motion_y,
int h)
460 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
461 int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y,
v_edge_pos,
linesize,
uvlinesize;
463 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
464 src_x = s->
mb_x * 16 + (motion_x >> 2);
465 src_y = s->
mb_y * (16 >> field_based) + (motion_y >> 2);
468 linesize = s->
linesize << field_based;
475 static const int rtab[8]= {0,0,1,1,0,0,0,1};
476 mx= (motion_x>>1) + rtab[motion_x&7];
477 my= (motion_y>>1) + rtab[motion_y&7];
479 mx= (motion_x>>1)|(motion_x&1);
480 my= (motion_y>>1)|(motion_y&1);
488 uvdxy= (mx&1) | ((my&1)<<1);
492 uvsrc_x = s->
mb_x * 8 + mx;
493 uvsrc_y = s->
mb_y * (8 >> field_based) + my;
495 ptr_y = ref_picture[0] + src_y * linesize + src_x;
496 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
497 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
500 || (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y&3) - h , 0)){
502 17, 17+field_based, src_x, src_y<<field_based,
509 uvsrc_x, uvsrc_y<<field_based,
513 uvsrc_x, uvsrc_y<<field_based,
521 qpix_op[0][dxy](dest_y, ptr_y,
linesize);
536 qpix_op[1][dxy](dest_y , ptr_y ,
linesize);
537 qpix_op[1][dxy](dest_y+8, ptr_y+8,
linesize);
540 pix_op[1][uvdxy](dest_cr, ptr_cr,
uvlinesize, h >> 1);
541 pix_op[1][uvdxy](dest_cb, ptr_cb,
uvlinesize, h >> 1);
554 int dxy, emu=0, src_x, src_y,
offset;
562 dxy = ((my & 1) << 1) | (mx & 1);
566 src_x = s->
mb_x * 8 + mx;
567 src_y = s->
mb_y * 8 + my;
568 src_x = av_clip(src_x, -8, (s->
width >> 1));
569 if (src_x == (s->
width >> 1))
571 src_y = av_clip(src_y, -8, (s->
height >> 1));
572 if (src_y == (s->
height >> 1))
576 ptr = ref_picture[1] +
offset;
589 ptr = ref_picture[2] +
offset;
603 const int mx= (s->
mv[dir][0][0]>>
shift) + 16*s->
mb_x + 8;
604 const int my= (s->
mv[dir][0][1]>>shift) + 16*s->
mb_y;
630 int dxy, mx, my, src_x, src_y, motion_x, motion_y;
644 const int mot_xy= mb_x*2 + mb_y*2*mot_stride;
658 AV_COPY32(mv_cache[0][1], mv_cache[1][1]);
659 AV_COPY32(mv_cache[0][2], mv_cache[1][2]);
666 AV_COPY32(mv_cache[1][0], mv_cache[1][1]);
667 AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
674 AV_COPY32(mv_cache[1][3], mv_cache[1][2]);
675 AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
684 const int x= (i&1)+1;
685 const int y= (i>>1)+1;
687 {mv_cache[
y][x ][0], mv_cache[
y][x ][1]},
688 {mv_cache[y-1][x][0], mv_cache[y-1][x][1]},
689 {mv_cache[
y][x-1][0], mv_cache[
y][x-1][1]},
690 {mv_cache[
y][x+1][0], mv_cache[
y][x+1][1]},
691 {mv_cache[y+1][x][0], mv_cache[y+1][x][1]}};
695 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
721 ref_picture, pix_op, qpix_op,
722 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
723 }
else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
727 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
732 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y);
741 motion_x = s->
mv[dir][i][0];
742 motion_y = s->
mv[dir][i][1];
744 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
745 src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
746 src_y = mb_y * 16 + (motion_y >> 2) + (i >>1) * 8;
749 src_x = av_clip(src_x, -16, s->
width);
750 if (src_x == s->
width)
752 src_y = av_clip(src_y, -16, s->
height);
756 ptr = ref_picture[0] + (src_y * s->
linesize) + (src_x);
767 dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->
linesize;
768 qpix_op[1][dxy](dest, ptr, s->
linesize);
770 mx += s->
mv[dir][i][0]/2;
771 my += s->
mv[dir][i][1]/2;
777 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
779 s->
mv[dir][i][0], s->
mv[dir][i][1]);
781 mx += s->
mv[dir][i][0];
782 my += s->
mv[dir][i][1];
796 ref_picture, pix_op, qpix_op,
797 s->
mv[dir][i][0], s->
mv[dir][i][1], 8);
804 s->
mv[dir][0][0], s->
mv[dir][0][1], 8, mb_y);
809 s->
mv[dir][1][0], s->
mv[dir][1][1], 8, mb_y);
820 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y>>1);
837 s->
mv[dir][i][0], s->
mv[dir][i][1] + 16*i, 8, mb_y>>1);
850 j, j^i, ref_picture, pix_op,
851 s->
mv[dir][2*i + j][0],
852 s->
mv[dir][2*i + j][1], 8, mb_y);
857 if (!ref_picture[0]) {
864 s->
mv[dir][2*i][0],s->
mv[dir][2*i][1],16, mb_y>>1);
890 ref_picture, pix_op, qpix_op, 1);
894 ref_picture, pix_op, qpix_op, 0);