[xiph-commits] r13192 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Wed Jun 27 06:42:38 PDT 2007


Author: jm
Date: 2007-06-27 06:42:37 -0700 (Wed, 27 Jun 2007)
New Revision: 13192

Modified:
   trunk/speex/libspeex/kiss_fft.c
   trunk/speex/libspeex/kiss_fftr.c
   trunk/speex/libspeex/mdf.c
   trunk/speex/libspeex/misc.c
   trunk/speex/libspeex/misc.h
   trunk/speex/libspeex/nb_celp.c
   trunk/speex/libspeex/quant_lsp.c
   trunk/speex/libspeex/sb_celp.c
Log:
Replaced speex_error() by speex_fatal() and speex_assert()


Modified: trunk/speex/libspeex/kiss_fft.c
===================================================================
--- trunk/speex/libspeex/kiss_fft.c	2007-06-25 16:00:28 UTC (rev 13191)
+++ trunk/speex/libspeex/kiss_fft.c	2007-06-27 13:42:37 UTC (rev 13192)
@@ -290,7 +290,7 @@
 
     /*CHECKBUF(scratchbuf,nscratchbuf,p);*/
     if (p>17)
-       speex_error("KissFFT: max radix supported is 17");
+       speex_fatal("KissFFT: max radix supported is 17");
     
     for ( u=0; u<m; ++u ) {
         k=u;
@@ -505,7 +505,7 @@
 {
     if (fin == fout) 
     {
-       speex_error("In-place FFT not supported");
+       speex_fatal("In-place FFT not supported");
        /*CHECKBUF(tmpbuf,ntmpbuf,st->nfft);
        kf_work(tmpbuf,fin,1,in_stride, st->factors,st);
        speex_move(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft);*/

Modified: trunk/speex/libspeex/kiss_fftr.c
===================================================================
--- trunk/speex/libspeex/kiss_fftr.c	2007-06-25 16:00:28 UTC (rev 13191)
+++ trunk/speex/libspeex/kiss_fftr.c	2007-06-27 13:42:37 UTC (rev 13192)
@@ -84,7 +84,7 @@
     kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc;
 
     if ( st->substate->inverse) {
-        speex_error("kiss fft usage error: improper alloc\n");
+        speex_fatal("kiss fft usage error: improper alloc\n");
     }
 
     ncfft = st->substate->nfft;
@@ -138,7 +138,7 @@
     int k, ncfft;
 
     if (st->substate->inverse == 0) {
-        speex_error ("kiss fft usage error: improper alloc\n");
+        speex_fatal("kiss fft usage error: improper alloc\n");
     }
 
     ncfft = st->substate->nfft;
@@ -177,7 +177,7 @@
    spx_word32_t f1kr, f1ki, twr, twi;
 
    if ( st->substate->inverse) {
-      speex_error("kiss fft usage error: improper alloc\n");
+      speex_fatal("kiss fft usage error: improper alloc\n");
    }
 
    ncfft = st->substate->nfft;
@@ -263,7 +263,7 @@
    int k, ncfft;
 
    if (st->substate->inverse == 0) {
-      speex_error ("kiss fft usage error: improper alloc\n");
+      speex_fatal ("kiss fft usage error: improper alloc\n");
    }
 
    ncfft = st->substate->nfft;

Modified: trunk/speex/libspeex/mdf.c
===================================================================
--- trunk/speex/libspeex/mdf.c	2007-06-25 16:00:28 UTC (rev 13191)
+++ trunk/speex/libspeex/mdf.c	2007-06-27 13:42:37 UTC (rev 13192)
@@ -368,7 +368,7 @@
 {
    if (!(rFile && pFile && oFile))
    {
-      speex_error("Dump files not open");
+      speex_fatal("Dump files not open");
    }
    fwrite(rec, sizeof(spx_int16_t), len, rFile);
    fwrite(play, sizeof(spx_int16_t), len, pFile);
@@ -384,7 +384,7 @@
 
 #ifdef DUMP_ECHO_CANCEL_DATA
    if (rFile || pFile || oFile)
-      speex_error("Opening dump files twice");
+      speex_fatal("Opening dump files twice");
    rFile = fopen("aec_rec.sw", "w");
    pFile = fopen("aec_play.sw", "w");
    oFile = fopen("aec_out.sw", "w");

Modified: trunk/speex/libspeex/misc.c
===================================================================
--- trunk/speex/libspeex/misc.c	2007-06-25 16:00:28 UTC (rev 13191)
+++ trunk/speex/libspeex/misc.c	2007-06-27 13:42:37 UTC (rev 13192)
@@ -105,10 +105,10 @@
 }
 #endif
 
-#ifndef OVERRIDE_SPEEX_ERROR
-void speex_error(const char *str)
+#ifndef OVERRIDE_SPEEX_FATAL
+void _speex_fatal(const char *str, const char *file, int line)
 {
-   fprintf (stderr, "Fatal (internal) error: %s\n", str);
+   fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
    exit(1);
 }
 #endif

Modified: trunk/speex/libspeex/misc.h
===================================================================
--- trunk/speex/libspeex/misc.h	2007-06-25 16:00:28 UTC (rev 13191)
+++ trunk/speex/libspeex/misc.h	2007-06-27 13:42:37 UTC (rev 13192)
@@ -91,6 +91,9 @@
 #endif
 }
 
+#define speex_fatal(str) _speex_fatal(str, __FILE__, __LINE__);
+#define speex_assert(cond) {if (!(cond)) {speex_fatal("assertion failed: " #cond);}}
+
 /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free */
 void *speex_alloc (int size);
 
@@ -110,7 +113,7 @@
 void *speex_move (void *dest, void *src, int n);
 
 /** Abort with an error message to stderr (internal Speex error) */
-void speex_error(const char *str);
+void _speex_fatal(const char *str, const char *file, int line);
 
 /** Print warning message to stderr (programming error) */
 void speex_warning(const char *str);

Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2007-06-25 16:00:28 UTC (rev 13191)
+++ trunk/speex/libspeex/nb_celp.c	2007-06-27 13:42:37 UTC (rev 13192)
@@ -787,18 +787,15 @@
       /*print_vec(st->bw_lpc1, 10, "bw_lpc");*/
 #endif
 
+      /*FIXME: This will break if we change the window size */
+      speex_assert(st->windowSize-st->frameSize == st->subframeSize);
+      if (sub==0)
       {
-         /*FIXME: This will break if we change the window size */
-         if (st->windowSize-st->frameSize != st->subframeSize)
-            speex_error("windowSize-frameSize != subframeSize");
-         if (sub==0)
-         {
-            for (i=0;i<st->subframeSize;i++)
-               real_exc[i] = sw[i] = st->winBuf[i];
-         } else {
-            for (i=0;i<st->subframeSize;i++)
-               real_exc[i] = sw[i] = in[i+((sub-1)*st->subframeSize)];
-         }
+         for (i=0;i<st->subframeSize;i++)
+            real_exc[i] = sw[i] = st->winBuf[i];
+      } else {
+         for (i=0;i<st->subframeSize;i++)
+            real_exc[i] = sw[i] = in[i+((sub-1)*st->subframeSize)];
       }
       fir_mem16(real_exc, interp_qlpc, real_exc, st->subframeSize, st->lpcSize, st->mem_exc2, stack);
       
@@ -845,7 +842,7 @@
          exc[i]=0;
 
       /* If we have a long-term predictor (otherwise, something's wrong) */
-      if (SUBMODE(ltp_quant))
+      speex_assert (SUBMODE(ltp_quant));
       {
          int pit_min, pit_max;
          /* Long-term prediction */
@@ -894,10 +891,7 @@
 #endif
 
          st->pitch[sub]=pitch;
-      } else {
-         speex_error ("No pitch prediction, what's wrong");
       }
-
       /* Quantization of innovation */
       for (i=0;i<st->subframeSize;i++)
          innov[i]=0;
@@ -944,7 +938,7 @@
       signal_div(target, target, ener, st->subframeSize);
       
       /* Quantize innovation */
-      if (SUBMODE(innovation_quant))
+      speex_assert (SUBMODE(innovation_quant));
       {
          /* Codebook search */
          SUBMODE(innovation_quant)(target, interp_qlpc, bw_lpc1, bw_lpc2, 
@@ -980,11 +974,8 @@
          {
             st->innov_rms_save[sub] = compute_rms(innov, st->subframeSize);
          }
-      } else {
-         speex_error("No fixed codebook");
       }
 
-
       for (i=0;i<st->subframeSize;i++)
          sw[i] = exc[i];
       /* Final signal synthesis from excitation */
@@ -1477,7 +1468,7 @@
          exc[i]=0;
 
       /*Adaptive codebook contribution*/
-      if (SUBMODE(ltp_unquant))
+      speex_assert (SUBMODE(ltp_unquant));
       {
          int pit_min, pit_max;
          /* Handle pitch constraints if any */
@@ -1542,8 +1533,6 @@
             if (tmp > best_pitch_gain)
                best_pitch_gain = tmp;
          }
-      } else {
-         speex_error("No pitch prediction, what's wrong");
       }
       
       /* Unquantize the innovation */
@@ -1567,7 +1556,7 @@
             ener = ol_gain;
          }
                   
-         if (SUBMODE(innovation_unquant))
+         speex_assert (SUBMODE(innovation_unquant));
          {
             /*Fixed codebook contribution*/
             SUBMODE(innovation_unquant)(innov, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed);
@@ -1599,8 +1588,6 @@
                for (i=0;i<st->subframeSize;i++)
                   innov_save[i] = EXTRACT16(PSHR32(innov[i], SIG_SHIFT));
             }
-         } else {
-            speex_error("No fixed codebook");
          }
 
          /*Vocoder mode*/

Modified: trunk/speex/libspeex/quant_lsp.c
===================================================================
--- trunk/speex/libspeex/quant_lsp.c	2007-06-25 16:00:28 UTC (rev 13191)
+++ trunk/speex/libspeex/quant_lsp.c	2007-06-27 13:42:37 UTC (rev 13192)
@@ -304,11 +304,11 @@
 #ifdef DISABLE_WIDEBAND
 void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
 {
-   speex_error("Wideband and Ultra-wideband are disabled");
+   speex_fatal("Wideband and Ultra-wideband are disabled");
 }
 void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits)
 {
-   speex_error("Wideband and Ultra-wideband are disabled");
+   speex_fatal("Wideband and Ultra-wideband are disabled");
 }
 #else
 extern const signed char high_lsp_cdbk[];

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2007-06-25 16:00:28 UTC (rev 13191)
+++ trunk/speex/libspeex/sb_celp.c	2007-06-27 13:42:37 UTC (rev 13192)
@@ -61,40 +61,40 @@
 #ifdef DISABLE_WIDEBAND
 void *sb_encoder_init(const SpeexMode *m)
 {
-   speex_error("Wideband and Ultra-wideband are disabled");
+   speex_fatal("Wideband and Ultra-wideband are disabled");
    return NULL;
 }
 void sb_encoder_destroy(void *state)
 {
-   speex_error("Wideband and Ultra-wideband are disabled");
+   speex_fatal("Wideband and Ultra-wideband are disabled");
 }
 int sb_encode(void *state, void *vin, SpeexBits *bits)
 {
-   speex_error("Wideband and Ultra-wideband are disabled");
+   speex_fatal("Wideband and Ultra-wideband are disabled");
    return -2;
 }
 void *sb_decoder_init(const SpeexMode *m)
 {
-   speex_error("Wideband and Ultra-wideband are disabled");
+   speex_fatal("Wideband and Ultra-wideband are disabled");
    return NULL;
 }
 void sb_decoder_destroy(void *state)
 {
-   speex_error("Wideband and Ultra-wideband are disabled");
+   speex_fatal("Wideband and Ultra-wideband are disabled");
 }
 int sb_decode(void *state, SpeexBits *bits, void *vout)
 {
-   speex_error("Wideband and Ultra-wideband are disabled");
+   speex_fatal("Wideband and Ultra-wideband are disabled");
    return -2;
 }
 int sb_encoder_ctl(void *state, int request, void *ptr)
 {
-   speex_error("Wideband and Ultra-wideband are disabled");
+   speex_fatal("Wideband and Ultra-wideband are disabled");
    return -2;
 }
 int sb_decoder_ctl(void *state, int request, void *ptr)
 {
-   speex_error("Wideband and Ultra-wideband are disabled");
+   speex_fatal("Wideband and Ultra-wideband are disabled");
    return -2;
 }
 #else



More information about the commits mailing list