comparison motion_est.c @ 765:7f0d502a42c5 libavcodec

clip MVs for direct mode
author michaelni
date Thu, 24 Oct 2002 00:51:17 +0000
parents 199b324b2693
children 0e1d375c537f
comparison
equal deleted inserted replaced
764:d4726182dfd2 765:7f0d502a42c5
1334 fbmin = (mv_penalty[motion_fx-pred_fx] + mv_penalty[motion_fy-pred_fy])*s->qscale; 1334 fbmin = (mv_penalty[motion_fx-pred_fx] + mv_penalty[motion_fy-pred_fy])*s->qscale;
1335 1335
1336 dxy = ((motion_fy & 1) << 1) | (motion_fx & 1); 1336 dxy = ((motion_fy & 1) << 1) | (motion_fx & 1);
1337 src_x = mb_x * 16 + (motion_fx >> 1); 1337 src_x = mb_x * 16 + (motion_fx >> 1);
1338 src_y = mb_y * 16 + (motion_fy >> 1); 1338 src_y = mb_y * 16 + (motion_fy >> 1);
1339 1339 src_x = clip(src_x, -16, s->width);
1340 if (src_x == s->width)
1341 dxy&= 2;
1342 src_y = clip(src_y, -16, s->height);
1343 if (src_y == s->height)
1344 dxy&= 1;
1345
1340 ptr = s->last_picture[0] + (src_y * s->linesize) + src_x; 1346 ptr = s->last_picture[0] + (src_y * s->linesize) + src_x;
1341 put_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16); 1347 put_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16);
1342 1348
1343 fbmin += (mv_penalty[motion_bx-pred_bx] + mv_penalty[motion_by-pred_by])*s->qscale; 1349 fbmin += (mv_penalty[motion_bx-pred_bx] + mv_penalty[motion_by-pred_by])*s->qscale;
1344 1350
1345 dxy = ((motion_by & 1) << 1) | (motion_bx & 1); 1351 dxy = ((motion_by & 1) << 1) | (motion_bx & 1);
1346 src_x = mb_x * 16 + (motion_bx >> 1); 1352 src_x = mb_x * 16 + (motion_bx >> 1);
1347 src_y = mb_y * 16 + (motion_by >> 1); 1353 src_y = mb_y * 16 + (motion_by >> 1);
1354 src_x = clip(src_x, -16, s->width);
1355 if (src_x == s->width)
1356 dxy&= 2;
1357 src_y = clip(src_y, -16, s->height);
1358 if (src_y == s->height)
1359 dxy&= 1;
1348 1360
1349 ptr = s->next_picture[0] + (src_y * s->linesize) + src_x; 1361 ptr = s->next_picture[0] + (src_y * s->linesize) + src_x;
1350 avg_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16); 1362 avg_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16);
1351 1363
1352 fbmin += pix_abs16x16(s->new_picture[0] + mb_x*16 + mb_y*16*s->linesize, dest_y, s->linesize); 1364 fbmin += pix_abs16x16(s->new_picture[0] + mb_x*16 + mb_y*16*s->linesize, dest_y, s->linesize);