Mercurial > libavcodec.hg
comparison mpegvideo.c @ 3595:eb4a515197da libavcodec
SWAP
author | michael |
---|---|
date | Sat, 19 Aug 2006 20:55:02 +0000 |
parents | 19c437d6aba5 |
children | acf9ca729bd2 |
comparison
equal
deleted
inserted
replaced
3594:10c577c37617 | 3595:eb4a515197da |
---|---|
1685 * @param h height of the image | 1685 * @param h height of the image |
1686 * @param stride stride/linesize of the image | 1686 * @param stride stride/linesize of the image |
1687 * @param color color of the arrow | 1687 * @param color color of the arrow |
1688 */ | 1688 */ |
1689 static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){ | 1689 static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){ |
1690 int t, x, y, fr, f; | 1690 int x, y, fr, f; |
1691 | 1691 |
1692 sx= clip(sx, 0, w-1); | 1692 sx= clip(sx, 0, w-1); |
1693 sy= clip(sy, 0, h-1); | 1693 sy= clip(sy, 0, h-1); |
1694 ex= clip(ex, 0, w-1); | 1694 ex= clip(ex, 0, w-1); |
1695 ey= clip(ey, 0, h-1); | 1695 ey= clip(ey, 0, h-1); |
1696 | 1696 |
1697 buf[sy*stride + sx]+= color; | 1697 buf[sy*stride + sx]+= color; |
1698 | 1698 |
1699 if(ABS(ex - sx) > ABS(ey - sy)){ | 1699 if(ABS(ex - sx) > ABS(ey - sy)){ |
1700 if(sx > ex){ | 1700 if(sx > ex){ |
1701 t=sx; sx=ex; ex=t; | 1701 SWAP(int, sx, ex); |
1702 t=sy; sy=ey; ey=t; | 1702 SWAP(int, sy, ey); |
1703 } | 1703 } |
1704 buf+= sx + sy*stride; | 1704 buf+= sx + sy*stride; |
1705 ex-= sx; | 1705 ex-= sx; |
1706 f= ((ey-sy)<<16)/ex; | 1706 f= ((ey-sy)<<16)/ex; |
1707 for(x= 0; x <= ex; x++){ | 1707 for(x= 0; x <= ex; x++){ |
1710 buf[ y *stride + x]+= (color*(0x10000-fr))>>16; | 1710 buf[ y *stride + x]+= (color*(0x10000-fr))>>16; |
1711 buf[(y+1)*stride + x]+= (color* fr )>>16; | 1711 buf[(y+1)*stride + x]+= (color* fr )>>16; |
1712 } | 1712 } |
1713 }else{ | 1713 }else{ |
1714 if(sy > ey){ | 1714 if(sy > ey){ |
1715 t=sx; sx=ex; ex=t; | 1715 SWAP(int, sx, ex); |
1716 t=sy; sy=ey; ey=t; | 1716 SWAP(int, sy, ey); |
1717 } | 1717 } |
1718 buf+= sx + sy*stride; | 1718 buf+= sx + sy*stride; |
1719 ey-= sy; | 1719 ey-= sy; |
1720 if(ey) f= ((ex-sx)<<16)/ey; | 1720 if(ey) f= ((ex-sx)<<16)/ey; |
1721 else f= 0; | 1721 else f= 0; |