diff --git a/Android.mk b/Android.mk index eb3b37491f..b3d345b78d 100644 --- a/Android.mk +++ b/Android.mk @@ -63,6 +63,7 @@ GST_PLUGINS_BASE_BUILT_SOURCES := \ gst/audiorate/Android.mk \ gst/volume/Android.mk \ tools/Android.mk \ + ext/vorbis/Android.mk \ ext/ogg/Android.mk GST_PLUGINS_BASE_BUILT_SOURCES := $(patsubst %, $(abspath $(GST_PLUGINS_BASE_TOP))/%, $(GST_PLUGINS_BASE_BUILT_SOURCES)) @@ -79,8 +80,10 @@ gst-plugins-base-configure: CPPFLAGS="$(CONFIGURE_CPPFLAGS)" \ PKG_CONFIG_LIBDIR="$(CONFIGURE_PKG_CONFIG_LIBDIR)" \ PKG_CONFIG_TOP_BUILD_DIR=/ \ + IVORBIS_CFLAGS="-I$(TOP)/external/tremolo -DTREMOR" \ + IVORBIS_LIBS="-lvorbisidec" \ $(abspath $(GST_PLUGINS_BASE_TOP))/$(CONFIGURE) --host=arm-linux-androideabi \ - --prefix=/system --disable-orc --disable-gio \ + --prefix=/system --disable-orc --disable-gio --enable-ivorbis \ --disable-valgrind --disable-gtk-doc && \ for file in $(GST_PLUGINS_BASE_BUILT_SOURCES); do \ rm -f $$file && \ @@ -118,4 +121,5 @@ CONFIGURE_TARGETS += gst-plugins-base-configure -include $(GST_PLUGINS_BASE_TOP)/gst/audiorate/Android.mk -include $(GST_PLUGINS_BASE_TOP)/gst/volume/Android.mk -include $(GST_PLUGINS_BASE_TOP)/ext/ogg/Android.mk +-include $(GST_PLUGINS_BASE_TOP)/ext/vorbis/Android.mk -include $(GST_PLUGINS_BASE_TOP)/tools/Android.mk diff --git a/configure.ac b/configure.ac index b91b4f485f..7b6a8ce244 100644 --- a/configure.ac +++ b/configure.ac @@ -715,6 +715,10 @@ AG_GST_CHECK_FEATURE(IVORBIS, [integer vorbis plug-in], ivorbisdec, [ HAVE_IVORBIS=no) AC_SUBST(IVORBIS_LIBS) AC_SUBST(IVORBIS_CFLAGS) + else + AC_CHECK_LIB(vorbisidec, vorbis_dsp_pcmout, + AC_DEFINE([USE_TREMOLO],1, "Define if building for android"), + USE_TREMOLO=no) fi ]) diff --git a/ext/vorbis/Makefile.am b/ext/vorbis/Makefile.am index fc285a8d7e..7c18ff1461 100644 --- a/ext/vorbis/Makefile.am +++ b/ext/vorbis/Makefile.am @@ -44,3 +44,17 @@ noinst_HEADERS = gstvorbisenc.h \ gstvorbistag.h \ gstvorbiscommon.h +Android.mk: Makefile.am $(BUILT_SOURCES) + androgenizer \ + -:PROJECT libgstivorbisdec -:SHARED libgstivorbisdec \ + -:TAGS eng debug \ + -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ + -:SOURCES $(libgstivorbisdec_la_SOURCES) \ + -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstivorbisdec_la_CFLAGS) \ + -:LDFLAGS $(libgstivorbisdec_la_LDFLAGS) \ + $(libgstivorbisdec_la_LIBADD) \ + -lvorbisidec \ + -ldl \ + -:PASSTHROUGH LOCAL_ARM_MODE:=arm \ + LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.10' \ + > $@ diff --git a/ext/vorbis/gstvorbisdec.c b/ext/vorbis/gstvorbisdec.c index ab6a0776d3..645c27d690 100644 --- a/ext/vorbis/gstvorbisdec.c +++ b/ext/vorbis/gstvorbisdec.c @@ -166,7 +166,10 @@ vorbis_dec_finalize (GObject * object) */ GstVorbisDec *vd = GST_VORBIS_DEC (object); +#ifndef USE_TREMOLO vorbis_block_clear (&vd->vb); +#endif + vorbis_dsp_clear (&vd->vd); vorbis_comment_clear (&vd->vc); vorbis_info_clear (&vd->vi); @@ -712,11 +715,16 @@ vorbis_handle_type_packet (GstVorbisDec * vd) g_assert (vd->initialized == FALSE); +#ifdef USE_TREMOLO + if (G_UNLIKELY ((res = vorbis_dsp_init (&vd->vd, &vd->vi)))) + goto synthesis_init_error; +#else if (G_UNLIKELY ((res = vorbis_synthesis_init (&vd->vd, &vd->vi)))) goto synthesis_init_error; if (G_UNLIKELY ((res = vorbis_block_init (&vd->vd, &vd->vb)))) goto block_init_error; +#endif vd->initialized = TRUE; @@ -760,7 +768,11 @@ vorbis_handle_header_packet (GstVorbisDec * vd, ogg_packet * packet) /* Packetno = 0 if the first byte is exactly 0x01 */ packet->b_o_s = ((gst_ogg_packet_data (packet))[0] == 0x1) ? 1 : 0; +#ifdef USE_TREMOLO + if ((ret = vorbis_dsp_headerin (&vd->vi, &vd->vc, packet))) +#else if ((ret = vorbis_synthesis_headerin (&vd->vi, &vd->vc, packet))) +#endif goto header_read_error; switch ((gst_ogg_packet_data (packet))[0]) { @@ -861,7 +873,11 @@ static GstFlowReturn vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet, GstClockTime timestamp, GstClockTime duration) { +#ifdef USE_TREMOLO + vorbis_sample_t *pcm; +#else vorbis_sample_t **pcm; +#endif guint sample_count; GstBuffer *out = NULL; GstFlowReturn result; @@ -876,17 +892,27 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet, * packet to decode the current one so we must be carefull not to * throw away too much. For now we decode everything and clip right * before pushing data. */ + +#ifdef USE_TREMOLO + if (G_UNLIKELY (vorbis_dsp_synthesis (&vd->vd, packet, 1))) + goto could_not_read; +#else if (G_UNLIKELY (vorbis_synthesis (&vd->vb, packet))) goto could_not_read; if (G_UNLIKELY (vorbis_synthesis_blockin (&vd->vd, &vd->vb) < 0)) goto not_accepted; +#endif /* assume all goes well here */ result = GST_FLOW_OK; /* count samples ready for reading */ +#ifdef USE_TREMOLO + if ((sample_count = vorbis_dsp_pcmout (&vd->vd, NULL, 0)) == 0) +#else if ((sample_count = vorbis_synthesis_pcmout (&vd->vd, NULL)) == 0) +#endif goto done; size = sample_count * vd->vi.channels * vd->width; @@ -901,12 +927,19 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet, goto done; /* get samples ready for reading now, should be sample_count */ +#ifdef USE_TREMOLO + pcm = GST_BUFFER_DATA (out); + if (G_UNLIKELY ((vorbis_dsp_pcmout (&vd->vd, pcm, sample_count)) != sample_count)) +#else if (G_UNLIKELY ((vorbis_synthesis_pcmout (&vd->vd, &pcm)) != sample_count)) +#endif goto wrong_samples; +#ifndef USE_TREMOLO /* copy samples in buffer */ vd->copy_samples ((vorbis_sample_t *) GST_BUFFER_DATA (out), pcm, sample_count, vd->vi.channels, vd->width); +#endif GST_LOG_OBJECT (vd, "setting output size to %d", size); GST_BUFFER_SIZE (out) = size; @@ -927,7 +960,12 @@ done: /* no output, still keep track of timestamps */ vorbis_do_timestamps (vd, NULL, FALSE, timestamp, duration); } + +#ifdef USE_TREMOLO + vorbis_dsp_read (&vd->vd, sample_count); +#else vorbis_synthesis_read (&vd->vd, sample_count); +#endif return result; @@ -1243,7 +1281,11 @@ vorbis_dec_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_PAUSED_TO_READY: GST_DEBUG_OBJECT (vd, "PAUSED -> READY, clearing vorbis structures"); vd->initialized = FALSE; + +#ifndef USE_TREMOLO vorbis_block_clear (&vd->vb); +#endif + vorbis_dsp_clear (&vd->vd); vorbis_comment_clear (&vd->vc); vorbis_info_clear (&vd->vi); diff --git a/ext/vorbis/gstvorbisdec.h b/ext/vorbis/gstvorbisdec.h index 0f4b3dd274..04e4677410 100644 --- a/ext/vorbis/gstvorbisdec.h +++ b/ext/vorbis/gstvorbisdec.h @@ -22,6 +22,9 @@ #ifndef __GST_VORBIS_DEC_H__ #define __GST_VORBIS_DEC_H__ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include #include "gstvorbisdeclib.h" @@ -56,7 +59,10 @@ struct _GstVorbisDec { vorbis_dsp_state vd; vorbis_info vi; vorbis_comment vc; + +#ifndef USE_TREMOLO vorbis_block vb; +#endif gboolean initialized; guint width; diff --git a/ext/vorbis/gstvorbisdeclib.h b/ext/vorbis/gstvorbisdeclib.h index c82f0c84ba..ca00af9db8 100644 --- a/ext/vorbis/gstvorbisdeclib.h +++ b/ext/vorbis/gstvorbisdeclib.h @@ -74,9 +74,15 @@ gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet) #else -#include +#ifdef USE_TREMOLO + #include + #include + typedef ogg_int16_t vorbis_sample_t; +#else + #include + typedef ogg_int32_t vorbis_sample_t; +#endif -typedef ogg_int32_t vorbis_sample_t; typedef struct _ogg_packet_wrapper ogg_packet_wrapper; struct _ogg_packet_wrapper {