diff options
author | Clément Bœsch <u@pkh.me> | 2015-11-12 15:03:07 +0100 |
---|---|---|
committer | Clément Bœsch <clement@stupeflix.com> | 2015-11-23 10:55:15 +0100 |
commit | 56bdf61baa04c4fd8d165f34499115ce0aa97c43 (patch) | |
tree | 9a973b765cba9ca2de8ff68c07805d32a2bdc319 /libavcodec/mpegvideo.c | |
parent | c7b933885343739e5fc37286d6d2c0736c1ffeb4 (diff) | |
download | ffmpeg-56bdf61baa04c4fd8d165f34499115ce0aa97c43.tar.gz |
avutil/motion_vector: export subpel motion information
FATE test changes because of the switch from shift to division.
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r-- | libavcodec/mpegvideo.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 60e19ffded..6d9e265eef 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1557,15 +1557,18 @@ static void draw_arrow(uint8_t *buf, int sx, int sy, int ex, static int add_mb(AVMotionVector *mb, uint32_t mb_type, int dst_x, int dst_y, - int src_x, int src_y, + int motion_x, int motion_y, int motion_scale, int direction) { mb->w = IS_8X8(mb_type) || IS_8X16(mb_type) ? 8 : 16; mb->h = IS_8X8(mb_type) || IS_16X8(mb_type) ? 8 : 16; - mb->src_x = src_x; - mb->src_y = src_y; + mb->motion_x = motion_x; + mb->motion_y = motion_y; + mb->motion_scale = motion_scale; mb->dst_x = dst_x; mb->dst_y = dst_y; + mb->src_x = dst_x + motion_x / motion_scale; + mb->src_y = dst_y + motion_y / motion_scale; mb->source = direction ? 1 : -1; mb->flags = 0; // XXX: does mb_type contain extra information that could be exported here? return 1; @@ -1581,6 +1584,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_ { if ((avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS) && mbtype_table && motion_val[0]) { const int shift = 1 + quarter_sample; + const int scale = 1 << shift; const int mv_sample_log2 = avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_SVQ3 ? 2 : 1; const int mv_stride = (mb_width << mv_sample_log2) + (avctx->codec->id == AV_CODEC_ID_H264 ? 0 : 1); @@ -1604,43 +1608,43 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_ int sy = mb_y * 16 + 4 + 8 * (i >> 1); int xy = (mb_x * 2 + (i & 1) + (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1); - int mx = (motion_val[direction][xy][0] >> shift) + sx; - int my = (motion_val[direction][xy][1] >> shift) + sy; - mbcount += add_mb(mvs + mbcount, mb_type, sx, sy, mx, my, direction); + int mx = motion_val[direction][xy][0]; + int my = motion_val[direction][xy][1]; + mbcount += add_mb(mvs + mbcount, mb_type, sx, sy, mx, my, scale, direction); } } else if (IS_16X8(mb_type)) { for (i = 0; i < 2; i++) { int sx = mb_x * 16 + 8; int sy = mb_y * 16 + 4 + 8 * i; int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1); - int mx = (motion_val[direction][xy][0] >> shift); - int my = (motion_val[direction][xy][1] >> shift); + int mx = motion_val[direction][xy][0]; + int my = motion_val[direction][xy][1]; if (IS_INTERLACED(mb_type)) my *= 2; - mbcount += add_mb(mvs + mbcount, mb_type, sx, sy, mx + sx, my + sy, direction); + mbcount += add_mb(mvs + mbcount, mb_type, sx, sy, mx, my, scale, direction); } } else if (IS_8X16(mb_type)) { for (i = 0; i < 2; i++) { int sx = mb_x * 16 + 4 + 8 * i; int sy = mb_y * 16 + 8; int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1); - int mx = motion_val[direction][xy][0] >> shift; - int my = motion_val[direction][xy][1] >> shift; + int mx = motion_val[direction][xy][0]; + int my = motion_val[direction][xy][1]; if (IS_INTERLACED(mb_type)) my *= 2; - mbcount += add_mb(mvs + mbcount, mb_type, sx, sy, mx + sx, my + sy, direction); + mbcount += add_mb(mvs + mbcount, mb_type, sx, sy, mx, my, scale, direction); } } else { int sx = mb_x * 16 + 8; int sy = mb_y * 16 + 8; int xy = (mb_x + mb_y * mv_stride) << mv_sample_log2; - int mx = (motion_val[direction][xy][0]>>shift) + sx; - int my = (motion_val[direction][xy][1]>>shift) + sy; - mbcount += add_mb(mvs + mbcount, mb_type, sx, sy, mx, my, direction); + int mx = motion_val[direction][xy][0]; + int my = motion_val[direction][xy][1]; + mbcount += add_mb(mvs + mbcount, mb_type, sx, sy, mx, my, scale, direction); } } } |