gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r9803 - Extractor/src/plugins


From: gnunet
Subject: [GNUnet-SVN] r9803 - Extractor/src/plugins
Date: Fri, 18 Dec 2009 22:52:30 +0100

Author: grothoff
Date: 2009-12-18 22:52:30 +0100 (Fri, 18 Dec 2009)
New Revision: 9803

Added:
   Extractor/src/plugins/riff_extractor.c
Removed:
   Extractor/src/plugins/riffextractor.c
Modified:
   Extractor/src/plugins/Makefile.am
Log:
riff

Modified: Extractor/src/plugins/Makefile.am
===================================================================
--- Extractor/src/plugins/Makefile.am   2009-12-18 21:45:18 UTC (rev 9802)
+++ Extractor/src/plugins/Makefile.am   2009-12-18 21:52:30 UTC (rev 9803)
@@ -91,6 +91,7 @@
   libextractor_ps.la \
   libextractor_qt.la \
   libextractor_real.la \
+  libextractor_riff.la \
   $(rpm) \
   libextractor_tar.la \
   $(thumbgtk) \
@@ -263,6 +264,14 @@
 libextractor_real_la_LDFLAGS = \
   $(PLUGINFLAGS)
 
+libextractor_riff_la_SOURCES = \
+  riff_extractor.c 
+libextractor_riff_la_LDFLAGS = \
+  $(PLUGINFLAGS)
+libextractor_riff_la_LIBADD = \
+  $(LE_LIBINTL) \
+  -lm 
+
 libextractor_rpm_la_SOURCES = \
   rpm_extractor.c 
 libextractor_rpm_la_LDFLAGS = \
@@ -319,7 +328,6 @@
   $(extrampeg) \
   libextractor_nsf.la \
   libextractor_nsfe.la \
-  libextractor_riff.la \
   libextractor_s3m.la \
   libextractor_sid.la \
   libextractor_tar.la \
@@ -350,15 +358,6 @@
   $(top_builddir)/src/common/libextractor_common.la
 
 
-libextractor_riff_la_SOURCES = \
-  riffextractor.c 
-libextractor_riff_la_LDFLAGS = \
-  $(PLUGINFLAGS)
-libextractor_riff_la_LIBADD = \
-  $(top_builddir)/src/main/libextractor.la \
-  $(LE_LIBINTL) \
-  -lm 
-
 libextractor_sid_la_SOURCES = \
   sidextractor.c 
 libextractor_sid_la_LDFLAGS = \

Copied: Extractor/src/plugins/riff_extractor.c (from rev 9791, 
Extractor/src/plugins/riffextractor.c)
===================================================================
--- Extractor/src/plugins/riff_extractor.c                              (rev 0)
+++ Extractor/src/plugins/riff_extractor.c      2009-12-18 21:52:30 UTC (rev 
9803)
@@ -0,0 +1,123 @@
+/*
+     This file is part of libextractor.
+     (C) 2004, 2009 Vidyut Samanta and Christian Grothoff
+
+     libextractor is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     libextractor is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with libextractor; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+
+     This code was based on AVInfo 1.0 alpha 11
+     (c) George Shuklin, gs]AT[shounen.ru, 2002-2004
+     http://shounen.ru/soft/avinfo/
+
+     and bitcollider 0.6.0
+     (PD) 2004 The Bitzi Corporation
+     http://bitzi.com/
+ */
+
+#include "platform.h"
+#include "extractor.h"
+#include <math.h>
+
+/**
+ * Read the specified number of bytes as a little-endian (least
+ * significant byte first) integer.
+ */
+static unsigned int
+fread_le (const char *data)
+{
+  int x;
+  unsigned int result = 0;
+
+  for (x = 0; x < 4; x++)
+    result |= ((unsigned char) data[x]) << (x * 8);
+  return result;
+}
+
+/* We implement our own rounding function, because the availability of
+ * C99's round(), nearbyint(), rint(), etc. seems to be spotty, whereas
+ * floor() is available in math.h on all C compilers.
+ */
+static double
+round_double (double num)
+{
+  return floor (num + 0.5);
+}
+
+#define ADD(s,t) do { if (0 != (ret = proc (proc_cls, "riff", t, 
EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1))) goto FINISH; } while 
(0)
+
+/* video/x-msvideo */
+int 
+EXTRACTOR_riff_extract (const char *xdata,
+                       size_t xsize,
+                       EXTRACTOR_MetaDataProcessor proc,
+                       void *proc_cls,
+                       const char *options)
+{
+  unsigned int blockLen;
+  unsigned int fps;
+  unsigned int duration;
+  size_t pos;
+  unsigned int width;
+  unsigned int height;
+  char codec[5];
+  char format[256];
+  int ret;
+
+  if (xsize < 32)
+    return 0;
+  if ((memcmp (&xdata[0],
+               "RIFF", 4) != 0) || (memcmp (&xdata[8], "AVI ", 4) != 0))
+    return 0;
+  if (memcmp (&xdata[12], "LIST", 4) != 0)
+    return 0;
+  if (memcmp (&xdata[20], "hdrlavih", 8) != 0)
+    return 0;
+
+  blockLen = fread_le (&xdata[28]);
+
+  /* begin of AVI header at 32 */
+  fps = (unsigned int) round_double ((double) 1.0e6 / fread_le (&xdata[32]));
+  duration = (unsigned int) round_double ((double) fread_le (&xdata[48])
+                                          * 1000 / fps);
+  width = fread_le (&xdata[64]);
+  height = fread_le (&xdata[68]);
+  /* pos: begin of video stream header */
+  pos = blockLen + 32;
+
+  if ((pos < blockLen) || (pos + 32 > xsize) || (pos > xsize))
+    return 0;
+  if (memcmp (&xdata[pos], "LIST", 4) != 0)
+    return 0;
+  blockLen = fread_le (&xdata[pos + 4]);
+  if (memcmp (&xdata[pos + 8], "strlstrh", 8) != 0)
+    return 0;
+  if (memcmp (&xdata[pos + 20], "vids", 4) != 0)
+    return 0;
+  ret = 0;
+  /* pos + 24: video stream header */
+  memcpy (codec, &xdata[pos + 24], 4);
+  codec[4] = '\0';
+  snprintf (format,
+           sizeof(format),
+           _("codec: %s, %u fps, %u ms"), codec, fps, duration);
+  ADD (format, EXTRACTOR_METATYPE_FORMAT);
+  snprintf (format, 
+           sizeof(format), 
+           "%ux%u", width, height);
+  ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS);
+  ADD ("video/x-msvideo", EXTRACTOR_METATYPE_MIMETYPE);
+ FINISH:
+  return ret;
+}

Deleted: Extractor/src/plugins/riffextractor.c
===================================================================
--- Extractor/src/plugins/riffextractor.c       2009-12-18 21:45:18 UTC (rev 
9802)
+++ Extractor/src/plugins/riffextractor.c       2009-12-18 21:52:30 UTC (rev 
9803)
@@ -1,158 +0,0 @@
-/*
-     This file is part of libextractor.
-     (C) 2004 Vidyut Samanta and Christian Grothoff
-
-     libextractor is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
-     option) any later version.
-
-     libextractor is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with libextractor; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-
-     This code was based on AVInfo 1.0 alpha 11
-     (c) George Shuklin, gs]AT[shounen.ru, 2002-2004
-     http://shounen.ru/soft/avinfo/
-
-     and bitcollider 0.6.0
-     (PD) 2004 The Bitzi Corporation
-     http://bitzi.com/
- */
-
-#include "platform.h"
-#include "extractor.h"
-#include <math.h>
-
-static void
-addKeyword (struct EXTRACTOR_Keywords **list,
-            char *keyword, EXTRACTOR_KeywordType type)
-{
-  EXTRACTOR_KeywordList *next;
-  next = malloc (sizeof (EXTRACTOR_KeywordList));
-  next->next = *list;
-  next->keyword = keyword;
-  next->keywordType = type;
-  *list = next;
-}
-
-
-#ifdef FIXME
-static struct EXTRACTOR_Keywords *
-riffparse_INFO (char *buffer, size_t size, struct EXTRACTOR_Keywords *prev)
-{
-  size_t c = 0;
-  char *word;
-
-  if (size < 64)
-    return prev;
-  c = 8;
-  while ((c < size) && isprint (buffer[c]))
-    c++;
-  if (c > 8)
-    {
-      word = malloc (c + 1 - 8);
-      memcpy (word, &buffer[8], c - 8);
-      word[c - 8] = '\0';
-      addKeyword (&prev, word, EXTRACTOR_UNKNOWN);      /* eh, what exactly is 
it */
-    }
-  return prev;
-}
-#endif
-
-
-/**
- * Read the specified number of bytes as a little-endian (least
- * significant byte first) integer.
- */
-static unsigned int
-fread_le (char *data)
-{
-  int x;
-  unsigned int result = 0;
-
-  for (x = 0; x < 4; x++)
-    result |= ((unsigned char) data[x]) << (x * 8);
-  return result;
-}
-
-/* We implement our own rounding function, because the availability of
- * C99's round(), nearbyint(), rint(), etc. seems to be spotty, whereas
- * floor() is available in math.h on all C compilers.
- */
-static double
-round_double (double num)
-{
-  return floor (num + 0.5);
-}
-
-/* video/x-msvideo */
-struct EXTRACTOR_Keywords *
-libextractor_riff_extract (char *filename,
-                           char *xdata,
-                           size_t xsize, struct EXTRACTOR_Keywords *prev)
-{
-  unsigned int blockLen;
-  unsigned int fps;
-  unsigned int duration;
-  size_t pos;
-  unsigned int width;
-  unsigned int height;
-  char codec[5];
-  char *format;
-
-  if (xsize < 32)
-    return prev;
-
-  if ((memcmp (&xdata[0],
-               "RIFF", 4) != 0) || (memcmp (&xdata[8], "AVI ", 4) != 0))
-    return prev;
-
-  if (memcmp (&xdata[12], "LIST", 4) != 0)
-    return prev;
-  if (memcmp (&xdata[20], "hdrlavih", 8) != 0)
-    return prev;
-
-
-  blockLen = fread_le (&xdata[28]);
-
-  /* begin of AVI header at 32 */
-  fps = (unsigned int) round_double ((double) 1.0e6 / fread_le (&xdata[32]));
-  duration = (unsigned int) round_double ((double) fread_le (&xdata[48])
-                                          * 1000 / fps);
-  width = fread_le (&xdata[64]);
-  height = fread_le (&xdata[68]);
-
-
-  /* pos: begin of video stream header */
-  pos = blockLen + 32;
-
-  if ((pos < blockLen) || (pos + 32 > xsize) || (pos > xsize))
-    return prev;
-
-  if (memcmp (&xdata[pos], "LIST", 4) != 0)
-    return prev;
-  blockLen = fread_le (&xdata[pos + 4]);
-  if (memcmp (&xdata[pos + 8], "strlstrh", 8) != 0)
-    return prev;
-  if (memcmp (&xdata[pos + 20], "vids", 4) != 0)
-    return prev;
-  /* pos + 24: video stream header */
-  memcpy (codec, &xdata[pos + 24], 4);
-  codec[4] = '\0';
-
-  format = malloc (256);
-  snprintf (format, 256, _("codec: %s, %u fps, %u ms"), codec, fps, duration);
-  addKeyword (&prev, format, EXTRACTOR_FORMAT);
-  format = malloc (256);
-  snprintf (format, 256, "%ux%u", width, height);
-  addKeyword (&prev, format, EXTRACTOR_SIZE);
-  addKeyword (&prev, strdup ("video/x-msvideo"), EXTRACTOR_MIMETYPE);
-  return prev;
-}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]