[tracker] Fixes GB#633118: Read comments embedded in GIF files
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] Fixes GB#633118: Read comments embedded in GIF files
- Date: Mon, 25 Oct 2010 16:54:13 +0000 (UTC)
commit 79d29a95e36ca57c618cffb39042455d8d6953f3
Author: Aleksander Morgado <aleksander lanedo com>
Date: Mon Oct 25 18:53:45 2010 +0200
Fixes GB#633118: Read comments embedded in GIF files
src/tracker-extract/tracker-extract-gif.c | 53 ++++++++++++++++++++++------
1 files changed, 41 insertions(+), 12 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gif.c b/src/tracker-extract/tracker-extract-gif.c
index 082ba6b..78a39fa 100644
--- a/src/tracker-extract/tracker-extract-gif.c
+++ b/src/tracker-extract/tracker-extract-gif.c
@@ -31,6 +31,7 @@
#include <libtracker-extract/tracker-extract.h>
#define XMP_MAGIC_TRAILER_LENGTH 256
+#define EXTENSION_RECORD_COMMENT_BLOCK_CODE 0xFE
typedef struct {
const gchar *title;
@@ -131,17 +132,17 @@ read_metadata (TrackerSparqlBuilder *preupdate,
extBlock.bytes = NULL;
extBlock.byteCount = 0;
- if ((status = DGifGetExtension(gifFile, &ExtCode, &ExtData)) != GIF_OK) {
+ if ((status = DGifGetExtension (gifFile, &ExtCode, &ExtData)) != GIF_OK) {
g_warning ("Problem getting the extension");
return;
}
#if defined(HAVE_EXEMPI)
if (ExtData && *ExtData &&
- strncmp(&ExtData[1],"XMP Data",8) == 0) {
+ strncmp (&ExtData[1],"XMP Data",8) == 0) {
while (ExtData != NULL && status == GIF_OK ) {
- if ((status = DGifGetExtensionNext(gifFile, &ExtData)) == GIF_OK) {
+ if ((status = DGifGetExtensionNext (gifFile, &ExtData)) == GIF_OK) {
if (ExtData != NULL) {
- if (ext_block_append(&extBlock, ExtData[0]+1, (char*)&(ExtData[0])) != GIF_OK) {
+ if (ext_block_append (&extBlock, ExtData[0]+1, (char *) &(ExtData[0])) != GIF_OK) {
g_warning ("Problem with extension data");
return;
}
@@ -154,10 +155,37 @@ read_metadata (TrackerSparqlBuilder *preupdate,
uri);
g_free (extBlock.bytes);
- } else {
-#else
- {
+ } else
#endif
+ /* See Section 24. Comment Extension. in the GIF format definition */
+ if (ExtCode == EXTENSION_RECORD_COMMENT_BLOCK_CODE &&
+ ExtData && *ExtData) {
+ guint block_count = 0;
+
+ /* Merge all blocks */
+ do {
+ block_count++;
+
+ g_debug ("Comment Extension block found (#%u, %u bytes)",
+ block_count,
+ ExtData[0]);
+ if (ext_block_append (&extBlock, ExtData[0], (char *) &(ExtData[1])) != GIF_OK) {
+ g_warning ("Problem with Comment extension data");
+ return;
+ }
+ } while (((status = DGifGetExtensionNext(gifFile, &ExtData)) == GIF_OK) &&
+ ExtData != NULL);
+
+ /* Add last NUL byte */
+ g_debug ("Comment Extension blocks found (%u) with %u bytes",
+ block_count,
+ extBlock.byteCount);
+ extBlock.bytes = g_realloc (extBlock.bytes, extBlock.byteCount + 1);
+ extBlock.bytes[extBlock.byteCount] = '\0';
+
+ /* Set commentt */
+ gd.comment = extBlock.bytes;
+ } else {
do {
status = DGifGetExtensionNext(gifFile, &ExtData);
} while ( status == GIF_OK && ExtData != NULL);
@@ -180,11 +208,6 @@ read_metadata (TrackerSparqlBuilder *preupdate,
md.date = tracker_coalesce_strip (2, xd->date, xd->time_original);
md.artist = tracker_coalesce_strip (2, xd->artist, xd->contributor);
- /* if (gd.comment) { */
- /* tracker_sparql_builder_predicate (metadata, "nie:comment"); */
- /* tracker_sparql_builder_object_unvalidated (metadata, md.comment); */
- /* } */
-
if (xd->license) {
tracker_sparql_builder_predicate (metadata, "nie:license");
tracker_sparql_builder_object_unvalidated (metadata, xd->license);
@@ -465,6 +488,12 @@ read_metadata (TrackerSparqlBuilder *preupdate,
g_free (gd.height);
}
+ if (gd.comment) {
+ tracker_sparql_builder_predicate (metadata, "nie:comment");
+ tracker_sparql_builder_object_unvalidated (metadata, gd.comment);
+ g_free (gd.comment);
+ }
+
tracker_xmp_free (xd);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]