41 int motion_x, motion_y;
50 src_x = av_clip(src_x, -16, s->
width);
51 if (src_x == s->
width)
53 src_y = av_clip(src_y, -16, s->
height);
60 ptr = ref_picture[0] + (src_y *
linesize) + src_x;
70 if((motion_x|motion_y)&7){
71 s->
dsp.
gmc1(dest_y , ptr , linesize, 16, motion_x&15, motion_y&15, 128 - s->
no_rounding);
72 s->
dsp.
gmc1(dest_y+8, ptr+8, linesize, 16, motion_x&15, motion_y&15, 128 - s->
no_rounding);
76 dxy= ((motion_x>>3)&1) | ((motion_y>>2)&2);
92 src_x = av_clip(src_x, -8, s->
width>>1);
93 if (src_x == s->
width>>1)
95 src_y = av_clip(src_y, -8, s->
height>>1);
100 ptr = ref_picture[1] +
offset;
109 s->
dsp.
gmc1(dest_cb, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->
no_rounding);
111 ptr = ref_picture[2] +
offset;
116 s->
dsp.
gmc1(dest_cr, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->
no_rounding);
133 ptr = ref_picture[0];
138 s->
dsp.
gmc(dest_y, ptr, linesize, 16,
145 s->
dsp.
gmc(dest_y+8, ptr, linesize, 16,
158 ptr = ref_picture[1];
159 s->
dsp.
gmc(dest_cb, ptr, uvlinesize, 8,
167 ptr = ref_picture[2];
168 s->
dsp.
gmc(dest_cr, ptr, uvlinesize, 8,
179 int src_x,
int src_y,
181 int motion_x,
int motion_y)
186 src_x += motion_x >> 1;
187 src_y += motion_y >> 1;
190 src_x = av_clip(src_x, -16, s->
width);
191 if (src_x != s->
width)
193 src_y = av_clip(src_y, -16, s->
height);
195 dxy |= (motion_y & 1) << 1;
216 int motion_x,
int motion_y,
int h,
int is_mpeg12,
int mb_y)
218 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
219 int dxy, uvdxy, mx, my, src_x, src_y,
234 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
235 src_x = s->
mb_x* 16 + (motion_x >> 1);
236 src_y =( mb_y<<(4-field_based)) + (motion_y >> 1);
240 mx = (motion_x>>1)|(motion_x&1);
242 uvdxy = ((my & 1) << 1) | (mx & 1);
243 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
244 uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
246 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
254 uvsrc_x = s->
mb_x*8 + mx;
255 uvsrc_y = mb_y*8 + my;
260 uvdxy = ((my & 1) << 1) | (mx & 1);
261 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
262 uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
267 uvdxy = ((motion_y & 1) << 1) | (mx & 1);
268 uvsrc_x = s->
mb_x* 8 + (mx >> 1);
279 ptr_y = ref_picture[0] + src_y * linesize + src_x;
280 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
281 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
284 || (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y&1) - h , 0)){
288 "MPEG motion vector out of boundary (%d %d)\n", src_x, src_y);
293 src_x, src_y<<field_based,
301 uvsrc_x, uvsrc_y<<field_based,
306 uvsrc_x, uvsrc_y<<field_based,
325 pix_op[0][dxy](dest_y, ptr_y,
linesize, h);
333 if(!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
341 int field_select,
uint8_t **ref_picture,
343 int motion_x,
int motion_y,
int h,
int mb_y)
348 field_select, ref_picture, pix_op,
349 motion_x, motion_y, h, 1, mb_y);
353 field_select, ref_picture, pix_op,
354 motion_x, motion_y, h, 0, mb_y);
359 int bottom_field,
int field_select,
362 int motion_x,
int motion_y,
int h,
int mb_y)
367 bottom_field, field_select, ref_picture, pix_op,
368 motion_x, motion_y, h, 1, mb_y);
372 bottom_field, field_select, ref_picture, pix_op,
373 motion_x, motion_y, h, 0, mb_y);
382 uint8_t *
const right = src[3];
383 uint8_t *
const bottom= src[4];
384 #define OBMC_FILTER(x, t, l, m, r, b)\
385 dst[x]= (t*top[x] + l*left[x] + m*mid[x] + r*right[x] + b*bottom[x] + 4)>>3
386 #define OBMC_FILTER4(x, t, l, m, r, b)\
387 OBMC_FILTER(x , t, l, m, r, b);\
388 OBMC_FILTER(x+1 , t, l, m, r, b);\
389 OBMC_FILTER(x +stride, t, l, m, r, b);\
390 OBMC_FILTER(x+1+stride, t, l, m, r, b);
431 int src_x,
int src_y,
442 if(i && mv[i][0]==mv[
MID][0] && mv[i][1]==mv[
MID][1]){
458 int field_based,
int bottom_field,
int field_select,
461 int motion_x,
int motion_y,
int h)
463 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
464 int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y,
v_edge_pos,
linesize,
uvlinesize;
466 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
467 src_x = s->
mb_x * 16 + (motion_x >> 2);
468 src_y = s->
mb_y * (16 >> field_based) + (motion_y >> 2);
471 linesize = s->
linesize << field_based;
478 static const int rtab[8]= {0,0,1,1,0,0,0,1};
479 mx= (motion_x>>1) + rtab[motion_x&7];
480 my= (motion_y>>1) + rtab[motion_y&7];
482 mx= (motion_x>>1)|(motion_x&1);
483 my= (motion_y>>1)|(motion_y&1);
491 uvdxy= (mx&1) | ((my&1)<<1);
495 uvsrc_x = s->
mb_x * 8 + mx;
496 uvsrc_y = s->
mb_y * (8 >> field_based) + my;
498 ptr_y = ref_picture[0] + src_y * linesize + src_x;
499 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
500 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
503 || (unsigned)src_y >
FFMAX( v_edge_pos - (motion_y&3) - h , 0)){
505 17, 17+field_based, src_x, src_y<<field_based,
512 uvsrc_x, uvsrc_y<<field_based,
516 uvsrc_x, uvsrc_y<<field_based,
524 qpix_op[0][dxy](dest_y, ptr_y,
linesize);
539 qpix_op[1][dxy](dest_y , ptr_y ,
linesize);
540 qpix_op[1][dxy](dest_y+8, ptr_y+8,
linesize);
543 pix_op[1][uvdxy](dest_cr, ptr_cr,
uvlinesize, h >> 1);
544 pix_op[1][uvdxy](dest_cb, ptr_cb,
uvlinesize, h >> 1);
557 int dxy, emu=0, src_x, src_y,
offset;
565 dxy = ((my & 1) << 1) | (mx & 1);
569 src_x = s->
mb_x * 8 + mx;
570 src_y = s->
mb_y * 8 + my;
571 src_x = av_clip(src_x, -8, (s->
width >> 1));
572 if (src_x == (s->
width >> 1))
574 src_y = av_clip(src_y, -8, (s->
height >> 1));
575 if (src_y == (s->
height >> 1))
579 ptr = ref_picture[1] +
offset;
592 ptr = ref_picture[2] +
offset;
606 const int mx= (s->
mv[dir][0][0]>>
shift) + 16*s->
mb_x + 8;
607 const int my= (s->
mv[dir][0][1]>>shift) + 16*s->
mb_y;
633 int dxy, mx, my, src_x, src_y, motion_x, motion_y;
647 const int mot_xy= mb_x*2 + mb_y*2*mot_stride;
661 AV_COPY32(mv_cache[0][1], mv_cache[1][1]);
662 AV_COPY32(mv_cache[0][2], mv_cache[1][2]);
669 AV_COPY32(mv_cache[1][0], mv_cache[1][1]);
670 AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
677 AV_COPY32(mv_cache[1][3], mv_cache[1][2]);
678 AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
687 const int x= (i&1)+1;
688 const int y= (i>>1)+1;
690 {mv_cache[
y][x ][0], mv_cache[
y][x ][1]},
691 {mv_cache[y-1][x][0], mv_cache[y-1][x][1]},
692 {mv_cache[
y][x-1][0], mv_cache[
y][x-1][1]},
693 {mv_cache[
y][x+1][0], mv_cache[
y][x+1][1]},
694 {mv_cache[y+1][x][0], mv_cache[y+1][x][1]}};
698 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
724 ref_picture, pix_op, qpix_op,
725 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
726 }
else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
730 s->
mv[dir][0][0], s->
mv[dir][0][1], 16);
735 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y);
744 motion_x = s->
mv[dir][i][0];
745 motion_y = s->
mv[dir][i][1];
747 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
748 src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
749 src_y = mb_y * 16 + (motion_y >> 2) + (i >>1) * 8;
752 src_x = av_clip(src_x, -16, s->
width);
753 if (src_x == s->
width)
755 src_y = av_clip(src_y, -16, s->
height);
759 ptr = ref_picture[0] + (src_y * s->
linesize) + (src_x);
770 dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->
linesize;
771 qpix_op[1][dxy](dest, ptr, s->
linesize);
773 mx += s->
mv[dir][i][0]/2;
774 my += s->
mv[dir][i][1]/2;
780 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
782 s->
mv[dir][i][0], s->
mv[dir][i][1]);
784 mx += s->
mv[dir][i][0];
785 my += s->
mv[dir][i][1];
799 ref_picture, pix_op, qpix_op,
800 s->
mv[dir][i][0], s->
mv[dir][i][1], 8);
807 s->
mv[dir][0][0], s->
mv[dir][0][1], 8, mb_y);
812 s->
mv[dir][1][0], s->
mv[dir][1][1], 8, mb_y);
822 s->
mv[dir][0][0], s->
mv[dir][0][1], 16, mb_y>>1);
831 ref2picture= ref_picture;
839 s->
mv[dir][i][0], s->
mv[dir][i][1] + 16*i, 8, mb_y>>1);
852 j, j^i, ref_picture, pix_op,
853 s->
mv[dir][2*i + j][0],
854 s->
mv[dir][2*i + j][1], 8, mb_y);
863 s->
mv[dir][2*i][0],s->
mv[dir][2*i][1],16, mb_y>>1);
889 ref_picture, pix_op, qpix_op, 1);
893 ref_picture, pix_op, qpix_op, 0);