[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58940] trunk/blender/source/blender/avi/ intern/avi_mjpeg.c: AVI JPEG: remove the restriction to write only sizes that are multiples of 16.

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Aug 5 20:02:21 CEST 2013


Revision: 58940
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58940
Author:   blendix
Date:     2013-08-05 18:02:21 +0000 (Mon, 05 Aug 2013)
Log Message:
-----------
AVI JPEG: remove the restriction to write only sizes that are multiples of 16.
Other encoders do not seem to have this restriction, and multiple video players
can play the files fine.

This also removes the same restriction for reading files, which actually caused
errors on some files with odd width/height.

Modified Paths:
--------------
    trunk/blender/source/blender/avi/intern/avi_mjpeg.c

Modified: trunk/blender/source/blender/avi/intern/avi_mjpeg.c
===================================================================
--- trunk/blender/source/blender/avi/intern/avi_mjpeg.c	2013-08-05 17:59:52 UTC (rev 58939)
+++ trunk/blender/source/blender/avi/intern/avi_mjpeg.c	2013-08-05 18:02:21 UTC (rev 58940)
@@ -294,56 +294,13 @@
 
 static int check_and_decode_jpeg(unsigned char *inbuf, unsigned char *outbuf, int width, int height, int bufsize)
 {
-	/* JPEG's are always multiples of 16, extra is cropped out AVI's */
-	if ((width & 0xF) || (height & 0xF)) {
-		int i, rrowstride, jrowstride;
-		int jwidth = PADUP(width, 16);
-		int jheight = PADUP(height, 16);
-		unsigned char *tmpbuf = MEM_mallocN(jwidth * jheight * 3, "avi.check_and_decode_jpeg");
-		int ret = Decode_JPEG(inbuf, tmpbuf, jwidth, jheight, bufsize);
-
-		/* crop the tmpbuf into the real buffer */
-		rrowstride = width * 3;
-		jrowstride = jwidth * 3;
-		for (i = 0; i < height; i++)
-			memcpy(&outbuf[i * rrowstride], &tmpbuf[i * jrowstride], rrowstride);
-		MEM_freeN(tmpbuf);
-		
-		return ret;
-	}
-	else {
-		return Decode_JPEG(inbuf, outbuf, width, height, bufsize);
-	}
+	return Decode_JPEG(inbuf, outbuf, width, height, bufsize);
 }
 
 static void check_and_compress_jpeg(int quality, unsigned char *outbuf, const unsigned char *inbuf,
                                     int width, int height, int bufsize)
 {
-	/* JPEG's are always multiples of 16, extra is ignored in AVI's */
-	if ((width & 0xF) || (height & 0xF)) {
-		int i, rrowstride, jrowstride;
-		int jwidth = PADUP(width, 16);
-		int jheight = PADUP(height, 16);
-		unsigned char *tmpbuf = MEM_mallocN(jwidth * jheight * 3, "avi.check_and_compress_jpeg");
-
-		/* resize the realbuf into the tmpbuf */
-		rrowstride = width * 3;
-		jrowstride = jwidth * 3;
-		for (i = 0; i < jheight; i++) {
-			if (i < height)
-				memcpy(&tmpbuf[i * jrowstride], &inbuf[i * rrowstride], rrowstride);
-			else
-				memset(&tmpbuf[i * jrowstride], 0, rrowstride);
-			memset(&tmpbuf[i * jrowstride + rrowstride], 0, jrowstride - rrowstride);
-		}
-
-		Compress_JPEG(quality, outbuf, tmpbuf, jwidth, jheight, bufsize);
-
-		MEM_freeN(tmpbuf);
-	}
-	else {
-		Compress_JPEG(quality, outbuf, inbuf, width, height, bufsize);
-	}
+	Compress_JPEG(quality, outbuf, inbuf, width, height, bufsize);
 }
 
 void *avi_converter_from_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, int *size)




More information about the Bf-blender-cvs mailing list