[xiph-cvs] cvs commit: speex/win32/libspeex libspeex.dsp

Jean-Marc Valin jm at xiph.org
Fri Nov 8 22:00:03 PST 2002



jm          02/11/09 01:00:02

  Modified:    libspeex Makefile.am sb_celp.c
               src      speexdec.1 speexdec.c speexenc.1 speexenc.c
               win32/libspeex libspeex.dsp
  Log:
  Preparing for beta 3, cleaned up the mode/bit-rate code in speexdec,
  updated the help and man pages, updated MSVC project.

Revision  Changes    Path
1.47      +2 -3      speex/libspeex/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/Makefile.am,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- Makefile.am	7 Nov 2002 22:13:15 -0000	1.46
+++ Makefile.am	9 Nov 2002 06:00:02 -0000	1.47
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in. -*-Makefile-*-
 
-# $Id: Makefile.am,v 1.46 2002/11/07 22:13:15 jm Exp $
+# $Id: Makefile.am,v 1.47 2002/11/09 06:00:02 jm Exp $
 
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
@@ -59,8 +59,7 @@
         misc.h \
         ltp_sse.h \
         filters_sse.h \
-	math_approx.h \
-	speex_stereo.h
+	math_approx.h
         
         
 libspeex_la_LDFLAGS = -release $(LT_RELEASE)

<p><p>1.91      +4 -3      speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -r1.90 -r1.91
--- sb_celp.c	8 Nov 2002 05:58:59 -0000	1.90
+++ sb_celp.c	9 Nov 2002 06:00:02 -0000	1.91
@@ -940,6 +940,7 @@
       {
          int nb_qual;
          int quality = (*(int*)ptr);
+         /*FIXME: Cleanup needed, should be a mode property*/
          switch (quality)
          {
          case 0:
@@ -955,15 +956,15 @@
             st->submodeID = 1;
             break;
          case 3:
-            nb_qual=4;
+            nb_qual=3;
             st->submodeID = 1;
             break;
          case 4:
-            nb_qual=6;
+            nb_qual=5;
             st->submodeID = 1;
             break;
          case 5:
-            nb_qual=8;
+            nb_qual=7;
             st->submodeID = 1;
             break;
          case 6:

<p><p>1.3       +23 -11    speex/src/speexdec.1

Index: speexdec.1
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexdec.1,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- speexdec.1	25 Sep 2002 17:51:21 -0000	1.2
+++ speexdec.1	9 Nov 2002 06:00:02 -0000	1.3
@@ -1,13 +1,10 @@
 .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.29.
-.TH SPEEX "1" "September 2002" "Speex decoder version 1.0beta1 (compiled Sep 18 2002)" "User Commands"
+.TH SPEEXDEC "1" "November 2002" "speexdec (Speex decoder) version 1.0beta3-cvs (compiled Nov  9 2002)" "User Commands"
 .SH NAME
-Speex \- manual page for Speex decoder version 1.0beta1 (compiled Sep 18 2002)
+speexdec \- manual page for speexdec (Speex decoder) version 1.0beta3-cvs (compiled Nov  9 2002)
 .SH SYNOPSIS
 .B speexdec
-[\fIoptions\fR] \fIinput_file.spx\fR
-.br
-.B speexdec
-[\fIoptions\fR] \fIinput_file.spx output_file.wav\fR
+[\fIoptions\fR] \fIinput_file.spx \fR[\fIoutput_file\fR]
 .SH DESCRIPTION
 Decodes a Speex file and produce a WAV file or raw file
 .SS "input_file can be:"
@@ -20,16 +17,16 @@
 .SS "output_file can be:"
 .TP
 filename.wav
-wav file
+Wav file
 .TP
 filename.*
-raw PCM file (any extension other that .wav)
+Raw PCM file (any extension other that .wav)
 .TP
 -
 stdout
 .TP
 (nothing)
-will be played to soundcard
+Will be played to soundcard
 .SH OPTIONS
 .TP
 \fB\-\-enh\fR
@@ -39,10 +36,19 @@
 Disable perceptual enhancement (default FOR NOW)
 .TP
 \fB\-\-force\-nb\fR
-Force decoding in narrowband, even for wideband
+Force decoding in narrowband
 .TP
 \fB\-\-force\-wb\fR
-Force decoding in wideband, even for narrowband
+Force decoding in wideband
+.TP
+\fB\-\-force\-uwb\fR
+Force decoding in ultra-wideband
+.TP
+\fB\-\-mono\fR
+Force decoding in mono
+.TP
+\fB\-\-stereo\fR
+Force decoding in stereo
 .TP
 \fB\-\-packet\-loss\fR n
 Simulate n % random packet loss
@@ -61,3 +67,9 @@
 .TP
 \fB\-\-no\-pf\fR
 Deprecated, use \fB\-\-no\-pf\fR instead
+.PP
+More information is available from the Speex site: http://www.speex.org
+.PP
+Please report bugs to the mailing list `speex-dev at xiph.org'.
+.SH COPYRIGHT
+Copyright \(co 2002 Jean-Marc Valin

<p><p>1.57      +34 -24    speex/src/speexdec.c

Index: speexdec.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexdec.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- speexdec.c	7 Nov 2002 22:13:15 -0000	1.56
+++ speexdec.c	9 Nov 2002 06:00:02 -0000	1.57
@@ -102,7 +102,12 @@
 #if defined HAVE_SYS_SOUNDCARD_H
       int audio_fd, format, stereo;
       audio_fd=open("/dev/dsp", O_WRONLY);
-      
+      if (audio_fd<0)
+      {
+         perror("Cannot open /dev/dsp");
+         exit(1);         
+      }
+
       format=AFMT_S16_LE;
       if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format)==-1)
       {
@@ -110,9 +115,9 @@
          close(audio_fd);
          exit(1);
       }
-      
+
       stereo=0;
-      if (*channels=2)
+      if (*channels==2)
          stereo=1;
       if (ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo)==-1)
       {
@@ -125,7 +130,6 @@
          if (*channels==1)
             fprintf (stderr, "Cannot set mono mode, will decode in stereo\n");
          *channels=2;
-         fprintf (stderr, "Cannot set mono mode\n");
       }
 
       if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &rate)==-1)
@@ -136,7 +140,7 @@
       }
       fout = fdopen(audio_fd, "w");
 #elif defined WIN32 || defined _WIN32
-      if (Set_WIN_Params (INVALID_FILEDESC, rate, SAMPLE_SIZE, 1))
+      if (Set_WIN_Params (INVALID_FILEDESC, rate, SAMPLE_SIZE, *channels))
       {
          fprintf (stderr, "Can't access %s\n", "WAVE OUT");
          exit(1);
@@ -174,28 +178,26 @@
 
 void usage()
 {
-   /*printf ("Speex decoder version " VERSION " (compiled " __DATE__ ")\n");
-   printf ("\n");*/
-   printf ("Usage: speexdec [options] input_file.spx\n");
-   printf ("       speexdec [options] input_file.spx output_file.wav\n");
+   printf ("Usage: speexdec [options] input_file.spx [output_file]\n");
    printf ("\n");
    printf ("Decodes a Speex file and produce a WAV file or raw file\n");
    printf ("\n");
    printf ("input_file can be:\n");
-   printf ("  filename.spx          regular Speex file\n");
-   printf ("  -                     stdin\n");
+   printf ("  filename.spx         regular Speex file\n");
+   printf ("  -                    stdin\n");
    printf ("\n");  
    printf ("output_file can be:\n");
-   printf ("  filename.wav          wav file\n");
-   printf ("  filename.*            raw PCM file (any extension other that .wav)\n");
-   printf ("  -                     stdout\n");
-   printf ("  (nothing)             will be played to soundcard\n");
+   printf ("  filename.wav         Wav file\n");
+   printf ("  filename.*           Raw PCM file (any extension other that .wav)\n");
+   printf ("  -                    stdout\n");
+   printf ("  (nothing)            Will be played to soundcard\n");
    printf ("\n");  
    printf ("Options:\n");
    printf (" --enh                 Enable perceptual enhancement\n");
    printf (" --no-enh              Disable perceptual enhancement (default FOR NOW)\n");
-   printf (" --force-nb            Force decoding in narrowband, even for wideband\n");
-   printf (" --force-wb            Force decoding in wideband, even for narrowband\n");
+   printf (" --force-nb            Force decoding in narrowband\n");
+   printf (" --force-wb            Force decoding in wideband\n");
+   printf (" --force-uwb           Force decoding in ultra-wideband\n");
    printf (" --mono                Force decoding in mono\n");
    printf (" --stereo              Force decoding in stereo\n");
    printf (" --packet-loss n       Simulate n %% random packet loss\n");
@@ -212,7 +214,8 @@
 
 void version()
 {
-   printf ("Speex decoder version " VERSION " (compiled " __DATE__ ")\n");
+   printf ("speexdec (Speex decoder) version " VERSION " (compiled " __DATE__ ")\n");
+   printf ("Copyright (C) 2002 Jean-Marc Valin\n");
 }
 
 static void *process_header(ogg_packet *op, int enh_enabled, int *frame_size, int *rate, int *nframes, int forceMode, int *channels, SpeexStereoState *stereo)
@@ -261,12 +264,16 @@
    callback.data = stereo;
    speex_decoder_ctl(st, SPEEX_SET_HANDLER, &callback);
    
-   /* FIXME: need to adjust in case the forceMode option is set */
    *rate = header->rate;
-   if (header->mode==1 && forceMode==0)
-      *rate/=2;
-   if (header->mode==0 && forceMode==1)
-      *rate*=2;
+   /* Adjust rate if --force-* options are used */
+   if (forceMode!=-1)
+   {
+      if (header->mode < forceMode)
+         *rate <<= (forceMode - header->mode);
+      if (header->mode > forceMode)
+         *rate >>= (header->mode - forceMode);
+   }
+
    *nframes = header->frames_per_packet;
 
    if (*channels==-1)
@@ -309,6 +316,7 @@
       {"no-pf", no_argument, NULL, 0},
       {"force-nb", no_argument, NULL, 0},
       {"force-wb", no_argument, NULL, 0},
+      {"force-uwb", no_argument, NULL, 0},
       {"mono", no_argument, NULL, 0},
       {"stereo", no_argument, NULL, 0},
       {"packet-loss", required_argument, NULL, 0},
@@ -370,6 +378,9 @@
          } else if (strcmp(long_options[option_index].name,"force-wb")==0)
          {
             forceMode=1;
+         } else if (strcmp(long_options[option_index].name,"force-uwb")==0)
+         {
+            forceMode=2;
          } else if (strcmp(long_options[option_index].name,"mono")==0)
          {
             channels=1;
@@ -526,7 +537,6 @@
 #endif
                   fwrite(out, sizeof(short), frame_size*channels, fout);
                   
-                  /*FIXME: Not sure we should multiply by channels here*/
                   audio_size+=sizeof(short)*frame_size*channels;
                }
             }

<p><p>1.2       +18 -7     speex/src/speexenc.1

Index: speexenc.1
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexenc.1,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- speexenc.1	16 Sep 2002 00:55:32 -0000	1.1
+++ speexenc.1	9 Nov 2002 06:00:02 -0000	1.2
@@ -1,7 +1,7 @@
 .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.29.
-.TH SPEEX "1" "September 2002" "Speex encoder version 1.0beta1 (compiled Sep 15 2002)" "User Commands"
+.TH SPEEXENC "1" "November 2002" "speexenc (Speex encoder) version 1.0beta3-cvs (compiled Nov  9 2002)" "User Commands"
 .SH NAME
-Speex \- manual page for Speex encoder version 1.0beta1 (compiled Sep 15 2002)
+speexenc \- manual page for speexenc (Speex encoder) version 1.0beta3-cvs (compiled Nov  9 2002)
 .SH SYNOPSIS
 .B speexenc
 [\fIoptions\fR] \fIinput_file output_file\fR
@@ -13,7 +13,7 @@
 wav file
 .TP
 filename.*
-raw PCM file (any extension other than .wav)
+Raw PCM file (any extension other than .wav)
 .TP
 -
 stdin
@@ -31,13 +31,12 @@
 .TP
 \fB\-w\fR, \fB\-\-wideband\fR
 Wideband (16 kHz) input file
+.HP
+\fB\-u\fR, \fB\-\-ultra\-wideband\fR "Ultra-wideband" (32 kHz) input file
 .TP
 \fB\-\-quality\fR n
 Encoding quality (0-10), default 3
 .TP
-\fB\-\-lbr\fR
-Low bit-rate mode (equivalent to \fB\-\-quality\fR 3)
-.TP
 \fB\-\-vbr\fR
 Enable variable bit-rate (VBR)
 .TP
@@ -67,6 +66,9 @@
 Verbose mode (show bit-rate)
 .SS "Raw input options:"
 .TP
+\fB\-\-rate\fR
+Sampling rate for raw input
+.TP
 \fB\-\-le\fR
 Raw input is little-endian
 .TP
@@ -78,5 +80,14 @@
 .TP
 \fB\-\-16bit\fR
 Raw input is 16-bit signed
+.TP
+\fB\-\-stereo\fR
+Consider raw input as stereo
+.PP
+Default raw PCM input is 16-bit, little-endian, mono
+.PP
+More information is available from the Speex site: http://www.speex.org
 .PP
-Default Raw PCM input is 16-bit, little-endian, mono
+Please report bugs to the mailing list `speex-dev at xiph.org'.
+.SH COPYRIGHT
+Copyright \(co 2002 Jean-Marc Valin

<p><p>1.58      +71 -106   speex/src/speexenc.c

Index: speexenc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexenc.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- speexenc.c	8 Nov 2002 05:58:59 -0000	1.57
+++ speexenc.c	9 Nov 2002 06:00:02 -0000	1.58
@@ -74,7 +74,7 @@
 int read_samples(FILE *fin,int frame_size, int bits, int channels, int lsb, float * input)
 {   
    unsigned char in[MAX_FRAME_BYTES*2];
-   int i,d;
+   int i;
    short *s;
 
    /*Read input audio*/
@@ -101,18 +101,6 @@
       }
    }
 
-#if 0
-   if(channels==2)
-   {
-      /* downmix to mono */
-      for(i=0;i<frame_size;i++)
-      {
-         d=s[i*2]+s[i*2+1];
-         s[i]=d>>1;
-      }
-   }
-#endif
-
    /* copy to float input buffer */
    for (i=0;i<frame_size*channels;i++)
    {
@@ -122,27 +110,31 @@
    return 0;
 }
 
+void version()
+{
+   printf ("speexenc (Speex encoder) version " VERSION " (compiled " __DATE__ ")\n");
+   printf ("Copyright (C) 2002 Jean-Marc Valin\n");
+}
+
 void usage()
 {
-   /*printf ("Speex encoder version " VERSION " (compiled " __DATE__ ")\n");
-   printf ("\n");*/
    printf ("Usage: speexenc [options] input_file output_file\n");
    printf ("\n");
    printf ("Encodes input_file using Speex. It can read the WAV or raw files.\n");
    printf ("\n");
    printf ("input_file can be:\n");
-   printf ("  filename.wav          wav file\n");
-   printf ("  filename.*            raw PCM file (any extension other than .wav)\n");
-   printf ("  -                     stdin\n");
+   printf ("  filename.wav      wav file\n");
+   printf ("  filename.*        Raw PCM file (any extension other than .wav)\n");
+   printf ("  -                 stdin\n");
    printf ("\n");  
    printf ("output_file can be:\n");
-   printf ("  filename.spx          Speex file\n");
-   printf ("  -                     stdout\n");
+   printf ("  filename.spx      Speex file\n");
+   printf ("  -                 stdout\n");
    printf ("\n");  
    printf ("Options:\n");
    printf (" -n, --narrowband   Narrowband (8 kHz) input file\n"); 
    printf (" -w, --wideband     Wideband (16 kHz) input file\n"); 
-   printf (" -u, --ultra-wideband \"Ultra-Wideband\" (32 kHz) input file\n"); 
+   printf (" -u, --ultra-wideband \"Ultra-wideband\" (32 kHz) input file\n"); 
    printf (" --quality n        Encoding quality (0-10), default 3\n"); 
    printf (" --vbr              Enable variable bit-rate (VBR)\n"); 
    printf (" --comp n           Set encoding complexity (0-10), default 3\n"); 
@@ -154,11 +146,12 @@
    printf (" -v, --version      Version information\n"); 
    printf (" -V                 Verbose mode (show bit-rate)\n"); 
    printf ("Raw input options:\n");
+   printf (" --rate             Sampling rate for raw input\n"); 
    printf (" --le               Raw input is little-endian\n"); 
    printf (" --be               Raw input is big-endian\n"); 
    printf (" --8bit             Raw input is 8-bit unsigned\n"); 
    printf (" --16bit            Raw input is 16-bit signed\n"); 
-   printf (" --stereo           Consider input as stereo\n"); 
+   printf (" --stereo           Consider raw input as stereo\n"); 
    printf ("Default raw PCM input is 16-bit, little-endian, mono\n"); 
    printf ("\n");
    printf ("More information is available from the Speex site: http://www.speex.org\n");
@@ -166,16 +159,11 @@
    printf ("Please report bugs to the mailing list `speex-dev at xiph.org'.\n");
 }
 
-void version()
-{
-   printf ("Speex encoder version " VERSION " (compiled " __DATE__ ")\n");
-}
 
 int main(int argc, char **argv)
 {
    int c;
    int option_index = 0;
-   int narrowband=0, wideband=0, ultrawide=0;
    char *inFile, *outFile;
    FILE *fin, *fout;
    float input[MAX_FRAME_SIZE];
@@ -201,6 +189,7 @@
       {"lin8", no_argument, NULL, 0},
       {"lin16", no_argument, NULL, 0},
       {"stereo", no_argument, NULL, 0},
+      {"rate", required_argument, NULL, 0},
       {"version", no_argument, NULL, 0},
       {"comment", required_argument, NULL, 0},
       {"author", required_argument, NULL, 0},
@@ -208,7 +197,7 @@
       {0, 0, 0, 0}
    };
    int print_bitrate=0;
-   int rate, size;
+   int rate=0, size;
    int chan=1;
    int fmt=16;
    int quality=-1;
@@ -242,14 +231,18 @@
       {
       case 0:
          if (strcmp(long_options[option_index].name,"narrowband")==0)
-            narrowband=1;
-         else if (strcmp(long_options[option_index].name,"wideband")==0)
-               wideband=1;
-         else if (strcmp(long_options[option_index].name,"ultra-wideband")==0)
-               ultrawide=1;
-         else if (strcmp(long_options[option_index].name,"vbr")==0)
-               vbr_enabled=1;
-         else if (strcmp(long_options[option_index].name,"quality")==0)
+         {
+            mode=&speex_nb_mode;
+         } else if (strcmp(long_options[option_index].name,"wideband")==0)
+         {
+            mode=&speex_wb_mode;
+         } else if (strcmp(long_options[option_index].name,"ultra-wideband")==0)
+         {
+            mode=&speex_uwb_mode;
+         } else if (strcmp(long_options[option_index].name,"vbr")==0)
+         {
+            vbr_enabled=1;
+         } else if (strcmp(long_options[option_index].name,"quality")==0)
          {
             quality = atoi (optarg);
             vbr_quality=atof(optarg);
@@ -286,6 +279,9 @@
          } else if (strcmp(long_options[option_index].name,"stereo")==0)
          {
             chan=2;
+         } else if (strcmp(long_options[option_index].name,"rate")==0)
+         {
+            rate=atoi (optarg);
          } else if (strcmp(long_options[option_index].name,"comment")==0)
          {
            comment_add(&comments, &comments_length, NULL, optarg); 
@@ -299,7 +295,7 @@
 
          break;
       case 'n':
-         narrowband=1;
+         mode=&speex_nb_mode;
          break;
       case 'h':
          usage();
@@ -313,10 +309,10 @@
          print_bitrate=1;
          break;
       case 'w':
-         wideband=1;
+         mode=&speex_wb_mode;
          break;
       case 'u':
-         ultrawide=1;
+         mode=&speex_uwb_mode;
          break;
       case '?':
          usage();
@@ -332,12 +328,6 @@
    inFile=argv[optind];
    outFile=argv[optind+1];
 
-   if ((wideband && narrowband) || (wideband && ultrawide) || (ultrawide && narrowband))
-   {
-      fprintf (stderr,"Cannot specify two modes at the same time\n");
-      exit(1);
-   };
-
    /*Initialize Ogg stream struct*/
    srand(time(NULL));
    if (ogg_stream_init(&os, rand())==-1)
@@ -368,76 +358,51 @@
       close_in=1;
    }
 
-   rate=0;
    if (strcmp(inFile+strlen(inFile)-4,".wav")==0 || strcmp(inFile+strlen(inFile)-4,".WAV")==0)
-      {
-         if (read_wav_header(fin, &rate, &chan, &fmt, &size)==-1)
-            exit(1);
-	 lsb=1; /* CHECK: exists big-endian .wav ?? */
-      }
-   /*fprintf (stderr, "wave info: %d %d %d %d\n", rate, chan, fmt, size);*/
-
-   if (rate==16000)
    {
-      wideband=1;
-      if (narrowband)
-         fprintf (stderr,"Warning: encoding a wideband file in narrowband\n");
-   } else if (rate==8000)
-   {
-      narrowband=1;
-      if (wideband)
-         fprintf (stderr,"Warning: encoding a narrowband file in wideband\n");
-   } else if (rate==22050)
-   {
-      wideband=1;
-      fprintf (stderr,"Warning: Speex is not optimized for 22.05 kHz sampling rate. Your mileage may vary\n");
-      if (narrowband)
-         fprintf (stderr,"Warning: encoding a wideband file in narrowband\n");
-   } else if (rate==32000)
-   {
-      ultrawide=1;
-      if (wideband)
-         fprintf (stderr,"Warning: encoding a narrowband file in wideband\n");
-   } else if (rate==44100)
-   {
-      fprintf (stderr,"Warning: Speex is not optimized for 44.1 kHz sampling rate. Your mileage may vary\n");
-      ultrawide=1;
-      if (wideband)
-         fprintf (stderr,"Warning: encoding a narrowband file in wideband\n");
-   } else if (rate==48000)
-   {
-      fprintf (stderr,"Warning: Speex is not optimized for 48 kHz sampling rate. Your mileage may vary\n");
-      ultrawide=1;
-      if (wideband)
-         fprintf (stderr,"Warning: encoding a narrowband file in wideband\n");
-   } else if (rate==11025)
-   {
-      fprintf (stderr,"Warning: Speex is not optimized for 11.025 kHz sampling rate. Your mileage may vary\n");
-      narrowband=1;
-      if (wideband)
-         fprintf (stderr,"Warning: encoding a narrowband file in wideband\n");
+      if (read_wav_header(fin, &rate, &chan, &fmt, &size)==-1)
+         exit(1);
+      lsb=1; /* CHECK: exists big-endian .wav ?? */
    }
+   /*fprintf (stderr, "wave info: %d %d %d %d\n", rate, chan, fmt, size);*/
 
-   if (!wideband && !ultrawide)
-      narrowband=1;
-   if (narrowband)
+   /* By default, use narrowband/8 kHz */
+   if (!mode && !rate)
    {
-      if (!rate)
-         rate = 8000;
       mode=&speex_nb_mode;
-   }
-   if (wideband)
+      rate=8000;
+   } else if (mode && rate)
    {
-      if (!rate)
-         rate = 16000;
-      mode=&speex_wb_mode;
-   }
-   if (ultrawide)
+      /*FIXME: Should print some warnings if mode doesn't fit with the rate*/
+   } else if (!mode)
    {
-      if (!rate)
-         rate = 32000;
-      mode=&speex_uwb_mode;
+      if (rate>48000)
+      {
+         fprintf (stderr, "Bit-rate too high: %d Hz, try down-sampling\n", rate);
+      } else if (rate>25000)
+      {
+         mode=&speex_uwb_mode;
+      } else if (rate>12500)
+      {
+         mode=&speex_wb_mode;
+      } else if (rate>6000)
+      {
+         mode=&speex_nb_mode;
+      } else {
+         fprintf (stderr, "Bit-rate too low: %d Hz\n", rate);
+      }
+   } else if (!rate)
+   {
+      if (mode==&speex_nb_mode)
+         rate=8000;
+      else if (mode==&speex_wb_mode)
+         rate=16000;
+      else if (mode==&speex_uwb_mode)
+         rate=32000;
    }
+
+   if (rate!=8000 && rate!=16000 && rate!=32000)
+      fprintf (stderr, "Warning: Speex is only optimized for 8,16 and 32 kHz. It will still work at %d Hz but your mileage may vary\n", rate); 
 
    speex_init_header(&header, rate, 1, mode);
    header.frames_per_packet=nframes;

<p><p>1.3       +8 -0      speex/win32/libspeex/libspeex.dsp

Index: libspeex.dsp
===================================================================
RCS file: /usr/local/cvsroot/speex/win32/libspeex/libspeex.dsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- libspeex.dsp	10 Oct 2002 06:09:14 -0000	1.2
+++ libspeex.dsp	9 Nov 2002 06:00:02 -0000	1.3
@@ -169,6 +169,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=..\..\libspeex\stereo.c
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\libspeex\sb_celp.c
 # End Source File
 # Begin Source File
@@ -238,6 +242,10 @@
 # Begin Source File
 
 SOURCE=..\..\libspeex\speex_bits.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\speex_stereo.h
 # End Source File
 # Begin Source File
 

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list