summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2003-10-24 20:13:49 +0000
committerBenjamin Otte <otte@gnome.org>2003-10-24 20:13:49 +0000
commit78b2064a46bcd633ebd3d3b35c57e390ef743b08 (patch)
tree1ff7e739fe9b8b4629d579ac0ac656925910ce7a
parent4de40d8ccd21dca15aaf792a842d266604cc59a7 (diff)
fixes:TYPEFIND
Original commit message from CVS: fixes: - bytestream needs to be gst_library_loaded again - typecast correctly on guint8* => guint32* in typefinding - remove unused/unnecessary files
-rw-r--r--ext/audiofile/gstaf.c3
-rw-r--r--ext/ivorbis/vorbis.c3
-rw-r--r--ext/mplex/gstmplex.cc4
-rw-r--r--gst/cdxaparse/gstcdxaparse.c3
-rw-r--r--gst/flx/gstflxdec.c3
-rw-r--r--gst/mixmatrix/mixmatrix.c3
-rw-r--r--gst/mpegaudioparse/Makefile.am1
-rw-r--r--gst/mpegaudioparse/README12
-rw-r--r--gst/mpegaudioparse/gstmp3types.c254
-rw-r--r--gst/qtdemux/qtdemux.c3
10 files changed, 20 insertions, 269 deletions
diff --git a/ext/audiofile/gstaf.c b/ext/audiofile/gstaf.c
index 4e2b3e9a7..cec38f1eb 100644
--- a/ext/audiofile/gstaf.c
+++ b/ext/audiofile/gstaf.c
@@ -25,6 +25,9 @@
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
+ if (!gst_library_load ("gstbytestream"))
+ return FALSE;
+
gst_afsink_plugin_init (module, plugin);
gst_afsrc_plugin_init (module, plugin);
gst_afparse_plugin_init (module, plugin);
diff --git a/ext/ivorbis/vorbis.c b/ext/ivorbis/vorbis.c
index a68e01a1d..9b12611ce 100644
--- a/ext/ivorbis/vorbis.c
+++ b/ext/ivorbis/vorbis.c
@@ -104,6 +104,9 @@ plugin_init (GModule *module, GstPlugin *plugin)
GstTypeFactory *type;
GstCaps *raw_caps, *vorbis_caps, *raw_caps2;
+ if (!gst_library_load ("gstbytestream"))
+ return FALSE;
+
gst_plugin_set_longname (plugin, "The OGG Vorbis Codec");
raw_caps = raw_caps_factory ();
diff --git a/ext/mplex/gstmplex.cc b/ext/mplex/gstmplex.cc
index 523cc74fe..8f8a94a3d 100644
--- a/ext/mplex/gstmplex.cc
+++ b/ext/mplex/gstmplex.cc
@@ -578,8 +578,8 @@ plugin_init (GModule *module, GstPlugin *plugin)
GstElementFactory *factory;
/* this filter needs the bytestream package */
-/* if (!gst_library_load ("gstbytestream"))
- return FALSE;*/
+ if (!gst_library_load ("gstbytestream"))
+ return FALSE;
/* create an elementfactory for the avi_demux element */
factory = gst_element_factory_new ("mplex",GST_TYPE_MPLEX,
diff --git a/gst/cdxaparse/gstcdxaparse.c b/gst/cdxaparse/gstcdxaparse.c
index 8356dc844..2ee3071d9 100644
--- a/gst/cdxaparse/gstcdxaparse.c
+++ b/gst/cdxaparse/gstcdxaparse.c
@@ -307,6 +307,9 @@ plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *factory;
+ if (!gst_library_load ("gstbytestream"))
+ return FALSE;
+
/* create an elementfactory for the cdxa_parse element */
factory = gst_element_factory_new ("cdxaparse", GST_TYPE_CDXA_PARSE,
&gst_cdxa_parse_details);
diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c
index 51ceec48b..f4e085c30 100644
--- a/gst/flx/gstflxdec.c
+++ b/gst/flx/gstflxdec.c
@@ -649,6 +649,9 @@ plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *factory;
+ if (!gst_library_load ("gstbytestream"))
+ return FALSE;
+
factory = gst_element_factory_new("flxdec", GST_TYPE_FLXDEC, &flxdec_details);
g_return_val_if_fail(factory != NULL, FALSE);
gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_PRIMARY);
diff --git a/gst/mixmatrix/mixmatrix.c b/gst/mixmatrix/mixmatrix.c
index 5e9ebe53f..7b03c83f7 100644
--- a/gst/mixmatrix/mixmatrix.c
+++ b/gst/mixmatrix/mixmatrix.c
@@ -500,6 +500,9 @@ plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *factory;
+ if (!gst_library_load ("gstbytestream"))
+ return FALSE;
+
factory = gst_element_factory_new ("mixmatrix", GST_TYPE_MIXMATRIX,
&mixmatrix_details);
g_return_val_if_fail (factory != NULL, FALSE);
diff --git a/gst/mpegaudioparse/Makefile.am b/gst/mpegaudioparse/Makefile.am
index cb06727fd..02f8a2ee7 100644
--- a/gst/mpegaudioparse/Makefile.am
+++ b/gst/mpegaudioparse/Makefile.am
@@ -6,4 +6,3 @@ libgstmpegaudioparse_la_LIBADD =
libgstmpegaudioparse_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS = gstmpegaudioparse.h
-EXTRA_DIST = README
diff --git a/gst/mpegaudioparse/README b/gst/mpegaudioparse/README
deleted file mode 100644
index 8a803d3e9..000000000
--- a/gst/mpegaudioparse/README
+++ /dev/null
@@ -1,12 +0,0 @@
-MP3 Audio Parser
-================
-
-This element acts as a parser for mpeg audio data. It's called 'mp3' but
-in reality will work for any MPEG-1, MPEG-2, or MPEG-2.5 elemental audio
-stream of any of Layers I, II, and III. It will not (currently, ever?)
-handle MPEG-2 BC or NBC streams, as those have rather specialized needs
-best served be a different filter.
-
-It will take an mpeg audio stream in any form on its 'src' input, with any
-buffer size, and split it into buffers containing a single frame each.
-NOTE: ancillary data is not dealt with right now.
diff --git a/gst/mpegaudioparse/gstmp3types.c b/gst/mpegaudioparse/gstmp3types.c
deleted file mode 100644
index af2f49146..000000000
--- a/gst/mpegaudioparse/gstmp3types.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/* GStreamer
- * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*#define DEBUG_ENABLED */
-#include <gst/gst.h>
-#include <string.h> /* memcmp */
-
-static GstCaps* mp3_type_find(GstBuffer *buf, gpointer private);
-static GstCaps* mp3_type_find_stream(GstBuffer *buf, gpointer private);
-
-static GstTypeDefinition mp3type_definitions[] = {
- { "mp3types_audio/mpeg", "audio/mpeg", ".mp3 .mp2 .mp1 .mpga", mp3_type_find },
- { "mp3types_stream_audio/mpeg", "audio/mpeg", ".mp3 .mp2 .mp1 .mpga", mp3_type_find_stream },
- { NULL, NULL, NULL, NULL },
-};
-
-static GstCaps*
-mp3_type_find(GstBuffer *buf, gpointer private)
-{
- guint8 *data;
- gint size, layer;
- guint32 head;
- GstCaps *caps;
-
- data = GST_BUFFER_DATA (buf);
- size = GST_BUFFER_SIZE (buf);
-
- GST_DEBUG ("mp3typefind: typefind");
-
- /* gracefully ripped from libid3 */
- if (size >= 3 &&
- data[0] == 'T' && data[1] == 'A' && data[2] == 'G') {
- /* ID V1 tags */
- data += 128;
- size -= 128;
-
- GST_DEBUG ("mp3typefind: detected ID3 Tag V1");
- } else if (size >= 10 &&
- (data[0] == 'I' && data[1] == 'D' && data[2] == '3') &&
- data[3] < 0xff && data[4] < 0xff &&
- data[6] < 0x80 && data[7] < 0x80 && data[8] < 0x80 && data[9] < 0x80)
- {
- guint32 skip = 0;
-
- skip = (skip << 7) | (data[6] & 0x7f);
- skip = (skip << 7) | (data[7] & 0x7f);
- skip = (skip << 7) | (data[8] & 0x7f);
- skip = (skip << 7) | (data[9] & 0x7f);
-
- /* include size of header */
- skip += 10;
- /* footer present? (only available since version 4) */
- if (data[3] > 3 && (data[5] & 0x10))
- skip += 10;
-
- GST_DEBUG ("mp3typefind: detected ID3 Tag V2 with %u bytes", skip);
- size -= skip;
- data += skip;
- }
-
- if (size < 4)
- return NULL;
-
- /* now with the right postion, do typefinding */
- head = GUINT32_FROM_BE(*((guint32 *)data));
- if ((head & 0xffe00000) != 0xffe00000)
- return NULL;
- if (!(layer = ((head >> 17) & 3)))
- return NULL;
- layer = 4 - layer;
- if (((head >> 12) & 0xf) == 0xf)
- return NULL;
- if (!((head >> 12) & 0xf))
- return NULL;
- if (((head >> 10) & 0x3) == 0x3)
- return NULL;
-
- caps = GST_CAPS_NEW ("mp3_type_find", "audio/mpeg", "layer", GST_PROPS_INT (layer));
-
- return caps;
-}
-static guint mp3types_bitrates[2][3][16] =
-{ { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, },
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, },
- {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, } },
- { {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, },
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, },
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, } },
-};
-static guint mp3types_freqs[3][3] =
-{ {44100, 48000, 32000},
- {22050, 24000, 16000},
- {11025, 12000, 8000}};
-static inline guint
-mp3_type_frame_length_from_header (guint32 header, guint *put_layer)
-{
- guint length;
- gulong samplerate, bitrate, layer, version;
-
- /* we don't need extension, mode, copyright, original or emphasis for the frame length */
- header >>= 9;
- /* padding */
- length = header & 0x1;
- header >>= 1;
- /* sampling frequency */
- samplerate = header & 0x3;
- if (samplerate == 3)
- return 0;
- header >>= 2;
- /* bitrate index */
- bitrate = header & 0xF;
- if (bitrate == 15 || bitrate == 0)
- return 0;
- /* ignore error correction, too */
- header >>= 5;
- /* layer */
- layer = 4 - (header & 0x3);
- if (layer == 4)
- return 0;
- header >>= 2;
- /* version */
- version = header & 0x3;
- if (version == 1)
- return 0;
- /* lookup */
- bitrate = mp3types_bitrates[version == 3 ? 0 : 1][layer - 1][bitrate];
- samplerate = mp3types_freqs[version > 0 ? version - 1 : 0][samplerate];
- /* calculating */
- if (layer == 1) {
- length = ((12000 * bitrate / samplerate) + length) * 4;
- } else {
- length += ((layer == 3 && version == 0) ? 144000 : 72000) * bitrate / samplerate;
- }
-
- GST_DEBUG ("Calculated mad frame length of %u bytes", length);
- GST_DEBUG ("samplerate = %lu - bitrate = %lu - layer = %lu - version = %lu", samplerate, bitrate, layer, version);
- if (put_layer)
- *put_layer = layer;
- return length;
-}
-/* increase this value when this function finds too many false positives */
-/**
- * The chance that random data is identified as a valid mp3 header is 63 / 2^18
- * (0.024%) per try. This makes the function for calculating false positives
- * 1 - (1 - ((63 / 2 ^18) ^ GST_MP3_TYPEFIND_MIN_HEADERS)) ^ buffersize)
- * This has the following probabilities of false positives:
- * bufsize MIN_HEADERS
- * (bytes) 1 2 3 4
- * 4096 62.6% 0.02% 0% 0%
- * 16384 98% 0.09% 0% 0%
- * 1 MiB 100% 5.88% 0% 0%
- * 1 GiB 100% 100% 1.44% 0%
- * 1 TiB 100% 100% 100% 0.35%
- * This means that the current choice (3 headers by most of the time 4096 byte
- * buffers is pretty safe for now.
- * It is however important to note that in a worst case example a buffer of size
- * 1440 * GST_MP3_TYPEFIND_MIN_HEADERS + 3
- * bytes is needed to reliable find the mp3 stream in a buffer when scanning
- * starts at a random position. This is currently (4323 bytes) slightly above
- * the default buffer size. But you rarely hit the worst case - average mp3
- * frames are in the 500 bytes range.
- */
-#define GST_MP3_TYPEFIND_MIN_HEADERS 3
-static GstCaps*
-mp3_type_find_stream (GstBuffer *buf, gpointer private)
-{
- guint8 *data;
- guint size;
- guint32 head;
- gint layer = 0;
-
- data = GST_BUFFER_DATA (buf);
- size = GST_BUFFER_SIZE (buf);
-
- while (size >= 4) {
- head = GUINT32_FROM_BE(*((guint32 *)data));
- if ((head & 0xffe00000) == 0xffe00000) {
- guint length;
- guint prev_layer = 0;
- guint found = 0; /* number of valid headers found */
- guint pos = 0;
- do {
- if ((length = mp3_type_frame_length_from_header (head, &layer))) {
- if (prev_layer && prev_layer != layer)
- break;
- prev_layer = layer;
- pos += length;
- found++;
- if (pos + 4 >= size) {
- if (found >= GST_MP3_TYPEFIND_MIN_HEADERS) {
- goto success;
- } else {
- break;
- }
- }
- head = GUINT32_FROM_BE(*((guint32 *) &(data[pos])));
- if ((head & 0xffe00000) != 0xffe00000)
- break;
- } else {
- break;
- }
- } while (TRUE);
- }
- data++;
- size--;
- }
-
- return NULL;
-
-success:
- g_assert (layer);
- return GST_CAPS_NEW ("mp3_type_find", "audio/mpeg", "layer", GST_PROPS_INT (layer));
-}
-
-static gboolean
-plugin_init (GModule *module, GstPlugin *plugin)
-{
- gint i=0;
-
- while (mp3type_definitions[i].name) {
- GstTypeFactory *type;
-
- type = gst_type_factory_new (&mp3type_definitions[i]);
- gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
- i++;
- }
-
- /* gst_info("gsttypes: loaded %d mp3 types\n",i); */
-
- return TRUE;
-}
-
-GstPluginDesc plugin_desc = {
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "mp3types",
- plugin_init
-};
diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c
index c3cb63fb7..06352f1db 100644
--- a/gst/qtdemux/qtdemux.c
+++ b/gst/qtdemux/qtdemux.c
@@ -191,6 +191,9 @@ plugin_init (GModule *module, GstPlugin *plugin)
};
gint i;
+ if (!gst_library_load ("gstbytestream"))
+ return FALSE;
+
factory = gst_element_factory_new ("qtdemux", GST_TYPE_QTDEMUX,
&gst_qtdemux_details);
g_return_val_if_fail(factory != NULL, FALSE);