changeset 8342:86835828d5b5

Add Tremor (an integer-only Vorbis decoder) support.
author rguyom
date Wed, 04 Dec 2002 20:27:36 +0000
parents fd670708f87f
children 638ac2c26646
files configure libmpcodecs/ad_libvorbis.c libmpdemux/demux_ogg.c
diffstat 3 files changed, 36 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Wed Dec 04 12:41:57 2002 +0000
+++ b/configure	Wed Dec 04 20:27:36 2002 +0000
@@ -170,6 +170,7 @@
   --disable-libavcodec   disable libavcodec [autodetect]
   --enable-libfame       enable libfame realtime encoder [autodetect]
   --enable-vorbis        build with OggVorbis support [autodetect]
+  --enable-tremor        build with integer-only OggVorbis support [disabled]
   --enable-faad          build with FAAD2 (MP4/AAC) support [autodetect]
   --disable-libdv        disable libdv 0.9.5 en/decoding support [autodetect]
   --disable-mad          disable libmad (mpeg audio) support [autodetect]
@@ -964,6 +965,7 @@
 _liblzo=auto
 _mad=auto
 _vorbis=auto
+_tremor=no
 _faad=auto
 _css=auto
 _dvdnav=yes
@@ -1099,6 +1101,8 @@
   --disable-liblzo)	_liblzo=no		;;
   --enable-vorbis)	_vorbis=yes	;;
   --disable-vorbis)	_vorbis=no	;;
+  --enable-tremor)	_tremor=yes	;;
+  --disable-tremor)	_tremor=no	;;
   --enable-faad)	_faad=yes	;;
   --disable-faad)	_faad=no	;;
   --enable-css)		_css=yes	;;
@@ -3580,10 +3584,17 @@
 fi
 if test "$_vorbis" = yes ; then
   _def_vorbis='#define HAVE_OGGVORBIS 1'
-  _ld_vorbis='-lvorbis -logg'
+  if test "$_tremor" = yes ; then
+    _def_tremor='#define TREMOR 1'
+    _ld_vorbis='-lvorbisidec -logg'
+  else
+    _def_tremor='#undef TREMOR'
+    _ld_vorbis='-lvorbis -logg'
+  fi
   _codecmodules="libvorbis $_codecmodules"
 else
   _def_vorbis='#undef HAVE_OGGVORBIS'
+  _def_tremor='#undef TREMOR'
   _nocodecmodules="libvorbis $_nocodecmodules"
 fi
 echores "$_vorbis"
@@ -5020,6 +5031,9 @@
 /* enable OggVorbis support */
 $_def_vorbis
 
+/* enable Tremor as vorbis decoder */
+$_def_tremor
+
 /* enable FAAD (AAC) support */
 $_def_faad
 
--- a/libmpcodecs/ad_libvorbis.c	Wed Dec 04 12:41:57 2002 +0000
+++ b/libmpcodecs/ad_libvorbis.c	Wed Dec 04 20:27:36 2002 +0000
@@ -25,7 +25,11 @@
 
 LIBAD_EXTERN(libvorbis)
 
+#ifdef TREMOR
+#include <tremor/ivorbiscodec.h>
+#else
 #include <vorbis/codec.h>
+#endif
 
 // This struct is also defined in demux_ogg.c => common header ?
 typedef struct ov_struct_st {
@@ -35,6 +39,9 @@
   vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
   vorbis_block     vb; /* local working space for packet->PCM decode */
   float            rg_scale; /* replaygain scale */
+#ifdef TREMOR
+  int              rg_scale_int;
+#endif
 } ov_struct_t;
 
 static int read_vorbis_comment( char* ptr, char* comment, char* format, ... ) {
@@ -125,6 +132,9 @@
     /* replaygain: security */
     if(ov->rg_scale > 15.) 
       ov->rg_scale = 15.;
+#ifdef TREMOR
+    ov->rg_scale_int = (int)(ov->rg_scale*256.f);
+#endif
     mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Bitstream is %d channel%s, %dHz, %dbit/s %cBR\n",(int)ov->vi.channels,ov->vi.channels>1?"s":"",(int)ov->vi.rate,(int)ov->vi.bitrate_nominal,
 	(ov->vi.bitrate_lower!=ov->vi.bitrate_nominal)||(ov->vi.bitrate_upper!=ov->vi.bitrate_nominal)?'V':'C');
     if(rg_gain || rg_peak)
@@ -199,13 +209,15 @@
 	    for(i=0;i<ov->vi.channels;i++){
 	      ogg_int16_t *convbuffer=(ogg_int16_t *)(&buf[len]);
 	      ogg_int16_t *ptr=convbuffer+i;
+#ifdef TREMOR
+	      ogg_int32_t  *mono=pcm[i];
+	      for(j=0;j<bout;j++){
+		int val=(mono[j]*ov->rg_scale_int)>>(9+8);
+#else
 	      float  *mono=pcm[i];
 	      for(j=0;j<bout;j++){
-#if 1
 		int val=mono[j]*32767.f*ov->rg_scale;
-#else /* optional dither */
-		int val=mono[j]*32767.f*ov->rg_scale+drand48()-0.5f;
-#endif
+#endif    /* TREMOR */
 		/* might as well guard against clipping */
 		if(val>32767){
 		  val=32767;
--- a/libmpdemux/demux_ogg.c	Wed Dec 04 12:41:57 2002 +0000
+++ b/libmpdemux/demux_ogg.c	Wed Dec 04 20:27:36 2002 +0000
@@ -13,8 +13,13 @@
 #include "demuxer.h"
 #include "stheader.h"
 
+#ifdef TREMOR
+#include <tremor/ogg.h>
+#include <tremor/ivorbiscodec.h>
+#else
 #include <ogg/ogg.h>
 #include <vorbis/codec.h>
+#endif
 
 #define BLOCK_SIZE 4096