From f4e4e2594ce945b8ff900d4713cf7adcfa2d41d2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 Aug 2013 18:02:21 +0000 Subject: 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. --- source/blender/avi/intern/avi_mjpeg.c | 47 ++--------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) (limited to 'source') diff --git a/source/blender/avi/intern/avi_mjpeg.c b/source/blender/avi/intern/avi_mjpeg.c index 91b8fa5a060..797bca0bd0b 100644 --- a/source/blender/avi/intern/avi_mjpeg.c +++ b/source/blender/avi/intern/avi_mjpeg.c @@ -294,56 +294,13 @@ static void deinterlace(int odd, unsigned char *to, unsigned char *from, int wid 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) -- cgit v1.2.3