[xiph-commits] r7203 - in trunk/speex: include/speex libspeex

conrad at dactyl.lonelymoon.com conrad
Tue Jul 20 23:03:36 PDT 2004


Author: conrad
Date: Tue Jul 20 23:03:36 2004
New Revision: 7203

Modified:
trunk/speex/include/speex/speex_noglobals.h
trunk/speex/libspeex/modes_noglobals.c
Log:
add speex_mode_new() and speex_mode_destroy() API calls to _noglobals API


Modified: trunk/speex/include/speex/speex_noglobals.h
===================================================================
--- trunk/speex/include/speex/speex_noglobals.h	2004-07-21 05:47:26 UTC (rev 7202)
+++ trunk/speex/include/speex/speex_noglobals.h	2004-07-21 06:03:36 UTC (rev 7203)
@@ -59,6 +59,12 @@
/** Free a mode, using its ID */
void speex_mode_free_byID (SpeexMode * mode, int id);

+/** Instantiate a mode */
+const SpeexMode * speex_mode_new (int modeID);
+
+/** Destroy a mode */
+void speex_mode_destroy (const SpeexMode * mode);
+
#ifdef __cplusplus
}
#endif

Modified: trunk/speex/libspeex/modes_noglobals.c
===================================================================
--- trunk/speex/libspeex/modes_noglobals.c	2004-07-21 05:47:26 UTC (rev 7202)
+++ trunk/speex/libspeex/modes_noglobals.c	2004-07-21 06:03:36 UTC (rev 7203)
@@ -277,12 +277,12 @@
}

static SpeexMode *
-speex_mode_new (const void * b_mode, mode_query_func query, char * modeName,
-		int modeID, int bitstream_version, encoder_init_func enc_init,
-		encoder_destroy_func enc_destroy, encode_func enc,
-		decoder_init_func dec_init, decoder_destroy_func dec_destroy,
-		decode_func dec, encoder_ctl_func enc_ctl,
-		decoder_ctl_func dec_ctl)
+mode_new (const void * b_mode, mode_query_func query, char * modeName,
+	  int modeID, int bitstream_version, encoder_init_func enc_init,
+	  encoder_destroy_func enc_destroy, encode_func enc,
+	  decoder_init_func dec_init, decoder_destroy_func dec_destroy,
+	  decode_func dec, encoder_ctl_func enc_ctl,
+	  decoder_ctl_func dec_ctl)
{
SpeexMode * mode;

@@ -752,7 +752,7 @@
_nb_mode = nb_mode();
if (_nb_mode == NULL) return NULL;

-  return speex_mode_new (
+  return mode_new (
_nb_mode,
nb_mode_query,
"narrowband",
@@ -966,7 +966,7 @@
sb_mode = sb_wb_mode ();
if (sb_mode == NULL) return NULL;

-  return speex_mode_new (
+  return mode_new (
(const SpeexNBMode *)sb_mode,
wb_mode_query,
"wideband (sub-band CELP)",
@@ -1064,7 +1064,7 @@
sb_mode = sb_uwb_mode();
if (sb_mode == NULL) return NULL;

-  return speex_mode_new (
+  return mode_new (
sb_mode,
wb_mode_query,
"ultra-wideband (sub-band CELP)",
@@ -1107,6 +1107,26 @@
}
}

+const SpeexMode * speex_mode_new (int modeID)
+{
+  switch (modeID) {
+  case 0: return speex_nb_mode_new(); break;
+  case 1: return speex_wb_mode_new(); break;
+  case 2: return speex_uwb_mode_new(); break;
+  default: return NULL;
+  }
+}
+
+void speex_mode_destroy (const SpeexMode * mode)
+{
+  switch (mode->modeID) {
+  case 0: speex_nb_mode_free(mode); break;
+  case 1: speex_wb_mode_free(mode); break;
+  case 2:  speex_uwb_mode_free(mode); break;
+  default: break;
+  }
+}
+
/** XXX: This is just a dummy global mode, as used by nb_celp.c */
const SpeexMode speex_wb_mode = {
NULL,



More information about the commits mailing list