changeset 16915:6b1d1e4adaea

Speex support. Seeking and pts generation does not work.
author reimar
date Sat, 05 Nov 2005 11:58:25 +0000
parents 701af802aee7
children 56f3945e2a61
files AUTHORS ChangeLog Makefile configure etc/codecs.conf libmpcodecs/Makefile libmpcodecs/ad.c libmpdemux/demux_ogg.c
diffstat 8 files changed, 84 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/AUTHORS	Sat Nov 05 11:40:06 2005 +0000
+++ b/AUTHORS	Sat Nov 05 11:58:25 2005 +0000
@@ -216,6 +216,7 @@
     * made MMS over HTTP stream selection work and modified ASF header parsing
     * reimplemented ao_jack without bio2jack dependency
     * musepack demuxer and decoder, based on Reza's patch
+    * speex decoder via libspeex
     * MPEG-2 in GXF demuxer
     * vo_gl ported to windows
     * gl_commmon.[ch] to decrease code duplication
--- a/ChangeLog	Sat Nov 05 11:40:06 2005 +0000
+++ b/ChangeLog	Sat Nov 05 11:58:25 2005 +0000
@@ -34,6 +34,7 @@
     * support for dmb1 MJPEG files with ffmjpeg
     * support for musepack audio (WARNING: when muxing into e.g. AVI you will
       be able to seek, but you might get ear- and speaker-breaking noises)
+    * experimental speex support via libspeex
     * On2 VP7 video decoder via binary DLL
     * Duck/On2 TrueMotion2 (TM20) support via lavc
     * support FLX and DTA extensions for flic files
--- a/Makefile	Sat Nov 05 11:40:06 2005 +0000
+++ b/Makefile	Sat Nov 05 11:58:25 2005 +0000
@@ -104,6 +104,7 @@
              $(XMMS_LIB) \
              $(X264_LIB) \
              $(MUSEPACK_LIB) \
+             $(SPEEX_LIB) \
 
 COMMON_LIBS = libmpcodecs/libmpcodecs.a \
               $(W32_LIB) \
--- a/configure	Sat Nov 05 11:40:06 2005 +0000
+++ b/configure	Sat Nov 05 11:58:25 2005 +0000
@@ -243,6 +243,7 @@
   --enable-tremor-low    build with lower accuracy internal tremor [disabled]
   --enable-external-tremor build with external tremor [disabled]
   --disable-vorbis       disable OggVorbis support entirely [autodetect]
+  --disable-speex        disable Speex support [autodetect]
   --enable-theora        build with OggTheora support [autodetect]
   --disable-internal-matroska disable internal Matroska support [enabled]
   --enable-external-faad build with external FAAD2 (AAC) support [autodetect]
@@ -1486,6 +1487,7 @@
 _tremor_internal=yes
 _tremor_low=no
 _vorbis=auto
+_speex=auto
 _theora=auto
 _mp3lib=yes
 _liba52=yes
@@ -1679,6 +1681,8 @@
   --disable-liblzo)	_liblzo=no		;;
   --enable-vorbis)	_vorbis=yes	;;
   --disable-vorbis)	_vorbis=no	;;
+  --enable-speex)	_speex=yes	;;
+  --disable-speex)	_speex=no	;;
   --enable-internal-tremor)	_tremor_internal=yes	;;
   --disable-internal-tremor)	_tremor_internal=no	;;
   --enable-tremor-low)	_tremor_low=yes	;;
@@ -5389,6 +5393,29 @@
 fi
 echores "$_vorbis"
 
+echocheck "libspeex (version >= 1.1 required)"
+if test "$_speex" = auto ; then
+  _speex=no
+  cat > $TMPC << EOF
+#include <speex/speex.h>
+int main(void) {
+  SpeexBits bits;
+  void *dec;
+  speex_decode_int(dec, &bits, dec);
+}
+EOF
+  cc_check -lspeex $_ld_lm && _speex=yes
+fi
+if test "$_speex" = yes ; then
+  _def_speex='#define HAVE_SPEEX 1'
+  _ld_speex='-lspeex'
+  _codecmodules="speex $_codecmodules"
+else
+  _def_speex='#undef HAVE_SPEEX'
+  _nocodecmodules="speex $_nocodecmodules"
+fi
+echores "$_speex"
+
 echocheck "OggTheora support"
 if test "$_theora" = auto ; then
   _theora=no
@@ -6982,6 +7009,7 @@
 TREMOR = $_tremor_internal
 TREMOR_FLAGS = $_tremor_flags
 
+SPEEX = $_speex
 MUSEPACK = $_musepack
 
 UNRARLIB = $_unrarlib
@@ -7091,6 +7119,7 @@
 LIBLZO_LIB= $_ld_liblzo
 MAD_LIB = $_ld_mad
 VORBIS_LIB = $_ld_vorbis $_ld_libdv
+SPEEX_LIB = $_ld_speex
 THEORA_LIB = $_ld_theora
 FAAD_LIB = $_ld_faad
 INTERNAL_FAAD = $_faad_internal
@@ -7669,6 +7698,9 @@
 /* enable Tremor as vorbis decoder */
 $_def_tremor
 
+/* enable Speex support */
+$_def_speex
+
 /* enable musepack support */
 $_def_musepack
 
--- a/etc/codecs.conf	Sat Nov 05 11:40:06 2005 +0000
+++ b/etc/codecs.conf	Sat Nov 05 11:58:25 2005 +0000
@@ -2628,6 +2628,14 @@
 ;  driver acm
 ;  dll "vorbis.acm"
 
+audiocodec speex
+  info "Speex Audio Decoder"
+  status working
+  comment "Speex driver using libspeex"
+  fourcc 'spx '
+  driver speex
+  dll "speex"
+
 audiocodec vivoaudio
   info "Vivo G.723/Siren Audio Codec"
   status working
--- a/libmpcodecs/Makefile	Sat Nov 05 11:40:06 2005 +0000
+++ b/libmpcodecs/Makefile	Sat Nov 05 11:58:25 2005 +0000
@@ -209,6 +209,10 @@
 AUDIO_SRCS += ad_mpc.c
 endif
 
+ifeq ($(SPEEX),yes)
+AUDIO_SRCS += ad_speex.c
+endif
+
 ifeq ($(FAAC),yes)
 ENCODER_SRCS += ae_faac.c
 endif
--- a/libmpcodecs/ad.c	Sat Nov 05 11:40:06 2005 +0000
+++ b/libmpcodecs/ad.c	Sat Nov 05 11:58:25 2005 +0000
@@ -33,6 +33,7 @@
 extern ad_functions_t mpcodecs_ad_msgsm;
 extern ad_functions_t mpcodecs_ad_faad;
 extern ad_functions_t mpcodecs_ad_libvorbis;
+extern ad_functions_t mpcodecs_ad_speex;
 extern ad_functions_t mpcodecs_ad_libmad;
 extern ad_functions_t mpcodecs_ad_realaud;
 extern ad_functions_t mpcodecs_ad_libdv;
@@ -78,6 +79,9 @@
 #ifdef HAVE_OGGVORBIS
   &mpcodecs_ad_libvorbis,
 #endif
+#ifdef HAVE_SPEEX
+  &mpcodecs_ad_speex,
+#endif
 #ifdef USE_LIBMAD
   &mpcodecs_ad_libmad,
 #endif
--- a/libmpdemux/demux_ogg.c	Sat Nov 05 11:40:06 2005 +0000
+++ b/libmpdemux/demux_ogg.c	Sat Nov 05 11:58:25 2005 +0000
@@ -16,6 +16,7 @@
 #include "stheader.h"
 
 #define FOURCC_VORBIS mmioFOURCC('v', 'r', 'b', 's')
+#define FOURCC_SPEEX  mmioFOURCC('s', 'p', 'x', ' ')
 #define FOURCC_THEORA mmioFOURCC('t', 'h', 'e', 'o')
 
 #ifdef TREMOR
@@ -116,6 +117,7 @@
   ogg_stream_state stream;
   int hdr_packets;
   int vorbis;
+  int speex;
   int theora;
   int flac;
   int text;
@@ -352,6 +354,8 @@
        os->lastsize = blocksize;
        os->lastpos = pack->granulepos;
     }
+  } else if (os->speex) {
+    data = pack->packet;
 # ifdef HAVE_OGGTHEORA
   } else if (os->theora) {
      /* we pass complete packets to theora, mustn't strip the header! */
@@ -536,6 +540,13 @@
       demux_ogg_add_sub(os,pack);
     return 0;
   }
+  if (os->speex) {
+    // discard first two packets, they contain the header and comment
+    if (os->hdr_packets < 2) {
+      os->hdr_packets++;
+      return 0;
+    }
+  } else
   // If packet is an header we jump it except for vorbis and theora
   // (PACKET_TYPE_HEADER bit doesn't even exist for theora ?!)
   // We jump nothing for FLAC. Ain't this great? Packet contents have to be
@@ -916,6 +927,27 @@
       ogg_d->subs[ogg_d->num_sub].id = n_audio;
       n_audio++;
       mp_msg(MSGT_DEMUX,MSGL_INFO,"[Ogg] stream %d: audio (Vorbis), -aid %d\n",ogg_d->num_sub,n_audio-1);
+    } else if (pack.bytes >= 80 && !strncmp(pack.packet,"Speex", 5)) {
+      sh_a = new_sh_audio(demuxer, ogg_d->num_sub);
+      sh_a->wf = (WAVEFORMATEX*)calloc(1, sizeof(WAVEFORMATEX) + pack.bytes);
+      sh_a->format = FOURCC_SPEEX;
+      sh_a->samplerate = sh_a->wf->nSamplesPerSec = get_uint32(&pack.packet[36]);
+      sh_a->channels = sh_a->wf->nChannels = get_uint32(&pack.packet[48]);
+      sh_a->wf->wFormatTag = sh_a->format;
+      sh_a->wf->nAvgBytesPerSec = get_uint32(&pack.packet[52]);
+      sh_a->wf->nBlockAlign = 0;
+      sh_a->wf->wBitsPerSample = 16;
+      sh_a->samplesize = 2;
+      sh_a->wf->cbSize = pack.bytes;
+      memcpy(&sh_a->wf[1], pack.packet, pack.bytes);
+
+      ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate;
+      ogg_d->subs[ogg_d->num_sub].speex = 1;
+      if (identify)
+        mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio);
+      ogg_d->subs[ogg_d->num_sub].id = n_audio;
+      n_audio++;
+      mp_msg(MSGT_DEMUX,MSGL_INFO,"[Ogg] stream %d: audio (Speex), -aid %d\n",ogg_d->num_sub,n_audio-1);
 
       // check for Theora
 #   ifdef HAVE_OGGTHEORA
@@ -1549,7 +1581,7 @@
           break;
         }
       }
-      if(!precision && (is_keyframe || os->vorbis) ) {
+      if(!precision && (is_keyframe || os->vorbis || os->speex) ) {
         ogg_sub.lines = 0;
         vo_sub = &ogg_sub;
         vo_osd_changed(OSDTYPE_SUBTITLE);