gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r9795 - in Extractor/src: include main plugins


From: gnunet
Subject: [GNUnet-SVN] r9795 - in Extractor/src: include main plugins
Date: Fri, 18 Dec 2009 19:04:55 +0100

Author: grothoff
Date: 2009-12-18 19:04:55 +0100 (Fri, 18 Dec 2009)
New Revision: 9795

Added:
   Extractor/src/plugins/mpeg_extractor.c
Removed:
   Extractor/src/plugins/mpegextractor.c
Modified:
   Extractor/src/include/extractor.h
   Extractor/src/main/extractor_metatypes.c
   Extractor/src/plugins/Makefile.am
Log:
mpeg

Modified: Extractor/src/include/extractor.h
===================================================================
--- Extractor/src/include/extractor.h   2009-12-18 17:42:53 UTC (rev 9794)
+++ Extractor/src/include/extractor.h   2009-12-18 18:04:55 UTC (rev 9795)
@@ -271,8 +271,8 @@
     EXTRACTOR_METATYPE_CONTRIBUTOR_PICTURE = 139,
     EXTRACTOR_METATYPE_EVENT_PICTURE = 140,
     EXTRACTOR_METATYPE_LOGO = 141,
+    EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM = 142,
 
-    EXTRACTOR_METATYPE_PLAY_COUNTER = 118,
     EXTRACTOR_METATYPE_LYRICS = 67,
     EXTRACTOR_METATYPE_CONDUCTOR = 64,
     EXTRACTOR_METATYPE_INTERPRET = 65,

Modified: Extractor/src/main/extractor_metatypes.c
===================================================================
--- Extractor/src/main/extractor_metatypes.c    2009-12-18 17:42:53 UTC (rev 
9794)
+++ Extractor/src/main/extractor_metatypes.c    2009-12-18 18:04:55 UTC (rev 
9795)
@@ -349,14 +349,14 @@
     gettext_noop ("picture of an associated event") }, 
   { gettext_noop ("logo"),
     gettext_noop ("logo of an associated organization") }, 
+  { gettext_noop ("broadcast television system"),
+    gettext_noop ("name of the television system for which the data is coded") 
}, 
   { gettext_noop (""),
     gettext_noop ("") }, 
   { gettext_noop (""),
     gettext_noop ("") }, 
   { gettext_noop (""),
     gettext_noop ("") }, 
-  { gettext_noop (""),
-    gettext_noop ("") }, 
 #if 0
   
   gettext_noop("author"),

Modified: Extractor/src/plugins/Makefile.am
===================================================================
--- Extractor/src/plugins/Makefile.am   2009-12-18 17:42:53 UTC (rev 9794)
+++ Extractor/src/plugins/Makefile.am   2009-12-18 18:04:55 UTC (rev 9795)
@@ -82,6 +82,7 @@
   libextractor_man.la \
   libextractor_mime.la \
   libextractor_mp3.la \
+  $(mpeg) \
   libextractor_odf.la \
   $(ogg) \
   $(ole2) \
@@ -191,6 +192,13 @@
   $(top_builddir)/src/common/libextractor_common.la \
   $(LE_LIBINTL)
 
+libextractor_mpeg_la_SOURCES = \
+  mpeg_extractor.c 
+libextractor_mpeg_la_LDFLAGS = \
+  $(PLUGINFLAGS)
+libextractor_mpeg_la_LIBADD = \
+  -lmpeg2
+
 libextractor_odf_la_SOURCES = \
   odf_extractor.c
 libextractor_odf_la_LDFLAGS = \
@@ -338,14 +346,6 @@
 libextractor_zip_la_LIBADD = \
   $(top_builddir)/src/main/libextractor.la
 
-libextractor_mpeg_la_SOURCES = \
-  mpegextractor.c 
-libextractor_mpeg_la_LDFLAGS = \
-  $(PLUGINFLAGS)
-libextractor_mpeg_la_LIBADD = \
-  -lmpeg2 \
-  $(top_builddir)/src/main/libextractor.la
-
 libextractor_riff_la_SOURCES = \
   riffextractor.c 
 libextractor_riff_la_LDFLAGS = \

Copied: Extractor/src/plugins/mpeg_extractor.c (from rev 9791, 
Extractor/src/plugins/mpegextractor.c)
===================================================================
--- Extractor/src/plugins/mpeg_extractor.c                              (rev 0)
+++ Extractor/src/plugins/mpeg_extractor.c      2009-12-18 18:04:55 UTC (rev 
9795)
@@ -0,0 +1,116 @@
+
+/*
+     This file is part of libextractor.
+     (C) 2004, 2005, 2006, 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.
+ */
+
+#include "platform.h"
+#include "extractor.h"
+#include <mpeg2dec/mpeg2.h>
+
+#define ADD(s,t) do { if (0 != (ret = proc (proc_cls, "mpeg", t, 
EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1))) goto EXIT; } while 
(0)
+
+
+/* video/mpeg */
+int 
+EXTRACTOR_wav_extract (const unsigned char *data,
+                      size_t size,
+                      EXTRACTOR_MetaDataProcessor proc,
+                      void *proc_cls,
+                      const char *options)
+{
+  mpeg2dec_t *handle;
+  uint8_t *start;
+  uint8_t *end;
+  const mpeg2_info_t *info;
+  mpeg2_state_t state;
+  int ret;
+  char format[256];
+
+  if ((size < 4) ||
+      (!((data[0] == 0x00) &&
+         (data[1] == 0x00) &&
+         (data[2] == 0x01) && ((data[3] == 0xB3) || (data[3] == 0xBA)))))
+    return 0;
+
+  handle = mpeg2_init ();
+  if (handle == NULL)
+    return 0;
+  start = (uint8_t *) data;
+  end = (uint8_t *) & data[size];
+  mpeg2_buffer (handle, start, end);
+  state = mpeg2_parse (handle);
+  if (state != STATE_SEQUENCE)
+    {
+      mpeg2_close (handle);
+      return 0;
+    }
+  info = mpeg2_info (handle);
+  if (info == NULL)
+    {
+      mpeg2_close (handle);
+      return 0;
+    }
+  ret = 0;
+  ADD ("video/mpeg", EXTRACTOR_METATYPE_MIMETYPE);
+  if (info->sequence != NULL)
+    {
+      snprintf (format, 
+               sizeof(format), "%ux%u",
+                info->sequence->width, info->sequence->height);
+      ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS);
+      switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED)
+        {
+        case SEQ_VIDEO_FORMAT_PAL:
+          ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+          break;
+        case SEQ_VIDEO_FORMAT_NTSC:
+          ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+          break;
+        case SEQ_VIDEO_FORMAT_SECAM:
+          ADD ("SECAM", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+          break;
+        case SEQ_VIDEO_FORMAT_MAC:
+          ADD ("MAC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+          break;
+        default:
+          break;
+        }
+      if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0)
+        ADD ("MPEG2", EXTRACTOR_METATYPE_FORMAT_VERSION);
+      else
+        ADD ("MPEG1", EXTRACTOR_METATYPE_FORMAT_VERSION);
+    }
+  if (info->gop != NULL)
+    {
+      /* this usually does not work yet, since gop's are not
+         often at the beginning of the stream (and we
+         don't iterate over the stream hoping to find one).
+         Hence we usually don't get the size.  Not sure how
+         to *efficiently* get the gop (without scanning
+         through the entire file) */
+      snprintf (format, 
+               sizeof(format), "%u:%u:%u (%u frames)",
+                info->gop->hours,
+                info->gop->minutes, info->gop->seconds, info->gop->pictures);
+      ADD (format, EXTRACTOR_METATYPE_DURATION);
+    }
+ EXIT:
+  mpeg2_close (handle);
+  return ret;
+}

Deleted: Extractor/src/plugins/mpegextractor.c
===================================================================
--- Extractor/src/plugins/mpegextractor.c       2009-12-18 17:42:53 UTC (rev 
9794)
+++ Extractor/src/plugins/mpegextractor.c       2009-12-18 18:04:55 UTC (rev 
9795)
@@ -1,118 +0,0 @@
-
-/*
-     This file is part of libextractor.
-     (C) 2004, 2005, 2006 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.
- */
-
-#include "platform.h"
-#include "extractor.h"
-#include <mpeg2dec/mpeg2.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 = strdup (keyword);
-  next->keywordType = type;
-  *list = next;
-}
-
-/* video/mpeg */
-struct EXTRACTOR_Keywords *
-libextractor_mpeg_extract (const char *filename,
-                           const unsigned char *data,
-                           size_t size, struct EXTRACTOR_Keywords *prev)
-{
-  mpeg2dec_t *handle;
-  uint8_t *start;
-  uint8_t *end;
-  const mpeg2_info_t *info;
-  mpeg2_state_t state;
-  char format[256];
-
-  if ((size < 4) ||
-      (!((data[0] == 0x00) &&
-         (data[1] == 0x00) &&
-         (data[2] == 0x01) && ((data[3] == 0xB3) || (data[3] == 0xBA)))))
-    return prev;
-
-  handle = mpeg2_init ();
-  if (handle == NULL)
-    return prev;
-  start = (uint8_t *) data;
-  end = (uint8_t *) & data[size];
-  mpeg2_buffer (handle, start, end);
-  state = mpeg2_parse (handle);
-  if (state != STATE_SEQUENCE)
-    {
-      mpeg2_close (handle);
-      return prev;
-    }
-  info = mpeg2_info (handle);
-  if (info == NULL)
-    {
-      mpeg2_close (handle);
-      return prev;
-    }
-  addKeyword (&prev, "video/mpeg", EXTRACTOR_MIMETYPE);
-  if (info->sequence != NULL)
-    {
-      snprintf (format, 256, "%ux%u",
-                info->sequence->width, info->sequence->height);
-      addKeyword (&prev, format, EXTRACTOR_SIZE);
-      switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED)
-        {
-        case SEQ_VIDEO_FORMAT_PAL:
-          addKeyword (&prev, "PAL", EXTRACTOR_FORMAT);
-          break;
-        case SEQ_VIDEO_FORMAT_NTSC:
-          addKeyword (&prev, "NTSC", EXTRACTOR_FORMAT);
-          break;
-        case SEQ_VIDEO_FORMAT_SECAM:
-          addKeyword (&prev, "SECAM", EXTRACTOR_FORMAT);
-          break;
-        case SEQ_VIDEO_FORMAT_MAC:
-          addKeyword (&prev, "MAC", EXTRACTOR_FORMAT);
-          break;
-        default:
-          break;
-        }
-      if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0)
-        addKeyword (&prev, "MPEG2", EXTRACTOR_RESOURCE_TYPE);
-      else
-        addKeyword (&prev, "MPEG1", EXTRACTOR_RESOURCE_TYPE);
-    }
-  if (info->gop != NULL)
-    {
-      /* this usually does not work yet, since gop's are not
-         often at the beginning of the stream (and we
-         don't iterate over the stream hoping to find one).
-         Hence we usually don't get the size.  Not sure how
-         to *efficiently* get the gop (without scanning
-         through the entire file) */
-      snprintf (format, 256, "%u:%u:%u (%u frames)",
-                info->gop->hours,
-                info->gop->minutes, info->gop->seconds, info->gop->pictures);
-      addKeyword (&prev, format, EXTRACTOR_DURATION);
-    }
-  mpeg2_close (handle);
-  return prev;
-}





reply via email to

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