svn:eol-style properties, and make eol-style consistent in some files.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5738 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris
2007-09-21 18:49:14 +00:00
parent f2196e916b
commit 5bea2ea06c
147 changed files with 28889 additions and 28757 deletions
+64 -64
View File
@@ -1,64 +1,64 @@
/*---------------------------------------------------------------------------*\
Original Copyright
FILE........: AK2LSPD.H
TYPE........: Turbo C header file
COMPANY.....: Voicetronix
AUTHOR......: James Whitehall
DATE CREATED: 21/11/95
Modified by Jean-Marc Valin
This file contains functions for converting Linear Prediction
Coefficients (LPC) to Line Spectral Pair (LSP) and back. Note that the
LSP coefficients are not in radians format but in the x domain of the
unit circle.
\*---------------------------------------------------------------------------*/
/**
@file lsp.h
@brief Line Spectral Pair (LSP) functions.
*/
/* Speex License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __AK2LSPD__
#define __AK2LSPD__
#include "misc.h"
int lpc_to_lsp (spx_coef_t *a, int lpcrdr, spx_lsp_t *freq, int nb, spx_word16_t delta, char *stack);
void lsp_to_lpc(spx_lsp_t *freq, spx_coef_t *ak, int lpcrdr, char *stack);
/*Added by JMV*/
void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin);
void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes);
#endif /* __AK2LSPD__ */
/*---------------------------------------------------------------------------*\
Original Copyright
FILE........: AK2LSPD.H
TYPE........: Turbo C header file
COMPANY.....: Voicetronix
AUTHOR......: James Whitehall
DATE CREATED: 21/11/95
Modified by Jean-Marc Valin
This file contains functions for converting Linear Prediction
Coefficients (LPC) to Line Spectral Pair (LSP) and back. Note that the
LSP coefficients are not in radians format but in the x domain of the
unit circle.
\*---------------------------------------------------------------------------*/
/**
@file lsp.h
@brief Line Spectral Pair (LSP) functions.
*/
/* Speex License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __AK2LSPD__
#define __AK2LSPD__
#include "misc.h"
int lpc_to_lsp (spx_coef_t *a, int lpcrdr, spx_lsp_t *freq, int nb, spx_word16_t delta, char *stack);
void lsp_to_lpc(spx_lsp_t *freq, spx_coef_t *ak, int lpcrdr, char *stack);
/*Added by JMV*/
void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin);
void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes);
#endif /* __AK2LSPD__ */
+1047 -1047
View File
File diff suppressed because it is too large Load Diff
+188 -188
View File
@@ -1,188 +1,188 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "getopt_win.h"
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
#define const
#endif
#endif
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#define GETOPT_INTERFACE_VERSION 2
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
#include <gnu-versions.h>
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
#define ELIDE_CODE
#endif
#endif
#ifndef ELIDE_CODE
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#include <stdlib.h>
#endif
#ifndef NULL
#define NULL 0
#endif
int
getopt_long (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
If an option that starts with '-' (not '--') doesn't match a long option,
but does match a short option, it is parsed as a short option
instead. */
int
getopt_long_only (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
}
#endif /* Not ELIDE_CODE. */
#ifdef TEST
#include <stdio.h>
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] =
{
{"add", 1, 0, 0},
{"append", 0, 0, 0},
{"delete", 1, 0, 0},
{"verbose", 0, 0, 0},
{"create", 0, 0, 0},
{"file", 1, 0, 0},
{0, 0, 0, 0}
};
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
if (c == -1)
break;
switch (c)
{
case 0:
printf ("option %s", long_options[option_index].name);
if (optarg)
printf (" with arg %s", optarg);
printf ("\n");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case 'd':
printf ("option d with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "getopt_win.h"
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
#define const
#endif
#endif
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#define GETOPT_INTERFACE_VERSION 2
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
#include <gnu-versions.h>
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
#define ELIDE_CODE
#endif
#endif
#ifndef ELIDE_CODE
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#include <stdlib.h>
#endif
#ifndef NULL
#define NULL 0
#endif
int
getopt_long (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
If an option that starts with '-' (not '--') doesn't match a long option,
but does match a short option, it is parsed as a short option
instead. */
int
getopt_long_only (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
}
#endif /* Not ELIDE_CODE. */
#ifdef TEST
#include <stdio.h>
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] =
{
{"add", 1, 0, 0},
{"append", 0, 0, 0},
{"delete", 1, 0, 0},
{"verbose", 0, 0, 0},
{"create", 0, 0, 0},
{"file", 1, 0, 0},
{0, 0, 0, 0}
};
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
if (c == -1)
break;
switch (c)
{
case 0:
printf ("option %s", long_options[option_index].name);
if (optarg)
printf (" with arg %s", optarg);
printf ("\n");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case 'd':
printf ("option d with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */
+169 -169
View File
@@ -1,169 +1,169 @@
/* Declarations for getopt.
Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _GETOPT_H
#ifndef __need_getopt
# define _GETOPT_H 1
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
#ifndef __need_getopt
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
# if defined __STDC__ && __STDC__
const char *name;
# else
char *name;
# endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
# define no_argument 0
# define required_argument 1
# define optional_argument 2
#endif /* need getopt */
/* Get definitions and prototypes for functions to process the
arguments in ARGV (ARGC of them, minus the program name) for
options given in OPTS.
Return the option character from OPTS just read. Return -1 when
there are no more options. For unrecognized options, or options
missing arguments, `optopt' is set to the option letter, and '?' is
returned.
The OPTS string is a list of characters which are recognized option
letters, optionally followed by colons, specifying that that letter
takes an argument, to be placed in `optarg'.
If a letter in OPTS is followed by two colons, its argument is
optional. This behavior is specific to the GNU `getopt'.
The argument `--' causes premature termination of argument
scanning, explicitly telling `getopt' that there are no more
options.
If OPTS begins with `--', then non-option arguments are treated as
arguments to the option '\0'. This behavior is specific to the GNU
`getopt'. */
#if defined __STDC__ && __STDC__
# ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
# else /* not __GNU_LIBRARY__ */
extern int getopt ();
# endif /* __GNU_LIBRARY__ */
# ifndef __need_getopt
extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
const struct option *__longopts, int *__longind);
extern int getopt_long_only (int __argc, char *const *__argv,
const char *__shortopts,
const struct option *__longopts, int *__longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int __argc, char *const *__argv,
const char *__shortopts,
const struct option *__longopts, int *__longind,
int __long_only);
# endif
#else /* not __STDC__ */
extern int getopt ();
# ifndef __need_getopt
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
# endif
#endif /* __STDC__ */
#ifdef __cplusplus
}
#endif
/* Make sure we later can get all the definitions and declarations. */
#undef __need_getopt
#endif /* getopt.h */
/* Declarations for getopt.
Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _GETOPT_H
#ifndef __need_getopt
# define _GETOPT_H 1
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
#ifndef __need_getopt
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
# if defined __STDC__ && __STDC__
const char *name;
# else
char *name;
# endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
# define no_argument 0
# define required_argument 1
# define optional_argument 2
#endif /* need getopt */
/* Get definitions and prototypes for functions to process the
arguments in ARGV (ARGC of them, minus the program name) for
options given in OPTS.
Return the option character from OPTS just read. Return -1 when
there are no more options. For unrecognized options, or options
missing arguments, `optopt' is set to the option letter, and '?' is
returned.
The OPTS string is a list of characters which are recognized option
letters, optionally followed by colons, specifying that that letter
takes an argument, to be placed in `optarg'.
If a letter in OPTS is followed by two colons, its argument is
optional. This behavior is specific to the GNU `getopt'.
The argument `--' causes premature termination of argument
scanning, explicitly telling `getopt' that there are no more
options.
If OPTS begins with `--', then non-option arguments are treated as
arguments to the option '\0'. This behavior is specific to the GNU
`getopt'. */
#if defined __STDC__ && __STDC__
# ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
# else /* not __GNU_LIBRARY__ */
extern int getopt ();
# endif /* __GNU_LIBRARY__ */
# ifndef __need_getopt
extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
const struct option *__longopts, int *__longind);
extern int getopt_long_only (int __argc, char *const *__argv,
const char *__shortopts,
const struct option *__longopts, int *__longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int __argc, char *const *__argv,
const char *__shortopts,
const struct option *__longopts, int *__longind,
int __long_only);
# endif
#else /* not __STDC__ */
extern int getopt ();
# ifndef __need_getopt
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
# endif
#endif /* __STDC__ */
#ifdef __cplusplus
}
#endif
/* Make sure we later can get all the definitions and declarations. */
#undef __need_getopt
#endif /* getopt.h */
+220 -220
View File
@@ -1,220 +1,220 @@
/* Copyright (c) 2002, John Edwards
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* Set TABS = 4 */
/********************************************************************
function: To provide playback of 16 bit PCM wave data in Win32
environments from decoded compressed files.
********************************************************************/
#if defined WIN32 || defined _WIN32
#include <string.h>
#include <errno.h>
#include "wave_out.h"
#define MAXWAVESIZE 4294967040LU
#define MAX_WAVEBLOCKS 32
// This is modified for USE_WIN_AUDIO - ONLY 2002-02-27
static CRITICAL_SECTION cs;
static HWAVEOUT dev = NULL;
static int ScheduledBlocks = 0;
static int PlayedWaveHeadersCount = 0; // free index
static WAVEHDR* PlayedWaveHeaders [MAX_WAVEBLOCKS];
static int
Box ( const char* msg )
{
MessageBox ( NULL, msg, " "VERSION_STRING": Error Message . . .", MB_OK | MB_ICONEXCLAMATION );
return -1;
}
/*
* This function registers already played WAVE chunks. Freeing is done by free_memory(),
*/
static void CALLBACK
wave_callback ( HWAVE hWave, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 )
{
if ( uMsg == WOM_DONE ) {
EnterCriticalSection ( &cs );
PlayedWaveHeaders [PlayedWaveHeadersCount++] = (WAVEHDR*) dwParam1;
LeaveCriticalSection ( &cs );
}
}
static void
free_memory ( void )
{
WAVEHDR* wh;
HGLOBAL hg;
EnterCriticalSection ( &cs );
wh = PlayedWaveHeaders [--PlayedWaveHeadersCount];
ScheduledBlocks--; // decrease the number of USED blocks
LeaveCriticalSection ( &cs );
waveOutUnprepareHeader ( dev, wh, sizeof (WAVEHDR) );
hg = GlobalHandle ( wh -> lpData ); // Deallocate the buffer memory
GlobalUnlock (hg);
GlobalFree (hg);
hg = GlobalHandle ( wh ); // Deallocate the header memory
GlobalUnlock (hg);
GlobalFree (hg);
}
Int
Set_WIN_Params ( FILE_T dummyFile ,
Ldouble SampleFreq,
Uint BitsPerSample,
Uint Channels )
{
WAVEFORMATEX outFormat;
UINT deviceID = WAVE_MAPPER;
(void) dummyFile;
if ( waveOutGetNumDevs () == 0 )
return Box ( "No audio device present." );
outFormat.wFormatTag = WAVE_FORMAT_PCM;
outFormat.wBitsPerSample = BitsPerSample;
outFormat.nChannels = Channels;
outFormat.nSamplesPerSec = (unsigned long)(SampleFreq + 0.5);
outFormat.nBlockAlign = (outFormat.wBitsPerSample + 7) / 8 * outFormat.nChannels;
outFormat.nAvgBytesPerSec = outFormat.nSamplesPerSec * outFormat.nBlockAlign;
switch ( waveOutOpen ( &dev, deviceID, &outFormat, (DWORD)wave_callback, 0, CALLBACK_FUNCTION ) )
{
case MMSYSERR_ALLOCATED: return Box ( "Device is already open." );
case MMSYSERR_BADDEVICEID: return Box ( "The specified device is out of range." );
case MMSYSERR_NODRIVER: return Box ( "There is no audio driver in this system." );
case MMSYSERR_NOMEM: return Box ( "Unable to allocate sound memory." );
case WAVERR_BADFORMAT: return Box ( "This audio format is not supported." );
case WAVERR_SYNC: return Box ( "The device is synchronous." );
default: return Box ( "Unknown media error." );
case MMSYSERR_NOERROR: break;
}
waveOutReset ( dev );
InitializeCriticalSection ( &cs );
SetPriorityClass ( GetCurrentProcess (), HIGH_PRIORITY_CLASS );
return 0;
}
int
WIN_Play_Samples ( const void* data, size_t len )
{
HGLOBAL hg;
HGLOBAL hg2;
LPWAVEHDR wh;
void* allocptr;
do {
while ( PlayedWaveHeadersCount > 0 ) // free used blocks ...
free_memory ();
if ( ScheduledBlocks < sizeof(PlayedWaveHeaders)/sizeof(*PlayedWaveHeaders) ) // wait for a free block ...
break;
Sleep (26);
} while (1);
if ( (hg2 = GlobalAlloc ( GMEM_MOVEABLE, len )) == NULL ) // allocate some memory for a copy of the buffer
return Box ( "GlobalAlloc failed." );
allocptr = GlobalLock (hg2);
CopyMemory ( allocptr, data, len ); // Here we can call any modification output functions we want....
if ( (hg = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof (WAVEHDR))) == NULL ) // now make a header and WRITE IT!
return -1;
wh = GlobalLock (hg);
wh -> dwBufferLength = len;
wh -> lpData = allocptr;
if ( waveOutPrepareHeader ( dev, wh, sizeof (WAVEHDR)) != MMSYSERR_NOERROR ) {
GlobalUnlock (hg);
GlobalFree (hg);
return -1;
}
if ( waveOutWrite ( dev, wh, sizeof (WAVEHDR)) != MMSYSERR_NOERROR ) {
GlobalUnlock (hg);
GlobalFree (hg);
return -1;
}
EnterCriticalSection ( &cs );
ScheduledBlocks++;
LeaveCriticalSection ( &cs );
return len;
}
int
WIN_Audio_close ( void )
{
if ( dev != NULL ) {
while ( ScheduledBlocks > 0 ) {
Sleep (ScheduledBlocks);
while ( PlayedWaveHeadersCount > 0 ) // free used blocks ...
free_memory ();
}
waveOutReset (dev); // reset the device
waveOutClose (dev); // close the device
dev = NULL;
}
DeleteCriticalSection ( &cs );
ScheduledBlocks = 0;
return 0;
}
#endif
/* end of wave_out.c */
/* Copyright (c) 2002, John Edwards
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* Set TABS = 4 */
/********************************************************************
function: To provide playback of 16 bit PCM wave data in Win32
environments from decoded compressed files.
********************************************************************/
#if defined WIN32 || defined _WIN32
#include <string.h>
#include <errno.h>
#include "wave_out.h"
#define MAXWAVESIZE 4294967040LU
#define MAX_WAVEBLOCKS 32
// This is modified for USE_WIN_AUDIO - ONLY 2002-02-27
static CRITICAL_SECTION cs;
static HWAVEOUT dev = NULL;
static int ScheduledBlocks = 0;
static int PlayedWaveHeadersCount = 0; // free index
static WAVEHDR* PlayedWaveHeaders [MAX_WAVEBLOCKS];
static int
Box ( const char* msg )
{
MessageBox ( NULL, msg, " "VERSION_STRING": Error Message . . .", MB_OK | MB_ICONEXCLAMATION );
return -1;
}
/*
* This function registers already played WAVE chunks. Freeing is done by free_memory(),
*/
static void CALLBACK
wave_callback ( HWAVE hWave, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 )
{
if ( uMsg == WOM_DONE ) {
EnterCriticalSection ( &cs );
PlayedWaveHeaders [PlayedWaveHeadersCount++] = (WAVEHDR*) dwParam1;
LeaveCriticalSection ( &cs );
}
}
static void
free_memory ( void )
{
WAVEHDR* wh;
HGLOBAL hg;
EnterCriticalSection ( &cs );
wh = PlayedWaveHeaders [--PlayedWaveHeadersCount];
ScheduledBlocks--; // decrease the number of USED blocks
LeaveCriticalSection ( &cs );
waveOutUnprepareHeader ( dev, wh, sizeof (WAVEHDR) );
hg = GlobalHandle ( wh -> lpData ); // Deallocate the buffer memory
GlobalUnlock (hg);
GlobalFree (hg);
hg = GlobalHandle ( wh ); // Deallocate the header memory
GlobalUnlock (hg);
GlobalFree (hg);
}
Int
Set_WIN_Params ( FILE_T dummyFile ,
Ldouble SampleFreq,
Uint BitsPerSample,
Uint Channels )
{
WAVEFORMATEX outFormat;
UINT deviceID = WAVE_MAPPER;
(void) dummyFile;
if ( waveOutGetNumDevs () == 0 )
return Box ( "No audio device present." );
outFormat.wFormatTag = WAVE_FORMAT_PCM;
outFormat.wBitsPerSample = BitsPerSample;
outFormat.nChannels = Channels;
outFormat.nSamplesPerSec = (unsigned long)(SampleFreq + 0.5);
outFormat.nBlockAlign = (outFormat.wBitsPerSample + 7) / 8 * outFormat.nChannels;
outFormat.nAvgBytesPerSec = outFormat.nSamplesPerSec * outFormat.nBlockAlign;
switch ( waveOutOpen ( &dev, deviceID, &outFormat, (DWORD)wave_callback, 0, CALLBACK_FUNCTION ) )
{
case MMSYSERR_ALLOCATED: return Box ( "Device is already open." );
case MMSYSERR_BADDEVICEID: return Box ( "The specified device is out of range." );
case MMSYSERR_NODRIVER: return Box ( "There is no audio driver in this system." );
case MMSYSERR_NOMEM: return Box ( "Unable to allocate sound memory." );
case WAVERR_BADFORMAT: return Box ( "This audio format is not supported." );
case WAVERR_SYNC: return Box ( "The device is synchronous." );
default: return Box ( "Unknown media error." );
case MMSYSERR_NOERROR: break;
}
waveOutReset ( dev );
InitializeCriticalSection ( &cs );
SetPriorityClass ( GetCurrentProcess (), HIGH_PRIORITY_CLASS );
return 0;
}
int
WIN_Play_Samples ( const void* data, size_t len )
{
HGLOBAL hg;
HGLOBAL hg2;
LPWAVEHDR wh;
void* allocptr;
do {
while ( PlayedWaveHeadersCount > 0 ) // free used blocks ...
free_memory ();
if ( ScheduledBlocks < sizeof(PlayedWaveHeaders)/sizeof(*PlayedWaveHeaders) ) // wait for a free block ...
break;
Sleep (26);
} while (1);
if ( (hg2 = GlobalAlloc ( GMEM_MOVEABLE, len )) == NULL ) // allocate some memory for a copy of the buffer
return Box ( "GlobalAlloc failed." );
allocptr = GlobalLock (hg2);
CopyMemory ( allocptr, data, len ); // Here we can call any modification output functions we want....
if ( (hg = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof (WAVEHDR))) == NULL ) // now make a header and WRITE IT!
return -1;
wh = GlobalLock (hg);
wh -> dwBufferLength = len;
wh -> lpData = allocptr;
if ( waveOutPrepareHeader ( dev, wh, sizeof (WAVEHDR)) != MMSYSERR_NOERROR ) {
GlobalUnlock (hg);
GlobalFree (hg);
return -1;
}
if ( waveOutWrite ( dev, wh, sizeof (WAVEHDR)) != MMSYSERR_NOERROR ) {
GlobalUnlock (hg);
GlobalFree (hg);
return -1;
}
EnterCriticalSection ( &cs );
ScheduledBlocks++;
LeaveCriticalSection ( &cs );
return len;
}
int
WIN_Audio_close ( void )
{
if ( dev != NULL ) {
while ( ScheduledBlocks > 0 ) {
Sleep (ScheduledBlocks);
while ( PlayedWaveHeadersCount > 0 ) // free used blocks ...
free_memory ();
}
waveOutReset (dev); // reset the device
waveOutClose (dev); // close the device
dev = NULL;
}
DeleteCriticalSection ( &cs );
ScheduledBlocks = 0;
return 0;
}
#endif
/* end of wave_out.c */
+71 -71
View File
@@ -1,71 +1,71 @@
/* Copyright (c) 2002, John Edwards
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// WAVE_OUT.H - Necessary stuff for WIN_AUDIO
#ifndef WAVE_OUT_H
#define WAVE_OUT_H
#include <stdio.h>
#include <windows.h>
#ifdef __MINGW32__
#include <mmsystem.h>
#endif
#define VERSION_STRING "\n 0.7.0\n"
#define Cdecl __cdecl
#define __attribute__(x)
#define sleep(__sec) Sleep ((__sec) * 1000)
#define inline __inline
#define restrict
//// constants /////////////////////////////////////////////////////
#define CD_SAMPLE_FREQ 44.1e3
#define SAMPLE_SIZE 16
#define SAMPLE_SIZE_STRING ""
#define WINAUDIO_FD ((FILE_T)-128)
#define FILE_T FILE*
#define INVALID_FILEDESC NULL
//// Simple types //////////////////////////////////////////////////
typedef signed int Int; // at least -32767...+32767, fast type
typedef unsigned int Uint; // at least 0...65535, fast type
typedef long double Ldouble; // most exact floating point format
//// procedures/functions //////////////////////////////////////////
// wave_out.c
Int Set_WIN_Params ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels);
int WIN_Play_Samples ( const void* buff, size_t len );
int WIN_Audio_close ( void );
#endif /* WAVE_OUT_H */
/* Copyright (c) 2002, John Edwards
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// WAVE_OUT.H - Necessary stuff for WIN_AUDIO
#ifndef WAVE_OUT_H
#define WAVE_OUT_H
#include <stdio.h>
#include <windows.h>
#ifdef __MINGW32__
#include <mmsystem.h>
#endif
#define VERSION_STRING "\n 0.7.0\n"
#define Cdecl __cdecl
#define __attribute__(x)
#define sleep(__sec) Sleep ((__sec) * 1000)
#define inline __inline
#define restrict
//// constants /////////////////////////////////////////////////////
#define CD_SAMPLE_FREQ 44.1e3
#define SAMPLE_SIZE 16
#define SAMPLE_SIZE_STRING ""
#define WINAUDIO_FD ((FILE_T)-128)
#define FILE_T FILE*
#define INVALID_FILEDESC NULL
//// Simple types //////////////////////////////////////////////////
typedef signed int Int; // at least -32767...+32767, fast type
typedef unsigned int Uint; // at least 0...65535, fast type
typedef long double Ldouble; // most exact floating point format
//// procedures/functions //////////////////////////////////////////
// wave_out.c
Int Set_WIN_Params ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels);
int WIN_Play_Samples ( const void* buff, size_t len );
int WIN_Audio_close ( void );
#endif /* WAVE_OUT_H */
+57 -57
View File
@@ -1,57 +1,57 @@
/*
Copyright (C) 2003 Commonwealth Scientific and Industrial Research
Organisation (CSIRO) Australia
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of CSIRO Australia nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CONFIG_H
#define CONFIG_H
/* An inline macro is required for use of the inline keyword as not all C compilers support */
/* inline. It is officially C99 and C++ only */
#ifdef __WINS__
#define inline __inline
/* Disable some pointless/stupid warnings */
#pragma warning(disable: 4100) /* unreferenced formal parameter */
#pragma warning(disable: 4127) /* conditional expression is constant */
#pragma warning(disable: 4305) /* truncation from '...' to '...' */
#pragma warning(disable: 4244) /* conversion from '...' to '...', possible loss of data */
#pragma warning(disable: 4701) /* local variable may be be used without having been initialized */
#endif /* ! __WINS__ */
/* Use only fixed point arithmetic */
#define FIXED_POINT 1
#endif /* ! CONFIG_H */
/*
Copyright (C) 2003 Commonwealth Scientific and Industrial Research
Organisation (CSIRO) Australia
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of CSIRO Australia nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CONFIG_H
#define CONFIG_H
/* An inline macro is required for use of the inline keyword as not all C compilers support */
/* inline. It is officially C99 and C++ only */
#ifdef __WINS__
#define inline __inline
/* Disable some pointless/stupid warnings */
#pragma warning(disable: 4100) /* unreferenced formal parameter */
#pragma warning(disable: 4127) /* conditional expression is constant */
#pragma warning(disable: 4305) /* truncation from '...' to '...' */
#pragma warning(disable: 4244) /* conversion from '...' to '...', possible loss of data */
#pragma warning(disable: 4701) /* local variable may be be used without having been initialized */
#endif /* ! __WINS__ */
/* Use only fixed point arithmetic */
#define FIXED_POINT 1
#endif /* ! CONFIG_H */
+42 -42
View File
@@ -1,6 +1,6 @@
/* Copyright (C) 2005 Psi Systems, Inc.
File: config.h
Main Speex option include file for TI C64xx, C54xx and C55xx processors
Main Speex option include file for TI C64xx, C54xx and C55xx processors
for use with TI Code Composer (TM) DSP development tools.
Redistribution and use in source and binary forms, with or without
@@ -30,44 +30,44 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define FIXED_POINT
#define FRAME_SIZE 160
#define DISABLE_WIDEBAND
/* Allow for 2 20ms narrowband blocks per frame, plus a couple of bytes */
#define MAX_CHARS_PER_FRAME (42/BYTES_PER_CHAR)
/* for debug */
#undef DECODE_ONLY
/* EITHER Allocate from fixed array (C heap not used) */
/* Enable VERBOSE_ALLOC to see how much is used */
#define MANUAL_ALLOC
#define USER_MISC
#define VERBOSE_ALLOC
/* OR Use CALLOC (heap size must be increased in linker command file) */
//#undef MANUAL_ALLOC
//#undef USER_MISC
#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
//#define PRECISION16
// These values determined by analysis for 8kbps narrowband
#define SPEEXENC_PERSIST_STACK_SIZE 5000
#define SPEEXENC_SCRATCH_STACK_SIZE 3000
#define SPEEXDEC_PERSIST_STACK_SIZE 2500
#define SPEEXDEC_SCRATCH_STACK_SIZE 1000
#else /* C6X */
#define NO_LONGLONG
#define SPEEXENC_PERSIST_STACK_SIZE 10000
#define SPEEXENC_SCRATCH_STACK_SIZE 6000
#define SPEEXDEC_PERSIST_STACK_SIZE 5000
#define SPEEXDEC_SCRATCH_STACK_SIZE 2000
#endif
#define SPEEX_PERSIST_STACK_SIZE (SPEEXENC_PERSIST_STACK_SIZE + SPEEXDEC_PERSIST_STACK_SIZE)
#define SPEEX_SCRATCH_STACK_SIZE SPEEXENC_SCRATCH_STACK_SIZE
#define NB_ENC_STACK SPEEXENC_SCRATCH_STACK_SIZE
#define NB_DEC_STACK SPEEXDEC_SCRATCH_STACK_SIZE
#define FIXED_POINT
#define FRAME_SIZE 160
#define DISABLE_WIDEBAND
/* Allow for 2 20ms narrowband blocks per frame, plus a couple of bytes */
#define MAX_CHARS_PER_FRAME (42/BYTES_PER_CHAR)
/* for debug */
#undef DECODE_ONLY
/* EITHER Allocate from fixed array (C heap not used) */
/* Enable VERBOSE_ALLOC to see how much is used */
#define MANUAL_ALLOC
#define USER_MISC
#define VERBOSE_ALLOC
/* OR Use CALLOC (heap size must be increased in linker command file) */
//#undef MANUAL_ALLOC
//#undef USER_MISC
#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
//#define PRECISION16
// These values determined by analysis for 8kbps narrowband
#define SPEEXENC_PERSIST_STACK_SIZE 5000
#define SPEEXENC_SCRATCH_STACK_SIZE 3000
#define SPEEXDEC_PERSIST_STACK_SIZE 2500
#define SPEEXDEC_SCRATCH_STACK_SIZE 1000
#else /* C6X */
#define NO_LONGLONG
#define SPEEXENC_PERSIST_STACK_SIZE 10000
#define SPEEXENC_SCRATCH_STACK_SIZE 6000
#define SPEEXDEC_PERSIST_STACK_SIZE 5000
#define SPEEXDEC_SCRATCH_STACK_SIZE 2000
#endif
#define SPEEX_PERSIST_STACK_SIZE (SPEEXENC_PERSIST_STACK_SIZE + SPEEXDEC_PERSIST_STACK_SIZE)
#define SPEEX_SCRATCH_STACK_SIZE SPEEXENC_SCRATCH_STACK_SIZE
#define NB_ENC_STACK SPEEXENC_SCRATCH_STACK_SIZE
#define NB_DEC_STACK SPEEXDEC_SCRATCH_STACK_SIZE
+284 -284
View File
@@ -1,287 +1,287 @@
/* Copyright (C) 2005 Psi Systems, Inc.
File: testenc-TI-C5x.c
Encoder/Decoder Loop Main file for TI C54xx and C55xx processors
for use with TI Code Composer (TM) DSP development tools.
Modified from speexlib/testenc.c
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* Modified from speexlib/testenc.c for Code Composer simulator */
#include <speex/speex.h>
#include <stdio.h>
#include <stdlib.h>
#include <speex/speex_callbacks.h>
#include <..\libspeex\arch.h>
#undef DECODE_ONLY
#define CHECK_RESULT /* Compares original file with encoded/decoder file */
#define TESTENC_BYTES_PER_FRAME 20 /* 8kbps */
#define TESTENC_QUALITY 4 /* 8kbps */
//#define TESTENC_BYTES_PER_FRAME 28 /* 11kbps */
//#define TESTENC_QUALITY 5 /* 11 kbps */
/* For narrowband, QUALITY maps to these bit rates (see modes.c, manual.pdf)
* {1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7}
* 0 -> 2150
* 1 -> 3950
* 2 -> 5950
* 3 -> 8000
* 4 -> 8000
* 5 -> 11000
* 6 -> 11000
* 7 -> 15000
* 8 -> 15000
* 9 -> 18200
*10 -> 26400 */
#ifdef FIXED_DEBUG
extern long long spx_mips;
#endif
#include <math.h>
#ifdef MANUAL_ALLOC
/* Take all Speex space from this private heap */
/* This is useful for multichannel applications */
#pragma DATA_SECTION(spxHeap, ".myheap");
static char spxHeap[SPEEX_PERSIST_STACK_SIZE];
#pragma DATA_SECTION(spxScratch, ".myheap");
static char spxScratch[SPEEX_SCRATCH_STACK_SIZE];
char *spxGlobalHeapPtr, *spxGlobalHeapEnd;
char *spxGlobalScratchPtr, *spxGlobalScratchEnd;
#endif
void byte2word(short* pInBuf, short* pOutBuf, int nWords)
{
short *pIn, *pOut, sNext;
int i;
pIn = pInBuf;
pOut = pOutBuf;
for(i=0;i<nWords;i++)
{
sNext = *pIn++; // Get low byte
*pOut++ = (sNext & 0x00ff) | (*pIn++ << 8); // insert high byte
}
}
void word2byte(short* pInBuf, short* pOutBuf, int nWords)
{
short *pIn, *pOut;
int i;
pIn = pInBuf;
pOut = pOutBuf;
for(i=0;i<nWords;i++)
{
*pOut++ = *pIn & 0x00ff; // Get low byte
*pOut++ = (short) ((unsigned short) *pIn++ >> 8);
}
}
void main()
{
char *outFile, *bitsFile;
FILE *fout, *fbits=NULL;
#if !defined(DECODE_ONLY) || defined(CHECK_RESULT)
char *inFile;
FILE *fin;
short in_short[FRAME_SIZE];
#endif
short out_short[FRAME_SIZE];
short inout_byte[2*FRAME_SIZE];
#ifndef DECODE_ONLY
int nbChars;
#endif
#ifdef CHECK_RESULT
float sigpow,errpow,snr, seg_snr=0;
int snr_frames = 0;
int i;
#endif
char cbits[TESTENC_BYTES_PER_FRAME/2 + 2]; /* temp store for encoded data */
void *st;
void *dec;
SpeexBits bits;
spx_int32_t tmp;
unsigned long bitCount=0;
spx_int32_t skip_group_delay;
SpeexCallback callback;
/* C54xx defaults to max wait states, even for parts like C5416 with
larger internal memory. Need to force the wait state register to zero */
#ifdef CONFIG_TI_C54X
asm(" STM #0,SWWSR");
#endif
#ifdef CHECK_RESULT
sigpow = 0;
errpow = 0;
#endif
#ifdef MANUAL_ALLOC
spxGlobalHeapPtr = spxHeap;
spxGlobalHeapEnd = spxHeap + sizeof(spxHeap);
spxGlobalScratchPtr = spxScratch;
spxGlobalScratchEnd = spxScratch + sizeof(spxScratch);
#endif
st = speex_encoder_init(&speex_nb_mode);
#ifdef MANUAL_ALLOC
spxGlobalScratchPtr = spxScratch; /* Reuse scratch for decoder */
#endif
dec = speex_decoder_init(&speex_nb_mode);
callback.callback_id = SPEEX_INBAND_CHAR;
callback.func = speex_std_char_handler;
callback.data = stderr;
speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
callback.func = speex_std_mode_request_handler;
callback.data = st;
speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
tmp=0;
speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
tmp=0;
speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
tmp=TESTENC_QUALITY;
speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
tmp=1; /* Lowest */
speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
/* Copyright (C) 2005 Psi Systems, Inc.
File: testenc-TI-C5x.c
Encoder/Decoder Loop Main file for TI C54xx and C55xx processors
for use with TI Code Composer (TM) DSP development tools.
Modified from speexlib/testenc.c
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* Modified from speexlib/testenc.c for Code Composer simulator */
#include <speex/speex.h>
#include <stdio.h>
#include <stdlib.h>
#include <speex/speex_callbacks.h>
#include <..\libspeex\arch.h>
#undef DECODE_ONLY
#define CHECK_RESULT /* Compares original file with encoded/decoder file */
#define TESTENC_BYTES_PER_FRAME 20 /* 8kbps */
#define TESTENC_QUALITY 4 /* 8kbps */
//#define TESTENC_BYTES_PER_FRAME 28 /* 11kbps */
//#define TESTENC_QUALITY 5 /* 11 kbps */
/* For narrowband, QUALITY maps to these bit rates (see modes.c, manual.pdf)
* {1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7}
* 0 -> 2150
* 1 -> 3950
* 2 -> 5950
* 3 -> 8000
* 4 -> 8000
* 5 -> 11000
* 6 -> 11000
* 7 -> 15000
* 8 -> 15000
* 9 -> 18200
*10 -> 26400 */
#ifdef FIXED_DEBUG
extern long long spx_mips;
#endif
#include <math.h>
#ifdef MANUAL_ALLOC
/* Take all Speex space from this private heap */
/* This is useful for multichannel applications */
#pragma DATA_SECTION(spxHeap, ".myheap");
static char spxHeap[SPEEX_PERSIST_STACK_SIZE];
#pragma DATA_SECTION(spxScratch, ".myheap");
static char spxScratch[SPEEX_SCRATCH_STACK_SIZE];
char *spxGlobalHeapPtr, *spxGlobalHeapEnd;
char *spxGlobalScratchPtr, *spxGlobalScratchEnd;
#endif
void byte2word(short* pInBuf, short* pOutBuf, int nWords)
{
short *pIn, *pOut, sNext;
int i;
pIn = pInBuf;
pOut = pOutBuf;
for(i=0;i<nWords;i++)
{
sNext = *pIn++; // Get low byte
*pOut++ = (sNext & 0x00ff) | (*pIn++ << 8); // insert high byte
}
}
void word2byte(short* pInBuf, short* pOutBuf, int nWords)
{
short *pIn, *pOut;
int i;
pIn = pInBuf;
pOut = pOutBuf;
for(i=0;i<nWords;i++)
{
*pOut++ = *pIn & 0x00ff; // Get low byte
*pOut++ = (short) ((unsigned short) *pIn++ >> 8);
}
}
void main()
{
char *outFile, *bitsFile;
FILE *fout, *fbits=NULL;
#if !defined(DECODE_ONLY) || defined(CHECK_RESULT)
char *inFile;
FILE *fin;
short in_short[FRAME_SIZE];
#endif
short out_short[FRAME_SIZE];
short inout_byte[2*FRAME_SIZE];
#ifndef DECODE_ONLY
int nbChars;
#endif
#ifdef CHECK_RESULT
float sigpow,errpow,snr, seg_snr=0;
int snr_frames = 0;
int i;
#endif
char cbits[TESTENC_BYTES_PER_FRAME/2 + 2]; /* temp store for encoded data */
void *st;
void *dec;
SpeexBits bits;
spx_int32_t tmp;
unsigned long bitCount=0;
spx_int32_t skip_group_delay;
SpeexCallback callback;
/* C54xx defaults to max wait states, even for parts like C5416 with
larger internal memory. Need to force the wait state register to zero */
#ifdef CONFIG_TI_C54X
asm(" STM #0,SWWSR");
#endif
#ifdef CHECK_RESULT
sigpow = 0;
errpow = 0;
#endif
#ifdef MANUAL_ALLOC
spxGlobalHeapPtr = spxHeap;
spxGlobalHeapEnd = spxHeap + sizeof(spxHeap);
spxGlobalScratchPtr = spxScratch;
spxGlobalScratchEnd = spxScratch + sizeof(spxScratch);
#endif
st = speex_encoder_init(&speex_nb_mode);
#ifdef MANUAL_ALLOC
spxGlobalScratchPtr = spxScratch; /* Reuse scratch for decoder */
#endif
dec = speex_decoder_init(&speex_nb_mode);
callback.callback_id = SPEEX_INBAND_CHAR;
callback.func = speex_std_char_handler;
callback.data = stderr;
speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
callback.func = speex_std_mode_request_handler;
callback.data = st;
speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
tmp=0;
speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
tmp=0;
speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
tmp=TESTENC_QUALITY;
speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
tmp=1; /* Lowest */
speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &skip_group_delay);
speex_decoder_ctl(dec, SPEEX_GET_LOOKAHEAD, &tmp);
skip_group_delay += tmp;
fprintf (stderr, "decoder lookahead = %d\n", skip_group_delay);
#ifdef DECODE_ONLY
bitsFile = "c:\\speextrunktest\\samples\\malebitsin.dat";
fbits = fopen(bitsFile, "rb");
#else
bitsFile = "c:\\speextrunktest\\samples\\malebits5x.dat";
fbits = fopen(bitsFile, "wb");
#endif
#if !defined(DECODE_ONLY) || defined(CHECK_RESULT)
inFile = "c:\\speextrunktest\\samples\\male.snd";
fin = fopen(inFile, "rb");
#endif
outFile = "c:\\speextrunktest\\samples\\maleout5x.snd";
fout = fopen(outFile, "wb+");
speex_bits_init(&bits);
#ifndef DECODE_ONLY
while (!feof(fin))
{
fread(inout_byte, 2, FRAME_SIZE, fin);
byte2word(inout_byte, in_short, FRAME_SIZE); /* C5x has 16-bit char */
if (feof(fin))
break;
speex_bits_reset(&bits);
speex_encode_int(st, in_short, &bits);
nbChars = speex_bits_write(&bits, cbits,
sizeof(cbits)*BYTES_PER_CHAR) /BYTES_PER_CHAR;
bitCount+=bits.nbBits;
word2byte((short *) cbits, inout_byte, nbChars);
fwrite(inout_byte, 2, nbChars, fbits);
speex_bits_rewind(&bits);
#else /* DECODE_ONLY */
while (!feof(fbits))
{
fread(inout_byte, 1, TESTENC_BYTES_PER_FRAME, fbits);
if (feof(fbits))
break;
byte2word(inout_byte, (short *)cbits, TESTENC_BYTES_PER_FRAME/2);
speex_bits_read_from(&bits, cbits, TESTENC_BYTES_PER_FRAME);
bitCount+=160;
#endif
speex_decode_int(dec, &bits, out_short);
speex_bits_reset(&bits);
word2byte(&out_short[skip_group_delay], inout_byte, FRAME_SIZE-skip_group_delay);
fwrite(inout_byte, 2, FRAME_SIZE-skip_group_delay, fout);
skip_group_delay = 0;
#if 1
fprintf (stderr, "Bits so far: %lu \n", bitCount);
#endif
}
fprintf (stderr, "Total encoded size: %lu bits\n", bitCount);
speex_encoder_destroy(st);
speex_decoder_destroy(dec);
#ifdef CHECK_RESULT
rewind(fin);
rewind(fout);
while ( FRAME_SIZE == fread(inout_byte, 2, FRAME_SIZE, fin))
{
float s=0, e=0;
byte2word(inout_byte, in_short, FRAME_SIZE);
fread(inout_byte, 2, FRAME_SIZE, fout);
byte2word(inout_byte, out_short, FRAME_SIZE);
for (i=0;i<FRAME_SIZE;++i) {
s += (float)in_short[i] * in_short[i];
e += ((float)in_short[i]-out_short[i]) * ((float)in_short[i]-out_short[i]);
}
seg_snr += 10*log10((s+160)/(e+160));
sigpow += s;
errpow += e;
snr_frames++;
}
snr = 10 * log10( sigpow / errpow );
seg_snr /= snr_frames;
fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
#ifdef FIXED_DEBUG
printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
#endif
#endif /* CHECK_RESULT */
#if !defined(DECODE_ONLY) || defined(CHECK_RESULT)
fclose(fin);
#endif
fclose(fout);
fclose(fbits);
}
fprintf (stderr, "decoder lookahead = %d\n", skip_group_delay);
#ifdef DECODE_ONLY
bitsFile = "c:\\speextrunktest\\samples\\malebitsin.dat";
fbits = fopen(bitsFile, "rb");
#else
bitsFile = "c:\\speextrunktest\\samples\\malebits5x.dat";
fbits = fopen(bitsFile, "wb");
#endif
#if !defined(DECODE_ONLY) || defined(CHECK_RESULT)
inFile = "c:\\speextrunktest\\samples\\male.snd";
fin = fopen(inFile, "rb");
#endif
outFile = "c:\\speextrunktest\\samples\\maleout5x.snd";
fout = fopen(outFile, "wb+");
speex_bits_init(&bits);
#ifndef DECODE_ONLY
while (!feof(fin))
{
fread(inout_byte, 2, FRAME_SIZE, fin);
byte2word(inout_byte, in_short, FRAME_SIZE); /* C5x has 16-bit char */
if (feof(fin))
break;
speex_bits_reset(&bits);
speex_encode_int(st, in_short, &bits);
nbChars = speex_bits_write(&bits, cbits,
sizeof(cbits)*BYTES_PER_CHAR) /BYTES_PER_CHAR;
bitCount+=bits.nbBits;
word2byte((short *) cbits, inout_byte, nbChars);
fwrite(inout_byte, 2, nbChars, fbits);
speex_bits_rewind(&bits);
#else /* DECODE_ONLY */
while (!feof(fbits))
{
fread(inout_byte, 1, TESTENC_BYTES_PER_FRAME, fbits);
if (feof(fbits))
break;
byte2word(inout_byte, (short *)cbits, TESTENC_BYTES_PER_FRAME/2);
speex_bits_read_from(&bits, cbits, TESTENC_BYTES_PER_FRAME);
bitCount+=160;
#endif
speex_decode_int(dec, &bits, out_short);
speex_bits_reset(&bits);
word2byte(&out_short[skip_group_delay], inout_byte, FRAME_SIZE-skip_group_delay);
fwrite(inout_byte, 2, FRAME_SIZE-skip_group_delay, fout);
skip_group_delay = 0;
#if 1
fprintf (stderr, "Bits so far: %lu \n", bitCount);
#endif
}
fprintf (stderr, "Total encoded size: %lu bits\n", bitCount);
speex_encoder_destroy(st);
speex_decoder_destroy(dec);
#ifdef CHECK_RESULT
rewind(fin);
rewind(fout);
while ( FRAME_SIZE == fread(inout_byte, 2, FRAME_SIZE, fin))
{
float s=0, e=0;
byte2word(inout_byte, in_short, FRAME_SIZE);
fread(inout_byte, 2, FRAME_SIZE, fout);
byte2word(inout_byte, out_short, FRAME_SIZE);
for (i=0;i<FRAME_SIZE;++i) {
s += (float)in_short[i] * in_short[i];
e += ((float)in_short[i]-out_short[i]) * ((float)in_short[i]-out_short[i]);
}
seg_snr += 10*log10((s+160)/(e+160));
sigpow += s;
errpow += e;
snr_frames++;
}
snr = 10 * log10( sigpow / errpow );
seg_snr /= snr_frames;
fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
#ifdef FIXED_DEBUG
printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
#endif
#endif /* CHECK_RESULT */
#if !defined(DECODE_ONLY) || defined(CHECK_RESULT)
fclose(fin);
#endif
fclose(fout);
fclose(fbits);
}
+207 -207
View File
@@ -1,10 +1,10 @@
/* Copyright (C) 2005 Psi Systems, Inc.
Author: Jean-Marc Valin
File: testenc-TI-C64x.c
Encoder/Decoder Loop Main file for TI TMS320C64xx processor
Encoder/Decoder Loop Main file for TI TMS320C64xx processor
for use with TI Code Composer (TM) DSP development tools.
Modified from speexlib/testenc.c
Modified from speexlib/testenc.c
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -33,210 +33,210 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <speex/speex.h>
#include <stdio.h>
#include <stdlib.h>
#include <speex/speex_callbacks.h>
#undef DECODE_ONLY
#define CHECK_RESULT /* Compares original file with encoded/decoder file */
#define TESTENC_BYTES_PER_FRAME 20 /* 8kbps */
#define TESTENC_QUALITY 4 /* 8kbps */
//#define TESTENC_BYTES_PER_FRAME 28 /* 11kbps */
//#define TESTENC_QUALITY 5 /* 11 kbps */
/* For narrowband, QUALITY maps to these bit rates (see modes.c, manual.pdf)
* {1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7}
* 0 -> 2150
* 1 -> 3950
* 2 -> 5950
* 3 -> 8000
* 4 -> 8000
* 5 -> 11000
* 6 -> 11000
* 7 -> 15000
* 8 -> 15000
* 9 -> 18200
*10 -> 26400 */
#ifdef FIXED_DEBUG
extern long long spx_mips;
#endif
#ifdef MANUAL_ALLOC
/* Take all Speex space from this private heap */
/* This is useful for multichannel applications */
#pragma DATA_SECTION(spxHeap, ".myheap");
static char spxHeap[SPEEX_PERSIST_STACK_SIZE];
#pragma DATA_SECTION(spxScratch, ".myheap");
static char spxScratch[SPEEX_SCRATCH_STACK_SIZE];
char *spxGlobalHeapPtr, *spxGlobalHeapEnd;
char *spxGlobalScratchPtr, *spxGlobalScratchEnd;
#endif /* MANUAL_ALLOC */
#include <math.h>
void main()
{
char *outFile, *bitsFile;
FILE *fout, *fbits=NULL;
#if !defined(DECODE_ONLY) || defined(CHECK_RESULT)
char *inFile;
FILE *fin;
short in_short[FRAME_SIZE];
#endif
short out_short[FRAME_SIZE];
#ifndef DECODE_ONLY
int nbBits;
#endif
#ifdef CHECK_RESULT
float sigpow,errpow,snr, seg_snr=0;
int snr_frames = 0;
int i;
#endif
char cbits[200];
void *st;
void *dec;
SpeexBits bits;
spx_int32_t tmp;
unsigned long bitCount=0;
spx_int32_t skip_group_delay;
SpeexCallback callback;
#ifdef CHECK_RESULT
sigpow = 0;
errpow = 0;
#endif
#ifdef MANUAL_ALLOC
spxGlobalHeapPtr = spxHeap;
spxGlobalHeapEnd = spxHeap + sizeof(spxHeap);
spxGlobalScratchPtr = spxScratch;
spxGlobalScratchEnd = spxScratch + sizeof(spxScratch);
#endif
st = speex_encoder_init(&speex_nb_mode);
#ifdef MANUAL_ALLOC
spxGlobalScratchPtr = spxScratch; /* Reuse scratch for decoder */
#endif
dec = speex_decoder_init(&speex_nb_mode);
callback.callback_id = SPEEX_INBAND_CHAR;
callback.func = speex_std_char_handler;
callback.data = stderr;
speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
callback.func = speex_std_mode_request_handler;
callback.data = st;
speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
tmp=0;
speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
tmp=0;
speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
tmp=TESTENC_QUALITY;
speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
tmp=1; /* Lowest */
speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <speex/speex.h>
#include <stdio.h>
#include <stdlib.h>
#include <speex/speex_callbacks.h>
#undef DECODE_ONLY
#define CHECK_RESULT /* Compares original file with encoded/decoder file */
#define TESTENC_BYTES_PER_FRAME 20 /* 8kbps */
#define TESTENC_QUALITY 4 /* 8kbps */
//#define TESTENC_BYTES_PER_FRAME 28 /* 11kbps */
//#define TESTENC_QUALITY 5 /* 11 kbps */
/* For narrowband, QUALITY maps to these bit rates (see modes.c, manual.pdf)
* {1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7}
* 0 -> 2150
* 1 -> 3950
* 2 -> 5950
* 3 -> 8000
* 4 -> 8000
* 5 -> 11000
* 6 -> 11000
* 7 -> 15000
* 8 -> 15000
* 9 -> 18200
*10 -> 26400 */
#ifdef FIXED_DEBUG
extern long long spx_mips;
#endif
#ifdef MANUAL_ALLOC
/* Take all Speex space from this private heap */
/* This is useful for multichannel applications */
#pragma DATA_SECTION(spxHeap, ".myheap");
static char spxHeap[SPEEX_PERSIST_STACK_SIZE];
#pragma DATA_SECTION(spxScratch, ".myheap");
static char spxScratch[SPEEX_SCRATCH_STACK_SIZE];
char *spxGlobalHeapPtr, *spxGlobalHeapEnd;
char *spxGlobalScratchPtr, *spxGlobalScratchEnd;
#endif /* MANUAL_ALLOC */
#include <math.h>
void main()
{
char *outFile, *bitsFile;
FILE *fout, *fbits=NULL;
#if !defined(DECODE_ONLY) || defined(CHECK_RESULT)
char *inFile;
FILE *fin;
short in_short[FRAME_SIZE];
#endif
short out_short[FRAME_SIZE];
#ifndef DECODE_ONLY
int nbBits;
#endif
#ifdef CHECK_RESULT
float sigpow,errpow,snr, seg_snr=0;
int snr_frames = 0;
int i;
#endif
char cbits[200];
void *st;
void *dec;
SpeexBits bits;
spx_int32_t tmp;
unsigned long bitCount=0;
spx_int32_t skip_group_delay;
SpeexCallback callback;
#ifdef CHECK_RESULT
sigpow = 0;
errpow = 0;
#endif
#ifdef MANUAL_ALLOC
spxGlobalHeapPtr = spxHeap;
spxGlobalHeapEnd = spxHeap + sizeof(spxHeap);
spxGlobalScratchPtr = spxScratch;
spxGlobalScratchEnd = spxScratch + sizeof(spxScratch);
#endif
st = speex_encoder_init(&speex_nb_mode);
#ifdef MANUAL_ALLOC
spxGlobalScratchPtr = spxScratch; /* Reuse scratch for decoder */
#endif
dec = speex_decoder_init(&speex_nb_mode);
callback.callback_id = SPEEX_INBAND_CHAR;
callback.func = speex_std_char_handler;
callback.data = stderr;
speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
callback.func = speex_std_mode_request_handler;
callback.data = st;
speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
tmp=0;
speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
tmp=0;
speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
tmp=TESTENC_QUALITY;
speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
tmp=1; /* Lowest */
speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &skip_group_delay);
speex_decoder_ctl(dec, SPEEX_GET_LOOKAHEAD, &tmp);
skip_group_delay += tmp;
fprintf (stderr, "decoder lookahead = %d\n", skip_group_delay);
#ifdef DECODE_ONLY
bitsFile = "c:\\speextrunktest\\samples\\malebitsin.dat";
fbits = fopen(bitsFile, "rb");
#else
bitsFile = "c:\\speextrunktest\\samples\\malebits6x.dat";
fbits = fopen(bitsFile, "wb");
#endif
#if !defined(DECODE_ONLY) || defined(CHECK_RESULT)
inFile = "c:\\speextrunktest\\samples\\male.snd";
fin = fopen(inFile, "rb");
#endif
outFile = "c:\\speextrunktest\\samples\\maleout6x.snd";
fout = fopen(outFile, "wb+");
speex_bits_init(&bits);
#ifndef DECODE_ONLY
while (!feof(fin))
{
fread(in_short, sizeof(short), FRAME_SIZE, fin);
if (feof(fin))
break;
speex_bits_reset(&bits);
speex_encode_int(st, in_short, &bits);
nbBits = speex_bits_write(&bits, cbits, 200);
bitCount+=bits.nbBits;
fwrite(cbits, 1, nbBits, fbits);
speex_bits_rewind(&bits);
#else /* DECODE_ONLY */
while (!feof(fbits))
{
fread(cbits, 1, TESTENC_BYTES_PER_FRAME, fbits);
if (feof(fbits))
break;
speex_bits_read_from(&bits, cbits, TESTENC_BYTES_PER_FRAME);
// bitCount+=160; /* only correct for 8kbps, but just for the printf */
bitCount+=bits.nbBits;
#endif
speex_decode_int(dec, &bits, out_short);
speex_bits_reset(&bits);
fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout);
skip_group_delay = 0;
#if 1
fprintf (stderr, "Bits so far: %lu \n", bitCount);
#endif
}
fprintf (stderr, "Total encoded size: %lu bits\n", bitCount);
speex_encoder_destroy(st);
speex_decoder_destroy(dec);
#ifdef CHECK_RESULT
rewind(fin);
rewind(fout);
while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin)
&&
FRAME_SIZE == fread(out_short, sizeof(short), FRAME_SIZE,fout) )
{
float s=0, e=0;
for (i=0;i<FRAME_SIZE;++i) {
s += (float)in_short[i] * in_short[i];
e += ((float)in_short[i]-out_short[i]) * ((float)in_short[i]-out_short[i]);
}
seg_snr += 10*log10((s+160)/(e+160));
sigpow += s;
errpow += e;
snr_frames++;
}
snr = 10 * log10( sigpow / errpow );
seg_snr /= snr_frames;
fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
#ifdef FIXED_DEBUG
printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
#endif
#endif /* CHECK_RESULT */
#if !defined(DECODE_ONLY) || defined(CHECK_RESULT)
fclose(fin);
#endif
fclose(fout);
fclose(fbits);
}
fprintf (stderr, "decoder lookahead = %d\n", skip_group_delay);
#ifdef DECODE_ONLY
bitsFile = "c:\\speextrunktest\\samples\\malebitsin.dat";
fbits = fopen(bitsFile, "rb");
#else
bitsFile = "c:\\speextrunktest\\samples\\malebits6x.dat";
fbits = fopen(bitsFile, "wb");
#endif
#if !defined(DECODE_ONLY) || defined(CHECK_RESULT)
inFile = "c:\\speextrunktest\\samples\\male.snd";
fin = fopen(inFile, "rb");
#endif
outFile = "c:\\speextrunktest\\samples\\maleout6x.snd";
fout = fopen(outFile, "wb+");
speex_bits_init(&bits);
#ifndef DECODE_ONLY
while (!feof(fin))
{
fread(in_short, sizeof(short), FRAME_SIZE, fin);
if (feof(fin))
break;
speex_bits_reset(&bits);
speex_encode_int(st, in_short, &bits);
nbBits = speex_bits_write(&bits, cbits, 200);
bitCount+=bits.nbBits;
fwrite(cbits, 1, nbBits, fbits);
speex_bits_rewind(&bits);
#else /* DECODE_ONLY */
while (!feof(fbits))
{
fread(cbits, 1, TESTENC_BYTES_PER_FRAME, fbits);
if (feof(fbits))
break;
speex_bits_read_from(&bits, cbits, TESTENC_BYTES_PER_FRAME);
// bitCount+=160; /* only correct for 8kbps, but just for the printf */
bitCount+=bits.nbBits;
#endif
speex_decode_int(dec, &bits, out_short);
speex_bits_reset(&bits);
fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout);
skip_group_delay = 0;
#if 1
fprintf (stderr, "Bits so far: %lu \n", bitCount);
#endif
}
fprintf (stderr, "Total encoded size: %lu bits\n", bitCount);
speex_encoder_destroy(st);
speex_decoder_destroy(dec);
#ifdef CHECK_RESULT
rewind(fin);
rewind(fout);
while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin)
&&
FRAME_SIZE == fread(out_short, sizeof(short), FRAME_SIZE,fout) )
{
float s=0, e=0;
for (i=0;i<FRAME_SIZE;++i) {
s += (float)in_short[i] * in_short[i];
e += ((float)in_short[i]-out_short[i]) * ((float)in_short[i]-out_short[i]);
}
seg_snr += 10*log10((s+160)/(e+160));
sigpow += s;
errpow += e;
snr_frames++;
}
snr = 10 * log10( sigpow / errpow );
seg_snr /= snr_frames;
fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
#ifdef FIXED_DEBUG
printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
#endif
#endif /* CHECK_RESULT */
#if !defined(DECODE_ONLY) || defined(CHECK_RESULT)
fclose(fin);
#endif
fclose(fout);
fclose(fbits);
}
+95 -95
View File
@@ -30,98 +30,98 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef MANUAL_ALLOC
/* To avoid changing the Speex call model, this file relies on four static variables
The user main creates two linear buffers, and initializes spxGlobalHeap/ScratchPtr
to point to the start of the two buffers, and initializes spxGlobalHeap/ScratchEnd
to point to the first address following the last byte of the two buffers.
This mechanism allows, for example, data caching for multichannel applications,
where the Speex state is swapped from a large slow memory to a small fast memory
each time the codec runs.
Persistent data is allocated in spxGlobalHeap (instead of calloc), while scratch
data is allocated in spxGlobalScratch.
*/
extern char *spxGlobalHeapPtr, *spxGlobalHeapEnd;
extern char *spxGlobalScratchPtr, *spxGlobalScratchEnd;
/* Make sure that all structures are aligned to largest type */
#define BLOCK_MASK (sizeof(long double)-1)
#define OVERRIDE_SPEEX_ALLOC
void *speex_alloc (int size)
{
void *ptr;
ptr = (void *) (((int)spxGlobalHeapPtr + BLOCK_MASK) & ~BLOCK_MASK); //Start on 8 boundary
spxGlobalHeapPtr = (char *)((int)ptr + size); // Update pointer to next free location
if (spxGlobalHeapPtr > spxGlobalHeapEnd )
{
#ifdef VERBOSE_ALLOC
fprintf (stderr, "insufficient space for persistent alloc request %d bytes\n", size);
#endif
return 0;
}
#ifdef VERBOSE_ALLOC
fprintf (stderr, "Persist Allocated %d chars at %x, %d remaining\n", size, ptr, ((int)spxGlobalHeapEnd - (int)spxGlobalHeapPtr));
#endif
memset(ptr, 0, size);
return ptr;
}
#define OVERRIDE_SPEEX_ALLOC_SCRATCH
void *speex_alloc_scratch (int size)
{
void *ptr;
ptr = (void *) (((int)spxGlobalScratchPtr + BLOCK_MASK) & ~BLOCK_MASK); //Start on 8 boundary
spxGlobalScratchPtr = (char *)((int)ptr + size); // Update pointer to next free location
if (spxGlobalScratchPtr > spxGlobalScratchEnd )
{
#ifdef VERBOSE_ALLOC
fprintf (stderr, "insufficient space for scratch alloc request %d bytes\n", size);
#endif
return 0;
}
#ifdef VERBOSE_ALLOC
fprintf (stderr, "Scratch Allocated %d chars at %x, %d remaining\n", size, ptr, ((int)spxGlobalScratchEnd - (int)spxGlobalScratchPtr));
#endif
memset(ptr, 0, size);
return ptr;
}
#define OVERRIDE_SPEEX_REALLOC
void *speex_realloc (void *ptr, int size)
{
#ifdef VERBOSE_ALLOC
speex_warning("realloc attempted, not allowed");
#endif
return 0;
}
#define OVERRIDE_SPEEX_FREE
void speex_free (void *ptr)
{
#ifdef VERBOSE_ALLOC
speex_warning("at speex_free");
#endif
}
#define OVERRIDE_SPEEX_FREE_SCRATCH
void speex_free_scratch (void *ptr)
{
#ifdef VERBOSE_ALLOC
speex_warning("at speex_free_scratch");
#endif
}
#endif /* !MANUAL_ALLOC */
#ifdef MANUAL_ALLOC
/* To avoid changing the Speex call model, this file relies on four static variables
The user main creates two linear buffers, and initializes spxGlobalHeap/ScratchPtr
to point to the start of the two buffers, and initializes spxGlobalHeap/ScratchEnd
to point to the first address following the last byte of the two buffers.
This mechanism allows, for example, data caching for multichannel applications,
where the Speex state is swapped from a large slow memory to a small fast memory
each time the codec runs.
Persistent data is allocated in spxGlobalHeap (instead of calloc), while scratch
data is allocated in spxGlobalScratch.
*/
extern char *spxGlobalHeapPtr, *spxGlobalHeapEnd;
extern char *spxGlobalScratchPtr, *spxGlobalScratchEnd;
/* Make sure that all structures are aligned to largest type */
#define BLOCK_MASK (sizeof(long double)-1)
#define OVERRIDE_SPEEX_ALLOC
void *speex_alloc (int size)
{
void *ptr;
ptr = (void *) (((int)spxGlobalHeapPtr + BLOCK_MASK) & ~BLOCK_MASK); //Start on 8 boundary
spxGlobalHeapPtr = (char *)((int)ptr + size); // Update pointer to next free location
if (spxGlobalHeapPtr > spxGlobalHeapEnd )
{
#ifdef VERBOSE_ALLOC
fprintf (stderr, "insufficient space for persistent alloc request %d bytes\n", size);
#endif
return 0;
}
#ifdef VERBOSE_ALLOC
fprintf (stderr, "Persist Allocated %d chars at %x, %d remaining\n", size, ptr, ((int)spxGlobalHeapEnd - (int)spxGlobalHeapPtr));
#endif
memset(ptr, 0, size);
return ptr;
}
#define OVERRIDE_SPEEX_ALLOC_SCRATCH
void *speex_alloc_scratch (int size)
{
void *ptr;
ptr = (void *) (((int)spxGlobalScratchPtr + BLOCK_MASK) & ~BLOCK_MASK); //Start on 8 boundary
spxGlobalScratchPtr = (char *)((int)ptr + size); // Update pointer to next free location
if (spxGlobalScratchPtr > spxGlobalScratchEnd )
{
#ifdef VERBOSE_ALLOC
fprintf (stderr, "insufficient space for scratch alloc request %d bytes\n", size);
#endif
return 0;
}
#ifdef VERBOSE_ALLOC
fprintf (stderr, "Scratch Allocated %d chars at %x, %d remaining\n", size, ptr, ((int)spxGlobalScratchEnd - (int)spxGlobalScratchPtr));
#endif
memset(ptr, 0, size);
return ptr;
}
#define OVERRIDE_SPEEX_REALLOC
void *speex_realloc (void *ptr, int size)
{
#ifdef VERBOSE_ALLOC
speex_warning("realloc attempted, not allowed");
#endif
return 0;
}
#define OVERRIDE_SPEEX_FREE
void speex_free (void *ptr)
{
#ifdef VERBOSE_ALLOC
speex_warning("at speex_free");
#endif
}
#define OVERRIDE_SPEEX_FREE_SCRATCH
void speex_free_scratch (void *ptr)
{
#ifdef VERBOSE_ALLOC
speex_warning("at speex_free_scratch");
#endif
}
#endif /* !MANUAL_ALLOC */
+2 -2
View File
@@ -1,3 +1,3 @@
#define inline __inline
#define restrict
#define inline __inline
#define restrict
#include "misc.h"