Mercurial > libavcodec.hg
comparison mpegvideo.c @ 1918:ea20f38b8d57 libavcodec
nicer looking arrows for the motion vector vissualization
author | michael |
---|---|
date | Sat, 03 Apr 2004 01:55:24 +0000 |
parents | f2d134308a70 |
children | e2501e6e7ff7 |
comparison
equal
deleted
inserted
replaced
1917:1c382d137275 | 1918:ea20f38b8d57 |
---|---|
813 avcodec_default_free_buffers(s->avctx); | 813 avcodec_default_free_buffers(s->avctx); |
814 s->context_initialized = 0; | 814 s->context_initialized = 0; |
815 s->last_picture_ptr= | 815 s->last_picture_ptr= |
816 s->next_picture_ptr= | 816 s->next_picture_ptr= |
817 s->current_picture_ptr= NULL; | 817 s->current_picture_ptr= NULL; |
818 | |
818 for(i=0; i<3; i++) | 819 for(i=0; i<3; i++) |
819 if (s->visualization_buffer[i]) | 820 av_freep(&s->visualization_buffer[i]); |
820 av_free(s->visualization_buffer[i]); | |
821 } | 821 } |
822 | 822 |
823 #ifdef CONFIG_ENCODERS | 823 #ifdef CONFIG_ENCODERS |
824 | 824 |
825 /* init video encoder */ | 825 /* init video encoder */ |
1484 * @param h height of the image | 1484 * @param h height of the image |
1485 * @param stride stride/linesize of the image | 1485 * @param stride stride/linesize of the image |
1486 * @param color color of the arrow | 1486 * @param color color of the arrow |
1487 */ | 1487 */ |
1488 static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){ | 1488 static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){ |
1489 int t, x, y, f; | 1489 int t, x, y, fr, f; |
1490 | 1490 |
1491 sx= clip(sx, 0, w-1); | 1491 sx= clip(sx, 0, w-1); |
1492 sy= clip(sy, 0, h-1); | 1492 sy= clip(sy, 0, h-1); |
1493 ex= clip(ex, 0, w-1); | 1493 ex= clip(ex, 0, w-1); |
1494 ey= clip(ey, 0, h-1); | 1494 ey= clip(ey, 0, h-1); |
1502 } | 1502 } |
1503 buf+= sx + sy*stride; | 1503 buf+= sx + sy*stride; |
1504 ex-= sx; | 1504 ex-= sx; |
1505 f= ((ey-sy)<<16)/ex; | 1505 f= ((ey-sy)<<16)/ex; |
1506 for(x= 0; x <= ex; x++){ | 1506 for(x= 0; x <= ex; x++){ |
1507 y= ((x*f) + (1<<15))>>16; | 1507 y = (x*f)>>16; |
1508 buf[y*stride + x]+= color; | 1508 fr= (x*f)&0xFFFF; |
1509 buf[ y *stride + x]+= (color*(0x10000-fr))>>16; | |
1510 buf[(y+1)*stride + x]+= (color* fr )>>16; | |
1509 } | 1511 } |
1510 }else{ | 1512 }else{ |
1511 if(sy > ey){ | 1513 if(sy > ey){ |
1512 t=sx; sx=ex; ex=t; | 1514 t=sx; sx=ex; ex=t; |
1513 t=sy; sy=ey; ey=t; | 1515 t=sy; sy=ey; ey=t; |
1515 buf+= sx + sy*stride; | 1517 buf+= sx + sy*stride; |
1516 ey-= sy; | 1518 ey-= sy; |
1517 if(ey) f= ((ex-sx)<<16)/ey; | 1519 if(ey) f= ((ex-sx)<<16)/ey; |
1518 else f= 0; | 1520 else f= 0; |
1519 for(y= 0; y <= ey; y++){ | 1521 for(y= 0; y <= ey; y++){ |
1520 x= ((y*f) + (1<<15))>>16; | 1522 x = (y*f)>>16; |
1521 buf[y*stride + x]+= color; | 1523 fr= (y*f)&0xFFFF; |
1524 buf[y*stride + x ]+= (color*(0x10000-fr))>>16;; | |
1525 buf[y*stride + x+1]+= (color* fr )>>16;; | |
1522 } | 1526 } |
1523 } | 1527 } |
1524 } | 1528 } |
1525 | 1529 |
1526 /** | 1530 /** |