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

jm at svn.xiph.org jm at svn.xiph.org
Sat Mar 17 06:58:02 PDT 2007


Author: jm
Date: 2007-03-17 06:57:59 -0700 (Sat, 17 Mar 2007)
New Revision: 12769

Modified:
   trunk/speex/libspeex/modes.h
   trunk/speex/libspeex/nb_celp.c
   trunk/speex/libspeex/sb_celp.c
Log:
pseudo-stack is now shared between the narrowband and wideband layers.


Modified: trunk/speex/libspeex/modes.h
===================================================================
--- trunk/speex/libspeex/modes.h	2007-03-16 14:27:26 UTC (rev 12768)
+++ trunk/speex/libspeex/modes.h	2007-03-17 13:57:59 UTC (rev 12769)
@@ -60,7 +60,10 @@
 /** Used internally*/
 #define SPEEX_SET_WIDEBAND   105
 
+/** Used internally*/
+#define SPEEX_GET_STACK   106
 
+
 /** Quantizes LSPs */
 typedef void (*lsp_quant_func)(spx_lsp_t *, spx_lsp_t *, int, SpeexBits *);
 

Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2007-03-16 14:27:26 UTC (rev 12768)
+++ trunk/speex/libspeex/nb_celp.c	2007-03-17 13:57:59 UTC (rev 12769)
@@ -1928,6 +1928,9 @@
    case SPEEX_SET_WIDEBAND:
       st->isWideband = *((spx_int32_t*)ptr);
       break;
+   case SPEEX_GET_STACK:
+      *((char**)ptr) = st->stack;
+      break;
    default:
       speex_warning_int("Unknown nb_ctl request: ", request);
       return -1;
@@ -2035,6 +2038,9 @@
    case SPEEX_SET_WIDEBAND:
       st->isWideband = *((spx_int32_t*)ptr);
       break;
+   case SPEEX_GET_STACK:
+      *((char**)ptr) = st->stack;
+      break;
    default:
       speex_warning_int("Unknown nb_ctl request: ", request);
       return -1;

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2007-03-16 14:27:26 UTC (rev 12768)
+++ trunk/speex/libspeex/sb_celp.c	2007-03-17 13:57:59 UTC (rev 12769)
@@ -192,16 +192,18 @@
    st = (SBEncState*)speex_alloc(sizeof(SBEncState));
    if (!st)
       return NULL;
+   st->mode = m;
+   mode = (const SpeexSBMode*)m->mode;
+
+
+   st->st_low = speex_encoder_init(mode->nb_mode);
 #if defined(VAR_ARRAYS) || defined (USE_ALLOCA)
    st->stack = NULL;
 #else
-   st->stack = (char*)speex_alloc_scratch(SB_ENC_STACK);
+   /*st->stack = (char*)speex_alloc_scratch(SB_ENC_STACK);*/
+   speex_encoder_ctl(st->st_low, SPEEX_GET_STACK, &st->stack);
 #endif
-   st->mode = m;
-   mode = (const SpeexSBMode*)m->mode;
 
-
-   st->st_low = speex_encoder_init(mode->nb_mode);
    st->full_frame_size = 2*mode->frameSize;
    st->frame_size = mode->frameSize;
    st->subframeSize = mode->subframeSize;
@@ -275,7 +277,7 @@
 
    speex_encoder_destroy(st->st_low);
 #if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA))
-   speex_free_scratch(st->stack);
+   /*speex_free_scratch(st->stack);*/
 #endif
 
    speex_free(st->high);
@@ -758,20 +760,18 @@
    st = (SBDecState*)speex_alloc(sizeof(SBDecState));
    if (!st)
       return NULL;
+   st->mode = m;
+   mode=(const SpeexSBMode*)m->mode;
+   st->encode_submode = 1;
+
+   st->st_low = speex_decoder_init(mode->nb_mode);
 #if defined(VAR_ARRAYS) || defined (USE_ALLOCA)
    st->stack = NULL;
 #else
-   st->stack = (char*)speex_alloc_scratch(SB_DEC_STACK);
+   /*st->stack = (char*)speex_alloc_scratch(SB_DEC_STACK);*/
+   speex_decoder_ctl(st->st_low, SPEEX_GET_STACK, &st->stack);
 #endif
-   st->mode = m;
-   mode=(const SpeexSBMode*)m->mode;
 
-   st->encode_submode = 1;
-
-
-
-
-   st->st_low = speex_decoder_init(mode->nb_mode);
    st->full_frame_size = 2*mode->frameSize;
    st->frame_size = mode->frameSize;
    st->subframeSize = mode->subframeSize;
@@ -817,7 +817,7 @@
    st = (SBDecState*)state;
    speex_decoder_destroy(st->st_low);
 #if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA))
-   speex_free_scratch(st->stack);
+   /*speex_free_scratch(st->stack);*/
 #endif
 
    speex_free(st->g0_mem);
@@ -1341,7 +1341,9 @@
    case SPEEX_SET_WIDEBAND:
       speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr);
       break;
-
+   case SPEEX_GET_STACK:
+      *((char**)ptr) = st->stack;
+      break;
    default:
       speex_warning_int("Unknown nb_ctl request: ", request);
       return -1;
@@ -1464,7 +1466,9 @@
    case SPEEX_SET_WIDEBAND:
       speex_decoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr);
       break;
-
+   case SPEEX_GET_STACK:
+      *((char**)ptr) = st->stack;
+      break;
    default:
       speex_warning_int("Unknown nb_ctl request: ", request);
       return -1;



More information about the commits mailing list