MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / draw_line

Function draw_line

libavcodec/mpegvideo.c:1105–1145  ·  view source on GitHub ↗

* draws an line from (ex, ey) -> (sx, sy). * @param w width of the image * @param h height of the image * @param stride stride/linesize of the image * @param color color of the arrow */

Source from the content-addressed store, hash-verified

1103 * @param color color of the arrow
1104 */
1105static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){
1106 int x, y, fr, f;
1107
1108 sx= av_clip(sx, 0, w-1);
1109 sy= av_clip(sy, 0, h-1);
1110 ex= av_clip(ex, 0, w-1);
1111 ey= av_clip(ey, 0, h-1);
1112
1113 buf[sy*stride + sx]+= color;
1114
1115 if(FFABS(ex - sx) > FFABS(ey - sy)){
1116 if(sx > ex){
1117 FFSWAP(int, sx, ex);
1118 FFSWAP(int, sy, ey);
1119 }
1120 buf+= sx + sy*stride;
1121 ex-= sx;
1122 f= ((ey-sy)<<16)/ex;
1123 for(x= 0; x <= ex; x++){
1124 y = (x*f)>>16;
1125 fr= (x*f)&0xFFFF;
1126 buf[ y *stride + x]+= (color*(0x10000-fr))>>16;
1127 buf[(y+1)*stride + x]+= (color* fr )>>16;
1128 }
1129 }else{
1130 if(sy > ey){
1131 FFSWAP(int, sx, ex);
1132 FFSWAP(int, sy, ey);
1133 }
1134 buf+= sx + sy*stride;
1135 ey-= sy;
1136 if(ey) f= ((ex-sx)<<16)/ey;
1137 else f= 0;
1138 for(y= 0; y <= ey; y++){
1139 x = (y*f)>>16;
1140 fr= (y*f)&0xFFFF;
1141 buf[y*stride + x ]+= (color*(0x10000-fr))>>16;
1142 buf[y*stride + x+1]+= (color* fr )>>16;
1143 }
1144 }
1145}
1146
1147/**
1148 * draws an arrow from (ex, ey) -> (sx, sy).

Callers 1

draw_arrowFunction · 0.85

Calls 1

av_clipFunction · 0.85

Tested by

no test coverage detected