[tracker/coalesce] Fixes after Jürg's first quick review



commit b90c9d286dafdafae004c7496cf953997834b23f
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Sep 4 13:45:25 2009 +0200

    Fixes after Jürg's first quick review

 src/tracker-extract/tracker-exif.c         |  152 ++++++++--------------------
 src/tracker-extract/tracker-exif.h         |    2 +-
 src/tracker-extract/tracker-extract-jpeg.c |    4 +-
 src/tracker-extract/tracker-extract-tiff.c |   22 ++--
 4 files changed, 57 insertions(+), 123 deletions(-)
---
diff --git a/src/tracker-extract/tracker-exif.c b/src/tracker-extract/tracker-exif.c
index a7ba24f..e67aefa 100644
--- a/src/tracker-extract/tracker-exif.c
+++ b/src/tracker-extract/tracker-exif.c
@@ -325,28 +325,7 @@ tracker_read_exif (const unsigned char *buffer,
                    TrackerExifData     *data)
 {
 #ifdef HAVE_LIBEXIF
-	guint i;
 	ExifData *exif;
-	ExifTag p[20] = { EXIF_TAG_PIXEL_Y_DIMENSION, 
-	        /* 01 */  EXIF_TAG_PIXEL_X_DIMENSION,
-	        /* 02 */  EXIF_TAG_RELATED_IMAGE_WIDTH,
-	        /* 03 */  EXIF_TAG_DOCUMENT_NAME, 
-	        /* 04 */  EXIF_TAG_DATE_TIME,
-	        /* 05 */  EXIF_TAG_DATE_TIME_ORIGINAL, 
-	        /* 06 */  EXIF_TAG_ARTIST,
-	        /* 07 */  EXIF_TAG_USER_COMMENT, 
-	        /* 08 */  EXIF_TAG_IMAGE_DESCRIPTION,
-	        /* 09 */  EXIF_TAG_MAKE, 
-	        /* 10 */  EXIF_TAG_ORIENTATION,
-	        /* 11 */  EXIF_TAG_EXPOSURE_TIME,
-	        /* 12 */  EXIF_TAG_FNUMBER, 
-	        /* 13 */  EXIF_TAG_FLASH, 
-	        /* 14 */  EXIF_TAG_FOCAL_LENGTH, 
-	        /* 15 */  EXIF_TAG_ISO_SPEED_RATINGS,
-	        /* 16 */  EXIF_TAG_METERING_MODE,
-	        /* 17 */  EXIF_TAG_WHITE_BALANCE, 
-	        /* 18 */  EXIF_TAG_COPYRIGHT,
-		/* 19 */  EXIF_TAG_MODEL };
 
 	exif = exif_data_new();
 
@@ -356,94 +335,49 @@ tracker_read_exif (const unsigned char *buffer,
 
 	exif_data_load_data (exif, (unsigned char *) buffer, len);
 
-	for (i = 0 ; i < 20; i++) {
-		switch (p[i]) {
-			case EXIF_TAG_PIXEL_Y_DIMENSION:
-				if (!data->y_dimention)
-					data->y_dimention = get_value (exif, p[i]);
-				break;
-			case EXIF_TAG_PIXEL_X_DIMENSION:
-				if (!data->x_dimention)
-					data->x_dimention = get_value (exif, p[i]);
-				break;
-			case EXIF_TAG_RELATED_IMAGE_WIDTH:
-				if (!data->image_width)
-					data->image_width = get_value (exif, p[i]);
-				break;
-			case EXIF_TAG_DOCUMENT_NAME:
-				if (!data->document_name)
-					data->document_name = get_value (exif, p[i]);
-				break;
-			case EXIF_TAG_DATE_TIME:
-				if (!data->time) {
-					data->time = get_date (exif, p[1]);
-				}
-				break;
-			case EXIF_TAG_DATE_TIME_ORIGINAL:
-				if (!data->time_original)
-					data->time_original = get_date (exif, p[i]);
-				break;
-			case EXIF_TAG_ARTIST:
-				if (!data->artist)
-					data->artist = get_value (exif, p[i]);
-				break;
-			case EXIF_TAG_USER_COMMENT:
-				if (!data->user_comment)
-					data->user_comment = get_value (exif, p[i]);
-				break;
-			case EXIF_TAG_IMAGE_DESCRIPTION:
-				if (!data->description)
-					data->description = get_value (exif, p[i]);
-				break;
-			case EXIF_TAG_MAKE:
-				if (!data->make)
-					data->make = get_value (exif, p[i]);
-				break;
-			case EXIF_TAG_MODEL:
-				if (!data->model)
-					data->model = get_value (exif, p[i]);
-				break;
-			case EXIF_TAG_ORIENTATION:
-				if (!data->orientation)
-					data->orientation = get_orientation (exif, p[i]);
-				break;
-			case EXIF_TAG_EXPOSURE_TIME:
-				if (!data->exposure_time)
-					data->exposure_time = get_exposure_time (exif, p[i]);
-				break;
-			case EXIF_TAG_FNUMBER:
-				if (!data->fnumber)
-					data->fnumber = get_fnumber (exif, p[i]);
-				break;
-			case EXIF_TAG_FLASH:
-				if (!data->flash)
-					data->flash = get_flash (exif, p[i]);
-				break;
-			case EXIF_TAG_FOCAL_LENGTH:
-				if (!data->focal_length)
-					data->focal_length = get_focal_length (exif, p[i]);
-				break;
-			case EXIF_TAG_ISO_SPEED_RATINGS:
-				if (!data->iso_speed_ratings)
-					data->iso_speed_ratings = get_value (exif, p[i]);
-				break;
-			case EXIF_TAG_METERING_MODE:
-				if (!data->metering_mode)
-					data->metering_mode = get_metering_mode (exif, p[i]);
-				break;
-			case EXIF_TAG_WHITE_BALANCE:
-				if (!data->white_balance)
-					data->white_balance = get_white_balance (exif, p[i]);
-				break;
-			case EXIF_TAG_COPYRIGHT:
-				if (!data->copyright)
-					data->copyright = get_value (exif, p[i]);
-				break;
-			default:
-				break;
-		}
-	
-	}
+	/* Unused in the current only user of this code (JPeg extractor)
+	if (!data->y_dimension)
+		data->y_dimension = get_value (exif, EXIF_TAG_PIXEL_Y_DIMENSION);
+	if (!data->x_dimension)
+		data->x_dimension = get_value (exif, EXIF_TAG_PIXEL_X_DIMENSION);
+	if (!data->image_width)
+		data->image_width = get_value (exif, EXIF_TAG_RELATED_IMAGE_WIDTH);
+	*/
+
+	if (!data->document_name)
+		data->document_name = get_value (exif, EXIF_TAG_DOCUMENT_NAME);
+	if (!data->time)
+		data->time = get_date (exif, EXIF_TAG_DATE_TIME);
+	if (!data->time_original)
+		data->time_original = get_date (exif, EXIF_TAG_DATE_TIME_ORIGINAL);
+	if (!data->artist)
+		data->artist = get_value (exif, EXIF_TAG_ARTIST);
+	if (!data->user_comment)
+		data->user_comment = get_value (exif, EXIF_TAG_USER_COMMENT);
+	if (!data->description)
+		data->description = get_value (exif, EXIF_TAG_IMAGE_DESCRIPTION);
+	if (!data->make)
+		data->make = get_value (exif, EXIF_TAG_MAKE);
+	if (!data->model)
+		data->model = get_value (exif, EXIF_TAG_MODEL);
+	if (!data->orientation)
+		data->orientation = get_orientation (exif, EXIF_TAG_ORIENTATION);
+	if (!data->exposure_time)
+		data->exposure_time = get_exposure_time (exif, EXIF_TAG_EXPOSURE_TIME);
+	if (!data->fnumber)
+		data->fnumber = get_fnumber (exif, EXIF_TAG_FNUMBER);
+	if (!data->flash)
+		data->flash = get_flash (exif, EXIF_TAG_FLASH);
+	if (!data->focal_length)
+		data->focal_length = get_focal_length (exif, EXIF_TAG_FOCAL_LENGTH);
+	if (!data->iso_speed_ratings)
+		data->iso_speed_ratings = get_value (exif, EXIF_TAG_ISO_SPEED_RATINGS);
+	if (!data->metering_mode)
+		data->metering_mode = get_metering_mode (exif, EXIF_TAG_METERING_MODE);
+	if (!data->white_balance)
+		data->white_balance = get_white_balance (exif, EXIF_TAG_WHITE_BALANCE);
+	if (!data->copyright)
+		data->copyright = get_value (exif, EXIF_TAG_COPYRIGHT);
 
 	exif_data_free (exif);
 
diff --git a/src/tracker-extract/tracker-exif.h b/src/tracker-extract/tracker-exif.h
index ccedc31..934c2e9 100644
--- a/src/tracker-extract/tracker-exif.h
+++ b/src/tracker-extract/tracker-exif.h
@@ -25,7 +25,7 @@
 #include <glib.h>
 
 typedef struct {
-	gchar *y_dimention, *x_dimention, *image_width, *document_name, *time, *time_original,
+	gchar *y_dimension, *x_dimension, *image_width, *document_name, *time, *time_original,
 	      *artist, *user_comment, *description, *make, *model, *orientation,
 	      *exposure_time, *fnumber, *flash, *focal_length, *iso_speed_ratings,
 	      *metering_mode, *white_balance, *copyright;
diff --git a/src/tracker-extract/tracker-extract-jpeg.c b/src/tracker-extract/tracker-extract-jpeg.c
index cc36fa9..c94416e 100644
--- a/src/tracker-extract/tracker-extract-jpeg.c
+++ b/src/tracker-extract/tracker-extract-jpeg.c
@@ -328,12 +328,12 @@ extract_jpeg (const gchar *uri,
 		tracker_statement_list_insert_with_int (metadata, uri,
 						   NFO_PREFIX "width",
 						   cinfo.image_width);
-		g_free (exif_data.x_dimention);
+		g_free (exif_data.x_dimension);
 
 		tracker_statement_list_insert_with_int (metadata, uri,
 						   NFO_PREFIX "height",
 						    cinfo.image_height);
-		g_free (exif_data.y_dimention);
+		g_free (exif_data.y_dimension);
 
 		if (xmp_data.keywords) {
 			insert_keywords (metadata, uri, xmp_data.keywords);
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index 47c73ef..af0b195 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -66,7 +66,7 @@ typedef struct {
 	gchar *camera, *title, *orientation, *copyright, *white_balance, 
 	      *fnumber, *flash, *focal_length, *artist, 
 	      *exposure_time, *iso_speed_ratings, *date, *description,
-	      *metering_mode, *creator, *x_dimention, *y_dimention;
+	      *metering_mode, *creator, *x_dimension, *y_dimension;
 } TiffNeedsMergeData;
 
 typedef struct {
@@ -420,24 +420,24 @@ extract_tiff (const gchar *uri, TrackerSparqlBuilder *metadata)
 	                                        xmp_data.creator,
 	                                        iptc_data.credit);
 
-	merge_data.x_dimention =  tracker_coalesce (2, tiff_data.imagewidth,
-	                                            exif_data.x_dimention);
-	merge_data.y_dimention =  tracker_coalesce (2, tiff_data.imagelength,
-	                                            exif_data.y_dimention);
+	merge_data.x_dimension =  tracker_coalesce (2, tiff_data.imagewidth,
+	                                            exif_data.x_dimension);
+	merge_data.y_dimension =  tracker_coalesce (2, tiff_data.imagelength,
+	                                            exif_data.y_dimension);
 
 	if (exif_data.user_comment) {
 		tracker_statement_list_insert (metadata, uri, NIE_PREFIX "comment", exif_data.user_comment);
 		g_free (exif_data.user_comment);
 	}
 
-	if (merge_data.x_dimention) {
-		tracker_statement_list_insert (metadata, uri, NFO_PREFIX "width", merge_data.x_dimention);
-		g_free (merge_data.x_dimention);
+	if (merge_data.x_dimension) {
+		tracker_statement_list_insert (metadata, uri, NFO_PREFIX "width", merge_data.x_dimension);
+		g_free (merge_data.x_dimension);
 	}
 
-	if (merge_data.y_dimention) {
-		tracker_statement_list_insert (metadata, uri, NFO_PREFIX "height", merge_data.y_dimention);
-		g_free (merge_data.y_dimention);
+	if (merge_data.y_dimension) {
+		tracker_statement_list_insert (metadata, uri, NFO_PREFIX "height", merge_data.y_dimension);
+		g_free (merge_data.y_dimension);
 	}
 
 	if (xmp_data.keywords) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]