[Bf-blender-cvs] [57d919c] blender-v2.76a-release: Cleanup: remove historic, blender-only jpeg io

Campbell Barton noreply at git.blender.org
Thu Oct 29 11:39:17 CET 2015


Commit: 57d919c1ec679ad0011ee0cf0c59c99cef93cb72
Author: Campbell Barton
Date:   Wed Oct 14 20:13:57 2015 +1100
Branches: blender-v2.76a-release
https://developer.blender.org/rB57d919c1ec679ad0011ee0cf0c59c99cef93cb72

Cleanup: remove historic, blender-only jpeg io

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

M	source/blender/imbuf/IMB_imbuf_types.h
M	source/blender/imbuf/intern/jpeg.c

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

diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index 08ce9c0..4de07bf 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -124,12 +124,6 @@ enum eImbTypes {
 
 #define RAWTGA	        1
 
-#define JPG_STD	        0
-#define JPG_VID	        1
-#define JPG_JST	        2
-#define JPG_MAX	        3
-#define JPG_MSK	        0x03
-
 #ifdef WITH_TIFF
 #define TIF_16BIT		(1 << 8 )
 #endif
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index ff2a976..77e20a4 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -54,12 +54,6 @@
 #include "IMB_colormanagement.h"
 #include "IMB_colormanagement_intern.h"
 
-// #define IS_jpg(x)       (x->ftype & JPG) // UNUSED
-#define IS_stdjpg(x)    ((x->foptions.flag & JPG_MSK) == JPG_STD)
-// #define IS_vidjpg(x)    ((x->foptions & JPG_MSK) == JPG_VID) // UNUSED
-#define IS_jstjpg(x)    ((x->foptions.flag & JPG_MSK) == JPG_JST)
-#define IS_maxjpg(x)    ((x->foptions.flag & JPG_MSK) == JPG_MAX)
-
 /* the types are from the jpeg lib */
 static void jpeg_error(j_common_ptr cinfo) ATTR_NORETURN;
 static void init_source(j_decompress_ptr cinfo);
@@ -70,20 +64,6 @@ static void memory_source(j_decompress_ptr cinfo, const unsigned char *buffer, s
 static boolean handle_app1(j_decompress_ptr cinfo);
 static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int flags);
 
-
-/*
- * In principle there are 4 jpeg formats.
- *
- * 1. jpeg - standard printing, u & v at quarter of resolution
- * 2. jvid - standard video, u & v half resolution, frame not interlaced
- *
- * type 3 is unsupported as of jul 05 2000 Frank.
- *
- * 3. jstr - as 2, but written in 2 separate fields
- *
- * 4. jmax - no scaling in the components
- */
-
 static int jpeg_default_quality;
 static int ibuf_foptions;
 
@@ -304,14 +284,6 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla
 
 		jpeg_start_decompress(cinfo);
 
-		if (ibuf_foptions == 0) {
-			ibuf_foptions = JPG_STD;
-			if (cinfo->max_v_samp_factor == 1) {
-				if (cinfo->max_h_samp_factor == 1) ibuf_foptions = JPG_MAX;
-				else ibuf_foptions = JPG_VID;
-			}
-		}
-
 		if (flags & IB_test) {
 			jpeg_abort_decompress(cinfo);
 			ibuf = IMB_allocImBuf(x, y, 8 * depth, 0);
@@ -640,124 +612,9 @@ static int save_stdjpeg(const char *name, struct ImBuf *ibuf)
 	return 1;
 }
 
-
-static int save_vidjpeg(const char *name, struct ImBuf *ibuf)
-{
-	FILE *outfile;
-	struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
-	struct my_error_mgr jerr;
-
-	if ((outfile = BLI_fopen(name, "wb")) == NULL) return 0;
-	jpeg_default_quality = 90;
-
-	cinfo->err = jpeg_std_error(&jerr.pub);
-	jerr.pub.error_exit = jpeg_error;
-
-	/* Establish the setjmp return context for jpeg_error to use. */
-	if (setjmp(jerr.setjmp_buffer)) {
-		/* If we get here, the JPEG code has signaled an error.
-		 * We need to clean up the JPEG object, close the input file, and return.
-		 */
-		jpeg_destroy_compress(cinfo);
-		fclose(outfile);
-		remove(name);
-		return 0;
-	}
-
-	init_jpeg(outfile, cinfo, ibuf);
-
-	/* adjust scaling factors */
-	if (cinfo->in_color_space == JCS_RGB) {
-		cinfo->comp_info[0].h_samp_factor = 2;
-		cinfo->comp_info[0].v_samp_factor = 1;
-	}
-
-	write_jpeg(cinfo, ibuf);
-
-	fclose(outfile);
-	jpeg_destroy_compress(cinfo);
-
-	return 1;
-}
-
-static int save_jstjpeg(const char *name, struct ImBuf *ibuf)
-{
-	char fieldname[1024];
-	struct ImBuf *tbuf;
-	int oldy, returnval;
-
-	tbuf = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 24, IB_rect);
-	tbuf->ftype = ibuf->ftype;
-	tbuf->foptions = ibuf->foptions;
-	tbuf->flags = ibuf->flags;
-	
-	oldy = ibuf->y;
-	ibuf->x *= 2;
-	ibuf->y /= 2;
-
-	IMB_rectcpy(tbuf, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
-	sprintf(fieldname, "%s.jf0", name);
-
-	returnval = save_vidjpeg(fieldname, tbuf);
-	if (returnval == 1) {
-		IMB_rectcpy(tbuf, ibuf, 0, 0, tbuf->x, 0, ibuf->x, ibuf->y);
-		sprintf(fieldname, "%s.jf1", name);
-		returnval = save_vidjpeg(fieldname, tbuf);
-	}
-
-	ibuf->y = oldy;
-	ibuf->x /= 2;
-	IMB_freeImBuf(tbuf);
-
-	return returnval;
-}
-
-static int save_maxjpeg(const char *name, struct ImBuf *ibuf)
-{
-	FILE *outfile;
-	struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
-	struct my_error_mgr jerr;
-
-	if ((outfile = BLI_fopen(name, "wb")) == NULL) return 0;
-	jpeg_default_quality = 100;
-
-	cinfo->err = jpeg_std_error(&jerr.pub);
-	jerr.pub.error_exit = jpeg_error;
-
-	/* Establish the setjmp return context for jpeg_error to use. */
-	if (setjmp(jerr.setjmp_buffer)) {
-		/* If we get here, the JPEG code has signaled an error.
-		 * We need to clean up the JPEG object, close the input file, and return.
-		 */
-		jpeg_destroy_compress(cinfo);
-		fclose(outfile);
-		remove(name);
-		return 0;
-	}
-
-	init_jpeg(outfile, cinfo, ibuf);
-
-	/* adjust scaling factors */
-	if (cinfo->in_color_space == JCS_RGB) {
-		cinfo->comp_info[0].h_samp_factor = 1;
-		cinfo->comp_info[0].v_samp_factor = 1;
-	}
-
-	write_jpeg(cinfo, ibuf);
-
-	fclose(outfile);
-	jpeg_destroy_compress(cinfo);
-
-	return 1;
-}
-
 int imb_savejpeg(struct ImBuf *ibuf, const char *name, int flags)
 {
 	
 	ibuf->flags = flags;
-	if (IS_stdjpg(ibuf)) return save_stdjpeg(name, ibuf);
-	if (IS_jstjpg(ibuf)) return save_jstjpeg(name, ibuf);
-	if (IS_maxjpg(ibuf)) return save_maxjpeg(name, ibuf);
-	return save_vidjpeg(name, ibuf);
+	return save_stdjpeg(name, ibuf);
 }
-




More information about the Bf-blender-cvs mailing list