Commit b0669133 authored by Edgard Gusmão Lima's avatar Edgard Gusmão Lima

Wavpack ported to 0.9. No support for correction file yet.

Original commit message from CVS:
Wavpack ported to 0.9. No support for correction file yet.
parent 584acf39
2005-11-25 Edgard Lima <edgard.lima@indt.org.br>
* configure.ac:
* PORTED_09:
* ext/Makefile.am:
* ext/wavpack/Makefile.am:
* ext/wavpack/gstwavpackdec.c:
* ext/wavpack/gstwavpackdec.h:
* ext/wavpack/gstwavpackparse.c:
* ext/wavpack/gstwavpackparse.h:
Wavpack ported to 0.9. No support for correction file yet.
2005-11-25 Thomas Vander Stichele <thomas at apestaart dot org>
* ext/wavpack/Makefile.am:
......
When porting a plugin start with 0.8 CVS head, not the old code in this module. There are many bugfixes which have gone into 0.8 which you want to keep.
List of ported plugins (update when you commit a ported plugin):
wavpack (alima)
musepack (alima)
ivorbis (alima)
gsmdec (alima)
......
......@@ -418,6 +418,15 @@ GST_CHECK_FEATURE(SDL, [SDL plug-in], sdlvideosink, [
AM_PATH_SDL(, HAVE_SDL=yes, HAVE_SDL=no)
])
dnl *** wavpack ***
dnl We ship our own version of the library
translit(dnm, m, l) AM_CONDITIONAL(USE_WAVPACK, true)
GST_CHECK_FEATURE(WAVPACK, [wavpack plug-in], wavpack, [
PKG_CHECK_MODULES(WAVPACK, wavpack >= 4.2, HAVE_WAVPACK=yes, HAVE_WAVPACK=no)
AC_SUBST(WAVPACK_CFLAGS)
AC_SUBST(WAVPACK_LIBS)
])
dnl *** ivorbis ***
dnl AM_PATH_IVORBIS only takes two options
translit(dnm, m, l) AM_CONDITIONAL(USE_IVORBIS, true)
......@@ -518,6 +527,7 @@ ext/Makefile
ext/directfb/Makefile
ext/faac/Makefile
ext/faad/Makefile
ext/wavpack/Makefile
ext/ivorbis/Makefile
ext/gsm/Makefile
ext/musepack/Makefile
......
......@@ -76,6 +76,12 @@ endif
HERMES_DIR=
# endif
if USE_WAVPACK
WAVPACK_DIR=wavpack
else
WAVPACK_DIR=
endif
if USE_IVORBIS
IVORBIS_DIR=ivorbis
else
......@@ -231,4 +237,6 @@ DIST_SUBDIRS= \
musepack \
sdl \
directfb \
musepack \
wavpack \
ivorbis
plugin_LTLIBRARIES = libgstwavpack.la
libgstwavpack_la_SOURCES = gstwavpack.c \
gstwavpackcommon.c \
gstwavpackparse.c \
gstwavpackdec.c
libgstwavpack_la_SOURCES = gstwavpack.c \
gstwavpackcommon.c \
gstwavpackparse.c \
gstwavpackdec.c
libgstwavpack_la_CFLAGS = $(GST_CFLAGS) $(WAVPACK_CFLAGS)
libgstwavpack_la_LIBADD = $(WAVPACK_LIBS)
......
......@@ -76,20 +76,20 @@ static void gst_wavpack_dec_class_init (GstWavpackDecClass * klass);
static void gst_wavpack_dec_base_init (GstWavpackDecClass * klass);
static void gst_wavpack_dec_init (GstWavpackDec * wavpackdec);
static void gst_wavpack_dec_loop (GstElement * element);
static GstFlowReturn gst_wavpack_dec_chain (GstPad * pad, GstBuffer * buffer);
static GstElementClass *parent = NULL;
static GstPadLinkReturn
gst_wavpack_dec_link (GstPad * pad, const GstCaps * caps)
gst_wavpack_dec_link (GstPad * pad, GstPad * peer)
{
GstWavpackDec *wavpackdec = GST_WAVPACK_DEC (gst_pad_get_parent (pad));
GstStructure *structure = gst_caps_get_structure (caps, 0);
GstStructure *structure = gst_caps_get_structure (GST_PAD_CAPS (peer), 0);
GstCaps *srccaps;
gint bits;
if (!gst_caps_is_fixed (caps))
return GST_PAD_LINK_DELAYED;
if (!gst_caps_is_fixed (GST_PAD_CAPS (peer)))
return GST_PAD_LINK_REFUSED;
gst_structure_get_int (structure, "rate",
(gint32 *) & wavpackdec->samplerate);
......@@ -114,24 +114,22 @@ gst_wavpack_dec_link (GstPad * pad, const GstCaps * caps)
"endianness", G_TYPE_INT, LITTLE_ENDIAN,
"buffer-frames", G_TYPE_INT, 0, NULL);
}
gst_pad_set_caps (wavpackdec->srcpad, srccaps);
gst_pad_use_fixed_caps (wavpackdec->srcpad);
gst_pad_set_explicit_caps (wavpackdec->srcpad, srccaps);
// blocks are usually 0.5 seconds long, assume that's always the case for now
wavpackdec->decodebuf =
(int32_t *) g_malloc ((wavpackdec->samplerate / 2) *
wavpackdec->channels * sizeof (int32_t));
return GST_PAD_LINK_OK;
}
#if 0
static GstPadLinkReturn
gst_wavpack_dec_wvclink (GstPad * pad, const GstCaps * caps)
gst_wavpack_dec_wvclink (GstPad * pad, GstPad * peer)
{
if (!gst_caps_is_fixed (caps))
return GST_PAD_LINK_DELAYED;
if (!gst_caps_is_fixed (GST_PAD_CAPS (peer)))
return GST_PAD_LINK_REFUSED;
return GST_PAD_LINK_OK;
}
#endif
GType
gst_wavpack_dec_get_type (void)
......@@ -201,10 +199,9 @@ gst_wavpack_dec_class_init (GstWavpackDecClass * klass)
}
static gboolean
gst_wavpack_dec_src_query (GstPad * pad, GstQueryType type,
GstFormat * format, gint64 * value)
gst_wavpack_dec_src_query (GstPad * pad, GstQuery * query)
{
return gst_pad_query_default (pad, type, format, value);
return gst_pad_query_default (pad, query);
}
static void
......@@ -215,27 +212,31 @@ gst_wavpack_dec_init (GstWavpackDec * wavpackdec)
wavpackdec->sinkpad =
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
"sink"), "sink");
gst_element_add_pad (GST_ELEMENT (wavpackdec), wavpackdec->sinkpad);
gst_pad_set_chain_function (wavpackdec->sinkpad, gst_wavpack_dec_chain);
gst_pad_set_link_function (wavpackdec->sinkpad, gst_wavpack_dec_link);
#if 0
wavpackdec->wvcsinkpad =
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
"wvcsink"), "wvcsink");
gst_pad_set_link_function (wavpackdec->wvcsinkpad, gst_wavpack_dec_wvclink);
gst_element_add_pad (GST_ELEMENT (wavpackdec), wavpackdec->wvcsinkpad);
#endif
wavpackdec->srcpad =
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
"src"), "src");
gst_pad_use_explicit_caps (wavpackdec->srcpad);
gst_pad_use_fixed_caps (wavpackdec->srcpad);
gst_pad_set_query_function (wavpackdec->srcpad, gst_wavpack_dec_src_query);
gst_element_add_pad (GST_ELEMENT (wavpackdec), wavpackdec->sinkpad);
gst_element_add_pad (GST_ELEMENT (wavpackdec), wavpackdec->srcpad);
gst_element_add_pad (GST_ELEMENT (wavpackdec), wavpackdec->wvcsinkpad);
gst_element_set_loop_function (GST_ELEMENT (wavpackdec),
gst_wavpack_dec_loop);
wavpackdec->decodebuf = NULL;
wavpackdec->decodebuf_size = 0;
wavpackdec->stream = (WavpackStream *) g_malloc0 (sizeof (WavpackStream));
wavpackdec->context = (WavpackContext *) g_malloc0 (sizeof (WavpackContext));
}
......@@ -246,6 +247,7 @@ gst_wavpack_dec_setup_context (GstWavpackDec * wavpackdec, guchar * data,
{
WavpackContext *context = wavpackdec->context;
WavpackStream *stream = wavpackdec->stream;
guint buffer_size;
memset (context, 0, sizeof (context));
......@@ -267,6 +269,14 @@ gst_wavpack_dec_setup_context (GstWavpackDec * wavpackdec, guchar * data,
context->wvc_flag = FALSE;
}
buffer_size =
stream->wphdr.block_samples * wavpackdec->channels * sizeof (int32_t);
if (wavpackdec->decodebuf_size < buffer_size) {
wavpackdec->decodebuf =
(int32_t *) g_realloc (wavpackdec->decodebuf, buffer_size);
wavpackdec->decodebuf_size = buffer_size;
}
unpack_init (context);
}
......@@ -317,71 +327,25 @@ gst_wavpack_dec_format_samples (GstWavpackDec * wavpackdec, int32_t * samples,
return buf;
}
static void
gst_wavpack_dec_loop (GstElement * element)
static GstFlowReturn
gst_wavpack_dec_chain (GstPad * pad, GstBuffer * buf)
{
GstWavpackDec *wavpackdec = GST_WAVPACK_DEC (element);
GstData *data, *cdata = NULL;
GstBuffer *buf, *outbuf, *cbuf = NULL;
gboolean got_event = FALSE;
if (!gst_pad_is_linked (wavpackdec->sinkpad)) {
return;
}
/*
if (!gst_pad_is_linked (wavpackdec->wvcsinkpad)) {
return;
}
*/
data = gst_pad_pull (wavpackdec->sinkpad);
if (GST_IS_EVENT (data)) {
GstEvent *event = GST_EVENT (data);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
gst_event_unref (event);
gst_pad_push (wavpackdec->srcpad,
GST_DATA (gst_event_new (GST_EVENT_EOS)));
gst_element_set_eos (element);
break;
default:
gst_pad_event_default (wavpackdec->srcpad, event);
break;
}
got_event = TRUE;
}
GstWavpackDec *wavpackdec = GST_WAVPACK_DEC (gst_pad_get_parent (pad));
GstBuffer *outbuf, *cbuf = NULL;
GstFlowReturn ret = GST_FLOW_OK;
#if 0
if (gst_pad_is_linked (wavpackdec->wvcsinkpad)) {
cdata = gst_pad_pull (wavpackdec->wvcsinkpad);
if (GST_IS_EVENT (cdata)) {
GstEvent *event = GST_EVENT (cdata);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
gst_event_unref (event);
gst_pad_push (wavpackdec->srcpad,
GST_DATA (gst_event_new (GST_EVENT_EOS)));
gst_element_set_eos (element);
break;
default:
gst_pad_event_default (wavpackdec->srcpad, event);
break;
}
got_event = TRUE;
if (GST_FLOW_OK != gst_pad_pull_range (wavpackdec->wvcsinkpad,
wavpackdec->wvcflushed_bytes, -1, &cbuf)) {
cbuf = NULL;
} else {
cbuf = GST_BUFFER (cdata);
wavpackdec->wvcflushed_bytes += GST_BUFFER_SIZE (cbuf);
}
}
if (got_event)
return;
buf = GST_BUFFER (data);
}
#endif
gst_wavpack_dec_setup_context (wavpackdec, GST_BUFFER_DATA (buf),
cbuf ? GST_BUFFER_DATA (cbuf) : NULL);
......@@ -393,9 +357,19 @@ gst_wavpack_dec_loop (GstElement * element)
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
gst_buffer_unref (buf);
if (cbuf) {
gst_buffer_unref (cbuf);
}
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (wavpackdec->srcpad));
if (GST_FLOW_OK != (ret = gst_pad_push (wavpackdec->srcpad, outbuf))) {
gst_buffer_unref (outbuf);
}
return ret;
gst_pad_push (wavpackdec->srcpad, GST_DATA (outbuf));
}
gboolean
......
......@@ -48,11 +48,14 @@ struct _GstWavpackDec
GstElement element;
GstPad *sinkpad, *srcpad;
#if 0
GstPad *wvcsinkpad;
#endif
WavpackContext *context;
int32_t *decodebuf;
guint decodebuf_size;
WavpackStream *stream;
......@@ -61,6 +64,10 @@ struct _GstWavpackDec
guint width;
long frame_length;
guint64 wvcflushed_bytes;
guint64 duration;
guint64 wvcduration;
guchar *decdata;
long *cache;
};
......
This diff is collapsed.
......@@ -23,7 +23,6 @@
#define __GST_WAVPACK_PARSE_H__
#include <gst/gst.h>
#include <gst/bytestream/bytestream.h>
G_BEGIN_DECLS
......@@ -48,17 +47,19 @@ struct _GstWavpackParse
GstPad *sinkpad, *srcpad;
GstByteStream* bs;
guint32 samplerate;
guint32 channels;
guint32 total_samples;
guint64 timestamp;
guint64 flushed_bytes;
guint64 duration;
guint64 seek_offset;
gboolean seek_pending;
gboolean need_discont;
gboolean need_flush;
gboolean eos;
};
struct _GstWavpackParseClass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment