Fix T4201: AVI Broken when width not multiple of 4

This commit is contained in:
Campbell Barton 2014-10-06 16:35:11 +02:00 committed by Sergey Sharybin
parent a064f56f5d
commit 855e377a5c
2 changed files with 6 additions and 7 deletions

View File

@ -123,13 +123,12 @@ void *avi_converter_to_avi_rgb(AviMovie *movie, int stream, unsigned char *buffe
(void)stream; /* unused */
*size = movie->header->Height * movie->header->Width * 3;
if (movie->header->Width % 2) *size += movie->header->Height;
buf = MEM_mallocN(*size, "toavirgbbuf");
rowstride = movie->header->Width * 3;
if (movie->header->Width % 2) rowstride++;
/* AVI files has uncompressed lines 4-byte aligned */
rowstride = (rowstride + 3) & ~3;
*size = movie->header->Height * rowstride;
buf = MEM_mallocN(*size, "toavirgbbuf");
for (y = 0; y < movie->header->Height; y++) {
memcpy(&buf[y * rowstride], &buffer[((movie->header->Height - 1) - y) * movie->header->Width * 3], movie->header->Width * 3);

View File

@ -74,8 +74,8 @@ void *avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer,
(void)stream; /* unused */
buf = MEM_mallocN(movie->header->Height * movie->header->Width * 4, "torgb32buf");
*size = movie->header->Height * movie->header->Width * 4;
buf = MEM_mallocN(*size, "torgb32buf");
memset(buf, 255, *size);