Commit 592601bb authored by Karl Heyes's avatar Karl Heyes
Browse files

rename the res_* calls/structures as res_init can conflict with a DNS

resolver call (-lresolv)

svn path=/trunk/ices/; revision=4493
parent 304ef99b
......@@ -2,7 +2,7 @@
* stereo->mono downmixing
* resampling
*
* $Id: audio.c,v 1.5 2002/08/17 05:17:57 msmith Exp $
* $Id: audio.c,v 1.6 2003/03/15 02:24:18 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith@labyrinth.net.au>
*
......@@ -83,7 +83,7 @@ resample_state *resample_initialise(int channels, int infreq, int outfreq)
{
resample_state *state = calloc(1, sizeof(resample_state));
if(res_init(&state->resampler, channels, outfreq, infreq, RES_END)) {
if(resampler_init(&state->resampler, channels, outfreq, infreq, RES_END)) {
LOG_ERROR0("Couldn't initialise resampler to specified frequency\n");
return NULL;
}
......@@ -113,7 +113,7 @@ void resample_clear(resample_state *s)
free(s->convbuf[c]);
free(s->convbuf);
}
res_clear(&s->resampler);
resampler_clear(&s->resampler);
free(s);
}
}
......@@ -156,9 +156,9 @@ void resample_buffer_float(resample_state *s, float **buf, int buflen)
int c;
int res;
s->buffill = res_push_check(&s->resampler, buflen);
s->buffill = resampler_push_check(&s->resampler, buflen);
if(s->buffill <= 0) {
LOG_ERROR1("Fatal reencoding error: res_push_check returned %d",
LOG_ERROR1("Fatal reencoding error: resampler_push_check returned %d",
s->buffill);
}
......@@ -168,7 +168,7 @@ void resample_buffer_float(resample_state *s, float **buf, int buflen)
s->buffers[c] = realloc(s->buffers[c], s->bufsize * sizeof(float));
}
if((res = res_push(&s->resampler, s->buffers, (float const **)buf, buflen))
if((res = resampler_push(&s->resampler, s->buffers, (float const **)buf, buflen))
!= s->buffill) {
LOG_ERROR2("Internal error in resampling: returned number of samples %d"
", expected %d", res, s->buffill);
......@@ -185,7 +185,7 @@ void resample_finish(resample_state *s)
if(!s->buffers[0])
return;
ret = res_drain(&s->resampler, s->buffers);
ret = resampler_drain(&s->resampler, s->buffers);
if(ret > s->bufsize) {
LOG_ERROR0("Fatal error in resampler: buffers too small");
......
......@@ -2,7 +2,7 @@
* - stereo->mono downmixing
* - resampling
*
* $Id: audio.h,v 1.2 2002/08/03 14:41:10 msmith Exp $
* $Id: audio.h,v 1.3 2003/03/15 02:24:18 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith@labyrinth.net.au>
*
......@@ -23,7 +23,7 @@ typedef struct {
} downmix_state;
typedef struct {
res_state resampler;
resampler_state resampler;
int channels;
float **buffers;
......
......@@ -125,7 +125,7 @@ static void win_kaiser(float *dest, int N, double alpha, int width)
}
int res_init(res_state *state, int channels, int outfreq, int infreq, res_parameter op1, ...)
int resampler_init(resampler_state *state, int channels, int outfreq, int infreq, resampler_parameter op1, ...)
{
double beta = 16.0,
cutoff = 0.80,
......@@ -173,7 +173,7 @@ int res_init(res_state *state, int channels, int outfreq, int infreq, res_parame
assert("arglist" == "valid");
return -1;
}
op1 = va_arg(argp, res_parameter);
op1 = va_arg(argp, resampler_parameter);
} while (op1 != RES_END);
va_end(argp);
}
......@@ -236,7 +236,7 @@ static SAMPLE sum(float const *scale, int count, SAMPLE const *source, SAMPLE co
}
static int push(res_state const * const state, SAMPLE *pool, int * const poolfill, int * const offset, SAMPLE *dest, int dststep, SAMPLE const *source, int srcstep, size_t srclen)
static int push(resampler_state const * const state, SAMPLE *pool, int * const poolfill, int * const offset, SAMPLE *dest, int dststep, SAMPLE const *source, int srcstep, size_t srclen)
{
SAMPLE * const destbase = dest,
*poolhead = pool + *poolfill,
......@@ -254,7 +254,7 @@ static int push(res_state const * const state, SAMPLE *pool, int * const poolfil
assert(state->poolfill != -1);
lencheck = res_push_check(state, srclen);
lencheck = resampler_push_check(state, srclen);
/* fill the pool before diving in */
while (poolhead < poolend && srclen > 0)
......@@ -315,13 +315,13 @@ static int push(res_state const * const state, SAMPLE *pool, int * const poolfil
}
int res_push_max_input(res_state const * const state, size_t maxoutput)
int resampler_push_max_input(resampler_state const * const state, size_t maxoutput)
{
return maxoutput * state->infreq / state->outfreq;
}
int res_push_check(res_state const * const state, size_t srclen)
int resampler_push_check(resampler_state const * const state, size_t srclen)
{
if (state->poolfill < state->taps)
srclen -= state->taps - state->poolfill;
......@@ -330,7 +330,7 @@ int res_push_check(res_state const * const state, size_t srclen)
}
int res_push(res_state *state, SAMPLE **dstlist, SAMPLE const **srclist, size_t srclen)
int resampler_push(resampler_state *state, SAMPLE **dstlist, SAMPLE const **srclist, size_t srclen)
{
int result = -1, poolfill = -1, offset = -1, i;
......@@ -352,7 +352,7 @@ int res_push(res_state *state, SAMPLE **dstlist, SAMPLE const **srclist, size_t
}
int res_push_interleaved(res_state *state, SAMPLE *dest, SAMPLE const *source, size_t srclen)
int resampler_push_interleaved(resampler_state *state, SAMPLE *dest, SAMPLE const *source, size_t srclen)
{
int result = -1, poolfill = -1, offset = -1, i;
......@@ -374,7 +374,7 @@ int res_push_interleaved(res_state *state, SAMPLE *dest, SAMPLE const *source, s
}
int res_drain(res_state *state, SAMPLE **dstlist)
int resampler_drain(resampler_state *state, SAMPLE **dstlist)
{
SAMPLE *tail;
int result = -1, poolfill = -1, offset = -1, i;
......@@ -401,7 +401,7 @@ int res_drain(res_state *state, SAMPLE **dstlist)
}
int res_drain_interleaved(res_state *state, SAMPLE *dest)
int resampler_drain_interleaved(resampler_state *state, SAMPLE *dest)
{
SAMPLE *tail;
int result = -1, poolfill = -1, offset = -1, i;
......@@ -428,7 +428,7 @@ int res_drain_interleaved(res_state *state, SAMPLE *dest)
}
void res_clear(res_state *state)
void resampler_clear(resampler_state *state)
{
assert(state);
assert(state->table);
......
......@@ -31,7 +31,7 @@ typedef struct
/* dynamic bits */
int poolfill;
int offset;
} res_state;
} resampler_state;
typedef enum
{
......@@ -40,15 +40,15 @@ typedef enum
RES_CUTOFF, /* (double)0.80 */
RES_TAPS, /* (int)45 */
RES_BETA /* (double)16.0 */
} res_parameter;
} resampler_parameter;
int res_init(res_state *state, int channels, int outfreq, int infreq, res_parameter op1, ...);
int resampler_init(resampler_state *state, int channels, int outfreq, int infreq, resampler_parameter op1, ...);
/*
* Configure *state to manage a data stream with the specified parameters. The
* string 'params' is currently unspecified, but will configure the parameters
* of the filter.
*
* This function allocates memory, and requires that res_clear() be called when
* This function allocates memory, and requires that resampler_clear() be called when
* the buffer is no longer needed.
*
*
......@@ -58,7 +58,7 @@ int res_init(res_state *state, int channels, int outfreq, int infreq, res_parame
*/
int res_push_max_input(res_state const *state, size_t maxoutput);
int resampler_push_max_input(resampler_state const *state, size_t maxoutput);
/*
* Returns the maximum number of input elements that may be provided without
* risk of flooding an output buffer of size maxoutput. maxoutput is
......@@ -66,39 +66,39 @@ int res_push_max_input(res_state const *state, size_t maxoutput);
*/
int res_push_check(res_state const *state, size_t srclen);
int resampler_push_check(resampler_state const *state, size_t srclen);
/*
* Returns the number of elements that will be returned if the given srclen
* is used in the next call to res_push().
* is used in the next call to resampler_push().
*/
int res_push(res_state *state, SAMPLE **dstlist, SAMPLE const **srclist, size_t srclen);
int res_push_interleaved(res_state *state, SAMPLE *dest, SAMPLE const *source, size_t srclen);
int resampler_push(resampler_state *state, SAMPLE **dstlist, SAMPLE const **srclist, size_t srclen);
int resampler_push_interleaved(resampler_state *state, SAMPLE *dest, SAMPLE const *source, size_t srclen);
/*
* Pushes srclen samples into the front end of the filter, and returns the
* number of resulting samples.
*
* res_push(): srclist and dstlist point to lists of pointers, each of which
* resampler_push(): srclist and dstlist point to lists of pointers, each of which
* indicates the beginning of a list of samples.
*
* res_push_interleaved(): source and dest point to the beginning of a list of
* resampler_push_interleaved(): source and dest point to the beginning of a list of
* interleaved samples.
*/
int res_drain(res_state *state, SAMPLE **dstlist);
int res_drain_interleaved(res_state *state, SAMPLE *dest);
int resampler_drain(resampler_state *state, SAMPLE **dstlist);
int resampler_drain_interleaved(resampler_state *state, SAMPLE *dest);
/*
* Recover the remaining elements by flushing the internal pool with 0 values,
* and storing the resulting samples.
*
* After either of these functions are called, *state should only re-used in a
* final call to res_clear().
* final call to resampler_clear().
*/
void res_clear(res_state *state);
void resampler_clear(resampler_state *state);
/*
* Free allocated buffers, etc.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment