Mercurial > libavcodec.hg
changeset 1326:6cdd3b8f4fd3 libavcodec
DMV support patch by ("Ivan Kalvachev" <ivan at cacad dot com>)
author | michaelni |
---|---|
date | Mon, 23 Jun 2003 22:32:15 +0000 |
parents | 1cbc2380d172 |
children | 854571532c89 |
files | mpeg12.c mpegvideo.c |
diffstat | 2 files changed, 85 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/mpeg12.c Sun Jun 22 11:08:22 2003 +0000 +++ b/mpeg12.c Mon Jun 23 22:32:15 2003 +0000 @@ -1108,34 +1108,37 @@ s->last_mv[i][0][1] >> 1); dmy = get_dmv(s); s->mv_type = MV_TYPE_DMV; - /* XXX: totally broken */ + + + s->last_mv[i][0][1] = my<<1; + s->last_mv[i][1][1] = my<<1; + + s->mv[i][0][0] = mx; + s->mv[i][0][1] = my; + s->mv[i][1][0] = mx;//not used + s->mv[i][1][1] = my;//not used + if (s->picture_structure == PICT_FRAME) { mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED; - s->last_mv[i][0][1] = my << 1; - s->last_mv[i][1][1] = my << 1; + //m = 1 + 2 * s->top_field_first; + m = s->top_field_first ? 1 : 3; - m = s->top_field_first ? 1 : 3; /* top -> top pred */ - s->mv[i][0][0] = mx; - s->mv[i][0][1] = my << 1; - s->mv[i][1][0] = ((mx * m + (mx > 0)) >> 1) + dmx; - s->mv[i][1][1] = ((my * m + (my > 0)) >> 1) + dmy - 1; + s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx; + s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1; m = 4 - m; - s->mv[i][2][0] = mx; - s->mv[i][2][1] = my << 1; s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx; s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1; } else { mb_type |= MB_TYPE_16x16; - s->last_mv[i][0][1] = my; - s->last_mv[i][1][1] = my; - s->mv[i][0][0] = mx; - s->mv[i][0][1] = my; - s->mv[i][1][0] = ((mx + (mx > 0)) >> 1) + dmx; - s->mv[i][1][1] = ((my + (my > 0)) >> 1) + dmy - 1 - /* + 2 * cur_field */; + s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx; + s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy; + if(s->picture_structure == PICT_TOP_FIELD) + s->mv[i][2][1]--; + else + s->mv[i][2][1]++; } } break;
--- a/mpegvideo.c Sun Jun 22 11:08:22 2003 +0000 +++ b/mpegvideo.c Mon Jun 23 22:32:15 2003 +0000 @@ -2190,6 +2190,71 @@ s->mv[dir][0][0], s->mv[dir][0][1], 16); } break; + case MV_TYPE_DMV: + { + op_pixels_func (*dmv_pix_op)[4]; + int offset; + + dmv_pix_op = s->dsp.put_pixels_tab; + + if(s->picture_structure == PICT_FRAME){ + //put top field from top field + mpeg_motion(s, dest_y, dest_cb, dest_cr, 0, + ref_picture, 0, + 1, dmv_pix_op, + s->mv[dir][0][0], s->mv[dir][0][1], 8); + //put bottom field from bottom field + mpeg_motion(s, dest_y, dest_cb, dest_cr, s->linesize, + ref_picture, s->linesize, + 1, dmv_pix_op, + s->mv[dir][0][0], s->mv[dir][0][1], 8); + + dmv_pix_op = s->dsp.avg_pixels_tab; + + //avg top field from bottom field + mpeg_motion(s, dest_y, dest_cb, dest_cr, 0, + ref_picture, s->linesize, + 1, dmv_pix_op, + s->mv[dir][2][0], s->mv[dir][2][1], 8); + //avg bottom field from top field + mpeg_motion(s, dest_y, dest_cb, dest_cr, s->linesize, + ref_picture, 0, + 1, dmv_pix_op, + s->mv[dir][3][0], s->mv[dir][3][1], 8); + + }else{ + offset=(s->picture_structure == PICT_BOTTOM_FIELD)? + s->linesize : 0; + + //put field from the same parity + //same parity is never in the same frame + mpeg_motion(s, dest_y, dest_cb, dest_cr, 0, + ref_picture,offset, + 0,dmv_pix_op, + s->mv[dir][0][0],s->mv[dir][0][1],16); + + // after put we make avg of the same block + dmv_pix_op=s->dsp.avg_pixels_tab; + + //opposite parity is always in the same frame if this is second field + if(!s->first_field){ + ref_picture = s->current_picture.data; + //top field is one linesize from frame beginig + offset=(s->picture_structure == PICT_BOTTOM_FIELD)? + -s->linesize : s->linesize; + }else + offset=(s->picture_structure == PICT_BOTTOM_FIELD)? + 0 : s->linesize; + + //avg field from the opposite parity + mpeg_motion(s, dest_y, dest_cb, dest_cr,0, + ref_picture, offset, + 0,dmv_pix_op, + s->mv[dir][2][0],s->mv[dir][2][1],16); + } + } + break; + } }