Commit: 0e7d4a828afc65cf69132f5812bb736ad5e6c0b1
Author: Campbell Barton
Date:   Mon Oct 6 16:35:11 2014 +0200
Branches: master
https://developer.blender.org/rB0e7d4a828afc65cf69132f5812bb736ad5e6c0b1

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);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to