[xiph-cvs] cvs commit: speex/src speexenc.c wav_io.c

Jean-Marc Valin jm at xiph.org
Sun Nov 3 19:00:52 PST 2002



jm          02/11/03 22:00:52

  Modified:    doc      manual.lyx
               libspeex modes.c sb_celp.c speex.h testenc_uwb.c
               src      speexenc.c wav_io.c
  Log:
  Integrated "ultra-wideband" with encoder/decoder.

Revision  Changes    Path
1.32      +1 -1      speex/doc/manual.lyx

Index: manual.lyx
===================================================================
RCS file: /usr/local/cvsroot/speex/doc/manual.lyx,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- manual.lyx	1 Nov 2002 00:02:57 -0000	1.31
+++ manual.lyx	4 Nov 2002 03:00:51 -0000	1.32
@@ -3037,7 +3037,7 @@
 
 
 \layout Section
-
+\pagebreak_top 
 Command-line encoder/decoder
 \layout Standard
 

<p><p>1.85      +1 -1      speex/libspeex/modes.c

Index: modes.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/modes.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- modes.c	30 Oct 2002 22:12:19 -0000	1.84
+++ modes.c	4 Nov 2002 03:00:51 -0000	1.85
@@ -41,7 +41,7 @@
 #include "sb_celp.h"
 #include "nb_celp.h"
 
-SpeexMode *speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode};
+SpeexMode *speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode};
 
 /* Extern declarations for all codebooks we use here */
 extern float gain_cdbk_nb[];

<p><p>1.87      +1 -9      speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- sb_celp.c	2 Nov 2002 06:25:52 -0000	1.86
+++ sb_celp.c	4 Nov 2002 03:00:51 -0000	1.87
@@ -463,10 +463,6 @@
 
          g *= filter_ratio;
 
-         if (st->full_frame_size==640)
-         {
-            printf ("encode: %f %f %f %f %f\n", g, rl, rh, el, eh);
-         }
          /* Gain quantization */
          {
             int quant = (int) floor(.5 + 27 + 8.0 * log((g+.0001)));
@@ -842,15 +838,11 @@
       {
          float g;
          int quant;
-         printf ("subframes: %d\n", st->subframeSize);
+
          for (i=0;i<st->subframeSize;i++)
             el+=sqr(low_innov[offset+i]);
          quant = speex_bits_unpack_unsigned(bits, 5);
          g= exp(((float)quant-27)/8.0);
-         if (st->full_frame_size==640)
-         {
-            printf ("decode: %f %f %f %f\n", g, rl, rh, el);
-         }
          
          /*printf ("unquant folding gain: %f\n", g);*/
          g /= filter_ratio;

<p><p>1.64      +1 -1      speex/libspeex/speex.h

Index: speex.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/speex.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- speex.h	30 Oct 2002 22:12:19 -0000	1.63
+++ speex.h	4 Nov 2002 03:00:51 -0000	1.64
@@ -122,7 +122,7 @@
 
 
 /** Number of defined modes in Speex */
-#define SPEEX_NB_MODES 2
+#define SPEEX_NB_MODES 3
 
 struct SpeexMode;
 

<p><p>1.2       +2 -2      speex/libspeex/testenc_uwb.c

Index: testenc_uwb.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/testenc_uwb.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- testenc_uwb.c	30 Oct 2002 22:12:19 -0000	1.1
+++ testenc_uwb.c	4 Nov 2002 03:00:51 -0000	1.2
@@ -24,8 +24,8 @@
    st = speex_encoder_init(&speex_uwb_mode);
    dec = speex_decoder_init(&speex_uwb_mode);
    
-   /*tmp=0;
-   speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
+   tmp=0;
+   /*speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
    tmp=0;
    speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
    tmp=10;

<p><p>1.53      +33 -8     speex/src/speexenc.c

Index: speexenc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexenc.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- speexenc.c	1 Nov 2002 03:50:50 -0000	1.52
+++ speexenc.c	4 Nov 2002 03:00:51 -0000	1.53
@@ -139,8 +139,8 @@
    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 (" --quality n        Encoding quality (0-10), default 3\n"); 
-   printf (" --lbr              Low bit-rate mode (equivalent to --quality 3)\n"); 
    printf (" --vbr              Enable variable bit-rate (VBR)\n"); 
    printf (" --comp n           Set encoding complexity (0-10), default 3\n"); 
    printf (" --nframes n        Number of frames per Ogg packet (1-10), default 1\n"); 
@@ -168,7 +168,7 @@
 {
    int c;
    int option_index = 0;
-   int narrowband=0, wideband=0;
+   int narrowband=0, wideband=0, ultrawide=0;
    char *inFile, *outFile;
    FILE *fin, *fout;
    float input[MAX_FRAME_SIZE];
@@ -182,8 +182,8 @@
    struct option long_options[] =
    {
       {"wideband", no_argument, NULL, 0},
+      {"ultra-wideband", no_argument, NULL, 0},
       {"narrowband", no_argument, NULL, 0},
-      {"lbr", no_argument, NULL, 0},
       {"vbr", no_argument, NULL, 0},
       {"quality", required_argument, NULL, 0},
       {"nframes", required_argument, NULL, 0},
@@ -205,7 +205,6 @@
    int fmt=16;
    int quality=-1;
    float vbr_quality=-1;
-   int lbr=0;
    int lsb=1;
    ogg_stream_state os;
    ogg_page 		 og;
@@ -238,8 +237,8 @@
             narrowband=1;
          else if (strcmp(long_options[option_index].name,"wideband")==0)
                wideband=1;
-         else if (strcmp(long_options[option_index].name,"lbr")==0)
-               lbr=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)
@@ -305,6 +304,9 @@
       case 'w':
          wideband=1;
          break;
+      case 'u':
+         ultrawide=1;
+         break;
       case '?':
          usage();
          exit(1);
@@ -319,9 +321,9 @@
    inFile=argv[optind];
    outFile=argv[optind+1];
 
-   if (wideband && narrowband)
+   if ((wideband && narrowband) || (wideband && ultrawide) || (ultrawide && narrowband))
    {
-      fprintf (stderr,"Cannot specify both wideband and narrowband at the same time\n");
+      fprintf (stderr,"Cannot specify two modes at the same time\n");
       exit(1);
    };
 
@@ -380,6 +382,23 @@
       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");
@@ -401,6 +420,12 @@
       if (!rate)
          rate = 16000;
       mode=&speex_wb_mode;
+   }
+   if (ultrawide)
+   {
+      if (!rate)
+         rate = 32000;
+      mode=&speex_uwb_mode;
    }
 
    speex_init_header(&header, rate, 1, mode);

<p><p>1.8       +1 -1      speex/src/wav_io.c

Index: wav_io.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/wav_io.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- wav_io.c	20 Oct 2002 04:19:40 -0000	1.7
+++ wav_io.c	4 Nov 2002 03:00:52 -0000	1.8
@@ -96,7 +96,7 @@
    fread(&itmp, 4, 1, file);
    itmp = le_int(itmp);
    *rate = itmp;
-   if (*rate != 8000 && *rate != 16000 && *rate != 11025 && *rate != 22050)
+   if (*rate != 8000 && *rate != 16000 && *rate != 11025 && *rate != 22050 && *rate != 32000 && *rate != 44100 && *rate != 48000)
    {
       fprintf (stderr, "Only 8 kHz (narrowband) and 16 kHz (wideband) supported (plus 11.025 kHz and 22.05 kHz, but your mileage may vary)\n");
       return -1;

<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