summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-10-17 14:06:03 +0200
committerwm4 <wm4@nowhere>2012-10-24 21:56:33 +0200
commit0e72b0d5d3aeae5c4a04ca1baceda3ceb2d63ce3 (patch)
treeec26f985e187a2cd5fe63b08008f370a20f92fab /sub
parent34d974032b45131331794364fe408008c96d96e9 (diff)
downloadmpv-0e72b0d5d3aeae5c4a04ca1baceda3ceb2d63ce3.tar.bz2
mpv-0e72b0d5d3aeae5c4a04ca1baceda3ceb2d63ce3.tar.xz
draw_bmp: compensate for libswscale writing past image bounds
libswscale tends to overwrite the area between (w,y)-(0,y+1). It tries to process multiple pixels at once, and if the memory past the last x pixel is inside a SIMD operation, but still below the image stride, it overwrites that data with black. This happens with vo_x11 and 32 bit RGBA formats. The bug is visible as black bar right of the subtitle bounding box. Fix by giving libswscale more alignment. Then the "outside" pixels are inside, and are processed normally instead of overwritten with black. NOTE: we do not increase the alignment constant, because this is a separate issue from pointer alignment. libavutil's av_malloc() wouldn't actually satisfy the increased alignment either.
Diffstat (limited to 'sub')
-rw-r--r--sub/draw_bmp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sub/draw_bmp.c b/sub/draw_bmp.c
index 8612336dfa..fba3513ee4 100644
--- a/sub/draw_bmp.c
+++ b/sub/draw_bmp.c
@@ -393,7 +393,8 @@ static void get_swscale_requirements(int *sx, int *sy,
for (p = 0; p < img->num_planes; ++p) {
int bits = MP_IMAGE_BITS_PER_PIXEL_ON_PLANE(img, p);
- while (((*sx >> img->chroma_x_shift) * bits) % (SWS_MIN_BYTE_ALIGN * 8))
+ // the * 2 fixes problems with writing past the destination width
+ while (((*sx >> img->chroma_x_shift) * bits) % (SWS_MIN_BYTE_ALIGN * 8 * 2))
*sx *= 2;
}
}