Mercurial > libavcodec.hg
comparison h263dec.c @ 1035:9fbad5cf7e9e libavcodec
drawing cute arrows instead of lame lines for motion vector visualization
author | michaelni |
---|---|
date | Sun, 26 Jan 2003 23:11:08 +0000 |
parents | d6ba0641cc36 |
children | 75a659fae7e0 |
comparison
equal
deleted
inserted
replaced
1034:af7ba8d8b43a | 1035:9fbad5cf7e9e |
---|---|
375 buf[y*stride + x]+= color; | 375 buf[y*stride + x]+= color; |
376 } | 376 } |
377 } | 377 } |
378 } | 378 } |
379 | 379 |
380 static void draw_arrow(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){ | |
381 int dx= ex - sx; | |
382 int dy= ey - sy; | |
383 | |
384 if(dx*dx + dy*dy > 3*3){ | |
385 int rx= dx + dy; | |
386 int ry= -dx + dy; | |
387 int length= ff_sqrt((rx*rx + ry*ry)<<8); | |
388 | |
389 //FIXME subpixel accuracy | |
390 rx= ROUNDED_DIV(rx*3<<4, length); | |
391 ry= ROUNDED_DIV(ry*3<<4, length); | |
392 | |
393 draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color); | |
394 draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color); | |
395 } | |
396 draw_line(buf, sx, sy, ex, ey, w, h, stride, color); | |
397 } | |
398 | |
380 int ff_h263_decode_frame(AVCodecContext *avctx, | 399 int ff_h263_decode_frame(AVCodecContext *avctx, |
381 void *data, int *data_size, | 400 void *data, int *data_size, |
382 UINT8 *buf, int buf_size) | 401 UINT8 *buf, int buf_size) |
383 { | 402 { |
384 MpegEncContext *s = avctx->priv_data; | 403 MpegEncContext *s = avctx->priv_data; |
701 int sx= mb_x*16 + 4 + 8*(i&1); | 720 int sx= mb_x*16 + 4 + 8*(i&1); |
702 int sy= mb_y*16 + 4 + 8*(i>>1); | 721 int sy= mb_y*16 + 4 + 8*(i>>1); |
703 int xy= 1 + mb_x*2 + (i&1) + (mb_y*2 + 1 + (i>>1))*(s->mb_width*2 + 2); | 722 int xy= 1 + mb_x*2 + (i&1) + (mb_y*2 + 1 + (i>>1))*(s->mb_width*2 + 2); |
704 int mx= (s->motion_val[xy][0]>>shift) + sx; | 723 int mx= (s->motion_val[xy][0]>>shift) + sx; |
705 int my= (s->motion_val[xy][1]>>shift) + sy; | 724 int my= (s->motion_val[xy][1]>>shift) + sy; |
706 draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); | 725 draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); |
707 } | 726 } |
708 }else{ | 727 }else{ |
709 int sx= mb_x*16 + 8; | 728 int sx= mb_x*16 + 8; |
710 int sy= mb_y*16 + 8; | 729 int sy= mb_y*16 + 8; |
711 int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); | 730 int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); |
712 int mx= (s->motion_val[xy][0]>>shift) + sx; | 731 int mx= (s->motion_val[xy][0]>>shift) + sx; |
713 int my= (s->motion_val[xy][1]>>shift) + sy; | 732 int my= (s->motion_val[xy][1]>>shift) + sy; |
714 draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); | 733 draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); |
715 } | 734 } |
716 s->mbskip_table[mb_index]=0; | 735 s->mbskip_table[mb_index]=0; |
717 } | 736 } |
718 } | 737 } |
719 } | 738 } |