ref: 83a45b1ea7aad4eb145be84f734991a47e16bbc6
parent: 6a3d2b7f771c654f43f3d72327c1c37b0b974f7b
author: rrt <rrt>
date: Fri Nov 24 16:41:01 EST 2006
Move min and max macros into st.h
--- a/src/dcshift.c
+++ b/src/dcshift.c
@@ -111,10 +111,6 @@
return ST_SUCCESS;
}
-#ifndef MIN
-#define MIN(s1,s2) ((s1)<(s2)?(s1):(s2))
-#endif
-
/*
* Process data.
*/
@@ -128,7 +124,7 @@
register DCSHIFT_FLOAT sample;
register st_size_t len;
- len = MIN(*osamp, *isamp);
+ len = min(*osamp, *isamp);
/* report back dealt with amount. */
*isamp = len; *osamp = len;
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -25,10 +25,6 @@
#include <math.h>
#endif
-#ifndef MIN
-#define MIN(s1,s2) ((s1)<(s2)?(s1):(s2))
-#endif
-
#define INPUT_BUFFER_SIZE (ST_BUFSIZ)
/* Private data */
@@ -291,7 +287,7 @@
int chan;
do {
- donow=MIN(len,(p->Synth->pcm.length - p->cursamp)*ft->info.channels);
+ donow=min(len,(p->Synth->pcm.length - p->cursamp)*ft->info.channels);
i=0;
while(i<donow){
for(chan=0;chan<ft->info.channels;chan++){
--- a/src/pan.c
+++ b/src/pan.c
@@ -91,10 +91,6 @@
}
-#ifndef MIN
-#define MIN(s1,s2) ((s1)<(s2)?(s1):(s2))
-#endif
-
#define UNEXPECTED_CHANNELS \
st_fail("unexpected number of channels (in=%d, out=%d)", ich, och); \
return ST_EOF
@@ -119,7 +115,7 @@
ich = effp->ininfo.channels;
och = effp->outinfo.channels;
- len = MIN(*osamp/och,*isamp/ich);
+ len = min(*osamp/och,*isamp/ich);
/* report back how much is processed. */
*isamp = len*ich;
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -44,10 +44,6 @@
static st_effect_t st_pitch_effect;
-#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
-
/* float type for the computations.
should be common to all effects?
I use such trick in vol, pan, speed, pitch and stretch...
@@ -487,7 +483,7 @@
size = pitch->size;
/* size to process */
- len = MIN(*isamp, *osamp);
+ len = min(*isamp, *osamp);
iindex = 0;
oindex = 0;
@@ -501,7 +497,7 @@
{
if (pitch->state == pi_input)
{
- register int tocopy = MIN(pitch->size-pitch->index, len);
+ register int tocopy = min(pitch->size-pitch->index, len);
memcpy(pitch->buf+pitch->index, ibuf+iindex, tocopy*sizeof(st_sample_t));
@@ -522,7 +518,7 @@
if (pitch->state == pi_output)
{
- int toout = MIN(*osamp-oindex, pitch->step-pitch->iacc);
+ int toout = min(*osamp-oindex, pitch->step-pitch->iacc);
for (i=0; i<toout; i++)
{
--- a/src/rabbit.c
+++ b/src/rabbit.c
@@ -29,16 +29,6 @@
static st_effect_t st_rabbit_effect;
-#ifdef min
-#undef min
-#endif
-#define min(a, b) ((a) <= (b) ? (a) : (b))
-
-#ifdef max
-#undef max
-#endif
-#define max(a, b) ((a) >= (b) ? (a) : (b))
-
/* Private data for resampling */
typedef struct {
int converter_type; /* SRC converter type */
--- a/src/raw.c
+++ b/src/raw.c
@@ -34,10 +34,6 @@
#define MAXWSPEED 1
-#ifndef MIN
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#endif
-
/* Lookup table to reverse the bit order of a byte. ie MSB become LSB */
unsigned char cswap[256] = {
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0,
@@ -485,7 +481,7 @@
}
- len = MIN((st_size_t)nsamp,(ft->file.count-ft->file.pos)/ft->info.size);
+ len = min((st_size_t)nsamp,(ft->file.count-ft->file.pos)/ft->info.size);
if (len)
{
read_buf(buf + done, ft->file.buf + ft->file.pos, len, ft->swap);
@@ -517,7 +513,7 @@
ft->file.count += i;
}
- len = MIN((st_size_t)nsamp - done,(ft->file.count-ft->file.pos)/ft->info.size);
+ len = min((st_size_t)nsamp - done,(ft->file.count-ft->file.pos)/ft->info.size);
if (len)
{
read_buf(buf + done, ft->file.buf + ft->file.pos, len, ft->swap);
@@ -863,7 +859,7 @@
writeflush(ft);
}
- len = MIN(nsamp-done,(ft->file.size-ft->file.pos)/ft->info.size);
+ len = min(nsamp-done,(ft->file.size-ft->file.pos)/ft->info.size);
if (len)
{
write_buf(ft->file.buf + ft->file.pos, buf+done, len, ft->swap);
--- a/src/speed.c
+++ b/src/speed.c
@@ -156,10 +156,6 @@
return ST_SUCCESS;
}
-#ifndef MIN
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#endif
-
/* transfer input buffer to computation buffer.
*/
static void transfer(speed_t speed)
@@ -222,7 +218,7 @@
speed = (speed_t) effp->priv;
- len = MIN(*isamp, *osamp);
+ len = min(*isamp, *osamp);
iindex = 0;
oindex = 0;
--- a/src/st.h
+++ b/src/st.h
@@ -32,6 +32,16 @@
/* e.g. assert_static(sizeof(int) >= 4, int_type_too_small) */
#define assert_static(e,f) enum {assert_static__##f = 1/(e)}
+#ifdef min
+#undef min
+#endif
+#define min(a, b) ((a) <= (b) ? (a) : (b))
+
+#ifdef max
+#undef max
+#endif
+#define max(a, b) ((a) >= (b) ? (a) : (b))
+
/* Array-length operator */
#define array_length(a) (sizeof(a)/sizeof(a[0]))
--- a/src/stretch.c
+++ b/src/stretch.c
@@ -26,10 +26,6 @@
static st_effect_t st_stretch_effect;
-#ifndef MIN
-#define MIN(s1,s2) ((s1)<(s2)?(s1):(s2))
-#endif
-
#ifndef STRETCH_FLOAT
#define STRETCH_FLOAT float
#define STRETCH_FLOAT_SCAN "%f"
@@ -310,7 +306,7 @@
{
if (stretch->state == input_state)
{
- st_size_t tocopy = MIN(*isamp-iindex,
+ st_size_t tocopy = min(*isamp-iindex,
stretch->size-stretch->index);
memcpy(stretch->ibuf+stretch->index,
--- a/src/vol.c
+++ b/src/vol.c
@@ -128,10 +128,6 @@
return ST_SUCCESS;
}
-#ifndef MIN
-#define MIN(s1,s2) ((s1)<(s2)?(s1):(s2))
-#endif
-
/*
* Process data.
*/
@@ -144,7 +140,7 @@
register VOL_FLOAT sample;
register st_size_t len;
- len = MIN(*osamp, *isamp);
+ len = min(*osamp, *isamp);
/* report back dealt with amount. */
*isamp = len; *osamp = len;