Skip to content

Commit cc3b05e

Browse files
committed
avfilter/vf_codecview: Fix undefined left shifts of negative numbers
Affected the filter-codecview-mvs FATE-test. Signed-off-by: Andreas Rheinhardt <[email protected]> (cherry picked from commit 3c151e7)
1 parent 195cce4 commit cc3b05e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libavfilter/vf_codecview.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey,
141141
}
142142
buf += sx + sy * stride;
143143
ex -= sx;
144-
f = ((ey - sy) << 16) / ex;
144+
f = ((ey - sy) * (1 << 16)) / ex;
145145
for (x = 0; x <= ex; x++) {
146146
y = (x * f) >> 16;
147147
fr = (x * f) & 0xFFFF;
@@ -156,7 +156,7 @@ static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey,
156156
buf += sx + sy * stride;
157157
ey -= sy;
158158
if (ey)
159-
f = ((ex - sx) << 16) / ey;
159+
f = ((ex - sx) * (1 << 16)) / ey;
160160
else
161161
f = 0;
162162
for(y= 0; y <= ey; y++){
@@ -199,8 +199,8 @@ static void draw_arrow(uint8_t *buf, int sx, int sy, int ex,
199199
int length = sqrt((rx * rx + ry * ry) << 8);
200200

201201
// FIXME subpixel accuracy
202-
rx = ROUNDED_DIV(rx * 3 << 4, length);
203-
ry = ROUNDED_DIV(ry * 3 << 4, length);
202+
rx = ROUNDED_DIV(rx * (3 << 4), length);
203+
ry = ROUNDED_DIV(ry * (3 << 4), length);
204204

205205
if (tail) {
206206
rx = -rx;

0 commit comments

Comments
 (0)