Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
Icecast-IceS
Commits
592601bb
Commit
592601bb
authored
Mar 15, 2003
by
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
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/audio.c
View file @
592601bb
...
...
@@ -2,7 +2,7 @@
* stereo->mono downmixing
* resampling
*
* $Id: audio.c,v 1.
5
200
2
/0
8
/1
7
0
5:17:57 msmith
Exp $
* $Id: audio.c,v 1.
6
200
3
/0
3
/1
5
0
2: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
(
res
ampler
_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
);
res
ampler
_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
=
res
ampler
_push_check
(
&
s
->
resampler
,
buflen
);
if
(
s
->
buffill
<=
0
)
{
LOG_ERROR1
(
"Fatal reencoding error: res_push_check returned %d"
,
LOG_ERROR1
(
"Fatal reencoding error: res
ampler
_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
=
res
ampler
_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
=
res
ampler
_drain
(
&
s
->
resampler
,
s
->
buffers
);
if
(
ret
>
s
->
bufsize
)
{
LOG_ERROR0
(
"Fatal error in resampler: buffers too small"
);
...
...
src/audio.h
View file @
592601bb
...
...
@@ -2,7 +2,7 @@
* - stereo->mono downmixing
* - resampling
*
* $Id: audio.h,v 1.
2
200
2/08/03 14:41:10 msmith
Exp $
* $Id: audio.h,v 1.
3
200
3/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
;
res
ampler
_state
resampler
;
int
channels
;
float
**
buffers
;
...
...
src/resample.c
View file @
592601bb
...
...
@@ -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
res
ampler
_init
(
res
ampler
_state
*
state
,
int
channels
,
int
outfreq
,
int
infreq
,
res
ampler
_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
,
res
ampler
_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
(
res
ampler
_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
=
res
ampler
_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
res
ampler
_push_max_input
(
res
ampler
_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
res
ampler
_push_check
(
res
ampler
_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
res
ampler
_push
(
res
ampler
_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
res
ampler
_push_interleaved
(
res
ampler
_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
res
ampler
_drain
(
res
ampler
_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
res
ampler
_drain_interleaved
(
res
ampler
_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
res
ampler
_clear
(
res
ampler
_state
*
state
)
{
assert
(
state
);
assert
(
state
->
table
);
...
...
src/resample.h
View file @
592601bb
...
...
@@ -31,7 +31,7 @@ typedef struct
/* dynamic bits */
int
poolfill
;
int
offset
;
}
res_state
;
}
res
ampler
_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
;
}
res
ampler
_parameter
;
int
res_init
(
res_state
*
state
,
int
channels
,
int
outfreq
,
int
infreq
,
res_parameter
op1
,
...);
int
res
ampler
_init
(
res
ampler
_state
*
state
,
int
channels
,
int
outfreq
,
int
infreq
,
res
ampler
_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 res
ampler
_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
res
ampler
_push_max_input
(
res
ampler
_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
res
ampler
_push_check
(
res
ampler
_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 res
ampler
_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
res
ampler
_push
(
res
ampler
_state
*
state
,
SAMPLE
**
dstlist
,
SAMPLE
const
**
srclist
,
size_t
srclen
);
int
res
ampler
_push_interleaved
(
res
ampler
_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
* res
ampler
_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
* res
ampler
_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
res
ampler
_drain
(
res
ampler
_state
*
state
,
SAMPLE
**
dstlist
);
int
res
ampler
_drain_interleaved
(
res
ampler
_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 res
ampler
_clear().
*/
void
res_clear
(
res_state
*
state
);
void
res
ampler
_clear
(
res
ampler
_state
*
state
);
/*
* Free allocated buffers, etc.
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment