[xiph-cvs] cvs commit: speex/src speexdec.c speexenc.c
Jean-Marc Valin
jm at xiph.org
Sat Nov 9 21:17:53 PST 2002
jm 02/11/10 00:17:53
Modified: . Speex.spec.in configure.in
libspeex nb_celp.c nb_celp.h sb_celp.c sb_celp.h speex.h
src speexdec.c speexenc.c
Log:
Update for non-standard (not 8,16,32 kHz) sampling rates, changed package
name from "Speex" to "speex" (removed capital S) and moved doc to the
devel package.
Revision Changes Path
1.11 +3 -4 speex/Speex.spec.in
Index: Speex.spec.in
===================================================================
RCS file: /usr/local/cvsroot/speex/Speex.spec.in,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Speex.spec.in 11 Oct 2002 03:51:37 -0000 1.10
+++ Speex.spec.in 10 Nov 2002 05:17:52 -0000 1.11
@@ -8,8 +8,8 @@
Release: %rel
Copyright: BSD
Group: Application/Devel
-Source: http://prdownloads.sourceforge.net/speex/%{name}-%{ver}.tar.gz
-URL: http://speex.sourceforge.net/
+Source: http://www.speex.org/download/%{name}-%{ver}.tar.gz
+URL: http://www.speex.org/
Vendor: Speex
Packager: Jean-Marc Valin (jean-marc.valin at hermes.usherb.ca)
BuildRoot: /var/tmp/%{name}-build-root
@@ -57,7 +57,6 @@
%doc COPYING AUTHORS ChangeLog NEWS README
/usr/share/man/man1/speexenc.1*
/usr/share/man/man1/speexdec.1*
-%doc doc/manual.pdf
%attr(755,root,root) %{_bindir}/speex*
%attr(755,root,root) %{_libdir}/libspeex*.so
@@ -66,4 +65,4 @@
%attr(755,root,root) %{_libdir}/libspeex*.la
%{_includedir}/speex*.h
%{_libdir}/libspeex*.a
-
+%doc doc/manual.pdf
<p><p>1.36 +2 -2 speex/configure.in
Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/speex/configure.in,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- configure.in 1 Nov 2002 00:02:57 -0000 1.35
+++ configure.in 10 Nov 2002 05:17:52 -0000 1.36
@@ -5,7 +5,7 @@
SPEEX_MAJOR_VERSION=0
SPEEX_MINOR_VERSION=99
SPEEX_MICRO_VERSION=0
-SPEEX_VERSION=1.0beta3-cvs
+SPEEX_VERSION=1.0beta3cvs
SPEEX_BINARY_AGE=0
SPEEX_INTERFACE_AGE=0
@@ -21,7 +21,7 @@
# For automake.
VERSION=$SPEEX_VERSION
-PACKAGE=Speex
+PACKAGE=speex
AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
AM_MAINTAINER_MODE
<p><p>1.79 +18 -5 speex/libspeex/nb_celp.c
Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- nb_celp.c 6 Nov 2002 01:47:39 -0000 1.78
+++ nb_celp.c 10 Nov 2002 05:17:52 -0000 1.79
@@ -171,6 +171,7 @@
st->vbr = 0;
}
st->complexity=2;
+ st->sampling_rate=8000;
return st;
}
@@ -783,7 +784,7 @@
st->pi_gain = (float*)speex_alloc(st->nbSubframes*sizeof(float));
st->last_pitch = 40;
st->count_lost=0;
-
+ st->sampling_rate=8000;
st->user_callback.func = &speex_default_user_handler;
st->user_callback.data = NULL;
@@ -1281,9 +1282,15 @@
break;
case SPEEX_GET_BITRATE:
if (st->submodes[st->submodeID])
- (*(int*)ptr) = 50*SUBMODE(bits_per_frame);
+ (*(int*)ptr) = st->sampling_rate*SUBMODE(bits_per_frame)/st->frameSize;
else
- (*(int*)ptr) = 50*(NB_SUBMODE_BITS+1);
+ (*(int*)ptr) = st->sampling_rate*(NB_SUBMODE_BITS+1)/st->frameSize;
+ break;
+ case SPEEX_SET_SAMPLING_RATE:
+ st->sampling_rate = (*(int*)ptr);
+ break;
+ case SPEEX_GET_SAMPLING_RATE:
+ (*(int*)ptr)=st->sampling_rate;
break;
case SPEEX_GET_PI_GAIN:
{
@@ -1331,9 +1338,15 @@
break;
case SPEEX_GET_BITRATE:
if (st->submodes[st->submodeID])
- (*(int*)ptr) = 50*SUBMODE(bits_per_frame);
+ (*(int*)ptr) = st->sampling_rate*SUBMODE(bits_per_frame)/st->frameSize;
else
- (*(int*)ptr) = 50*(NB_SUBMODE_BITS+1);
+ (*(int*)ptr) = st->sampling_rate*(NB_SUBMODE_BITS+1)/st->frameSize;
+ break;
+ case SPEEX_SET_SAMPLING_RATE:
+ st->sampling_rate = (*(int*)ptr);
+ break;
+ case SPEEX_GET_SAMPLING_RATE:
+ (*(int*)ptr)=st->sampling_rate;
break;
case SPEEX_SET_HANDLER:
{
<p><p>1.34 +3 -0 speex/libspeex/nb_celp.h
Index: nb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- nb_celp.h 1 Nov 2002 03:50:50 -0000 1.33
+++ nb_celp.h 10 Nov 2002 05:17:52 -0000 1.34
@@ -102,6 +102,7 @@
float vbr_quality; /**< Quality setting for VBR encoding */
int vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */
int complexity; /**< Complexity setting (0-10 from least complex to most complex) */
+ int sampling_rate;
SpeexSubmode **submodes; /**< Sub-mode data */
int submodeID; /**< Activated sub-mode */
@@ -120,6 +121,8 @@
int bufSize; /**< Buffer size */
int min_pitch; /**< Minimum pitch value allowed */
int max_pitch; /**< Maximum pitch value allowed */
+ int sampling_rate;
+
float gamma1; /**< Perceptual filter: A(z/gamma1) */
float gamma2; /**< Perceptual filter: A(z/gamma2) */
<p><p>1.92 +30 -4 speex/libspeex/sb_celp.c
Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- sb_celp.c 9 Nov 2002 06:00:02 -0000 1.91
+++ sb_celp.c 10 Nov 2002 05:17:52 -0000 1.92
@@ -218,6 +218,8 @@
st->mem_sp2 = (float*)speex_alloc(st->lpcSize*sizeof(float));
st->mem_sw = (float*)speex_alloc(st->lpcSize*sizeof(float));
st->complexity=2;
+ speex_decoder_ctl(st->st_low, SPEEX_GET_SAMPLING_RATE, &st->sampling_rate);
+ st->sampling_rate*=2;
return st;
}
@@ -637,6 +639,8 @@
st->subframeSize = mode->subframeSize;
st->nbSubframes = mode->frameSize/mode->subframeSize;
st->lpcSize=8;
+ speex_decoder_ctl(st->st_low, SPEEX_GET_SAMPLING_RATE, &st->sampling_rate);
+ st->sampling_rate*=2;
st->submodes=mode->submodes;
st->submodeID=mode->defaultSubmode;
@@ -1008,9 +1012,20 @@
case SPEEX_GET_BITRATE:
speex_encoder_ctl(st->st_low, request, ptr);
if (st->submodes[st->submodeID])
- (*(int*)ptr) += 50*SUBMODE(bits_per_frame);
+ (*(int*)ptr) += st->sampling_rate*SUBMODE(bits_per_frame)/st->full_frame_size;
else
- (*(int*)ptr) += 50*(SB_SUBMODE_BITS+1);
+ (*(int*)ptr) += st->sampling_rate*(SB_SUBMODE_BITS+1)/st->full_frame_size;
+ break;
+ case SPEEX_SET_SAMPLING_RATE:
+ {
+ int tmp=(*(int*)ptr);
+ st->sampling_rate = tmp;
+ tmp>>=1;
+ speex_encoder_ctl(st->st_low, SPEEX_SET_SAMPLING_RATE, &tmp);
+ }
+ break;
+ case SPEEX_GET_SAMPLING_RATE:
+ (*(int*)ptr)=st->sampling_rate;
break;
case SPEEX_GET_PI_GAIN:
{
@@ -1061,9 +1076,20 @@
case SPEEX_GET_BITRATE:
speex_decoder_ctl(st->st_low, request, ptr);
if (st->submodes[st->submodeID])
- (*(int*)ptr) += 50*SUBMODE(bits_per_frame);
+ (*(int*)ptr) += st->sampling_rate*SUBMODE(bits_per_frame)/st->full_frame_size;
else
- (*(int*)ptr) += 50*(SB_SUBMODE_BITS+1);
+ (*(int*)ptr) += st->sampling_rate*(SB_SUBMODE_BITS+1)/st->full_frame_size;
+ break;
+ case SPEEX_SET_SAMPLING_RATE:
+ {
+ int tmp=(*(int*)ptr);
+ st->sampling_rate = tmp;
+ tmp>>=1;
+ speex_decoder_ctl(st->st_low, SPEEX_SET_SAMPLING_RATE, &tmp);
+ }
+ break;
+ case SPEEX_GET_SAMPLING_RATE:
+ (*(int*)ptr)=st->sampling_rate;
break;
case SPEEX_SET_HANDLER:
speex_decoder_ctl(st->st_low, SPEEX_SET_HANDLER, ptr);
<p><p>1.30 +2 -0 speex/libspeex/sb_celp.h
Index: sb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- sb_celp.h 30 Oct 2002 22:12:19 -0000 1.29
+++ sb_celp.h 10 Nov 2002 05:17:52 -0000 1.30
@@ -93,6 +93,7 @@
SpeexSubmode **submodes;
int submodeID;
int complexity;
+ int sampling_rate;
} SBEncState;
@@ -107,6 +108,7 @@
int nbSubframes;
int lpcSize;
int first;
+ int sampling_rate;
void *stack;
float *x0d, *x1d;
<p><p>1.65 +5 -2 speex/libspeex/speex.h
Index: speex.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/speex.h,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- speex.h 4 Nov 2002 03:00:51 -0000 1.64
+++ speex.h 10 Nov 2002 05:17:52 -0000 1.65
@@ -88,16 +88,19 @@
/** Get current complexity of the encoder (0-10) */
#define SPEEX_GET_COMPLEXITY 17
-/*Would be SPEEX_SET_FRAME_SIZE, but it's (currently) invalid*/
+/** Set bit-rate used by the encoder (or lower) */
+#define SPEEX_SET_BITRATE 18
/** Get current bit-rate used by the encoder or decoder */
#define SPEEX_GET_BITRATE 19
/**Define a handler function for in-band Speex request*/
#define SPEEX_SET_HANDLER 20
-
/**Define a handler function for in-band user-defined request*/
#define SPEEX_SET_USER_HANDLER 22
+
+#define SPEEX_SET_SAMPLING_RATE 24
+#define SPEEX_GET_SAMPLING_RATE 25
/* Used internally, not to be used in applications */
<p><p>1.58 +8 -3 speex/src/speexdec.c
Index: speexdec.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexdec.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- speexdec.c 9 Nov 2002 06:00:02 -0000 1.57
+++ speexdec.c 10 Nov 2002 05:17:53 -0000 1.58
@@ -140,10 +140,13 @@
}
fout = fdopen(audio_fd, "w");
#elif defined WIN32 || defined _WIN32
- if (Set_WIN_Params (INVALID_FILEDESC, rate, SAMPLE_SIZE, *channels))
{
- fprintf (stderr, "Can't access %s\n", "WAVE OUT");
- exit(1);
+ unsigned int speex_channels = *channels;
+ if (Set_WIN_Params (INVALID_FILEDESC, rate, SAMPLE_SIZE, speex_channels))
+ {
+ fprintf (stderr, "Can't access %s\n", "WAVE OUT");
+ exit(1);
+ }
}
#else
fprintf (stderr, "No soundcard support\n");
@@ -273,6 +276,8 @@
if (header->mode > forceMode)
*rate >>= (header->mode - forceMode);
}
+
+ speex_decoder_ctl(st, SPEEX_SET_SAMPLING_RATE, rate);
*nframes = header->frames_per_packet;
<p><p>1.59 +40 -7 speex/src/speexenc.c
Index: speexenc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexenc.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- speexenc.c 9 Nov 2002 06:00:02 -0000 1.58
+++ speexenc.c 10 Nov 2002 05:17:53 -0000 1.59
@@ -222,7 +222,7 @@
/*Process command-line options*/
while(1)
{
- c = getopt_long (argc, argv, "nwhvV",
+ c = getopt_long (argc, argv, "nwuhvV",
long_options, &option_index);
if (c==-1)
break;
@@ -364,21 +364,46 @@
exit(1);
lsb=1; /* CHECK: exists big-endian .wav ?? */
}
- /*fprintf (stderr, "wave info: %d %d %d %d\n", rate, chan, fmt, size);*/
- /* By default, use narrowband/8 kHz */
if (!mode && !rate)
{
+ /* By default, use narrowband/8 kHz */
mode=&speex_nb_mode;
rate=8000;
} else if (mode && rate)
{
- /*FIXME: Should print some warnings if mode doesn't fit with the rate*/
+ if (rate>48000)
+ {
+ fprintf (stderr, "Bit-rate too high: %d Hz, try down-sampling\n", rate);
+ exit(1);
+ } else if (rate>25000)
+ {
+ if (mode!=&speex_uwb_mode)
+ {
+ fprintf (stderr, "WARNING: Trying to encode in %s at %d Hz. I'll do it but I suggest you try ultra-wideband instead\n", mode->modeName , rate);
+ }
+ } else if (rate>12500)
+ {
+ if (mode!=&speex_wb_mode)
+ {
+ fprintf (stderr, "WARNING: Trying to encode in %s at %d Hz. I'll do it but I suggest you try wideband instead\n", mode->modeName , rate);
+ }
+ } else if (rate>6000)
+ {
+ if (mode!=&speex_nb_mode)
+ {
+ fprintf (stderr, "WARNING: Trying to encode in %s at %d Hz. I'll do it but I suggest you try narrowband instead\n", mode->modeName , rate);
+ }
+ } else {
+ fprintf (stderr, "Bit-rate too low: %d Hz\n", rate);
+ exit(1);
+ }
} else if (!mode)
{
if (rate>48000)
{
fprintf (stderr, "Bit-rate too high: %d Hz, try down-sampling\n", rate);
+ exit(1);
} else if (rate>25000)
{
mode=&speex_uwb_mode;
@@ -390,6 +415,7 @@
mode=&speex_nb_mode;
} else {
fprintf (stderr, "Bit-rate too low: %d Hz\n", rate);
+ exit(1);
}
} else if (!rate)
{
@@ -402,15 +428,20 @@
}
if (rate!=8000 && rate!=16000 && rate!=32000)
- fprintf (stderr, "Warning: Speex is only optimized for 8,16 and 32 kHz. It will still work at %d Hz but your mileage may vary\n", rate);
+ fprintf (stderr, "Warning: Speex is only optimized for 8, 16 and 32 kHz. It will still work at %d Hz but your mileage may vary\n", rate);
speex_init_header(&header, rate, 1, mode);
header.frames_per_packet=nframes;
header.vbr=vbr_enabled;
header.nb_channels = chan;
- fprintf (stderr, "Encoding %d Hz audio using %s mode\n",
- header.rate, mode->modeName);
+ {
+ char *st_string="mono";
+ if (chan==2)
+ st_string="stereo";
+ fprintf (stderr, "Encoding %d Hz audio using %s mode (%s)\n",
+ header.rate, mode->modeName, st_string);
+ }
/*fprintf (stderr, "Encoding %d Hz audio at %d bps using %s mode\n",
header.rate, mode->bitrate, mode->modeName);*/
@@ -477,6 +508,8 @@
speex_encoder_ctl(st, SPEEX_GET_FRAME_SIZE, &frame_size);
speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &complexity);
+ speex_encoder_ctl(st, SPEEX_SET_SAMPLING_RATE, &rate);
+
if (vbr_enabled)
{
int tmp;
<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