Rename files and types from speexresample to audioresample

Rename files and types from speexresample to audioresample
to finish the move and to prevent any confusion.
This commit is contained in:
Sebastian Dröge 2009-01-23 12:31:06 +01:00
parent e327bbcd7d
commit 5dfcb63252
73 changed files with 2774 additions and 6090 deletions

View file

@ -305,7 +305,7 @@ AG_GST_CHECK_PLUGIN(audiotestsrc)
AG_GST_CHECK_PLUGIN(ffmpegcolorspace)
AG_GST_CHECK_PLUGIN(gdp)
AG_GST_CHECK_PLUGIN(playback)
AG_GST_CHECK_PLUGIN(speexresample)
AG_GST_CHECK_PLUGIN(audioresample)
AG_GST_CHECK_PLUGIN(subparse)
AG_GST_CHECK_PLUGIN(tcp)
AG_GST_CHECK_PLUGIN(typefind)
@ -690,7 +690,7 @@ gst/audiotestsrc/Makefile
gst/ffmpegcolorspace/Makefile
gst/gdp/Makefile
gst/playback/Makefile
gst/speexresample/Makefile
gst/audioresample/Makefile
gst/subparse/Makefile
gst/tcp/Makefile
gst/typefind/Makefile

View file

@ -106,7 +106,7 @@ EXTRA_HFILES = \
$(top_srcdir)/gst/gdp/gstgdpdepay.h \
$(top_srcdir)/gst/gdp/gstgdppay.h \
$(top_srcdir)/gst/playback/gstplay-enum.h \
$(top_srcdir)/gst/speexresample/gstspeexresample.h \
$(top_srcdir)/gst/audioresample/gstaudioresample.h \
$(top_srcdir)/gst/tcp/gstmultifdsink.h \
$(top_srcdir)/gst/tcp/gsttcpclientsrc.h \
$(top_srcdir)/gst/tcp/gsttcpclientsink.h \

View file

@ -107,15 +107,15 @@ audio_convert_prepare_context
<SECTION>
<FILE>element-audioresample</FILE>
<TITLE>audioresample</TITLE>
GstSpeexResample
GstAudioResample
<SUBSECTION Standard>
GST_SPEEX_RESAMPLE
GST_IS_SPEEX_RESAMPLE
GST_TYPE_SPEEX_RESAMPLE
gst_speex_resample_get_type
GST_SPEEX_RESAMPLE_CLASS
GST_IS_SPEEX_RESAMPLE_CLASS
GstSpeexResampleClass
GST_AUDIO_RESAMPLE
GST_IS_AUDIO_RESAMPLE
GST_TYPE_AUDIO_RESAMPLE
gst_audio_resample_get_type
GST_AUDIO_RESAMPLE_CLASS
GST_IS_AUDIO_RESAMPLE_CLASS
GstAudioResampleClass
</SECTION>
<SECTION>

View file

@ -641,7 +641,7 @@
<ARG>
<NAME>GstMultiFdSink::buffers-max</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Buffers max</NICK>
<BLURB>max number of buffers to queue for a client (-1 = no limit).</BLURB>
@ -661,7 +661,7 @@
<ARG>
<NAME>GstMultiFdSink::buffers-soft-max</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Buffers soft max</NICK>
<BLURB>Recover client when going over this limit (-1 = no limit).</BLURB>
@ -751,7 +751,7 @@
<ARG>
<NAME>GstMultiFdSink::buffers-min</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Buffers min</NICK>
<BLURB>min number of buffers to queue (-1 = as few as possible).</BLURB>
@ -781,7 +781,7 @@
<ARG>
<NAME>GstMultiFdSink::bytes-min</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Bytes min</NICK>
<BLURB>min number of bytes to queue (-1 = as little as possible).</BLURB>
@ -791,7 +791,7 @@
<ARG>
<NAME>GstMultiFdSink::time-min</NAME>
<TYPE>gint64</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Time min</NICK>
<BLURB>min number of time to queue (-1 = as little as possible).</BLURB>
@ -811,7 +811,7 @@
<ARG>
<NAME>GstMultiFdSink::units-max</NAME>
<TYPE>gint64</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Units max</NICK>
<BLURB>max number of units to queue (-1 = no limit).</BLURB>
@ -821,7 +821,7 @@
<ARG>
<NAME>GstMultiFdSink::units-soft-max</NAME>
<TYPE>gint64</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Units soft max</NICK>
<BLURB>Recover client when going over this limit (-1 = no limit).</BLURB>
@ -831,7 +831,7 @@
<ARG>
<NAME>GstMultiFdSink::qos-dscp</NAME>
<TYPE>gint</TYPE>
<RANGE>[-1,63]</RANGE>
<RANGE>[G_MAXULONG,63]</RANGE>
<FLAGS>rw</FLAGS>
<NICK>QoS diff srv code point</NICK>
<BLURB>Quality of Service, differentiated services code point (-1 default).</BLURB>
@ -981,7 +981,7 @@
<ARG>
<NAME>GstVorbisEnc::bitrate</NAME>
<TYPE>gint</TYPE>
<RANGE>[-1,250001]</RANGE>
<RANGE>[G_MAXULONG,250001]</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Target Bitrate</NICK>
<BLURB>Attempt to encode at a bitrate averaging this (in bps). This uses the bitrate management engine, and is not recommended for most users. Quality is a better alternative. (-1 == disabled).</BLURB>
@ -1011,7 +1011,7 @@
<ARG>
<NAME>GstVorbisEnc::max-bitrate</NAME>
<TYPE>gint</TYPE>
<RANGE>[-1,250001]</RANGE>
<RANGE>[G_MAXULONG,250001]</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Maximum Bitrate</NICK>
<BLURB>Specify a maximum bitrate (in bps). Useful for streaming applications. (-1 == disabled).</BLURB>
@ -1021,7 +1021,7 @@
<ARG>
<NAME>GstVorbisEnc::min-bitrate</NAME>
<TYPE>gint</TYPE>
<RANGE>[-1,250001]</RANGE>
<RANGE>[G_MAXULONG,250001]</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Minimum Bitrate</NICK>
<BLURB>Specify a minimum bitrate (in bps). Useful for encoding for a fixed-size channel. (-1 == disabled).</BLURB>
@ -1861,7 +1861,7 @@
<ARG>
<NAME>GstCdParanoiaSrc::read-speed</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Read speed</NICK>
<BLURB>Read from device at specified speed.</BLURB>
@ -1871,7 +1871,7 @@
<ARG>
<NAME>GstCdParanoiaSrc::search-overlap</NAME>
<TYPE>gint</TYPE>
<RANGE>[-1,75]</RANGE>
<RANGE>[G_MAXULONG,75]</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Search overlap</NICK>
<BLURB>Force minimum overlap search during verification to n sectors.</BLURB>
@ -2011,7 +2011,7 @@
<ARG>
<NAME>GstURIDecodeBin::buffer-duration</NAME>
<TYPE>gint64</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Buffer duration (ns)</NICK>
<BLURB>Buffer duration when buffering network streams.</BLURB>
@ -2021,7 +2021,7 @@
<ARG>
<NAME>GstURIDecodeBin::buffer-size</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Buffer size (bytes)</NICK>
<BLURB>Buffer size when buffering network streams.</BLURB>
@ -2181,7 +2181,7 @@
<ARG>
<NAME>GstPlayBin2::current-audio</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Current audio</NICK>
<BLURB>Currently playing audio stream (-1 = auto).</BLURB>
@ -2191,7 +2191,7 @@
<ARG>
<NAME>GstPlayBin2::current-text</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Current Text</NICK>
<BLURB>Currently playing text stream (-1 = auto).</BLURB>
@ -2201,7 +2201,7 @@
<ARG>
<NAME>GstPlayBin2::current-video</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Current Video</NICK>
<BLURB>Currently playing video stream (-1 = auto).</BLURB>
@ -2361,7 +2361,7 @@
<ARG>
<NAME>GstPlayBin2::buffer-duration</NAME>
<TYPE>gint64</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Buffer duration (ns)</NICK>
<BLURB>Buffer duration when buffering network streams.</BLURB>
@ -2371,7 +2371,7 @@
<ARG>
<NAME>GstPlayBin2::buffer-size</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Buffer size (bytes)</NICK>
<BLURB>Buffer size when buffering network streams.</BLURB>
@ -2711,7 +2711,7 @@
<ARG>
<NAME>GstAppSrc::max-latency</NAME>
<TYPE>gint64</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Max Latency</NICK>
<BLURB>The maximum latency (-1 = unlimited).</BLURB>
@ -2721,7 +2721,7 @@
<ARG>
<NAME>GstAppSrc::min-latency</NAME>
<TYPE>gint64</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Min Latency</NICK>
<BLURB>The minimum latency (-1 = default).</BLURB>
@ -2731,7 +2731,7 @@
<ARG>
<NAME>GstAppSrc::size</NAME>
<TYPE>gint64</TYPE>
<RANGE>>= -1</RANGE>
<RANGE>>= G_MAXULONG</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Size</NICK>
<BLURB>The size of the data stream in bytes (-1 if unknown).</BLURB>
@ -2748,3 +2748,23 @@
<DEFAULT>Stream</DEFAULT>
</ARG>
<ARG>
<NAME>GstAudioResample::filter-length</NAME>
<TYPE>gint</TYPE>
<RANGE>>= 0</RANGE>
<FLAGS>rwx</FLAGS>
<NICK>Filter length</NICK>
<BLURB>DEPRECATED, DON'T USE THIS! Length of the resample filter.</BLURB>
<DEFAULT>64</DEFAULT>
</ARG>
<ARG>
<NAME>GstAudioResample::quality</NAME>
<TYPE>gint</TYPE>
<RANGE>[0,10]</RANGE>
<FLAGS>rwx</FLAGS>
<NICK>Quality</NICK>
<BLURB>Resample quality with 0 being the lowest and 10 being the best.</BLURB>
<DEFAULT>4</DEFAULT>
</ARG>

View file

@ -12,28 +12,9 @@ GObject
GstPlayBaseBin
GstPlayBin
GstPlayBin2
GstDecodeBin
GstDecodeBin2
GstURIDecodeBin
GstDecodeBin
GstBaseSrc
GstPushSrc
GstCddaBaseSrc
GstCdParanoiaSrc
GstBaseAudioSrc
GstAudioSrc
GstAlsaSrc
GstV4lElement
GstV4lSrc
GstTCPClientSrc
GstTCPServerSrc
GstVideoTestSrc
GstGnomeVFSSrc
GstAppSrc
GstAudioTestSrc
GstVorbisEnc
GstVorbisDec
GstVorbisParse
GstVorbisTag
GstOggDemux
GstOggMux
GstOgmParse
@ -43,49 +24,74 @@ GObject
GstOggParse
GstOggAviParse
GstBaseSink
GstGnomeVFSSink
GstGioBaseSink
GstGioSink
GstGioStreamSink
GstBaseAudioSink
GstAudioSink
GstAlsaSink
GstGnomeVFSSink
GstVideoSink
GstXvImageSink
GstXImageSink
GstAppSink
GstTCPClientSink
GstMultiFdSink
GstTCPServerSink
GstAppSink
GstVisual
GstVisualbumpscope
GstVisualcorona
GstVisualinfinite
GstVisualjakdaw
GstVisualjess
GstVisuallv_analyzer
GstVisuallv_scope
GstVisualoinksie
GstTheoraDec
GstTheoraEnc
GstTheoraParse
GstBaseSrc
GstGioBaseSrc
GstGioSrc
GstGioStreamSrc
GstPushSrc
GstBaseAudioSrc
GstAudioSrc
GstAlsaSrc
GstCddaBaseSrc
GstCdParanoiaSrc
GstV4lElement
GstV4lSrc
GstTCPClientSrc
GstTCPServerSrc
GstVideoTestSrc
GstGnomeVFSSrc
GstAudioTestSrc
GstAppSrc
GstVorbisEnc
GstVorbisDec
GstVorbisParse
GstVorbisTag
GstTextOverlay
GstTimeOverlay
GstClockOverlay
GstTextRender
GstTheoraDec
GstTheoraEnc
GstTheoraParse
GstAlsaMixerElement
GstGDPDepay
GstGDPPay
GstBaseTransform
GstFFMpegCsp
GstVideoScale
GstAudioFilter
GstVolume
GstSpeexResample
GstAudioConvert
GstVisual
GstVisualjess
GstVisualbumpscope
GstVisualcorona
GstVisualinfinite
GstVisualjakdaw
GstVisuallv_analyzer
GstVisuallv_scope
GstVisualoinksie
GstSubParse
GstSsaParse
GstAudioRate
GstBaseTransform
GstAudioConvert
GstFFMpegCsp
GstAudioFilter
GstVolume
GstAudioResample
GstVideoScale
GstAdder
GstGDPDepay
GstGDPPay
GstStreamSelector
GstQueue2
GstAudioRate
GstVideoRate
GstBus
GstTask
@ -96,26 +102,62 @@ GObject
GstRegistry
GstRingBuffer
GstSignalObject
GConfClient
GFileMonitor
GLocalDirectoryMonitor
GFamDirectoryMonitor
GInotifyDirectoryMonitor
GLocalFileMonitor
GFamFileMonitor
GInotifyFileMonitor
GVolumeMonitor
GNativeVolumeMonitor
GProxyVolumeMonitor
GProxyVolumeMonitorHal
GProxyVolumeMonitorGPhoto2
GUnixVolumeMonitor
GDaemonVolumeMonitor
GVfs
GDaemonVfs
GLocalVfs
GTypeModule
GIOModule
GVfsUriMapper
GVfsUriMapperSmb
GVfsUriMapperHttp
GAppLookupGConf
GProxyDrive
GProxyMount
GProxyVolume
GOutputStream
GInputStream
PangoFontMap
PangoFcFontMap
PangoFT2FontMap
PangoContext
GstMixerTrack
GstMixerOptions
LinkConnection
GIOPConnection
LinkServer
GIOPServer
GConfClient
GstColorBalanceChannel
GstTunerNorm
GstTunerChannel
GstColorBalanceChannel
GstMixerTrack
GstStreamInfo
GInterface
GTypePlugin
GstChildProxy
GstURIHandler
GFile
GDesktopAppInfoLookup
GDrive
GMount
GVolume
GstTagSetter
GstImplementsInterface
GstMixer
GstPropertyProbe
GstTuner
GstNavigation
GstXOverlay
GstColorBalance
GstNavigation
GstTuner

View file

@ -3,21 +3,29 @@ GstPipeline GstChildProxy
GstPlayBaseBin GstChildProxy
GstPlayBin GstChildProxy
GstPlayBin2 GstChildProxy
GstDecodeBin GstChildProxy
GstDecodeBin2 GstChildProxy
GstURIDecodeBin GstChildProxy
GstDecodeBin GstChildProxy
GstGioSink GstURIHandler
GstAlsaSink GstPropertyProbe
GstGnomeVFSSink GstURIHandler
GstXvImageSink GstImplementsInterface GstPropertyProbe GstNavigation GstXOverlay GstColorBalance
GstXImageSink GstImplementsInterface GstNavigation GstXOverlay
GstGioSrc GstURIHandler
GstAlsaSrc GstImplementsInterface GstMixer GstPropertyProbe
GstCddaBaseSrc GstURIHandler
GstCdParanoiaSrc GstURIHandler
GstAlsaSrc GstImplementsInterface GstMixer GstPropertyProbe
GstV4lElement GstImplementsInterface GstPropertyProbe GstTuner GstXOverlay GstColorBalance
GstV4lSrc GstImplementsInterface GstPropertyProbe GstTuner GstXOverlay GstColorBalance
GstV4lElement GstImplementsInterface GstPropertyProbe GstXOverlay GstColorBalance GstTuner
GstV4lSrc GstImplementsInterface GstPropertyProbe GstXOverlay GstColorBalance GstTuner
GstGnomeVFSSrc GstURIHandler
GstAppSrc GstURIHandler
GstVorbisEnc GstTagSetter
GstVorbisTag GstTagSetter
GstGnomeVFSSink GstURIHandler
GstAlsaSink GstPropertyProbe
GstXvImageSink GstImplementsInterface GstPropertyProbe GstXOverlay GstColorBalance GstNavigation
GstXImageSink GstImplementsInterface GstXOverlay GstNavigation
GstAlsaMixerElement GstImplementsInterface GstMixer GstPropertyProbe
GstVolume GstImplementsInterface GstMixer
GTypeModule GTypePlugin
GIOModule GTypePlugin
GAppLookupGConf GDesktopAppInfoLookup
GProxyDrive GDrive
GProxyMount GMount
GProxyVolume GVolume

View file

@ -1,7 +1,12 @@
GstChildProxy GstObject
GFile GObject
GDesktopAppInfoLookup GObject
GDrive GObject
GMount GObject
GVolume GObject
GstTagSetter GstObject GstElement
GstImplementsInterface GstObject GstElement
GstMixer GstObject GstImplementsInterface GstElement
GstTuner GstObject GstImplementsInterface GstElement
GstXOverlay GstObject GstImplementsInterface GstElement
GstColorBalance GstObject GstImplementsInterface GstElement
GstTuner GstObject GstImplementsInterface GstElement

View file

@ -3,10 +3,10 @@
<description>Adds multiple streams</description>
<filename>../../gst/adder/.libs/libgstadder.so</filename>
<basename>libgstadder.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>ALSA plugin library</description>
<filename>../../ext/alsa/.libs/libgstalsa.so</filename>
<basename>libgstalsa.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Elements used to communicate with applications</description>
<filename>../../gst/app/.libs/libgstapp.so</filename>
<basename>libgstapp.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Convert audio to different formats</description>
<filename>../../gst/audioconvert/.libs/libgstaudioconvert.so</filename>
<basename>libgstaudioconvert.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Adjusts audio frames</description>
<filename>../../gst/audiorate/.libs/libgstaudiorate.so</filename>
<basename>libgstaudiorate.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -1,12 +1,12 @@
<plugin>
<name>audioresample</name>
<description>Resamples audio</description>
<filename>../../gst/speexresample/.libs/libgstaudioresample.so</filename>
<filename>../../gst/audioresample/.libs/libgstaudioresample.so</filename>
<basename>libgstaudioresample.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Creates audio test signals of given frequency and volume</description>
<filename>../../gst/audiotestsrc/.libs/libgstaudiotestsrc.so</filename>
<basename>libgstaudiotestsrc.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Read audio from CD in paranoid mode</description>
<filename>../../ext/cdparanoia/.libs/libgstcdparanoia.so</filename>
<basename>libgstcdparanoia.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>GPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>decoder bin</description>
<filename>../../gst/playback/.libs/libgstdecodebin.so</filename>
<basename>libgstdecodebin.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,7 +3,7 @@
<description>colorspace conversion copied from FFMpeg 0.4.9-pre1</description>
<filename>../../gst/ffmpegcolorspace/.libs/libgstffmpegcolorspace.so</filename>
<basename>libgstffmpegcolorspace.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>FFMpeg</package>

View file

@ -3,10 +3,10 @@
<description>Payload/depayload GDP packets</description>
<filename>../../gst/gdp/.libs/libgstgdp.so</filename>
<basename>libgstgdp.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,7 +3,7 @@
<description>GIO elements</description>
<filename>../../ext/gio/.libs/libgstgio.so</filename>
<basename>libgstgio.so</basename>
<version>0.10.21.1</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins CVS/prerelease</package>

View file

@ -3,10 +3,10 @@
<description>elements to read from and write to Gnome-VFS uri's</description>
<filename>../../ext/gnomevfs/.libs/libgstgnomevfs.so</filename>
<basename>libgstgnomevfs.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>libvisual visualization plugins</description>
<filename>../../ext/libvisual/.libs/libgstlibvisual.so</filename>
<basename>libgstlibvisual.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>ogg stream manipulation (info about ogg: http://xiph.org)</description>
<filename>../../ext/ogg/.libs/libgstogg.so</filename>
<basename>libgstogg.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Pango-based text rendering and overlay</description>
<filename>../../ext/pango/.libs/libgstpango.so</filename>
<basename>libgstpango.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>various playback elements</description>
<filename>../../gst/playback/.libs/libgstplaybin.so</filename>
<basename>libgstplaybin.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Queue newer version</description>
<filename>../../gst/playback/.libs/libgstqueue2.so</filename>
<basename>libgstqueue2.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Subtitle parsing</description>
<filename>../../gst/subparse/.libs/libgstsubparse.so</filename>
<basename>libgstsubparse.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>transfer data over the network via TCP</description>
<filename>../../gst/tcp/.libs/libgsttcp.so</filename>
<basename>libgsttcp.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Theora plugin library</description>
<filename>../../ext/theora/.libs/libgsttheora.so</filename>
<basename>libgsttheora.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>default typefind functions</description>
<filename>../../gst/typefind/.libs/libgsttypefindfunctions.so</filename>
<basename>libgsttypefindfunctions.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>

View file

@ -3,10 +3,10 @@
<description>URI Decoder bin</description>
<filename>../../gst/playback/.libs/libgstdecodebin2.so</filename>
<basename>libgstdecodebin2.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>elements for Video 4 Linux</description>
<filename>../../sys/v4l/.libs/libgstvideo4linux.so</filename>
<basename>libgstvideo4linux.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Adjusts video frames</description>
<filename>../../gst/videorate/.libs/libgstvideorate.so</filename>
<basename>libgstvideorate.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Resizes video</description>
<filename>../../gst/videoscale/.libs/libgstvideoscale.so</filename>
<basename>libgstvideoscale.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Creates a test video stream</description>
<filename>../../gst/videotestsrc/.libs/libgstvideotestsrc.so</filename>
<basename>libgstvideotestsrc.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>plugin for controlling audio volume</description>
<filename>../../gst/volume/.libs/libgstvolume.so</filename>
<basename>libgstvolume.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>Vorbis plugin library</description>
<filename>../../ext/vorbis/.libs/libgstvorbis.so</filename>
<basename>libgstvorbis.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>X11 video output element based on standard Xlib calls</description>
<filename>../../sys/ximage/.libs/libgstximagesink.so</filename>
<basename>libgstximagesink.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -3,10 +3,10 @@
<description>XFree86 video output plugin using Xv extension</description>
<filename>../../sys/xvimage/.libs/libgstxvimagesink.so</filename>
<basename>libgstxvimagesink.so</basename>
<version>0.10.22</version>
<version>0.10.22.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins source release</package>
<package>GStreamer Base Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>

View file

@ -1,21 +1,37 @@
plugin_LTLIBRARIES = libgstaudioresample.la
resample_SOURCES = \
functable.c \
resample.c \
resample_functable.c \
resample_ref.c \
resample_chunk.c \
resample.h \
buffer.c
libgstaudioresample_la_SOURCES = \
gstaudioresample.c \
speex_resampler_int.c \
speex_resampler_float.c \
speex_resampler_double.c
libgstaudioresample_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_CFLAGS) \
$(LIBOIL_CFLAGS)
libgstaudioresample_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) \
$(GST_BASE_LIBS) \
$(GST_LIBS) \
$(LIBOIL_LIBS) \
$(LIBM)
libgstaudioresample_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstaudioresample_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = \
arch.h \
fixed_arm4.h \
fixed_arm5e.h \
fixed_bfin.h \
fixed_debug.h \
fixed_generic.h \
gstaudioresample.h \
functable.h \
debug.h \
buffer.h
resample.c \
resample_sse.h \
speex_resampler.h \
speex_resampler_wrapper.h
libgstaudioresample_la_SOURCES = gstaudioresample.c $(resample_SOURCES)
libgstaudioresample_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(LIBOIL_CFLAGS)
libgstaudioresample_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(LIBOIL_LIBS)
libgstaudioresample_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)

View file

@ -1,253 +0,0 @@
#ifndef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib.h>
#include <string.h>
#include "buffer.h"
#include "debug.h"
static void audioresample_buffer_free_mem (AudioresampleBuffer * buffer,
void *);
static void audioresample_buffer_free_subbuffer (AudioresampleBuffer * buffer,
void *priv);
AudioresampleBuffer *
audioresample_buffer_new (void)
{
AudioresampleBuffer *buffer;
buffer = g_new0 (AudioresampleBuffer, 1);
buffer->ref_count = 1;
return buffer;
}
AudioresampleBuffer *
audioresample_buffer_new_and_alloc (int size)
{
AudioresampleBuffer *buffer = audioresample_buffer_new ();
buffer->data = g_malloc (size);
buffer->length = size;
buffer->free = audioresample_buffer_free_mem;
return buffer;
}
AudioresampleBuffer *
audioresample_buffer_new_with_data (void *data, int size)
{
AudioresampleBuffer *buffer = audioresample_buffer_new ();
buffer->data = data;
buffer->length = size;
buffer->free = audioresample_buffer_free_mem;
return buffer;
}
AudioresampleBuffer *
audioresample_buffer_new_subbuffer (AudioresampleBuffer * buffer, int offset,
int length)
{
AudioresampleBuffer *subbuffer = audioresample_buffer_new ();
if (buffer->parent) {
audioresample_buffer_ref (buffer->parent);
subbuffer->parent = buffer->parent;
} else {
audioresample_buffer_ref (buffer);
subbuffer->parent = buffer;
}
subbuffer->data = buffer->data + offset;
subbuffer->length = length;
subbuffer->free = audioresample_buffer_free_subbuffer;
return subbuffer;
}
void
audioresample_buffer_ref (AudioresampleBuffer * buffer)
{
buffer->ref_count++;
}
void
audioresample_buffer_unref (AudioresampleBuffer * buffer)
{
buffer->ref_count--;
if (buffer->ref_count == 0) {
if (buffer->free)
buffer->free (buffer, buffer->priv);
g_free (buffer);
}
}
static void
audioresample_buffer_free_mem (AudioresampleBuffer * buffer, void *priv)
{
g_free (buffer->data);
}
static void
audioresample_buffer_free_subbuffer (AudioresampleBuffer * buffer, void *priv)
{
audioresample_buffer_unref (buffer->parent);
}
AudioresampleBufferQueue *
audioresample_buffer_queue_new (void)
{
return g_new0 (AudioresampleBufferQueue, 1);
}
int
audioresample_buffer_queue_get_depth (AudioresampleBufferQueue * queue)
{
return queue->depth;
}
int
audioresample_buffer_queue_get_offset (AudioresampleBufferQueue * queue)
{
return queue->offset;
}
void
audioresample_buffer_queue_free (AudioresampleBufferQueue * queue)
{
GList *g;
for (g = g_list_first (queue->buffers); g; g = g_list_next (g)) {
audioresample_buffer_unref ((AudioresampleBuffer *) g->data);
}
g_list_free (queue->buffers);
g_free (queue);
}
void
audioresample_buffer_queue_push (AudioresampleBufferQueue * queue,
AudioresampleBuffer * buffer)
{
queue->buffers = g_list_append (queue->buffers, buffer);
queue->depth += buffer->length;
}
AudioresampleBuffer *
audioresample_buffer_queue_pull (AudioresampleBufferQueue * queue, int length)
{
GList *g;
AudioresampleBuffer *newbuffer;
AudioresampleBuffer *buffer;
AudioresampleBuffer *subbuffer;
g_return_val_if_fail (length > 0, NULL);
if (queue->depth < length) {
return NULL;
}
RESAMPLE_LOG ("pulling %d, %d available", length, queue->depth);
g = g_list_first (queue->buffers);
buffer = g->data;
if (buffer->length > length) {
newbuffer = audioresample_buffer_new_subbuffer (buffer, 0, length);
subbuffer = audioresample_buffer_new_subbuffer (buffer, length,
buffer->length - length);
g->data = subbuffer;
audioresample_buffer_unref (buffer);
} else {
int offset = 0;
newbuffer = audioresample_buffer_new_and_alloc (length);
while (offset < length) {
g = g_list_first (queue->buffers);
buffer = g->data;
if (buffer->length > length - offset) {
int n = length - offset;
memcpy (newbuffer->data + offset, buffer->data, n);
subbuffer =
audioresample_buffer_new_subbuffer (buffer, n, buffer->length - n);
g->data = subbuffer;
audioresample_buffer_unref (buffer);
offset += n;
} else {
memcpy (newbuffer->data + offset, buffer->data, buffer->length);
queue->buffers = g_list_delete_link (queue->buffers, g);
offset += buffer->length;
audioresample_buffer_unref (buffer);
}
}
}
queue->depth -= length;
queue->offset += length;
return newbuffer;
}
AudioresampleBuffer *
audioresample_buffer_queue_peek (AudioresampleBufferQueue * queue, int length)
{
GList *g;
AudioresampleBuffer *newbuffer;
AudioresampleBuffer *buffer;
int offset = 0;
g_return_val_if_fail (length > 0, NULL);
if (queue->depth < length) {
return NULL;
}
RESAMPLE_LOG ("peeking %d, %d available", length, queue->depth);
g = g_list_first (queue->buffers);
buffer = g->data;
if (buffer->length > length) {
newbuffer = audioresample_buffer_new_subbuffer (buffer, 0, length);
} else {
newbuffer = audioresample_buffer_new_and_alloc (length);
while (offset < length) {
buffer = g->data;
if (buffer->length > length - offset) {
int n = length - offset;
memcpy (newbuffer->data + offset, buffer->data, n);
offset += n;
} else {
memcpy (newbuffer->data + offset, buffer->data, buffer->length);
offset += buffer->length;
}
g = g_list_next (g);
}
}
return newbuffer;
}
void
audioresample_buffer_queue_flush (AudioresampleBufferQueue * queue)
{
GList *g;
for (g = g_list_first (queue->buffers); g; g = g_list_next (g)) {
audioresample_buffer_unref ((AudioresampleBuffer *) g->data);
}
g_list_free (queue->buffers);
queue->buffers = NULL;
queue->depth = 0;
queue->offset = 0;
}

View file

@ -1,51 +0,0 @@
#ifndef __AUDIORESAMPLE_BUFFER_H__
#define __AUDIORESAMPLE_BUFFER_H__
#include <glib.h>
typedef struct _AudioresampleBuffer AudioresampleBuffer;
typedef struct _AudioresampleBufferQueue AudioresampleBufferQueue;
struct _AudioresampleBuffer
{
unsigned char *data;
int length;
int ref_count;
AudioresampleBuffer *parent;
void (*free) (AudioresampleBuffer *, void *);
void *priv;
void *priv2;
};
struct _AudioresampleBufferQueue
{
GList *buffers;
int depth;
int offset;
};
AudioresampleBuffer * audioresample_buffer_new (void);
AudioresampleBuffer * audioresample_buffer_new_and_alloc (int size);
AudioresampleBuffer * audioresample_buffer_new_with_data (void *data, int size);
AudioresampleBuffer * audioresample_buffer_new_subbuffer (AudioresampleBuffer * buffer,
int offset,
int length);
void audioresample_buffer_ref (AudioresampleBuffer * buffer);
void audioresample_buffer_unref (AudioresampleBuffer * buffer);
AudioresampleBufferQueue *
audioresample_buffer_queue_new (void);
void audioresample_buffer_queue_free (AudioresampleBufferQueue * queue);
int audioresample_buffer_queue_get_depth (AudioresampleBufferQueue * queue);
int audioresample_buffer_queue_get_offset (AudioresampleBufferQueue * queue);
void audioresample_buffer_queue_push (AudioresampleBufferQueue * queue,
AudioresampleBuffer * buffer);
AudioresampleBuffer * audioresample_buffer_queue_pull (AudioresampleBufferQueue * queue, int len);
AudioresampleBuffer * audioresample_buffer_queue_peek (AudioresampleBufferQueue * queue, int len);
void audioresample_buffer_queue_flush (AudioresampleBufferQueue * queue);
#endif

View file

@ -1,65 +0,0 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib.h>
#include <stdio.h>
#include <debug.h>
static const char *resample_debug_level_names[] = {
"NONE",
"ERROR",
"WARNING",
"INFO",
"DEBUG",
"LOG"
};
static int resample_debug_level = RESAMPLE_LEVEL_ERROR;
void
resample_debug_log (int level, const char *file, const char *function,
int line, const char *format, ...)
{
#ifndef GLIB_COMPAT
va_list varargs;
char *s;
if (level > resample_debug_level)
return;
va_start (varargs, format);
s = g_strdup_vprintf (format, varargs);
va_end (varargs);
fprintf (stderr, "RESAMPLE: %s: %s(%d): %s: %s\n",
resample_debug_level_names[level], file, line, function, s);
g_free (s);
#else
va_list varargs;
char s[1000];
if (level > resample_debug_level)
return;
va_start (varargs, format);
vsnprintf (s, 999, format, varargs);
va_end (varargs);
fprintf (stderr, "RESAMPLE: %s: %s(%d): %s: %s\n",
resample_debug_level_names[level], file, line, function, s);
#endif
}
void
resample_debug_set_level (int level)
{
resample_debug_level = level;
}
int
resample_debug_get_level (void)
{
return resample_debug_level;
}

View file

@ -1,51 +0,0 @@
#ifndef __RESAMPLE_DEBUG_H__
#define __RESAMPLE_DEBUG_H__
#if 0
enum
{
RESAMPLE_LEVEL_NONE = 0,
RESAMPLE_LEVEL_ERROR,
RESAMPLE_LEVEL_WARNING,
RESAMPLE_LEVEL_INFO,
RESAMPLE_LEVEL_DEBUG,
RESAMPLE_LEVEL_LOG
};
#define RESAMPLE_ERROR(...) \
RESAMPLE_DEBUG_LEVEL(RESAMPLE_LEVEL_ERROR, __VA_ARGS__)
#define RESAMPLE_WARNING(...) \
RESAMPLE_DEBUG_LEVEL(RESAMPLE_LEVEL_WARNING, __VA_ARGS__)
#define RESAMPLE_INFO(...) \
RESAMPLE_DEBUG_LEVEL(RESAMPLE_LEVEL_INFO, __VA_ARGS__)
#define RESAMPLE_DEBUG(...) \
RESAMPLE_DEBUG_LEVEL(RESAMPLE_LEVEL_DEBUG, __VA_ARGS__)
#define RESAMPLE_LOG(...) \
RESAMPLE_DEBUG_LEVEL(RESAMPLE_LEVEL_LOG, __VA_ARGS__)
#define RESAMPLE_DEBUG_LEVEL(level,...) \
resample_debug_log ((level), __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
void resample_debug_log (int level, const char *file, const char *function,
int line, const char *format, ...);
void resample_debug_set_level (int level);
int resample_debug_get_level (void);
#else
#include <gst/gst.h>
GST_DEBUG_CATEGORY_EXTERN (libaudioresample_debug);
#define GST_CAT_DEFAULT libaudioresample_debug
#define RESAMPLE_ERROR GST_ERROR
#define RESAMPLE_WARNING GST_WARNING
#define RESAMPLE_INFO GST_INFO
#define RESAMPLE_DEBUG GST_DEBUG
#define RESAMPLE_LOG GST_LOG
#define resample_debug_set_level(x) do { } while (0)
#endif
#endif

View file

@ -1,254 +0,0 @@
/* Resampling library
* Copyright (C) <2001> David A. Schleef <ds@schleef.org>
*
* 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 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "functable.h"
#include "debug.h"
void
functable_func_sinc (double *fx, double *dfx, double x, void *closure)
{
if (x == 0) {
*fx = 1;
*dfx = 0;
return;
}
*fx = sin (x) / x;
*dfx = (cos (x) - sin (x) / x) / x;
}
void
functable_func_boxcar (double *fx, double *dfx, double x, void *closure)
{
double width = *(double *) closure;
if (x < width && x > -width) {
*fx = 1;
} else {
*fx = 0;
}
*dfx = 0;
}
void
functable_func_hanning (double *fx, double *dfx, double x, void *closure)
{
double width = *(double *) closure;
if (x < width && x > -width) {
x /= width;
*fx = (1 - x * x) * (1 - x * x);
*dfx = -2 * 2 * x / width * (1 - x * x);
} else {
*fx = 0;
*dfx = 0;
}
}
Functable *
functable_new (void)
{
Functable *ft;
ft = malloc (sizeof (Functable));
memset (ft, 0, sizeof (Functable));
return ft;
}
void
functable_free (Functable * ft)
{
free (ft);
}
void
functable_set_length (Functable * t, int length)
{
t->length = length;
}
void
functable_set_offset (Functable * t, double offset)
{
t->offset = offset;
}
void
functable_set_multiplier (Functable * t, double multiplier)
{
t->multiplier = multiplier;
}
void
functable_calculate (Functable * t, FunctableFunc func, void *closure)
{
int i;
double x;
if (t->fx)
free (t->fx);
if (t->dfx)
free (t->dfx);
t->fx = malloc (sizeof (double) * (t->length + 1));
t->dfx = malloc (sizeof (double) * (t->length + 1));
t->inv_multiplier = 1.0 / t->multiplier;
for (i = 0; i < t->length + 1; i++) {
x = t->offset + t->multiplier * i;
func (&t->fx[i], &t->dfx[i], x, closure);
}
}
void
functable_calculate_multiply (Functable * t, FunctableFunc func, void *closure)
{
int i;
double x;
for (i = 0; i < t->length + 1; i++) {
double afx, adfx, bfx, bdfx;
afx = t->fx[i];
adfx = t->dfx[i];
x = t->offset + t->multiplier * i;
func (&bfx, &bdfx, x, closure);
t->fx[i] = afx * bfx;
t->dfx[i] = afx * bdfx + adfx * bfx;
}
}
double
functable_evaluate (Functable * t, double x)
{
int i;
double f0, f1, w0, w1;
double x2, x3;
double w;
if (x < t->offset || x > (t->offset + t->length * t->multiplier)) {
RESAMPLE_DEBUG ("x out of range %g", x);
}
x -= t->offset;
x *= t->inv_multiplier;
i = floor (x);
x -= i;
x2 = x * x;
x3 = x2 * x;
f1 = 3 * x2 - 2 * x3;
f0 = 1 - f1;
w0 = (x - 2 * x2 + x3) * t->multiplier;
w1 = (-x2 + x3) * t->multiplier;
w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->dfx[i] * w0 + t->dfx[i + 1] * w1;
/*w = t->fx[i] * (1-x) + t->fx[i+1] * x; */
return w;
}
double
functable_fir (Functable * t, double x, int n, double *data, int len)
{
int i, j;
double f0, f1, w0, w1;
double x2, x3;
double w;
double sum;
x -= t->offset;
x /= t->multiplier;
i = floor (x);
x -= i;
x2 = x * x;
x3 = x2 * x;
f1 = 3 * x2 - 2 * x3;
f0 = 1 - f1;
w0 = (x - 2 * x2 + x3) * t->multiplier;
w1 = (-x2 + x3) * t->multiplier;
sum = 0;
for (j = 0; j < len; j++) {
w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->dfx[i] * w0 + t->dfx[i + 1] * w1;
sum += data[j * 2] * w;
i += n;
}
return sum;
}
void
functable_fir2 (Functable * t, double *r0, double *r1, double x,
int n, double *data, int len)
{
int i, j;
double f0, f1, w0, w1;
double x2, x3;
double w;
double sum0, sum1;
double floor_x;
x -= t->offset;
x *= t->inv_multiplier;
floor_x = floor (x);
i = floor_x;
x -= floor_x;
x2 = x * x;
x3 = x2 * x;
f1 = 3 * x2 - 2 * x3;
f0 = 1 - f1;
w0 = (x - 2 * x2 + x3) * t->multiplier;
w1 = (-x2 + x3) * t->multiplier;
sum0 = 0;
sum1 = 0;
for (j = 0; j < len; j++) {
w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->dfx[i] * w0 + t->dfx[i + 1] * w1;
sum0 += data[j * 2] * w;
sum1 += data[j * 2 + 1] * w;
i += n;
}
*r0 = sum0;
*r1 = sum1;
}

View file

@ -1,61 +0,0 @@
/* Resampling library
* Copyright (C) <2001> David Schleef <ds@schleef.org>
*
* 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 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.
*/
#ifndef __FUNCTABLE_H__
#define __FUNCTABLE_H__
typedef void FunctableFunc (double *fx, double *dfx, double x, void *closure);
typedef struct _Functable Functable;
struct _Functable {
int length;
double offset;
double multiplier;
double inv_multiplier;
double *fx;
double *dfx;
};
Functable *functable_new (void);
void functable_setup (Functable *t);
void functable_free (Functable *t);
void functable_set_length (Functable *t, int length);
void functable_set_offset (Functable *t, double offset);
void functable_set_multiplier (Functable *t, double multiplier);
void functable_calculate (Functable *t, FunctableFunc func, void *closure);
void functable_calculate_multiply (Functable *t, FunctableFunc func, void *closure);
double functable_evaluate (Functable *t,double x);
double functable_fir(Functable *t,double x0,int n,double *data,int len);
void functable_fir2(Functable *t,double *r0, double *r1, double x0,
int n,double *data,int len);
void functable_func_sinc(double *fx, double *dfx, double x, void *closure);
void functable_func_boxcar(double *fx, double *dfx, double x, void *closure);
void functable_func_hanning(double *fx, double *dfx, double x, void *closure);
#endif /* __PRIVATE_H__ */

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,6 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2007-2008> Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -18,62 +19,72 @@
*/
#ifndef __AUDIORESAMPLE_H__
#define __AUDIORESAMPLE_H__
#ifndef __AUDIO_RESAMPLE_H__
#define __AUDIO_RESAMPLE_H__
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
#include <gst/audio/audio.h>
#include "resample.h"
#include "speex_resampler_wrapper.h"
G_BEGIN_DECLS
#define GST_TYPE_AUDIORESAMPLE \
(gst_audioresample_get_type())
#define GST_AUDIORESAMPLE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIORESAMPLE,GstAudioresample))
#define GST_AUDIORESAMPLE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIORESAMPLE,GstAudioresampleClass))
#define GST_IS_AUDIORESAMPLE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIORESAMPLE))
#define GST_IS_AUDIORESAMPLE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIORESAMPLE))
#define GST_TYPE_AUDIO_RESAMPLE \
(gst_audio_resample_get_type())
#define GST_AUDIO_RESAMPLE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_RESAMPLE,GstAudioResample))
#define GST_AUDIO_RESAMPLE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_RESAMPLE,GstAudioResampleClass))
#define GST_IS_AUDIO_RESAMPLE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_RESAMPLE))
#define GST_IS_AUDIO_RESAMPLE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_RESAMPLE))
typedef struct _GstAudioresample GstAudioresample;
typedef struct _GstAudioresampleClass GstAudioresampleClass;
typedef struct _GstAudioResample GstAudioResample;
typedef struct _GstAudioResampleClass GstAudioResampleClass;
/**
* GstAudioresample:
* GstAudioResample:
*
* Opaque data structure.
*/
struct _GstAudioresample {
struct _GstAudioResample {
GstBaseTransform element;
/* <private> */
GstCaps *srccaps, *sinkcaps;
gboolean passthru;
gboolean need_discont;
guint64 offset;
guint64 ts_offset;
guint64 next_offset;
GstClockTime next_ts;
GstClockTime prev_ts, prev_duration;
int channels;
GstClockTime next_upstream_ts;
gint channels;
gint inrate;
gint outrate;
gint quality;
gint width;
gboolean fp;
int i_rate;
int o_rate;
int filter_length;
guint8 *tmp_in;
guint tmp_in_size;
ResampleState * resample;
guint8 *tmp_out;
guint tmp_out_size;
SpeexResamplerState *state;
const SpeexResampleFuncs *funcs;
};
struct _GstAudioresampleClass {
struct _GstAudioResampleClass {
GstBaseTransformClass parent_class;
};
GType gst_audioresample_get_type(void);
GType gst_audio_resample_get_type(void);
G_END_DECLS
#endif /* __AUDIORESAMPLE_H__ */
#endif /* __AUDIO_RESAMPLE_H__ */

File diff suppressed because it is too large Load diff

View file

@ -1,128 +0,0 @@
/* Resampling library
* Copyright (C) <2001> David Schleef <ds@schleef.org>
*
* 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 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.
*/
#ifndef __RESAMPLE_H__
#define __RESAMPLE_H__
#include "functable.h"
#include "buffer.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifdef WIN32
#define rint(x) (floor((x)+0.5))
#endif
typedef enum {
RESAMPLE_FORMAT_S16 = 0,
RESAMPLE_FORMAT_S32,
RESAMPLE_FORMAT_F32,
RESAMPLE_FORMAT_F64
} ResampleFormat;
typedef void (*ResampleCallback) (void *);
typedef struct _ResampleState ResampleState;
struct _ResampleState {
/* parameters */
int n_channels;
ResampleFormat format;
int filter_length;
double i_rate;
double o_rate;
int method;
/* internal parameters */
int need_reinit;
double halftaps;
/* filter state */
unsigned char *o_buf;
int o_size;
AudioresampleBufferQueue *queue;
int eos;
int started;
int sample_size;
unsigned char *buffer;
int buffer_len;
int buffer_filled;
double i_start;
double o_start;
double i_inc;
double o_inc;
double sinc_scale;
double i_end;
double o_end;
int i_samples;
int o_samples;
//void *i_buf;
Functable *ft;
double *out_tmp;
};
void resample_init (void);
void resample_cleanup (void);
ResampleState *resample_new (void);
void resample_free (ResampleState *state);
void resample_add_input_data (ResampleState * r, void *data, int size,
ResampleCallback free_func, void *closure);
void resample_input_eos (ResampleState *r);
void resample_input_flush (ResampleState *r);
void resample_input_pushthrough (ResampleState *r);
int resample_get_output_size_for_input (ResampleState * r, int size);
int resample_get_input_size_for_output (ResampleState * r, int size);
int resample_get_output_size (ResampleState *r);
int resample_get_output_data (ResampleState *r, void *data, int size);
void resample_set_filter_length (ResampleState *r, int length);
void resample_set_input_rate (ResampleState *r, double rate);
void resample_set_output_rate (ResampleState *r, double rate);
void resample_set_n_channels (ResampleState *r, int n_channels);
void resample_set_format (ResampleState *r, ResampleFormat format);
void resample_set_method (ResampleState *r, int method);
int resample_format_size (ResampleFormat format);
#endif /* __RESAMPLE_H__ */

View file

@ -1,209 +0,0 @@
/* Resampling library
* Copyright (C) <2001> David A. Schleef <ds@schleef.org>
*
* 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 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <liboil/liboil.h>
#include "resample.h"
#include "buffer.h"
#include "debug.h"
static double
resample_sinc_window (double x, double halfwidth, double scale)
{
double y;
if (x == 0)
return 1.0;
if (x < -halfwidth || x > halfwidth)
return 0.0;
y = sin (x * M_PI * scale) / (x * M_PI * scale) * scale;
x /= halfwidth;
y *= (1 - x * x) * (1 - x * x);
return y;
}
void
resample_scale_chunk (ResampleState * r)
{
if (r->need_reinit) {
RESAMPLE_DEBUG ("sample size %d", r->sample_size);
if (r->buffer)
free (r->buffer);
r->buffer_len = r->sample_size * 1000;
r->buffer = malloc (r->buffer_len);
memset (r->buffer, 0, r->buffer_len);
r->i_inc = r->o_rate / r->i_rate;
r->o_inc = r->i_rate / r->o_rate;
RESAMPLE_DEBUG ("i_inc %g o_inc %g", r->i_inc, r->o_inc);
r->i_start = -r->i_inc * r->filter_length;
r->need_reinit = 0;
#if 0
if (r->i_inc < 1.0) {
r->sinc_scale = r->i_inc;
if (r->sinc_scale == 0.5) {
/* strange things happen at integer multiples */
r->sinc_scale = 1.0;
}
} else {
r->sinc_scale = 1.0;
}
#else
r->sinc_scale = 1.0;
#endif
}
while (r->o_size > 0) {
double midpoint;
int i;
int j;
RESAMPLE_DEBUG ("i_start %g", r->i_start);
midpoint = r->i_start + (r->filter_length - 1) * 0.5 * r->i_inc;
if (midpoint > 0.5 * r->i_inc) {
RESAMPLE_ERROR ("inconsistent state");
}
while (midpoint < -0.5 * r->i_inc) {
AudioresampleBuffer *buffer;
buffer = audioresample_buffer_queue_pull (r->queue, r->sample_size);
if (buffer == NULL) {
RESAMPLE_ERROR ("buffer_queue_pull returned NULL");
return;
}
r->i_start += r->i_inc;
RESAMPLE_DEBUG ("pulling (i_start = %g)", r->i_start);
midpoint += r->i_inc;
memmove (r->buffer, r->buffer + r->sample_size,
r->buffer_len - r->sample_size);
memcpy (r->buffer + r->buffer_len - r->sample_size, buffer->data,
r->sample_size);
audioresample_buffer_unref (buffer);
}
switch (r->format) {
case RESAMPLE_FORMAT_S16:
for (i = 0; i < r->n_channels; i++) {
double acc = 0;
double offset;
double x;
for (j = 0; j < r->filter_length; j++) {
offset = (r->i_start + j * r->i_inc) * r->o_inc;
x = *(int16_t *) (r->buffer + i * sizeof (int16_t) +
j * r->sample_size);
acc +=
resample_sinc_window (offset, r->filter_length * 0.5,
r->sinc_scale) * x;
}
if (acc < -32768.0)
acc = -32768.0;
if (acc > 32767.0)
acc = 32767.0;
*(int16_t *) (r->o_buf + i * sizeof (int16_t)) = rint (acc);
}
break;
case RESAMPLE_FORMAT_S32:
for (i = 0; i < r->n_channels; i++) {
double acc = 0;
double offset;
double x;
for (j = 0; j < r->filter_length; j++) {
offset = (r->i_start + j * r->i_inc) * r->o_inc;
x = *(int32_t *) (r->buffer + i * sizeof (int32_t) +
j * r->sample_size);
acc +=
resample_sinc_window (offset, r->filter_length * 0.5,
r->sinc_scale) * x;
}
if (acc < -2147483648.0)
acc = -2147483648.0;
if (acc > 2147483647.0)
acc = 2147483647.0;
*(int32_t *) (r->o_buf + i * sizeof (int32_t)) = rint (acc);
}
break;
case RESAMPLE_FORMAT_F32:
for (i = 0; i < r->n_channels; i++) {
double acc = 0;
double offset;
double x;
for (j = 0; j < r->filter_length; j++) {
offset = (r->i_start + j * r->i_inc) * r->o_inc;
x = *(float *) (r->buffer + i * sizeof (float) +
j * r->sample_size);
acc +=
resample_sinc_window (offset, r->filter_length * 0.5,
r->sinc_scale) * x;
}
*(float *) (r->o_buf + i * sizeof (float)) = acc;
}
break;
case RESAMPLE_FORMAT_F64:
for (i = 0; i < r->n_channels; i++) {
double acc = 0;
double offset;
double x;
for (j = 0; j < r->filter_length; j++) {
offset = (r->i_start + j * r->i_inc) * r->o_inc;
x = *(double *) (r->buffer + i * sizeof (double) +
j * r->sample_size);
acc +=
resample_sinc_window (offset, r->filter_length * 0.5,
r->sinc_scale) * x;
}
*(double *) (r->o_buf + i * sizeof (double)) = acc;
}
break;
}
r->i_start -= 1.0;
r->o_buf += r->sample_size;
r->o_size -= r->sample_size;
}
}

View file

@ -1,271 +0,0 @@
/* Resampling library
* Copyright (C) <2001> David A. Schleef <ds@schleef.org>
*
* 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 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <liboil/liboil.h>
#include "resample.h"
#include "buffer.h"
#include "debug.h"
static void
func_sinc (double *fx, double *dfx, double x, void *closure)
{
//double scale = *(double *)closure;
double scale = M_PI;
if (x == 0) {
*fx = 1;
*dfx = 0;
return;
}
x *= scale;
*fx = sin (x) / x;
*dfx = scale * (cos (x) - sin (x) / x) / x;
}
static void
func_hanning (double *fx, double *dfx, double x, void *closure)
{
double width = *(double *) closure;
if (x < width && x > -width) {
x /= width;
*fx = (1 - x * x) * (1 - x * x);
*dfx = -2 * 2 * x / width * (1 - x * x);
} else {
*fx = 0;
*dfx = 0;
}
}
#if 0
static double
resample_sinc_window (double x, double halfwidth, double scale)
{
double y;
if (x == 0)
return 1.0;
if (x < -halfwidth || x > halfwidth)
return 0.0;
y = sin (x * M_PI * scale) / (x * M_PI * scale) * scale;
x /= halfwidth;
y *= (1 - x * x) * (1 - x * x);
return y;
}
#endif
#if 0
static void
functable_test (Functable * ft, double halfwidth)
{
int i;
double x;
for (i = 0; i < 100; i++) {
x = i * 0.1;
printf ("%d %g %g\n", i, resample_sinc_window (x, halfwidth, 1.0),
functable_evaluate (ft, x));
}
exit (0);
}
#endif
void
resample_scale_functable (ResampleState * r)
{
if (r->need_reinit) {
double hanning_width;
RESAMPLE_DEBUG ("sample size %d", r->sample_size);
if (r->buffer)
free (r->buffer);
r->buffer_len = r->sample_size * r->filter_length;
r->buffer = malloc (r->buffer_len);
memset (r->buffer, 0, r->buffer_len);
r->i_inc = r->o_rate / r->i_rate;
r->o_inc = r->i_rate / r->o_rate;
RESAMPLE_DEBUG ("i_inc %g o_inc %g", r->i_inc, r->o_inc);
r->i_start = -r->i_inc * r->filter_length;
if (r->ft) {
functable_free (r->ft);
}
r->ft = functable_new ();
functable_set_length (r->ft, r->filter_length * 16);
functable_set_offset (r->ft, -r->filter_length / 2);
functable_set_multiplier (r->ft, 1 / 16.0);
hanning_width = r->filter_length / 2;
functable_calculate (r->ft, func_sinc, NULL);
functable_calculate_multiply (r->ft, func_hanning, &hanning_width);
//functable_test(r->ft, 0.5 * r->filter_length);
#if 0
if (r->i_inc < 1.0) {
r->sinc_scale = r->i_inc;
if (r->sinc_scale == 0.5) {
/* strange things happen at integer multiples */
r->sinc_scale = 1.0;
}
} else {
r->sinc_scale = 1.0;
}
#else
r->sinc_scale = 1.0;
#endif
r->need_reinit = 0;
}
while (r->o_size > 0) {
double midpoint;
int i;
int j;
RESAMPLE_DEBUG ("i_start %g", r->i_start);
midpoint = r->i_start + (r->filter_length - 1) * 0.5 * r->i_inc;
if (midpoint > 0.5 * r->i_inc) {
RESAMPLE_ERROR ("inconsistent state");
}
while (midpoint < -0.5 * r->i_inc) {
AudioresampleBuffer *buffer;
buffer = audioresample_buffer_queue_pull (r->queue, r->sample_size);
if (buffer == NULL) {
RESAMPLE_ERROR ("buffer_queue_pull returned NULL");
return;
}
r->i_start += r->i_inc;
RESAMPLE_DEBUG ("pulling (i_start = %g)", r->i_start);
midpoint += r->i_inc;
memmove (r->buffer, r->buffer + r->sample_size,
r->buffer_len - r->sample_size);
memcpy (r->buffer + r->buffer_len - r->sample_size, buffer->data,
r->sample_size);
audioresample_buffer_unref (buffer);
}
switch (r->format) {
case RESAMPLE_FORMAT_S16:
for (i = 0; i < r->n_channels; i++) {
double acc = 0;
double offset;
double x;
for (j = 0; j < r->filter_length; j++) {
offset = (r->i_start + j * r->i_inc) * r->o_inc;
x = *(int16_t *) (r->buffer + i * sizeof (int16_t) +
j * r->sample_size);
acc += functable_evaluate (r->ft, offset) * x;
//acc += resample_sinc_window (offset, r->filter_length * 0.5, r->sinc_scale) * x;
}
if (acc < -32768.0)
acc = -32768.0;
if (acc > 32767.0)
acc = 32767.0;
*(int16_t *) (r->o_buf + i * sizeof (int16_t)) = rint (acc);
}
break;
case RESAMPLE_FORMAT_S32:
for (i = 0; i < r->n_channels; i++) {
double acc = 0;
double offset;
double x;
for (j = 0; j < r->filter_length; j++) {
offset = (r->i_start + j * r->i_inc) * r->o_inc;
x = *(int32_t *) (r->buffer + i * sizeof (int32_t) +
j * r->sample_size);
acc += functable_evaluate (r->ft, offset) * x;
//acc += resample_sinc_window (offset, r->filter_length * 0.5, r->sinc_scale) * x;
}
if (acc < -2147483648.0)
acc = -2147483648.0;
if (acc > 2147483647.0)
acc = 2147483647.0;
*(int32_t *) (r->o_buf + i * sizeof (int32_t)) = rint (acc);
}
break;
case RESAMPLE_FORMAT_F32:
for (i = 0; i < r->n_channels; i++) {
double acc = 0;
double offset;
double x;
for (j = 0; j < r->filter_length; j++) {
offset = (r->i_start + j * r->i_inc) * r->o_inc;
x = *(float *) (r->buffer + i * sizeof (float) +
j * r->sample_size);
acc += functable_evaluate (r->ft, offset) * x;
//acc += resample_sinc_window (offset, r->filter_length * 0.5, r->sinc_scale) * x;
}
*(float *) (r->o_buf + i * sizeof (float)) = acc;
}
break;
case RESAMPLE_FORMAT_F64:
for (i = 0; i < r->n_channels; i++) {
double acc = 0;
double offset;
double x;
for (j = 0; j < r->filter_length; j++) {
offset = (r->i_start + j * r->i_inc) * r->o_inc;
x = *(double *) (r->buffer + i * sizeof (double) +
j * r->sample_size);
acc += functable_evaluate (r->ft, offset) * x;
//acc += resample_sinc_window (offset, r->filter_length * 0.5, r->sinc_scale) * x;
}
*(double *) (r->o_buf + i * sizeof (double)) = acc;
}
break;
}
r->i_start -= 1.0;
r->o_buf += r->sample_size;
r->o_size -= r->sample_size;
}
}

View file

@ -1,223 +0,0 @@
/* Resampling library
* Copyright (C) <2001> David A. Schleef <ds@schleef.org>
*
* 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 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <liboil/liboil.h>
#include "resample.h"
#include "buffer.h"
#include "debug.h"
static double
resample_sinc_window (double x, double halfwidth, double scale)
{
double y;
if (x == 0)
return 1.0;
if (x < -halfwidth || x > halfwidth)
return 0.0;
y = sin (x * M_PI * scale) / (x * M_PI * scale) * scale;
x /= halfwidth;
y *= (1 - x * x) * (1 - x * x);
return y;
}
void
resample_scale_ref (ResampleState * r)
{
if (r->need_reinit) {
RESAMPLE_DEBUG ("sample size %d", r->sample_size);
if (r->buffer)
free (r->buffer);
r->buffer_len = r->sample_size * r->filter_length;
r->buffer = malloc (r->buffer_len);
memset (r->buffer, 0, r->buffer_len);
r->buffer_filled = 0;
r->i_inc = r->o_rate / r->i_rate;
r->o_inc = r->i_rate / r->o_rate;
RESAMPLE_DEBUG ("i_inc %g o_inc %g", r->i_inc, r->o_inc);
r->i_start = -r->i_inc * r->filter_length;
r->need_reinit = 0;
#if 0
if (r->i_inc < 1.0) {
r->sinc_scale = r->i_inc;
if (r->sinc_scale == 0.5) {
/* strange things happen at integer multiples */
r->sinc_scale = 1.0;
}
} else {
r->sinc_scale = 1.0;
}
#else
r->sinc_scale = 1.0;
#endif
}
RESAMPLE_DEBUG ("asked to resample %d bytes", r->o_size);
RESAMPLE_DEBUG ("%d bytes in queue",
audioresample_buffer_queue_get_depth (r->queue));
while (r->o_size >= r->sample_size) {
double midpoint;
int i;
int j;
midpoint = r->i_start + (r->filter_length - 1) * 0.5 * r->i_inc;
RESAMPLE_DEBUG
("still need to output %d bytes, %d input left, i_start %g, midpoint %f",
r->o_size, audioresample_buffer_queue_get_depth (r->queue), r->i_start,
midpoint);
if (midpoint > 0.5 * r->i_inc) {
RESAMPLE_ERROR ("inconsistent state");
}
while (midpoint < -0.5 * r->i_inc) {
AudioresampleBuffer *buffer;
RESAMPLE_DEBUG ("midpoint %f < %f, r->i_inc %f", midpoint,
-0.5 * r->i_inc, r->i_inc);
buffer = audioresample_buffer_queue_pull (r->queue, r->sample_size);
if (buffer == NULL) {
/* FIXME: for the first buffer, this isn't necessarily an error,
* since because of the filter length we'll output less buffers.
* deal with that so we don't print to console */
RESAMPLE_ERROR ("buffer_queue_pull returned NULL");
return;
}
r->i_start += r->i_inc;
RESAMPLE_DEBUG ("pulling (i_start = %g)", r->i_start);
midpoint += r->i_inc;
memmove (r->buffer, r->buffer + r->sample_size,
r->buffer_len - r->sample_size);
memcpy (r->buffer + r->buffer_len - r->sample_size, buffer->data,
r->sample_size);
r->buffer_filled = MIN (r->buffer_filled + r->sample_size, r->buffer_len);
audioresample_buffer_unref (buffer);
}
switch (r->format) {
case RESAMPLE_FORMAT_S16:
for (i = 0; i < r->n_channels; i++) {
double acc = 0;
double offset;
double x;
for (j = 0; j < r->filter_length; j++) {
offset = (r->i_start + j * r->i_inc) * r->o_inc;
x = *(int16_t *) (r->buffer + i * sizeof (int16_t) +
j * r->sample_size);
acc +=
resample_sinc_window (offset, r->filter_length * 0.5,
r->sinc_scale) * x;
}
if (acc < -32768.0)
acc = -32768.0;
if (acc > 32767.0)
acc = 32767.0;
*(int16_t *) (r->o_buf + i * sizeof (int16_t)) = rint (acc);
}
break;
case RESAMPLE_FORMAT_S32:
for (i = 0; i < r->n_channels; i++) {
double acc = 0;
double offset;
double x;
for (j = 0; j < r->filter_length; j++) {
offset = (r->i_start + j * r->i_inc) * r->o_inc;
x = *(int32_t *) (r->buffer + i * sizeof (int32_t) +
j * r->sample_size);
acc +=
resample_sinc_window (offset, r->filter_length * 0.5,
r->sinc_scale) * x;
}
if (acc < -2147483648.0)
acc = -2147483648.0;
if (acc > 2147483647.0)
acc = 2147483647.0;
*(int32_t *) (r->o_buf + i * sizeof (int32_t)) = rint (acc);
}
break;
case RESAMPLE_FORMAT_F32:
for (i = 0; i < r->n_channels; i++) {
double acc = 0;
double offset;
double x;
for (j = 0; j < r->filter_length; j++) {
offset = (r->i_start + j * r->i_inc) * r->o_inc;
x = *(float *) (r->buffer + i * sizeof (float) +
j * r->sample_size);
acc +=
resample_sinc_window (offset, r->filter_length * 0.5,
r->sinc_scale) * x;
}
*(float *) (r->o_buf + i * sizeof (float)) = acc;
}
break;
case RESAMPLE_FORMAT_F64:
for (i = 0; i < r->n_channels; i++) {
double acc = 0;
double offset;
double x;
for (j = 0; j < r->filter_length; j++) {
offset = (r->i_start + j * r->i_inc) * r->o_inc;
x = *(double *) (r->buffer + i * sizeof (double) +
j * r->sample_size);
acc +=
resample_sinc_window (offset, r->filter_length * 0.5,
r->sinc_scale) * x;
}
*(double *) (r->o_buf + i * sizeof (double)) = acc;
}
break;
}
r->i_start -= 1.0;
r->o_buf += r->sample_size;
r->o_size -= r->sample_size;
}
}

View file

@ -1,37 +0,0 @@
plugin_LTLIBRARIES = libgstaudioresample.la
libgstaudioresample_la_SOURCES = \
gstspeexresample.c \
speex_resampler_int.c \
speex_resampler_float.c \
speex_resampler_double.c
libgstaudioresample_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_CFLAGS) \
$(LIBOIL_CFLAGS)
libgstaudioresample_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) \
$(GST_BASE_LIBS) \
$(GST_LIBS) \
$(LIBOIL_LIBS) \
$(LIBM)
libgstaudioresample_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstaudioresample_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = \
arch.h \
fixed_arm4.h \
fixed_arm5e.h \
fixed_bfin.h \
fixed_debug.h \
fixed_generic.h \
gstspeexresample.h \
resample.c \
resample_sse.h \
speex_resampler.h \
speex_resampler_wrapper.h

File diff suppressed because it is too large Load diff

View file

@ -1,90 +0,0 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2007-2008> Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* 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.
*/
#ifndef __SPEEX_RESAMPLE_H__
#define __SPEEX_RESAMPLE_H__
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
#include <gst/audio/audio.h>
#include "speex_resampler_wrapper.h"
G_BEGIN_DECLS
#define GST_TYPE_SPEEX_RESAMPLE \
(gst_speex_resample_get_type())
#define GST_SPEEX_RESAMPLE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SPEEX_RESAMPLE,GstSpeexResample))
#define GST_SPEEX_RESAMPLE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SPEEX_RESAMPLE,GstSpeexResampleClass))
#define GST_IS_SPEEX_RESAMPLE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SPEEX_RESAMPLE))
#define GST_IS_SPEEX_RESAMPLE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SPEEX_RESAMPLE))
typedef struct _GstSpeexResample GstSpeexResample;
typedef struct _GstSpeexResampleClass GstSpeexResampleClass;
/**
* GstSpeexResample:
*
* Opaque data structure.
*/
struct _GstSpeexResample {
GstBaseTransform element;
/* <private> */
GstCaps *srccaps, *sinkcaps;
gboolean need_discont;
guint64 next_offset;
GstClockTime next_ts;
GstClockTime next_upstream_ts;
gint channels;
gint inrate;
gint outrate;
gint quality;
gint width;
gboolean fp;
guint8 *tmp_in;
guint tmp_in_size;
guint8 *tmp_out;
guint tmp_out_size;
SpeexResamplerState *state;
const SpeexResampleFuncs *funcs;
};
struct _GstSpeexResampleClass {
GstBaseTransformClass parent_class;
};
GType gst_speex_resample_get_type(void);
G_END_DECLS
#endif /* __SPEEX_RESAMPLE_H__ */

File diff suppressed because it is too large Load diff

View file

@ -412,6 +412,7 @@ mid_type_find (GstTypeFind * tf, gpointer unused)
&& data[3] == 'd')
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MID_CAPS);
}
/*** audio/mobile-xmf ***/
static GstStaticCaps mxmf_caps = GST_STATIC_CAPS ("audio/mobile-xmf");
@ -422,21 +423,21 @@ mxmf_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data = NULL;
/* Search FileId "XMF_" 4 bytes */
/* Search FileId "XMF_" 4 bytes */
data = gst_type_find_peek (tf, 0, 4);
if (data && data[0] == 'X' && data[1] == 'M' && data[2] == 'F'
&& data[3] == '_') {
/* Search Format version "2.00" 4 bytes */
data = gst_type_find_peek (tf, 4, 4);
if (data && data[0] == '2' && data[1] == '.' && data[2] == '0'
&& data[3] == '0') {
/* Search TypeId 2 1 byte */
data = gst_type_find_peek (tf, 11, 1);
if (data && data[0] == 2 ) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MXMF_CAPS);
}
}
}
&& data[3] == '_') {
/* Search Format version "2.00" 4 bytes */
data = gst_type_find_peek (tf, 4, 4);
if (data && data[0] == '2' && data[1] == '.' && data[2] == '0'
&& data[3] == '0') {
/* Search TypeId 2 1 byte */
data = gst_type_find_peek (tf, 11, 1);
if (data && data[0] == 2) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MXMF_CAPS);
}
}
}
}
@ -3208,8 +3209,8 @@ plugin_init (GstPlugin * plugin)
#endif
TYPE_FIND_REGISTER (plugin, "audio/midi", GST_RANK_PRIMARY, mid_type_find,
mid_exts, MID_CAPS, NULL, NULL);
TYPE_FIND_REGISTER (plugin, "audio/mobile-xmf", GST_RANK_PRIMARY, mxmf_type_find,
mxmf_exts, MXMF_CAPS, NULL, NULL);
TYPE_FIND_REGISTER (plugin, "audio/mobile-xmf", GST_RANK_PRIMARY,
mxmf_type_find, mxmf_exts, MXMF_CAPS, NULL, NULL);
TYPE_FIND_REGISTER (plugin, "video/x-fli", GST_RANK_MARGINAL, flx_type_find,
flx_exts, FLX_CAPS, NULL, NULL);
TYPE_FIND_REGISTER (plugin, "application/x-id3v2", GST_RANK_PRIMARY + 103,
@ -3241,8 +3242,8 @@ plugin_init (GstPlugin * plugin)
mpeg4_video_type_find, m4v_exts, MPEG_VIDEO_CAPS, NULL, NULL);
TYPE_FIND_REGISTER (plugin, "video/x-h264", GST_RANK_PRIMARY,
h264_video_type_find, h264_exts, MPEG_VIDEO_CAPS, NULL, NULL);
TYPE_FIND_REGISTER (plugin, "video/x-nuv", GST_RANK_SECONDARY,
nuv_type_find, nuv_exts, NUV_CAPS, NULL, NULL);
TYPE_FIND_REGISTER (plugin, "video/x-nuv", GST_RANK_SECONDARY, nuv_type_find,
nuv_exts, NUV_CAPS, NULL, NULL);
/* ISO formats */
TYPE_FIND_REGISTER (plugin, "audio/x-m4a", GST_RANK_PRIMARY, m4a_type_find,

View file

@ -91,6 +91,7 @@ check_PROGRAMS = \
elements/adder \
elements/audioconvert \
elements/audiorate \
elements/audioresample \
elements/audiotestsrc \
elements/decodebin \
elements/ffmpegcolorspace \
@ -99,7 +100,6 @@ check_PROGRAMS = \
elements/multifdsink \
elements/playbin \
$(check_subparse) \
elements/speexresample \
elements/videorate \
elements/videotestsrc \
elements/volume \
@ -241,12 +241,12 @@ elements_decodebin_CFLAGS = $(GST_BASE_CFLAGS) $(AM_CFLAGS)
elements_subparse_LDADD = $(LDADD)
elements_subparse_CFLAGS = $(CFLAGS) $(AM_CFLAGS)
elements_speexresample_CFLAGS = \
elements_audioresample_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(AM_CFLAGS)
elements_speexresample_LDADD = \
elements_audioresample_LDADD = \
$(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \
$(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-@GST_MAJORMINOR@.la \
$(GST_BASE_LIBS) \

View file

@ -1,6 +1,6 @@
/* GStreamer
*
* unit test for audioresample
* unit test for audioresample, based on the audioresample unit test
*
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
* Copyright (C) <2006> Tim-Philipp Müller <tim at centricular net>
@ -25,13 +25,21 @@
#include <gst/check/gstcheck.h>
#include <gst/audio/audio.h>
/* For ease of programming we use globals to keep refs for our floating
* src and sink pads we create; otherwise we always have to do get_pad,
* get_peer, and then remove references in every test function */
static GstPad *mysrcpad, *mysinkpad;
#define RESAMPLE_CAPS_FLOAT \
"audio/x-raw-float, " \
"channels = (int) [ 1, MAX ], " \
"rate = (int) [ 1, MAX ], " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) { 32, 64 }"
#define RESAMPLE_CAPS_TEMPLATE_STRING \
#define RESAMPLE_CAPS_INT \
"audio/x-raw-int, " \
"channels = (int) [ 1, MAX ], " \
"rate = (int) [ 1, MAX ], " \
@ -40,6 +48,10 @@ static GstPad *mysrcpad, *mysinkpad;
"depth = (int) 16, " \
"signed = (bool) TRUE"
#define RESAMPLE_CAPS_TEMPLATE_STRING \
RESAMPLE_CAPS_FLOAT " ; " \
RESAMPLE_CAPS_INT
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
@ -52,7 +64,8 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
);
static GstElement *
setup_audioresample (int channels, int inrate, int outrate)
setup_audioresample (int channels, int inrate, int outrate, int width,
gboolean fp)
{
GstElement *audioresample;
GstCaps *caps;
@ -61,10 +74,15 @@ setup_audioresample (int channels, int inrate, int outrate)
GST_DEBUG ("setup_audioresample");
audioresample = gst_check_setup_element ("audioresample");
caps = gst_caps_from_string (RESAMPLE_CAPS_TEMPLATE_STRING);
if (fp)
caps = gst_caps_from_string (RESAMPLE_CAPS_FLOAT);
else
caps = gst_caps_from_string (RESAMPLE_CAPS_INT);
structure = gst_caps_get_structure (caps, 0);
gst_structure_set (structure, "channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, inrate, NULL);
"rate", G_TYPE_INT, inrate, "width", G_TYPE_INT, width, NULL);
if (!fp)
gst_structure_set (structure, "depth", G_TYPE_INT, width, NULL);
fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_element_set_state (audioresample,
@ -75,10 +93,15 @@ setup_audioresample (int channels, int inrate, int outrate)
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
caps = gst_caps_from_string (RESAMPLE_CAPS_TEMPLATE_STRING);
if (fp)
caps = gst_caps_from_string (RESAMPLE_CAPS_FLOAT);
else
caps = gst_caps_from_string (RESAMPLE_CAPS_INT);
structure = gst_caps_get_structure (caps, 0);
gst_structure_set (structure, "channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, outrate, NULL);
"rate", G_TYPE_INT, outrate, "width", G_TYPE_INT, width, NULL);
if (!fp)
gst_structure_set (structure, "depth", G_TYPE_INT, width, NULL);
fail_unless (gst_caps_is_fixed (caps));
mysinkpad = gst_check_setup_sink_pad (audioresample, &sinktemplate, caps);
@ -90,6 +113,8 @@ setup_audioresample (int channels, int inrate, int outrate)
gst_pad_set_active (mysinkpad, TRUE);
gst_pad_set_active (mysrcpad, TRUE);
gst_caps_unref (caps);
return audioresample;
}
@ -153,7 +178,7 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
int i, j;
gint16 *p;
audioresample = setup_audioresample (2, inrate, outrate);
audioresample = setup_audioresample (2, inrate, outrate, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps));
@ -164,7 +189,7 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
for (j = 1; j <= numbuffers; ++j) {
inbuffer = gst_buffer_new_and_alloc (samples * 4);
GST_BUFFER_DURATION (inbuffer) = samples * GST_SECOND / inrate;
GST_BUFFER_DURATION (inbuffer) = GST_FRAMES_TO_CLOCK_TIME (samples, inrate);
GST_BUFFER_TIMESTAMP (inbuffer) = GST_BUFFER_DURATION (inbuffer) * (j - 1);
GST_BUFFER_OFFSET (inbuffer) = offset;
offset += samples;
@ -240,7 +265,7 @@ test_discont_stream_instance (int inrate, int outrate, int samples,
GST_DEBUG ("inrate:%d outrate:%d samples:%d numbuffers:%d",
inrate, outrate, samples, numbuffers);
audioresample = setup_audioresample (2, inrate, outrate);
audioresample = setup_audioresample (2, inrate, outrate, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps));
@ -326,7 +351,7 @@ GST_START_TEST (test_reuse)
GstBuffer *inbuffer;
GstCaps *caps;
audioresample = setup_audioresample (1, 9343, 48000);
audioresample = setup_audioresample (1, 9343, 48000, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps));
@ -477,6 +502,7 @@ live_switch_push (int rate, GstCaps * caps)
desired = gst_caps_copy (caps);
gst_caps_set_simple (desired, "rate", G_TYPE_INT, rate, NULL);
gst_pad_set_caps (mysrcpad, desired);
fail_unless (gst_pad_alloc_buffer_and_set_caps (mysrcpad,
GST_BUFFER_OFFSET_NONE, rate * 4, desired, &inbuffer) == GST_FLOW_OK);
@ -485,6 +511,8 @@ live_switch_push (int rate, GstCaps * caps)
* returns a buffer with exactly the same caps as we requested so the actual
* renegotiation (if needed) will be done in the _chain*/
fail_unless (inbuffer != NULL);
GST_DEBUG ("desired: %" GST_PTR_FORMAT ".... got: %" GST_PTR_FORMAT,
desired, GST_BUFFER_CAPS (inbuffer));
fail_unless (gst_caps_is_equal (desired, GST_BUFFER_CAPS (inbuffer)));
memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
@ -516,7 +544,7 @@ GST_START_TEST (test_live_switch)
GstEvent *newseg;
GstCaps *caps;
audioresample = setup_audioresample (4, 48000, 48000);
audioresample = setup_audioresample (4, 48000, 48000, 16, FALSE);
/* Let the sinkpad act like something that can only handle things of
* rate 48000- and can only allocate buffers for that rate, but if someone
@ -525,6 +553,8 @@ GST_START_TEST (test_live_switch)
gst_pad_set_bufferalloc_function (mysinkpad, live_switch_alloc_only_48000);
gst_pad_set_getcaps_function (mysinkpad, live_switch_get_sink_caps);
gst_pad_use_fixed_caps (mysrcpad);
caps = gst_pad_get_negotiated_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps));
@ -549,7 +579,104 @@ GST_START_TEST (test_live_switch)
gst_caps_unref (caps);
}
GST_END_TEST static Suite *
GST_END_TEST;
#ifndef GST_DISABLE_PARSE
static GMainLoop *loop;
static gint messages = 0;
static void
element_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
{
gchar *s;
s = gst_structure_to_string (gst_message_get_structure (message));
GST_DEBUG ("Received message: %s", s);
g_free (s);
messages++;
}
static void
eos_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
{
GST_DEBUG ("Received eos");
g_main_loop_quit (loop);
}
static void
test_pipeline (gint width, gboolean fp, gint inrate, gint outrate, gint quality)
{
GstElement *pipeline;
GstBus *bus;
GError *error = NULL;
gchar *pipe_str;
pipe_str =
g_strdup_printf
("audiotestsrc num-buffers=10 ! audioconvert ! audio/x-raw-%s,rate=%d,width=%d,channels=2 ! audioresample quality=%d ! audio/x-raw-%s,rate=%d,width=%d ! identity check-imperfect-timestamp=TRUE ! fakesink",
(fp) ? "float" : "int", inrate, width, quality, (fp) ? "float" : "int",
outrate, width);
pipeline = gst_parse_launch (pipe_str, &error);
fail_unless (pipeline != NULL, "Error parsing pipeline: %s",
error ? error->message : "(invalid error)");
g_free (pipe_str);
bus = gst_element_get_bus (pipeline);
fail_if (bus == NULL);
gst_bus_add_signal_watch (bus);
g_signal_connect (bus, "message::element", (GCallback) element_message_cb,
NULL);
g_signal_connect (bus, "message::eos", (GCallback) eos_message_cb, NULL);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* run until we receive EOS */
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
g_main_loop_unref (loop);
loop = NULL;
gst_element_set_state (pipeline, GST_STATE_NULL);
fail_if (messages > 0, "Received imperfect timestamp messages");
gst_object_unref (pipeline);
}
GST_START_TEST (test_pipelines)
{
gint quality;
/* Test qualities 0, 5 and 10 */
for (quality = 0; quality < 11; quality += 5) {
test_pipeline (8, FALSE, 44100, 48000, quality);
test_pipeline (8, FALSE, 48000, 44100, quality);
test_pipeline (16, FALSE, 44100, 48000, quality);
test_pipeline (16, FALSE, 48000, 44100, quality);
test_pipeline (24, FALSE, 44100, 48000, quality);
test_pipeline (24, FALSE, 48000, 44100, quality);
test_pipeline (32, FALSE, 44100, 48000, quality);
test_pipeline (32, FALSE, 48000, 44100, quality);
test_pipeline (32, TRUE, 44100, 48000, quality);
test_pipeline (32, TRUE, 48000, 44100, quality);
test_pipeline (64, TRUE, 44100, 48000, quality);
test_pipeline (64, TRUE, 48000, 44100, quality);
}
}
GST_END_TEST;
#endif
static Suite *
audioresample_suite (void)
{
Suite *s = suite_create ("audioresample");
@ -562,6 +689,11 @@ audioresample_suite (void)
tcase_add_test (tc_chain, test_shutdown);
tcase_add_test (tc_chain, test_live_switch);
#ifndef GST_DISABLE_PARSE
tcase_set_timeout (tc_chain, 360);
tcase_add_test (tc_chain, test_pipelines);
#endif
return s;
}

View file

@ -1,700 +0,0 @@
/* GStreamer
*
* unit test for speexresample, based on the audioresample unit test
*
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
* Copyright (C) <2006> Tim-Philipp Müller <tim at centricular net>
*
* 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.
*/
#include <unistd.h>
#include <gst/check/gstcheck.h>
#include <gst/audio/audio.h>
/* For ease of programming we use globals to keep refs for our floating
* src and sink pads we create; otherwise we always have to do get_pad,
* get_peer, and then remove references in every test function */
static GstPad *mysrcpad, *mysinkpad;
#define RESAMPLE_CAPS_FLOAT \
"audio/x-raw-float, " \
"channels = (int) [ 1, MAX ], " \
"rate = (int) [ 1, MAX ], " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) { 32, 64 }"
#define RESAMPLE_CAPS_INT \
"audio/x-raw-int, " \
"channels = (int) [ 1, MAX ], " \
"rate = (int) [ 1, MAX ], " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 16, " \
"depth = (int) 16, " \
"signed = (bool) TRUE"
#define RESAMPLE_CAPS_TEMPLATE_STRING \
RESAMPLE_CAPS_FLOAT " ; " \
RESAMPLE_CAPS_INT
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (RESAMPLE_CAPS_TEMPLATE_STRING)
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (RESAMPLE_CAPS_TEMPLATE_STRING)
);
static GstElement *
setup_speexresample (int channels, int inrate, int outrate, int width,
gboolean fp)
{
GstElement *speexresample;
GstCaps *caps;
GstStructure *structure;
GST_DEBUG ("setup_speexresample");
speexresample = gst_check_setup_element ("audioresample");
if (fp)
caps = gst_caps_from_string (RESAMPLE_CAPS_FLOAT);
else
caps = gst_caps_from_string (RESAMPLE_CAPS_INT);
structure = gst_caps_get_structure (caps, 0);
gst_structure_set (structure, "channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, inrate, "width", G_TYPE_INT, width, NULL);
if (!fp)
gst_structure_set (structure, "depth", G_TYPE_INT, width, NULL);
fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_element_set_state (speexresample,
GST_STATE_PAUSED) == GST_STATE_CHANGE_SUCCESS,
"could not set to paused");
mysrcpad = gst_check_setup_src_pad (speexresample, &srctemplate, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
if (fp)
caps = gst_caps_from_string (RESAMPLE_CAPS_FLOAT);
else
caps = gst_caps_from_string (RESAMPLE_CAPS_INT);
structure = gst_caps_get_structure (caps, 0);
gst_structure_set (structure, "channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, outrate, "width", G_TYPE_INT, width, NULL);
if (!fp)
gst_structure_set (structure, "depth", G_TYPE_INT, width, NULL);
fail_unless (gst_caps_is_fixed (caps));
mysinkpad = gst_check_setup_sink_pad (speexresample, &sinktemplate, caps);
/* this installs a getcaps func that will always return the caps we set
* later */
gst_pad_set_caps (mysinkpad, caps);
gst_pad_use_fixed_caps (mysinkpad);
gst_pad_set_active (mysinkpad, TRUE);
gst_pad_set_active (mysrcpad, TRUE);
gst_caps_unref (caps);
return speexresample;
}
static void
cleanup_speexresample (GstElement * speexresample)
{
GST_DEBUG ("cleanup_speexresample");
fail_unless (gst_element_set_state (speexresample,
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to NULL");
gst_pad_set_active (mysrcpad, FALSE);
gst_pad_set_active (mysinkpad, FALSE);
gst_check_teardown_src_pad (speexresample);
gst_check_teardown_sink_pad (speexresample);
gst_check_teardown_element (speexresample);
}
static void
fail_unless_perfect_stream (void)
{
guint64 timestamp = 0L, duration = 0L;
guint64 offset = 0L, offset_end = 0L;
GList *l;
GstBuffer *buffer;
for (l = buffers; l; l = l->next) {
buffer = GST_BUFFER (l->data);
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
GST_DEBUG ("buffer timestamp %" G_GUINT64_FORMAT ", duration %"
G_GUINT64_FORMAT " offset %" G_GUINT64_FORMAT " offset_end %"
G_GUINT64_FORMAT,
GST_BUFFER_TIMESTAMP (buffer),
GST_BUFFER_DURATION (buffer),
GST_BUFFER_OFFSET (buffer), GST_BUFFER_OFFSET_END (buffer));
fail_unless_equals_uint64 (timestamp, GST_BUFFER_TIMESTAMP (buffer));
fail_unless_equals_uint64 (offset, GST_BUFFER_OFFSET (buffer));
duration = GST_BUFFER_DURATION (buffer);
offset_end = GST_BUFFER_OFFSET_END (buffer);
timestamp += duration;
offset = offset_end;
gst_buffer_unref (buffer);
}
g_list_free (buffers);
buffers = NULL;
}
/* this tests that the output is a perfect stream if the input is */
static void
test_perfect_stream_instance (int inrate, int outrate, int samples,
int numbuffers)
{
GstElement *speexresample;
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
guint64 offset = 0;
int i, j;
gint16 *p;
speexresample = setup_speexresample (2, inrate, outrate, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_element_set_state (speexresample,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
for (j = 1; j <= numbuffers; ++j) {
inbuffer = gst_buffer_new_and_alloc (samples * 4);
GST_BUFFER_DURATION (inbuffer) = GST_FRAMES_TO_CLOCK_TIME (samples, inrate);
GST_BUFFER_TIMESTAMP (inbuffer) = GST_BUFFER_DURATION (inbuffer) * (j - 1);
GST_BUFFER_OFFSET (inbuffer) = offset;
offset += samples;
GST_BUFFER_OFFSET_END (inbuffer) = offset;
gst_buffer_set_caps (inbuffer, caps);
p = (gint16 *) GST_BUFFER_DATA (inbuffer);
/* create a 16 bit signed ramp */
for (i = 0; i < samples; ++i) {
*p = -32767 + i * (65535 / samples);
++p;
*p = -32767 + i * (65535 / samples);
++p;
}
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
/* ... but it ends up being collected on the global buffer list */
fail_unless_equals_int (g_list_length (buffers), j);
}
/* FIXME: we should make speexresample handle eos by flushing out the last
* samples, which will give us one more, small, buffer */
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
fail_unless_perfect_stream ();
/* cleanup */
gst_caps_unref (caps);
cleanup_speexresample (speexresample);
}
/* make sure that outgoing buffers are contiguous in timestamp/duration and
* offset/offsetend
*/
GST_START_TEST (test_perfect_stream)
{
/* integral scalings */
test_perfect_stream_instance (48000, 24000, 500, 20);
test_perfect_stream_instance (48000, 12000, 500, 20);
test_perfect_stream_instance (12000, 24000, 500, 20);
test_perfect_stream_instance (12000, 48000, 500, 20);
/* non-integral scalings */
test_perfect_stream_instance (44100, 8000, 500, 20);
test_perfect_stream_instance (8000, 44100, 500, 20);
/* wacky scalings */
test_perfect_stream_instance (12345, 54321, 500, 20);
test_perfect_stream_instance (101, 99, 500, 20);
}
GST_END_TEST;
/* this tests that the output is a correct discontinuous stream
* if the input is; ie input drops in time come out the same way */
static void
test_discont_stream_instance (int inrate, int outrate, int samples,
int numbuffers)
{
GstElement *speexresample;
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
GstClockTime ints;
int i, j;
gint16 *p;
GST_DEBUG ("inrate:%d outrate:%d samples:%d numbuffers:%d",
inrate, outrate, samples, numbuffers);
speexresample = setup_speexresample (2, inrate, outrate, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_element_set_state (speexresample,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
for (j = 1; j <= numbuffers; ++j) {
inbuffer = gst_buffer_new_and_alloc (samples * 4);
GST_BUFFER_DURATION (inbuffer) = samples * GST_SECOND / inrate;
/* "drop" half the buffers */
ints = GST_BUFFER_DURATION (inbuffer) * 2 * (j - 1);
GST_BUFFER_TIMESTAMP (inbuffer) = ints;
GST_BUFFER_OFFSET (inbuffer) = (j - 1) * 2 * samples;
GST_BUFFER_OFFSET_END (inbuffer) = j * 2 * samples + samples;
gst_buffer_set_caps (inbuffer, caps);
p = (gint16 *) GST_BUFFER_DATA (inbuffer);
/* create a 16 bit signed ramp */
for (i = 0; i < samples; ++i) {
*p = -32767 + i * (65535 / samples);
++p;
*p = -32767 + i * (65535 / samples);
++p;
}
GST_DEBUG ("Sending Buffer time:%" G_GUINT64_FORMAT " duration:%"
G_GINT64_FORMAT " discont:%d offset:%" G_GUINT64_FORMAT " offset_end:%"
G_GUINT64_FORMAT, GST_BUFFER_TIMESTAMP (inbuffer),
GST_BUFFER_DURATION (inbuffer), GST_BUFFER_IS_DISCONT (inbuffer),
GST_BUFFER_OFFSET (inbuffer), GST_BUFFER_OFFSET_END (inbuffer));
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
/* check if the timestamp of the pushed buffer matches the incoming one */
outbuffer = g_list_nth_data (buffers, g_list_length (buffers) - 1);
fail_if (outbuffer == NULL);
fail_unless_equals_uint64 (ints, GST_BUFFER_TIMESTAMP (outbuffer));
GST_DEBUG ("Got Buffer time:%" G_GUINT64_FORMAT " duration:%"
G_GINT64_FORMAT " discont:%d offset:%" G_GUINT64_FORMAT " offset_end:%"
G_GUINT64_FORMAT, GST_BUFFER_TIMESTAMP (outbuffer),
GST_BUFFER_DURATION (outbuffer), GST_BUFFER_IS_DISCONT (outbuffer),
GST_BUFFER_OFFSET (outbuffer), GST_BUFFER_OFFSET_END (outbuffer));
if (j > 1) {
fail_unless (GST_BUFFER_IS_DISCONT (outbuffer),
"expected discont for buffer #%d", j);
}
}
/* cleanup */
gst_caps_unref (caps);
cleanup_speexresample (speexresample);
}
GST_START_TEST (test_discont_stream)
{
/* integral scalings */
test_discont_stream_instance (48000, 24000, 500, 20);
test_discont_stream_instance (48000, 12000, 500, 20);
test_discont_stream_instance (12000, 24000, 500, 20);
test_discont_stream_instance (12000, 48000, 500, 20);
/* non-integral scalings */
test_discont_stream_instance (44100, 8000, 500, 20);
test_discont_stream_instance (8000, 44100, 500, 20);
/* wacky scalings */
test_discont_stream_instance (12345, 54321, 500, 20);
test_discont_stream_instance (101, 99, 500, 20);
}
GST_END_TEST;
GST_START_TEST (test_reuse)
{
GstElement *speexresample;
GstEvent *newseg;
GstBuffer *inbuffer;
GstCaps *caps;
speexresample = setup_speexresample (1, 9343, 48000, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_element_set_state (speexresample,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
newseg = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1, 0);
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
inbuffer = gst_buffer_new_and_alloc (9343 * 4);
memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
gst_buffer_set_caps (inbuffer, caps);
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
/* ... but it ends up being collected on the global buffer list */
fail_unless_equals_int (g_list_length (buffers), 1);
/* now reset and try again ... */
fail_unless (gst_element_set_state (speexresample,
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to NULL");
fail_unless (gst_element_set_state (speexresample,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
newseg = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1, 0);
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
inbuffer = gst_buffer_new_and_alloc (9343 * 4);
memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
gst_buffer_set_caps (inbuffer, caps);
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
/* ... it also ends up being collected on the global buffer list. If we
* now have more than 2 buffers, then speexresample probably didn't clean
* up its internal buffer properly and tried to push the remaining samples
* when it got the second NEWSEGMENT event */
fail_unless_equals_int (g_list_length (buffers), 2);
cleanup_speexresample (speexresample);
gst_caps_unref (caps);
}
GST_END_TEST;
GST_START_TEST (test_shutdown)
{
GstElement *pipeline, *src, *cf1, *ar, *cf2, *sink;
GstCaps *caps;
guint i;
/* create pipeline, force speexresample to actually resample */
pipeline = gst_pipeline_new (NULL);
src = gst_check_setup_element ("audiotestsrc");
cf1 = gst_check_setup_element ("capsfilter");
ar = gst_check_setup_element ("audioresample");
cf2 = gst_check_setup_element ("capsfilter");
g_object_set (cf2, "name", "capsfilter2", NULL);
sink = gst_check_setup_element ("fakesink");
caps =
gst_caps_new_simple ("audio/x-raw-int", "rate", G_TYPE_INT, 11025, NULL);
g_object_set (cf1, "caps", caps, NULL);
gst_caps_unref (caps);
caps =
gst_caps_new_simple ("audio/x-raw-int", "rate", G_TYPE_INT, 48000, NULL);
g_object_set (cf2, "caps", caps, NULL);
gst_caps_unref (caps);
/* don't want to sync against the clock, the more throughput the better */
g_object_set (src, "is-live", FALSE, NULL);
g_object_set (sink, "sync", FALSE, NULL);
gst_bin_add_many (GST_BIN (pipeline), src, cf1, ar, cf2, sink, NULL);
fail_if (!gst_element_link_many (src, cf1, ar, cf2, sink, NULL));
/* now, wait until pipeline is running and then shut it down again; repeat */
for (i = 0; i < 20; ++i) {
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gst_element_get_state (pipeline, NULL, NULL, -1);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_usleep (100);
gst_element_set_state (pipeline, GST_STATE_NULL);
}
gst_object_unref (pipeline);
}
GST_END_TEST;
static GstFlowReturn
live_switch_alloc_only_48000 (GstPad * pad, guint64 offset,
guint size, GstCaps * caps, GstBuffer ** buf)
{
GstStructure *structure;
gint rate;
gint channels;
GstCaps *desired;
structure = gst_caps_get_structure (caps, 0);
fail_unless (gst_structure_get_int (structure, "rate", &rate));
fail_unless (gst_structure_get_int (structure, "channels", &channels));
if (rate < 48000)
return GST_FLOW_NOT_NEGOTIATED;
desired = gst_caps_copy (caps);
gst_caps_set_simple (desired, "rate", G_TYPE_INT, 48000, NULL);
*buf = gst_buffer_new_and_alloc (channels * 48000);
gst_buffer_set_caps (*buf, desired);
gst_caps_unref (desired);
return GST_FLOW_OK;
}
static GstCaps *
live_switch_get_sink_caps (GstPad * pad)
{
GstCaps *result;
result = gst_caps_copy (GST_PAD_CAPS (pad));
gst_caps_set_simple (result,
"rate", GST_TYPE_INT_RANGE, 48000, G_MAXINT, NULL);
return result;
}
static void
live_switch_push (int rate, GstCaps * caps)
{
GstBuffer *inbuffer;
GstCaps *desired;
GList *l;
desired = gst_caps_copy (caps);
gst_caps_set_simple (desired, "rate", G_TYPE_INT, rate, NULL);
gst_pad_set_caps (mysrcpad, desired);
fail_unless (gst_pad_alloc_buffer_and_set_caps (mysrcpad,
GST_BUFFER_OFFSET_NONE, rate * 4, desired, &inbuffer) == GST_FLOW_OK);
/* When the basetransform hits the non-configured case it always
* returns a buffer with exactly the same caps as we requested so the actual
* renegotiation (if needed) will be done in the _chain*/
fail_unless (inbuffer != NULL);
GST_DEBUG ("desired: %" GST_PTR_FORMAT ".... got: %" GST_PTR_FORMAT,
desired, GST_BUFFER_CAPS (inbuffer));
fail_unless (gst_caps_is_equal (desired, GST_BUFFER_CAPS (inbuffer)));
memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
/* ... but it ends up being collected on the global buffer list */
fail_unless_equals_int (g_list_length (buffers), 1);
for (l = buffers; l; l = l->next) {
GstBuffer *buffer = GST_BUFFER (l->data);
gst_buffer_unref (buffer);
}
g_list_free (buffers);
buffers = NULL;
gst_caps_unref (desired);
}
GST_START_TEST (test_live_switch)
{
GstElement *speexresample;
GstEvent *newseg;
GstCaps *caps;
speexresample = setup_speexresample (4, 48000, 48000, 16, FALSE);
/* Let the sinkpad act like something that can only handle things of
* rate 48000- and can only allocate buffers for that rate, but if someone
* tries to get a buffer with a rate higher then 48000 tries to renegotiate
* */
gst_pad_set_bufferalloc_function (mysinkpad, live_switch_alloc_only_48000);
gst_pad_set_getcaps_function (mysinkpad, live_switch_get_sink_caps);
gst_pad_use_fixed_caps (mysrcpad);
caps = gst_pad_get_negotiated_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_element_set_state (speexresample,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
newseg = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1, 0);
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
/* downstream can provide the requested rate, a buffer alloc will be passed
* on */
live_switch_push (48000, caps);
/* Downstream can never accept this rate, buffer alloc isn't passed on */
live_switch_push (40000, caps);
/* Downstream can provide the requested rate but will re-negotiate */
live_switch_push (50000, caps);
cleanup_speexresample (speexresample);
gst_caps_unref (caps);
}
GST_END_TEST;
#ifndef GST_DISABLE_PARSE
static GMainLoop *loop;
static gint messages = 0;
static void
element_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
{
gchar *s;
s = gst_structure_to_string (gst_message_get_structure (message));
GST_DEBUG ("Received message: %s", s);
g_free (s);
messages++;
}
static void
eos_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
{
GST_DEBUG ("Received eos");
g_main_loop_quit (loop);
}
static void
test_pipeline (gint width, gboolean fp, gint inrate, gint outrate, gint quality)
{
GstElement *pipeline;
GstBus *bus;
GError *error = NULL;
gchar *pipe_str;
pipe_str =
g_strdup_printf
("audiotestsrc num-buffers=10 ! audioconvert ! audio/x-raw-%s,rate=%d,width=%d,channels=2 ! audioresample quality=%d ! audio/x-raw-%s,rate=%d,width=%d ! identity check-imperfect-timestamp=TRUE ! fakesink",
(fp) ? "float" : "int", inrate, width, quality, (fp) ? "float" : "int",
outrate, width);
pipeline = gst_parse_launch (pipe_str, &error);
fail_unless (pipeline != NULL, "Error parsing pipeline: %s",
error ? error->message : "(invalid error)");
g_free (pipe_str);
bus = gst_element_get_bus (pipeline);
fail_if (bus == NULL);
gst_bus_add_signal_watch (bus);
g_signal_connect (bus, "message::element", (GCallback) element_message_cb,
NULL);
g_signal_connect (bus, "message::eos", (GCallback) eos_message_cb, NULL);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* run until we receive EOS */
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
g_main_loop_unref (loop);
loop = NULL;
gst_element_set_state (pipeline, GST_STATE_NULL);
fail_if (messages > 0, "Received imperfect timestamp messages");
gst_object_unref (pipeline);
}
GST_START_TEST (test_pipelines)
{
gint quality;
/* Test qualities 0, 5 and 10 */
for (quality = 0; quality < 11; quality += 5) {
test_pipeline (8, FALSE, 44100, 48000, quality);
test_pipeline (8, FALSE, 48000, 44100, quality);
test_pipeline (16, FALSE, 44100, 48000, quality);
test_pipeline (16, FALSE, 48000, 44100, quality);
test_pipeline (24, FALSE, 44100, 48000, quality);
test_pipeline (24, FALSE, 48000, 44100, quality);
test_pipeline (32, FALSE, 44100, 48000, quality);
test_pipeline (32, FALSE, 48000, 44100, quality);
test_pipeline (32, TRUE, 44100, 48000, quality);
test_pipeline (32, TRUE, 48000, 44100, quality);
test_pipeline (64, TRUE, 44100, 48000, quality);
test_pipeline (64, TRUE, 48000, 44100, quality);
}
}
GST_END_TEST;
#endif
static Suite *
speexresample_suite (void)
{
Suite *s = suite_create ("speexresample");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_perfect_stream);
tcase_add_test (tc_chain, test_discont_stream);
tcase_add_test (tc_chain, test_reuse);
tcase_add_test (tc_chain, test_shutdown);
tcase_add_test (tc_chain, test_live_switch);
#ifndef GST_DISABLE_PARSE
tcase_set_timeout (tc_chain, 360);
tcase_add_test (tc_chain, test_pipelines);
#endif
return s;
}
GST_CHECK_MAIN (speexresample);