Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-07-09 05:07:25 +0400
committerMichael Niedermayer <michaelni@gmx.at>2014-07-09 05:07:25 +0400
commitc8b2cf49966ff9801b53e915a6be608637445ab7 (patch)
tree1cab259ef8602caf98c11a52570710e7a94882f5
parent98eab9815961289b913ebd1b4230a661d190bc69 (diff)
avcodec/mpegvideo: flip motion vector visualization for backward motion vectors
Also support changing arrow head/tail shape Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/mpegvideo.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 6b9103da85..c173aac7c5 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -2036,10 +2036,15 @@ static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey,
* @param color color of the arrow
*/
static void draw_arrow(uint8_t *buf, int sx, int sy, int ex,
- int ey, int w, int h, int stride, int color)
+ int ey, int w, int h, int stride, int color, int tail, int direction)
{
int dx,dy;
+ if (direction) {
+ FFSWAP(int, sx, ex);
+ FFSWAP(int, sy, ey);
+ }
+
sx = av_clip(sx, -100, w + 100);
sy = av_clip(sy, -100, h + 100);
ex = av_clip(ex, -100, w + 100);
@@ -2057,6 +2062,11 @@ static void draw_arrow(uint8_t *buf, int sx, int sy, int ex,
rx = ROUNDED_DIV(rx * 3 << 4, length);
ry = ROUNDED_DIV(ry * 3 << 4, length);
+ if (tail) {
+ rx = -rx;
+ ry = -ry;
+ }
+
draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color);
draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color);
}
@@ -2210,7 +2220,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_
int mx = (motion_val[direction][xy][0] >> shift) + sx;
int my = (motion_val[direction][xy][1] >> shift) + sy;
draw_arrow(ptr, sx, sy, mx, my, width,
- height, pict->linesize[0], 100);
+ height, pict->linesize[0], 100, 0, direction);
}
} else if (IS_16X8(mbtype_table[mb_index])) {
int i;
@@ -2225,7 +2235,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_
my *= 2;
draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
- height, pict->linesize[0], 100);
+ height, pict->linesize[0], 100, 0, direction);
}
} else if (IS_8X16(mbtype_table[mb_index])) {
int i;
@@ -2240,7 +2250,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_
my *= 2;
draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
- height, pict->linesize[0], 100);
+ height, pict->linesize[0], 100, 0, direction);
}
} else {
int sx= mb_x * 16 + 8;
@@ -2248,7 +2258,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_
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;
- draw_arrow(ptr, sx, sy, mx, my, width, height, pict->linesize[0], 100);
+ draw_arrow(ptr, sx, sy, mx, my, width, height, pict->linesize[0], 100, 0, direction);
}
}
}