[Bf-blender-cvs] [855e377] blender-v2.72-release: Fix T4201: AVI Broken when width not multiple of 4

Campbell Barton noreply at git.blender.org
Wed Oct 15 13:07:54 CEST 2014


Commit: 855e377a5cdac92313cb3e735cd4ee3c2524ae04
Author: Campbell Barton
Date:   Mon Oct 6 16:35:11 2014 +0200
Branches: blender-v2.72-release
https://developer.blender.org/rB855e377a5cdac92313cb3e735cd4ee3c2524ae04

Fix T4201: AVI Broken when width not multiple of 4

===================================================================

M	source/blender/avi/intern/avi_rgb.c
M	source/blender/avi/intern/avi_rgb32.c

===================================================================

diff --git a/source/blender/avi/intern/avi_rgb.c b/source/blender/avi/intern/avi_rgb.c
index c6a78ec..632ecad 100644
--- a/source/blender/avi/intern/avi_rgb.c
+++ b/source/blender/avi/intern/avi_rgb.c
@@ -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);
diff --git a/source/blender/avi/intern/avi_rgb32.c b/source/blender/avi/intern/avi_rgb32.c
index 5c7a488..c9cbcb0 100644
--- a/source/blender/avi/intern/avi_rgb32.c
+++ b/source/blender/avi/intern/avi_rgb32.c
@@ -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);




More information about the Bf-blender-cvs mailing list