- int mx, my, i, j, hw;
- unsigned char *pa, *pb;
-
- mx = x + deltax;
- my = y + deltay;
-
- /* check MV against frame boundaries */
- if ((mx < 0) || (mx > ri->avctx->width - 8) ||
- (my < 0) || (my > ri->avctx->height - 8)) {
- av_log(ri->avctx, AV_LOG_ERROR, "motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\n",
- mx, my, ri->avctx->width, ri->avctx->height);
- return;
- }
-
- pa = ri->current_frame->data[0] + (y * ri->y_stride) + x;
- pb = ri->last_frame->data[0] + (my * ri->y_stride) + mx;
- for(i = 0; i < 8; i++) {
- pa[0] = pb[0];
- pa[1] = pb[1];
- pa[2] = pb[2];
- pa[3] = pb[3];
- pa[4] = pb[4];
- pa[5] = pb[5];
- pa[6] = pb[6];
- pa[7] = pb[7];
- pa += ri->y_stride;
- pb += ri->y_stride;
- }
-
- hw = ri->c_stride;
- pa = ri->current_frame->data[1] + (y * ri->y_stride)/4 + x/2;
- pb = ri->last_frame->data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
- for(j = 0; j < 2; j++) {
- for(i = 0; i < 4; i++) {
- switch(((my & 0x01) << 1) | (mx & 0x01)) {
-
- case 0:
- pa[0] = pb[0];
- pa[1] = pb[1];
- pa[2] = pb[2];
- pa[3] = pb[3];
- break;
-
- case 1:
- pa[0] = avg2(pb[0], pb[1]);
- pa[1] = avg2(pb[1], pb[2]);
- pa[2] = avg2(pb[2], pb[3]);
- pa[3] = avg2(pb[3], pb[4]);
- break;
-
- case 2:
- pa[0] = avg2(pb[0], pb[hw]);
- pa[1] = avg2(pb[1], pb[hw+1]);
- pa[2] = avg2(pb[2], pb[hw+2]);
- pa[3] = avg2(pb[3], pb[hw+3]);
- break;
-
- case 3:
- pa[0] = avg4(pb[0], pb[1], pb[hw], pb[hw+1]);
- pa[1] = avg4(pb[1], pb[2], pb[hw+1], pb[hw+2]);
- pa[2] = avg4(pb[2], pb[3], pb[hw+2], pb[hw+3]);
- pa[3] = avg4(pb[3], pb[4], pb[hw+3], pb[hw+4]);
- break;
- }
- pa += ri->c_stride;
- pb += ri->c_stride;
- }
-
- pa = ri->current_frame->data[2] + (y * ri->y_stride)/4 + x/2;
- pb = ri->last_frame->data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
- }