aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-01-26 23:11:08 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-01-26 23:11:08 +0000
commit49c79e6c5a4eeb7b54d83e38ad525bfd676be81f (patch)
tree2c767c00700e61e9c3a1a714313b6a5afd689dd3 /libavcodec
parent2ba8f6b81780c9c360a9c008b6dd50ad347cfa8d (diff)
downloadffmpeg-49c79e6c5a4eeb7b54d83e38ad525bfd676be81f.tar.gz
drawing cute arrows instead of lame lines for motion vector visualization
Originally committed as revision 1512 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h263dec.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 1ac7366290..a5dadeec4a 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -377,6 +377,25 @@ static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h
}
}
+static void draw_arrow(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){
+ int dx= ex - sx;
+ int dy= ey - sy;
+
+ if(dx*dx + dy*dy > 3*3){
+ int rx= dx + dy;
+ int ry= -dx + dy;
+ int length= ff_sqrt((rx*rx + ry*ry)<<8);
+
+ //FIXME subpixel accuracy
+ rx= ROUNDED_DIV(rx*3<<4, length);
+ ry= ROUNDED_DIV(ry*3<<4, length);
+
+ 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);
+ }
+ draw_line(buf, sx, sy, ex, ey, w, h, stride, color);
+}
+
int ff_h263_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
UINT8 *buf, int buf_size)
@@ -703,7 +722,7 @@ retry:
int xy= 1 + mb_x*2 + (i&1) + (mb_y*2 + 1 + (i>>1))*(s->mb_width*2 + 2);
int mx= (s->motion_val[xy][0]>>shift) + sx;
int my= (s->motion_val[xy][1]>>shift) + sy;
- draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100);
+ draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100);
}
}else{
int sx= mb_x*16 + 8;
@@ -711,7 +730,7 @@ retry:
int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2);
int mx= (s->motion_val[xy][0]>>shift) + sx;
int my= (s->motion_val[xy][1]>>shift) + sy;
- draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100);
+ draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100);
}
s->mbskip_table[mb_index]=0;
}