changeset 1906:dc0a62722612

store stereo flag in loader data
author Vladimir Nadvornik <nadvornik@suse.cz>
date Sun, 27 Mar 2011 12:52:09 +0200
parents 25f23890dabe
children b3238ae21c7a
files src/filefilter.c src/image_load_jpeg.c
diffstat 2 files changed, 21 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/filefilter.c	Sun Mar 27 12:02:30 2011 +0200
+++ b/src/filefilter.c	Sun Mar 27 12:52:09 2011 +0200
@@ -238,7 +238,11 @@
 	filter_add_if_missing("ico", "Icon file", ".ico;.cur", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
 	filter_add_if_missing("ras", "Raster", ".ras", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
 	filter_add_if_missing("svg", "Scalable Vector Graphics", ".svg", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
-
+	
+	/* special formats for stereo */
+	filter_add_if_missing("jps", "Stereo side-by-side jpeg", ".jps", FORMAT_CLASS_IMAGE, TRUE, FALSE, TRUE);
+	filter_add_if_missing("mpo", "Stereo multi-image jpeg", ".mpo", FORMAT_CLASS_IMAGE, FALSE, TRUE, TRUE);
+	
 	/* non-image files that might be desirable to show */
 	filter_add_if_missing("xmp", "XMP sidecar", ".xmp", FORMAT_CLASS_META, TRUE, FALSE, TRUE);
 	filter_add_if_missing("gqv", GQ_APPNAME " image collection", GQ_COLLECTION_EXT, FORMAT_CLASS_META, FALSE, FALSE, TRUE);
--- a/src/image_load_jpeg.c	Sun Mar 27 12:02:30 2011 +0200
+++ b/src/image_load_jpeg.c	Sun Mar 27 12:52:09 2011 +0200
@@ -21,6 +21,7 @@
 	guint requested_height;
 	
 	gboolean abort;
+	gboolean stereo;
 	
 };
 
@@ -191,11 +192,11 @@
 	struct error_handler_data jerr;
 //	stdio_src_ptr src;
 	MPOData *mpo = jpeg_get_mpo_data(buf, count);
-	gboolean stereo = (mpo && mpo->num_images > 1);
+	lj->stereo = (mpo && mpo->num_images > 1);
 
 	/* setup error handler */
 	cinfo.err = jpeg_std_error (&jerr.pub);
-	if (stereo) cinfo2.err = jpeg_std_error (&jerr.pub);
+	if (lj->stereo) cinfo2.err = jpeg_std_error (&jerr.pub);
 	jerr.pub.error_exit = fatal_error_handler;
         jerr.pub.output_message = output_message_handler;
 
@@ -208,7 +209,7 @@
 		 * We need to clean up the JPEG object, close the input file, and return.
 		*/
 		jpeg_destroy_decompress(&cinfo);
-		if (stereo) jpeg_destroy_decompress(&cinfo2);
+		if (lj->stereo) jpeg_destroy_decompress(&cinfo2);
 		return FALSE;
 		}
 	
@@ -219,9 +220,8 @@
 
 	jpeg_read_header(&cinfo, TRUE);
 	
-	if (stereo)
+	if (lj->stereo)
 		{
-		printf("decoding stereo");
 		jpeg_create_decompress(&cinfo2);
 		jpeg_mem_src(&cinfo2, (unsigned char *)buf + mpo->images[1].offset, mpo->images[1].length);
 		jpeg_read_header(&cinfo2, TRUE);
@@ -231,26 +231,26 @@
 			{
 			DEBUG_1("stereo data with different size");
 			jpeg_destroy_decompress(&cinfo2);
-			stereo = FALSE;
+			lj->stereo = FALSE;
 			}
 		}
 
 		    
 
-	lj->requested_width = stereo ? cinfo.image_width * 2: cinfo.image_width;
+	lj->requested_width = lj->stereo ? cinfo.image_width * 2: cinfo.image_width;
 	lj->requested_height = cinfo.image_height;
 	lj->size_cb(loader, lj->requested_width, lj->requested_height, lj->data);
 			
 	cinfo.scale_num = 1;
 	for (cinfo.scale_denom = 2; cinfo.scale_denom <= 8; cinfo.scale_denom *= 2) {
 		jpeg_calc_output_dimensions(&cinfo);
-		if (cinfo.output_width < (stereo ? lj->requested_width / 2 : lj->requested_width) || cinfo.output_height < lj->requested_height) {
+		if (cinfo.output_width < (lj->stereo ? lj->requested_width / 2 : lj->requested_width) || cinfo.output_height < lj->requested_height) {
 			cinfo.scale_denom /= 2;
 			break;
 		}
 	}
 	jpeg_calc_output_dimensions(&cinfo);
-	if (stereo)
+	if (lj->stereo)
 		{
 		cinfo2.scale_num = cinfo.scale_num;
 		cinfo2.scale_denom = cinfo.scale_denom;
@@ -262,7 +262,7 @@
 	jpeg_start_decompress(&cinfo);
 	
 
-	if (stereo)
+	if (lj->stereo)
 		{
 		if (cinfo.output_width != cinfo2.output_width ||
 		    cinfo.output_height != cinfo2.output_height ||
@@ -270,22 +270,22 @@
 			{
 			DEBUG_1("stereo data with different output size");
 			jpeg_destroy_decompress(&cinfo2);
-			stereo = FALSE;
+			lj->stereo = FALSE;
 			}
 		}
 	
 	
 	lj->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, 
 				     cinfo.out_color_components == 4 ? TRUE : FALSE, 
-				     8, stereo ? cinfo.output_width * 2: cinfo.output_width, cinfo.output_height);
+				     8, lj->stereo ? cinfo.output_width * 2: cinfo.output_width, cinfo.output_height);
 
 	if (!lj->pixbuf) 
 		{
 		jpeg_destroy_decompress (&cinfo);
-		if (stereo) jpeg_destroy_decompress (&cinfo2);
+		if (lj->stereo) jpeg_destroy_decompress (&cinfo2);
 		return 0;
 		}
-	if (stereo) g_object_set_data(G_OBJECT(lj->pixbuf), "stereo_data", GINT_TO_POINTER(STEREO_PIXBUF_CROSS));
+	if (lj->stereo) g_object_set_data(G_OBJECT(lj->pixbuf), "stereo_data", GINT_TO_POINTER(STEREO_PIXBUF_CROSS));
 	lj->area_prepared_cb(loader, lj->data);
 
 	rowstride = gdk_pixbuf_get_rowstride(lj->pixbuf);
@@ -298,7 +298,7 @@
 		guint scanline = cinfo.output_scanline;
 		image_loader_jpeg_read_scanline(&cinfo, &dptr, rowstride);
 		lj->area_updated_cb(loader, 0, scanline, cinfo.output_width, cinfo.rec_outbuf_height, lj->data);
-		if (stereo)
+		if (lj->stereo)
 			{
 			guint scanline = cinfo2.output_scanline;
 			image_loader_jpeg_read_scanline(&cinfo2, &dptr2, rowstride);
@@ -308,7 +308,7 @@
 
 	jpeg_finish_decompress(&cinfo);
 	jpeg_destroy_decompress(&cinfo);
-	if (stereo)
+	if (lj->stereo)
 		{
 		jpeg_finish_decompress(&cinfo);
 		jpeg_destroy_decompress(&cinfo);