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

jm at svn.xiph.org jm at svn.xiph.org
Sat Aug 12 19:42:49 PDT 2006


Author: jm
Date: 2006-08-12 19:42:43 -0700 (Sat, 12 Aug 2006)
New Revision: 11768

Modified:
   trunk/speex/libspeex/fftwrap.c
   trunk/speex/libspeex/jitter.c
   trunk/speex/libspeex/mdf.c
   trunk/speex/libspeex/medfilter.c
   trunk/speex/libspeex/nb_celp.c
   trunk/speex/libspeex/sb_celp.c
Log:
Making libspeex C++-friendly


Modified: trunk/speex/libspeex/fftwrap.c
===================================================================
--- trunk/speex/libspeex/fftwrap.c	2006-08-12 17:55:47 UTC (rev 11767)
+++ trunk/speex/libspeex/fftwrap.c	2006-08-13 02:42:43 UTC (rev 11768)
@@ -145,8 +145,8 @@
 void *spx_fft_init(int size)
 {
    struct kiss_config *table;
-   table = speex_alloc(sizeof(struct kiss_config));
-   table->freq_data = speex_alloc(sizeof(kiss_fft_cpx)*((size>>1)+1));
+   table = (struct kiss_config*)speex_alloc(sizeof(struct kiss_config));
+   table->freq_data = (kiss_fft_cpx*)speex_alloc(sizeof(kiss_fft_cpx)*((size>>1)+1));
    table->forward = kiss_fftr_alloc(size,0,NULL,NULL);
    table->backward = kiss_fftr_alloc(size,1,NULL,NULL);
    table->N = size;

Modified: trunk/speex/libspeex/jitter.c
===================================================================
--- trunk/speex/libspeex/jitter.c	2006-08-12 17:55:47 UTC (rev 11767)
+++ trunk/speex/libspeex/jitter.c	2006-08-13 02:42:43 UTC (rev 11768)
@@ -78,7 +78,7 @@
 /** Initialise jitter buffer */
 JitterBuffer *jitter_buffer_init(int tick)
 {
-   JitterBuffer *jitter = speex_alloc(sizeof(JitterBuffer));
+   JitterBuffer *jitter = (JitterBuffer*)speex_alloc(sizeof(JitterBuffer));
    if (jitter)
    {
       int i;
@@ -180,7 +180,7 @@
    }
    
    /* Copy packet in buffer */
-   jitter->buf[i]=speex_alloc(packet->len);
+   jitter->buf[i]=(char*)speex_alloc(packet->len);
    for (j=0;j<packet->len;j++)
       jitter->buf[i][j]=packet->data[j];
    jitter->timestamp[i]=packet->timestamp;

Modified: trunk/speex/libspeex/mdf.c
===================================================================
--- trunk/speex/libspeex/mdf.c	2006-08-12 17:55:47 UTC (rev 11767)
+++ trunk/speex/libspeex/mdf.c	2006-08-13 02:42:43 UTC (rev 11768)
@@ -559,7 +559,7 @@
          tmp_out = 0;
          saturated = 1;
       }
-      out[i] = tmp_out;
+      out[i] = (spx_int16_t)tmp_out;
       st->memE = tmp_out;
    }
 
@@ -803,7 +803,7 @@
 #endif
       /* Estimate residual echo */
       for (i=0;i<=st->frame_size;i++)
-         Yout[i] = MULT16_32_Q15(leak2,st->Yps[i]);
+         Yout[i] = (spx_int32_t)MULT16_32_Q15(leak2,st->Yps[i]);
    }
 }
 

Modified: trunk/speex/libspeex/medfilter.c
===================================================================
--- trunk/speex/libspeex/medfilter.c	2006-08-12 17:55:47 UTC (rev 11767)
+++ trunk/speex/libspeex/medfilter.c	2006-08-13 02:42:43 UTC (rev 11768)
@@ -37,10 +37,10 @@
 
 MedianFilter *median_filter_new(int N)
 {
-   MedianFilter *f = speex_alloc(sizeof(MedianFilter));
+   MedianFilter *f = (MedianFilter*)speex_alloc(sizeof(MedianFilter));
    f->N = N;
-   f->ids = speex_alloc(sizeof(int)*N);
-   f->val = speex_alloc(sizeof(float)*N);
+   f->ids = (int*)speex_alloc(sizeof(int)*N);
+   f->val = (float*)speex_alloc(sizeof(float)*N);
    f->filled = 0;
    return f;
 }

Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2006-08-12 17:55:47 UTC (rev 11767)
+++ trunk/speex/libspeex/nb_celp.c	2006-08-13 02:42:43 UTC (rev 11768)
@@ -150,48 +150,48 @@
 
 #ifdef VORBIS_PSYCHO
    st->psy = vorbis_psy_init(8000, 256);
-   st->curve = speex_alloc(128*sizeof(float));
-   st->old_curve = speex_alloc(128*sizeof(float));
-   st->psy_window = speex_alloc(256*sizeof(float));
+   st->curve = (float*)speex_alloc(128*sizeof(float));
+   st->old_curve = (float*)speex_alloc(128*sizeof(float));
+   st->psy_window = (float*)speex_alloc(256*sizeof(float));
 #endif
 
    st->cumul_gain = 1024;
 
    /* Allocating input buffer */
-   st->winBuf = speex_alloc((st->windowSize-st->frameSize)*sizeof(spx_word16_t));
+   st->winBuf = (spx_word16_t*)speex_alloc((st->windowSize-st->frameSize)*sizeof(spx_word16_t));
    /* Allocating excitation buffer */
-   st->excBuf = speex_alloc((mode->frameSize+mode->pitchEnd+2)*sizeof(spx_word16_t));
+   st->excBuf = (spx_word16_t*)speex_alloc((mode->frameSize+mode->pitchEnd+2)*sizeof(spx_word16_t));
    st->exc = st->excBuf + mode->pitchEnd + 2;
-   st->swBuf = speex_alloc((mode->frameSize+mode->pitchEnd+2)*sizeof(spx_word16_t));
+   st->swBuf = (spx_word16_t*)speex_alloc((mode->frameSize+mode->pitchEnd+2)*sizeof(spx_word16_t));
    st->sw = st->swBuf + mode->pitchEnd + 2;
 
    st->window= lpc_window;
    
    /* Create the window for autocorrelation (lag-windowing) */
-   st->lagWindow = speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
+   st->lagWindow = (spx_word16_t*)speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
    for (i=0;i<st->lpcSize+1;i++)
       st->lagWindow[i]=16384*exp(-.5*sqr(2*M_PI*st->lag_factor*i));
 
-   st->old_lsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
-   st->old_qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
+   st->old_lsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
+   st->old_qlsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
    st->first = 1;
    for (i=0;i<st->lpcSize;i++)
    {
       st->old_lsp[i]=LSP_SCALING*(M_PI*((float)(i+1)))/(st->lpcSize+1);
    }
 
-   st->mem_sp = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
-   st->mem_sw = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
-   st->mem_sw_whole = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
-   st->mem_exc = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
-   st->mem_exc2 = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_sp = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_sw = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_sw_whole = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_exc = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_exc2 = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
 
-   st->pi_gain = speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
+   st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
    st->innov_save = NULL;
    
-   st->pitch = speex_alloc((st->nbSubframes)*sizeof(int));
+   st->pitch = (int*)speex_alloc((st->nbSubframes)*sizeof(int));
 
-   st->vbr = speex_alloc(sizeof(VBRState));
+   st->vbr = (VBRState*)speex_alloc(sizeof(VBRState));
    vbr_init(st->vbr);
    st->vbr_quality = 8;
    st->vbr_enabled = 0;
@@ -280,7 +280,7 @@
    int pitch_half[2];
    int ol_pitch_id=0;
 #endif
-   spx_word16_t *in = vin;
+   spx_word16_t *in = (spx_word16_t*)vin;
 
    st=(EncState *)state;
    stack=st->stack;
@@ -1081,15 +1081,15 @@
 
    st->lpc_enh_enabled=1;
 
-   st->excBuf = speex_alloc((st->frameSize + 2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t));
+   st->excBuf = (spx_word16_t*)speex_alloc((st->frameSize + 2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t));
    st->exc = st->excBuf + 2*st->max_pitch + st->subframeSize + 6;
    for (i=0;i<st->frameSize + st->max_pitch + 1;i++)
       st->excBuf[i]=0;
 
-   st->interp_qlpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
-   st->old_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
-   st->mem_sp = speex_alloc(st->lpcSize*sizeof(spx_mem_t));
-   st->pi_gain = speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
+   st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->old_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->mem_sp = (spx_mem_t*)speex_alloc(st->lpcSize*sizeof(spx_mem_t));
+   st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
    st->last_pitch = 40;
    st->count_lost=0;
    st->pitch_gain_buf[0] = st->pitch_gain_buf[1] = st->pitch_gain_buf[2] = 0;
@@ -1247,7 +1247,7 @@
    int pitch_half[2];
    int ol_pitch_id=0;
 #endif
-   spx_word16_t *out = vout;
+   spx_word16_t *out = (spx_word16_t*)vout;
    VARDECL(spx_lsp_t *interp_qlsp);
 
    st=(DecState*)state;
@@ -1952,7 +1952,7 @@
       (*(float*)ptr)=st->relative_quality;
       break;
    case SPEEX_SET_INNOVATION_SAVE:
-      st->innov_save = ptr;
+      st->innov_save = (spx_sig_t*)ptr;
       break;
    case SPEEX_SET_WIDEBAND:
       st->isWideband = *((int*)ptr);
@@ -2060,7 +2060,7 @@
       *((int*)ptr) = st->dtx_enabled;
       break;
    case SPEEX_SET_INNOVATION_SAVE:
-      st->innov_save = ptr;
+      st->innov_save = (spx_sig_t*)ptr;
       break;
    case SPEEX_SET_WIDEBAND:
       st->isWideband = *((int*)ptr);

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2006-08-12 17:55:47 UTC (rev 11767)
+++ trunk/speex/libspeex/sb_celp.c	2006-08-13 02:42:43 UTC (rev 11768)
@@ -265,48 +265,48 @@
    st->gamma2=mode->gamma2;
    st->first=1;
 
-   st->x0d=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
-   st->x1d=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
-   st->high=speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
-   st->y0=speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
-   st->y1=speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
+   st->x0d=(spx_sig_t*)speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->x1d=(spx_sig_t*)speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->high=(spx_sig_t*)speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
+   st->y0=(spx_sig_t*)speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
+   st->y1=(spx_sig_t*)speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
 
-   st->h0_mem=speex_alloc((QMF_ORDER)*sizeof(spx_word16_t));
-   st->h1_mem=speex_alloc((QMF_ORDER)*sizeof(spx_word16_t));
-   st->g0_mem=speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
-   st->g1_mem=speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
+   st->h0_mem=(spx_word16_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word16_t));
+   st->h1_mem=(spx_word16_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word16_t));
+   st->g0_mem=(spx_word32_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
+   st->g1_mem=(spx_word32_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
 
-   st->excBuf=speex_alloc((st->bufSize)*sizeof(spx_sig_t));
+   st->excBuf=(spx_sig_t*)speex_alloc((st->bufSize)*sizeof(spx_sig_t));
    st->exc = st->excBuf + st->bufSize - st->windowSize;
 
-   st->res=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
-   st->sw=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->res=(spx_sig_t*)speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->sw=(spx_sig_t*)speex_alloc((st->frame_size)*sizeof(spx_sig_t));
    st->window= lpc_window;
 
-   st->lagWindow = speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
+   st->lagWindow = (spx_word16_t*)speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
    for (i=0;i<st->lpcSize+1;i++)
       st->lagWindow[i]=16384*exp(-.5*sqr(2*M_PI*st->lag_factor*i));
 
-   st->autocorr = speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
-   st->lpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
-   st->bw_lpc1 = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
-   st->bw_lpc2 = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
-   st->lsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
-   st->qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
-   st->old_lsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
-   st->old_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
-   st->interp_lsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
-   st->interp_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
-   st->interp_lpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
-   st->interp_qlpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
-   st->pi_gain = speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
-   st->low_innov = speex_alloc((st->frame_size)*sizeof(spx_word32_t));
+   st->autocorr = (spx_word16_t*)speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
+   st->lpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->bw_lpc1 = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->bw_lpc2 = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->lsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->old_lsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->old_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->interp_lsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->interp_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->interp_lpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
+   st->low_innov = (spx_word32_t*)speex_alloc((st->frame_size)*sizeof(spx_word32_t));
    speex_encoder_ctl(st->st_low, SPEEX_SET_INNOVATION_SAVE, st->low_innov);
    st->innov_save = NULL;
    
-   st->mem_sp = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
-   st->mem_sp2 = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
-   st->mem_sw = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_sp = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_sp2 = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_sw = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
 
    st->vbr_quality = 8;
    st->vbr_enabled = 0;
@@ -386,7 +386,7 @@
    VARDECL(spx_word16_t *low_exc);
    const SpeexSBMode *mode;
    int dtx;
-   spx_word16_t *in = vin;
+   spx_word16_t *in = (spx_word16_t*)vin;
 
    st = (SBEncState*)state;
    stack=st->stack;
@@ -871,27 +871,27 @@
    st->first=1;
 
 
-   st->x0d=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
-   st->x1d=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
-   st->high=speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
-   st->y0=speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
-   st->y1=speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
+   st->x0d = (spx_sig_t*)speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->x1d = (spx_sig_t*)speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->high = (spx_sig_t*)speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
+   st->y0 = (spx_sig_t*)speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
+   st->y1 = (spx_sig_t*)speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
 
-   st->g0_mem=speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
-   st->g1_mem=speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
+   st->g0_mem = (spx_word32_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
+   st->g1_mem = (spx_word32_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
 
-   st->exc=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
-   st->excBuf=speex_alloc((st->subframeSize)*sizeof(spx_sig_t));
+   st->exc = (spx_sig_t*)speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->excBuf = (spx_sig_t*)speex_alloc((st->subframeSize)*sizeof(spx_sig_t));
 
-   st->qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
-   st->old_qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
-   st->interp_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
-   st->interp_qlpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->qlsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
+   st->old_qlsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
+   st->interp_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t));
 
-   st->pi_gain = speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
-   st->mem_sp = speex_alloc((2*st->lpcSize)*sizeof(spx_mem_t));
+   st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
+   st->mem_sp = (spx_mem_t*)speex_alloc((2*st->lpcSize)*sizeof(spx_mem_t));
    
-   st->low_innov = speex_alloc((st->frame_size)*sizeof(spx_word32_t));
+   st->low_innov = (spx_word32_t*)speex_alloc((st->frame_size)*sizeof(spx_word32_t));
    speex_decoder_ctl(st->st_low, SPEEX_SET_INNOVATION_SAVE, st->low_innov);
    st->innov_save = NULL;
 
@@ -991,7 +991,7 @@
    VARDECL(spx_coef_t *ak);
    int dtx;
    const SpeexSBMode *mode;
-   spx_word16_t *out = vout;
+   spx_word16_t *out = (spx_word16_t*)vout;
    
    st = (SBDecState*)state;
    stack=st->stack;
@@ -1495,7 +1495,7 @@
       (*(float*)ptr)=st->relative_quality;
       break;
    case SPEEX_SET_INNOVATION_SAVE:
-      st->innov_save = ptr;
+      st->innov_save = (spx_sig_t*)ptr;
       break;
    case SPEEX_SET_WIDEBAND:
       speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr);
@@ -1630,7 +1630,7 @@
       speex_decoder_ctl(st->st_low, SPEEX_GET_DTX_STATUS, ptr);
       break;
    case SPEEX_SET_INNOVATION_SAVE:
-      st->innov_save = ptr;
+      st->innov_save = (spx_sig_t*)ptr;
       break;
    case SPEEX_SET_WIDEBAND:
       speex_decoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr);



More information about the commits mailing list