39 int motion_x, motion_y;
48 src_x = av_clip(src_x, -16, s->
width);
49 if (src_x == s->
width)
51 src_y = av_clip(src_y, -16, s->
height);
58 ptr = ref_picture[0] + (src_y *
linesize) + src_x;
68 if((motion_x|motion_y)&7){
69 s->
dsp.
gmc1(dest_y , ptr , linesize, 16, motion_x&15, motion_y&15, 128 - s->
no_rounding);
70 s->
dsp.
gmc1(dest_y+8, ptr+8, linesize, 16, motion_x&15, motion_y&15, 128 - s->
no_rounding);
74 dxy= ((motion_x>>3)&1) | ((motion_y>>2)&2);
90 src_x = av_clip(src_x, -8, s->
width>>1);
91 if (src_x == s->
width>>1)
93 src_y = av_clip(src_y, -8, s->
height>>1);
98 ptr = ref_picture[1] +
offset;
107 s->
dsp.
gmc1(dest_cb, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->
no_rounding);
109 ptr = ref_picture[2] +
offset;
114 s->
dsp.
gmc1(dest_cr, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->
no_rounding);
131 ptr = ref_picture[0];
136 s->
dsp.
gmc(dest_y, ptr, linesize, 16,
143 s->
dsp.
gmc(dest_y+8, ptr, linesize, 16,
156 ptr = ref_picture[1];
157 s->
dsp.
gmc(dest_cb, ptr, uvlinesize, 8,
165 ptr = ref_picture[2];
166 s->
dsp.
gmc(dest_cr, ptr, uvlinesize, 8,
177 int src_x,
int src_y,
179 int motion_x,
int motion_y)
184 src_x += motion_x >> 1;
185 src_y += motion_y >> 1;
188 src_x = av_clip(src_x, -16, s->
width);
189 if (src_x != s->
width)
191 src_y = av_clip(src_y, -16, s->
height);
193 dxy |= (motion_y & 1) << 1;
214 int motion_x,
int motion_y,
int h,
int is_mpeg12,
int mb_y)
216 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
217 int dxy, uvdxy, mx, my, src_x, src_y,
232 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
233 src_x = s->
mb_x* 16 + (motion_x >> 1);
234 src_y =( mb_y<<(4-field_based)) + (motion_y >> 1);
238 mx = (motion_x>>1)|(motion_x&1);
240 uvdxy = ((my & 1) << 1) | (mx & 1);
241 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
242 uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
244 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
252 uvsrc_x = s->
mb_x*8 + mx;
253 uvsrc_y = mb_y*8 + my;
258 uvdxy = ((my & 1) << 1) | (mx & 1);
259 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
260 uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
265 uvdxy = ((motion_y & 1) << 1) | (mx & 1);
266 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
277 ptr_y = ref_picture[0] + src_y * linesize + src_x;
278 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
279 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
282 || (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y&1) - h , 0)){
286 "MPEG motion vector out of boundary (%d %d)\n", src_x, src_y);
291 src_x, src_y<<field_based,
299 uvsrc_x, uvsrc_y<<field_based,
304 uvsrc_x, uvsrc_y<<field_based,
323 pix_op[0][dxy](dest_y, ptr_y,
linesize, h);
331 if(!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
339 int field_select,
uint8_t **ref_picture,
341 int motion_x,
int motion_y,
int h,
int mb_y)
346 field_select, ref_picture, pix_op,
347 motion_x, motion_y, h, 1, mb_y);
351 field_select, ref_picture, pix_op,
352 motion_x, motion_y, h, 0, mb_y);
357 int bottom_field,
int field_select,
360 int motion_x,
int motion_y,
int h,
int mb_y)
365 bottom_field, field_select, ref_picture, pix_op,
366 motion_x, motion_y, h, 1, mb_y);
370 bottom_field, field_select, ref_picture, pix_op,
371 motion_x, motion_y, h, 0, mb_y);
380 uint8_t *
const right = src[3];
381 uint8_t *
const bottom= src[4];
382 #define OBMC_FILTER(x, t, l, m, r, b)\
383 dst[x]= (t*top[x] + l*left[x] + m*mid[x] + r*right[x] + b*bottom[x] + 4)>>3
384 #define OBMC_FILTER4(x, t, l, m, r, b)\
385 OBMC_FILTER(x , t, l, m, r, b);\
386 OBMC_FILTER(x+1 , t, l, m, r, b);\
387 OBMC_FILTER(x +stride, t, l, m, r, b);\
388 OBMC_FILTER(x+1+stride, t, l, m, r, b);
429 int src_x,
int src_y,
440 if(i && mv[i][0]==mv[
MID][0] && mv[i][1]==mv[
MID][1]){
456 int field_based,
int bottom_field,
int field_select,
459 int motion_x,
int motion_y,
int h)
461 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
462 int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y,
v_edge_pos,
linesize,
uvlinesize;
464 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
465 src_x = s->
mb_x * 16 + (motion_x >> 2);
466 src_y = s->
mb_y * (16 >> field_based) + (motion_y >> 2);
469 linesize = s->
linesize << field_based;
476 static const int rtab[8]= {0,0,1,1,0,0,0,1};
477 mx= (motion_x>>1) + rtab[motion_x&7];
478 my= (motion_y>>1) + rtab[motion_y&7];
480 mx= (motion_x>>1)|(motion_x&1);
481 my= (motion_y>>1)|(motion_y&1);
489 uvdxy= (mx&1) | ((my&1)<<1);
493 uvsrc_x = s->
mb_x * 8 + mx;
494 uvsrc_y = s->
mb_y * (8 >> field_based) + my;
496 ptr_y = ref_picture[0] + src_y * linesize + src_x;
497 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
498 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
501 || (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y&3) - h , 0)){
503 17, 17+field_based, src_x, src_y<<field_based,
510 uvsrc_x, uvsrc_y<<field_based,
514 uvsrc_x, uvsrc_y<<field_based,
522 qpix_op[0][dxy](dest_y, ptr_y,
linesize);
537 qpix_op[1][dxy](dest_y , ptr_y ,
linesize);
538 qpix_op[1][dxy](dest_y+8, ptr_y+8,
linesize);
541 pix_op[1][uvdxy](dest_cr, ptr_cr,
uvlinesize, h >> 1);
542 pix_op[1][uvdxy](dest_cb, ptr_cb,
uvlinesize, h >> 1);
555 int dxy, emu=0, src_x, src_y,
offset;
563 dxy = ((my & 1) << 1) | (mx & 1);
567 src_x = s->
mb_x * 8 + mx;
568 src_y = s->
mb_y * 8 + my;
569 src_x = av_clip(src_x, -8, (s->
width >> 1));
570 if (src_x == (s->
width >> 1))
572 src_y = av_clip(src_y, -8, (s->
height >> 1));
573 if (src_y == (s->
height >> 1))
577 ptr = ref_picture[1] +
offset;
590 ptr = ref_picture[2] +
offset;
604 const int mx= (s->
mv[dir][0][0]>>
shift) + 16*s->
mb_x + 8;
605 const int my= (s->
mv[dir][0][1]>>shift) + 16*s->
mb_y;
631 int dxy, mx, my, src_x, src_y, motion_x, motion_y;
645 const int mot_xy= mb_x*2 + mb_y*2*mot_stride;
659 AV_COPY32(mv_cache[0][1], mv_cache[1][1]);
660 AV_COPY32(mv_cache[0][2], mv_cache[1][2]);
667 AV_COPY32(mv_cache[1][0], mv_cache[1][1]);
668 AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
675 AV_COPY32(mv_cache[1][3], mv_cache[1][2]);
676 AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
685 const int x= (i&1)+1;
686 const int y= (i>>1)+1;
688 {mv_cache[y][x ][0], mv_cache[y][x ][1]},
689 {mv_cache[y-1][x][0], mv_cache[y-1][x][1]},
690 {mv_cache[y][x-1][0], mv_cache[y][x-1][1]},
691 {mv_cache[y][x+1][0], mv_cache[y][x+1][1]},
692 {mv_cache[y+1][x][0], mv_cache[y+1][x][1]}};
696 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
722 ref_picture, pix_op, qpix_op,
723 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
724 }
else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
728 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
733 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y);
742 motion_x = s->
mv[dir][i][0];
743 motion_y = s->
mv[dir][i][1];
745 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
746 src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
747 src_y = mb_y * 16 + (motion_y >> 2) + (i >>1) * 8;
750 src_x = av_clip(src_x, -16, s->
width);
751 if (src_x == s->
width)
753 src_y = av_clip(src_y, -16, s->
height);
757 ptr = ref_picture[0] + (src_y * s->
linesize) + (src_x);
768 dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->
linesize;
769 qpix_op[1][dxy](dest, ptr, s->
linesize);
771 mx += s->
mv[dir][i][0]/2;
772 my += s->
mv[dir][i][1]/2;
778 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
780 s->
mv[dir][i][0], s->
mv[dir][i][1]);
782 mx += s->
mv[dir][i][0];
783 my += s->
mv[dir][i][1];
797 ref_picture, pix_op, qpix_op,
798 s->
mv[dir][i][0], s->
mv[dir][i][1], 8);
805 s->
mv[dir][0][0], s->
mv[dir][0][1], 8, mb_y);
810 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);
829 ref2picture= ref_picture;
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);
861 s->
mv[dir][2*i][0],s->
mv[dir][2*i][1],16, mb_y>>1);
887 ref_picture, pix_op, qpix_op, 1);
891 ref_picture, pix_op, qpix_op, 0);