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.
This commit is contained in:
wm4 2012-10-17 14:06:03 +02:00
parent 34d974032b
commit 0e72b0d5d3
1 changed files with 2 additions and 1 deletions

View File

@ -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;
}
}