aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-12-18 18:04:55 +0000
committerChristian Grothoff <christian@grothoff.org>2009-12-18 18:04:55 +0000
commit7cf17f598af0dc0194beb5224d5493b83959f70e (patch)
treeff12844c9272afba7c7290d8b31fb3af25385cb8
parent21d4464f2dd32afe60f3c5cb6d59723f7241a80e (diff)
downloadlibextractor-7cf17f598af0dc0194beb5224d5493b83959f70e.tar.gz
libextractor-7cf17f598af0dc0194beb5224d5493b83959f70e.zip
mpeg
-rw-r--r--src/include/extractor.h2
-rw-r--r--src/main/extractor_metatypes.c4
-rw-r--r--src/plugins/Makefile.am16
-rw-r--r--src/plugins/mpeg_extractor.c (renamed from src/plugins/mpegextractor.c)62
4 files changed, 41 insertions, 43 deletions
diff --git a/src/include/extractor.h b/src/include/extractor.h
index 0e45312..08a582a 100644
--- a/src/include/extractor.h
+++ b/src/include/extractor.h
@@ -271,8 +271,8 @@ enum EXTRACTOR_MetaType
271 EXTRACTOR_METATYPE_CONTRIBUTOR_PICTURE = 139, 271 EXTRACTOR_METATYPE_CONTRIBUTOR_PICTURE = 139,
272 EXTRACTOR_METATYPE_EVENT_PICTURE = 140, 272 EXTRACTOR_METATYPE_EVENT_PICTURE = 140,
273 EXTRACTOR_METATYPE_LOGO = 141, 273 EXTRACTOR_METATYPE_LOGO = 141,
274 EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM = 142,
274 275
275 EXTRACTOR_METATYPE_PLAY_COUNTER = 118,
276 EXTRACTOR_METATYPE_LYRICS = 67, 276 EXTRACTOR_METATYPE_LYRICS = 67,
277 EXTRACTOR_METATYPE_CONDUCTOR = 64, 277 EXTRACTOR_METATYPE_CONDUCTOR = 64,
278 EXTRACTOR_METATYPE_INTERPRET = 65, 278 EXTRACTOR_METATYPE_INTERPRET = 65,
diff --git a/src/main/extractor_metatypes.c b/src/main/extractor_metatypes.c
index 3665214..48c659d 100644
--- a/src/main/extractor_metatypes.c
+++ b/src/main/extractor_metatypes.c
@@ -349,8 +349,8 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
349 gettext_noop ("picture of an associated event") }, 349 gettext_noop ("picture of an associated event") },
350 { gettext_noop ("logo"), 350 { gettext_noop ("logo"),
351 gettext_noop ("logo of an associated organization") }, 351 gettext_noop ("logo of an associated organization") },
352 { gettext_noop (""), 352 { gettext_noop ("broadcast television system"),
353 gettext_noop ("") }, 353 gettext_noop ("name of the television system for which the data is coded") },
354 { gettext_noop (""), 354 { gettext_noop (""),
355 gettext_noop ("") }, 355 gettext_noop ("") },
356 { gettext_noop (""), 356 { gettext_noop (""),
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 3463654..841367e 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -82,6 +82,7 @@ plugin_LTLIBRARIES = \
82 libextractor_man.la \ 82 libextractor_man.la \
83 libextractor_mime.la \ 83 libextractor_mime.la \
84 libextractor_mp3.la \ 84 libextractor_mp3.la \
85 $(mpeg) \
85 libextractor_odf.la \ 86 libextractor_odf.la \
86 $(ogg) \ 87 $(ogg) \
87 $(ole2) \ 88 $(ole2) \
@@ -191,6 +192,13 @@ libextractor_mp3_la_LIBADD = \
191 $(top_builddir)/src/common/libextractor_common.la \ 192 $(top_builddir)/src/common/libextractor_common.la \
192 $(LE_LIBINTL) 193 $(LE_LIBINTL)
193 194
195libextractor_mpeg_la_SOURCES = \
196 mpeg_extractor.c
197libextractor_mpeg_la_LDFLAGS = \
198 $(PLUGINFLAGS)
199libextractor_mpeg_la_LIBADD = \
200 -lmpeg2
201
194libextractor_odf_la_SOURCES = \ 202libextractor_odf_la_SOURCES = \
195 odf_extractor.c 203 odf_extractor.c
196libextractor_odf_la_LDFLAGS = \ 204libextractor_odf_la_LDFLAGS = \
@@ -338,14 +346,6 @@ libextractor_zip_la_LDFLAGS = \
338libextractor_zip_la_LIBADD = \ 346libextractor_zip_la_LIBADD = \
339 $(top_builddir)/src/main/libextractor.la 347 $(top_builddir)/src/main/libextractor.la
340 348
341libextractor_mpeg_la_SOURCES = \
342 mpegextractor.c
343libextractor_mpeg_la_LDFLAGS = \
344 $(PLUGINFLAGS)
345libextractor_mpeg_la_LIBADD = \
346 -lmpeg2 \
347 $(top_builddir)/src/main/libextractor.la
348
349libextractor_riff_la_SOURCES = \ 349libextractor_riff_la_SOURCES = \
350 riffextractor.c 350 riffextractor.c
351libextractor_riff_la_LDFLAGS = \ 351libextractor_riff_la_LDFLAGS = \
diff --git a/src/plugins/mpegextractor.c b/src/plugins/mpeg_extractor.c
index 51834f7..85ca51c 100644
--- a/src/plugins/mpegextractor.c
+++ b/src/plugins/mpeg_extractor.c
@@ -1,7 +1,7 @@
1 1
2/* 2/*
3 This file is part of libextractor. 3 This file is part of libextractor.
4 (C) 2004, 2005, 2006 Vidyut Samanta and Christian Grothoff 4 (C) 2004, 2005, 2006, 2009 Vidyut Samanta and Christian Grothoff
5 5
6 libextractor is free software; you can redistribute it and/or modify 6 libextractor is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published 7 it under the terms of the GNU General Public License as published
@@ -23,40 +23,34 @@
23#include "extractor.h" 23#include "extractor.h"
24#include <mpeg2dec/mpeg2.h> 24#include <mpeg2dec/mpeg2.h>
25 25
26static void 26#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)
27addKeyword (struct EXTRACTOR_Keywords **list, 27
28 char *keyword, EXTRACTOR_KeywordType type)
29{
30 EXTRACTOR_KeywordList *next;
31 next = malloc (sizeof (EXTRACTOR_KeywordList));
32 next->next = *list;
33 next->keyword = strdup (keyword);
34 next->keywordType = type;
35 *list = next;
36}
37 28
38/* video/mpeg */ 29/* video/mpeg */
39struct EXTRACTOR_Keywords * 30int
40libextractor_mpeg_extract (const char *filename, 31EXTRACTOR_wav_extract (const unsigned char *data,
41 const unsigned char *data, 32 size_t size,
42 size_t size, struct EXTRACTOR_Keywords *prev) 33 EXTRACTOR_MetaDataProcessor proc,
34 void *proc_cls,
35 const char *options)
43{ 36{
44 mpeg2dec_t *handle; 37 mpeg2dec_t *handle;
45 uint8_t *start; 38 uint8_t *start;
46 uint8_t *end; 39 uint8_t *end;
47 const mpeg2_info_t *info; 40 const mpeg2_info_t *info;
48 mpeg2_state_t state; 41 mpeg2_state_t state;
42 int ret;
49 char format[256]; 43 char format[256];
50 44
51 if ((size < 4) || 45 if ((size < 4) ||
52 (!((data[0] == 0x00) && 46 (!((data[0] == 0x00) &&
53 (data[1] == 0x00) && 47 (data[1] == 0x00) &&
54 (data[2] == 0x01) && ((data[3] == 0xB3) || (data[3] == 0xBA))))) 48 (data[2] == 0x01) && ((data[3] == 0xB3) || (data[3] == 0xBA)))))
55 return prev; 49 return 0;
56 50
57 handle = mpeg2_init (); 51 handle = mpeg2_init ();
58 if (handle == NULL) 52 if (handle == NULL)
59 return prev; 53 return 0;
60 start = (uint8_t *) data; 54 start = (uint8_t *) data;
61 end = (uint8_t *) & data[size]; 55 end = (uint8_t *) & data[size];
62 mpeg2_buffer (handle, start, end); 56 mpeg2_buffer (handle, start, end);
@@ -64,41 +58,43 @@ libextractor_mpeg_extract (const char *filename,
64 if (state != STATE_SEQUENCE) 58 if (state != STATE_SEQUENCE)
65 { 59 {
66 mpeg2_close (handle); 60 mpeg2_close (handle);
67 return prev; 61 return 0;
68 } 62 }
69 info = mpeg2_info (handle); 63 info = mpeg2_info (handle);
70 if (info == NULL) 64 if (info == NULL)
71 { 65 {
72 mpeg2_close (handle); 66 mpeg2_close (handle);
73 return prev; 67 return 0;
74 } 68 }
75 addKeyword (&prev, "video/mpeg", EXTRACTOR_MIMETYPE); 69 ret = 0;
70 ADD ("video/mpeg", EXTRACTOR_METATYPE_MIMETYPE);
76 if (info->sequence != NULL) 71 if (info->sequence != NULL)
77 { 72 {
78 snprintf (format, 256, "%ux%u", 73 snprintf (format,
74 sizeof(format), "%ux%u",
79 info->sequence->width, info->sequence->height); 75 info->sequence->width, info->sequence->height);
80 addKeyword (&prev, format, EXTRACTOR_SIZE); 76 ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS);
81 switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED) 77 switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED)
82 { 78 {
83 case SEQ_VIDEO_FORMAT_PAL: 79 case SEQ_VIDEO_FORMAT_PAL:
84 addKeyword (&prev, "PAL", EXTRACTOR_FORMAT); 80 ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
85 break; 81 break;
86 case SEQ_VIDEO_FORMAT_NTSC: 82 case SEQ_VIDEO_FORMAT_NTSC:
87 addKeyword (&prev, "NTSC", EXTRACTOR_FORMAT); 83 ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
88 break; 84 break;
89 case SEQ_VIDEO_FORMAT_SECAM: 85 case SEQ_VIDEO_FORMAT_SECAM:
90 addKeyword (&prev, "SECAM", EXTRACTOR_FORMAT); 86 ADD ("SECAM", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
91 break; 87 break;
92 case SEQ_VIDEO_FORMAT_MAC: 88 case SEQ_VIDEO_FORMAT_MAC:
93 addKeyword (&prev, "MAC", EXTRACTOR_FORMAT); 89 ADD ("MAC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
94 break; 90 break;
95 default: 91 default:
96 break; 92 break;
97 } 93 }
98 if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0) 94 if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0)
99 addKeyword (&prev, "MPEG2", EXTRACTOR_RESOURCE_TYPE); 95 ADD ("MPEG2", EXTRACTOR_METATYPE_FORMAT_VERSION);
100 else 96 else
101 addKeyword (&prev, "MPEG1", EXTRACTOR_RESOURCE_TYPE); 97 ADD ("MPEG1", EXTRACTOR_METATYPE_FORMAT_VERSION);
102 } 98 }
103 if (info->gop != NULL) 99 if (info->gop != NULL)
104 { 100 {
@@ -108,11 +104,13 @@ libextractor_mpeg_extract (const char *filename,
108 Hence we usually don't get the size. Not sure how 104 Hence we usually don't get the size. Not sure how
109 to *efficiently* get the gop (without scanning 105 to *efficiently* get the gop (without scanning
110 through the entire file) */ 106 through the entire file) */
111 snprintf (format, 256, "%u:%u:%u (%u frames)", 107 snprintf (format,
108 sizeof(format), "%u:%u:%u (%u frames)",
112 info->gop->hours, 109 info->gop->hours,
113 info->gop->minutes, info->gop->seconds, info->gop->pictures); 110 info->gop->minutes, info->gop->seconds, info->gop->pictures);
114 addKeyword (&prev, format, EXTRACTOR_DURATION); 111 ADD (format, EXTRACTOR_METATYPE_DURATION);
115 } 112 }
113 EXIT:
116 mpeg2_close (handle); 114 mpeg2_close (handle);
117 return prev; 115 return ret;
118} 116}