5c9590
--- python/branches/py3k/Modules/audioop.c	2009/05/16 01:46:11	72674
5c9590
+++ python/branches/py3k/Modules/audioop.c	2010/05/09 15:52:27	81032
5c9590
@@ -53,13 +53,13 @@
5c9590
 static PyInt16
5c9590
 search(PyInt16 val, PyInt16 *table, int size)
5c9590
 {
5c9590
-        int i;
5c9590
+    int i;
5c9590
 
5c9590
-        for (i = 0; i < size; i++) {
5c9590
-                if (val <= *table++)
5c9590
-                        return (i);
5c9590
-        }
5c9590
-        return (size);
5c9590
+    for (i = 0; i < size; i++) {
5c9590
+        if (val <= *table++)
5c9590
+            return (i);
5c9590
+    }
5c9590
+    return (size);
5c9590
 }
5c9590
 #define st_ulaw2linear16(uc) (_st_ulaw2linear16[uc])
5c9590
 #define st_alaw2linear16(uc) (_st_alaw2linear16[uc])
5c9590
@@ -83,7 +83,7 @@
5c9590
       -228,    -212,    -196,    -180,    -164,    -148,    -132,
5c9590
       -120,    -112,    -104,     -96,     -88,     -80,     -72,
5c9590
        -64,     -56,     -48,     -40,     -32,     -24,     -16,
5c9590
-        -8,       0,   32124,   31100,   30076,   29052,   28028,
5c9590
+    -8,       0,   32124,   31100,   30076,   29052,   28028,
5c9590
      27004,   25980,   24956,   23932,   22908,   21884,   20860,
5c9590
      19836,   18812,   17788,   16764,   15996,   15484,   14972,
5c9590
      14460,   13948,   13436,   12924,   12412,   11900,   11388,
5c9590
@@ -100,8 +100,8 @@
5c9590
        372,     356,     340,     324,     308,     292,     276,
5c9590
        260,     244,     228,     212,     196,     180,     164,
5c9590
        148,     132,     120,     112,     104,      96,      88,
5c9590
-        80,      72,      64,      56,      48,      40,      32,
5c9590
-        24,      16,       8,       0
5c9590
+    80,      72,      64,      56,      48,      40,      32,
5c9590
+    24,      16,       8,       0
5c9590
 };
5c9590
 
5c9590
 /*
5c9590
@@ -137,39 +137,39 @@
5c9590
  * John Wiley & Sons, pps 98-111 and 472-476.
5c9590
  */
5c9590
 static unsigned char
5c9590
-st_14linear2ulaw(PyInt16 pcm_val)	/* 2's complement (14-bit range) */
5c9590
+st_14linear2ulaw(PyInt16 pcm_val)       /* 2's complement (14-bit range) */
5c9590
 {
5c9590
-        PyInt16         mask;
5c9590
-        PyInt16         seg;
5c9590
-        unsigned char   uval;
5c9590
-
5c9590
-        /* The original sox code does this in the calling function, not here */
5c9590
-        pcm_val = pcm_val >> 2;
5c9590
-
5c9590
-        /* u-law inverts all bits */
5c9590
-        /* Get the sign and the magnitude of the value. */
5c9590
-        if (pcm_val < 0) {
5c9590
-                pcm_val = -pcm_val;
5c9590
-                mask = 0x7F;
5c9590
-        } else {
5c9590
-                mask = 0xFF;
5c9590
-        }
5c9590
-        if ( pcm_val > CLIP ) pcm_val = CLIP;           /* clip the magnitude */
5c9590
-        pcm_val += (BIAS >> 2);
5c9590
-
5c9590
-        /* Convert the scaled magnitude to segment number. */
5c9590
-        seg = search(pcm_val, seg_uend, 8);
5c9590
-
5c9590
-        /*
5c9590
-         * Combine the sign, segment, quantization bits;
5c9590
-         * and complement the code word.
5c9590
-         */
5c9590
-        if (seg >= 8)           /* out of range, return maximum value. */
5c9590
-                return (unsigned char) (0x7F ^ mask);
5c9590
-        else {
5c9590
-                uval = (unsigned char) (seg << 4) | ((pcm_val >> (seg + 1)) & 0xF);
5c9590
-                return (uval ^ mask);
5c9590
-        }
5c9590
+    PyInt16         mask;
5c9590
+    PyInt16         seg;
5c9590
+    unsigned char   uval;
5c9590
+
5c9590
+    /* The original sox code does this in the calling function, not here */
5c9590
+    pcm_val = pcm_val >> 2;
5c9590
+
5c9590
+    /* u-law inverts all bits */
5c9590
+    /* Get the sign and the magnitude of the value. */
5c9590
+    if (pcm_val < 0) {
5c9590
+        pcm_val = -pcm_val;
5c9590
+        mask = 0x7F;
5c9590
+    } else {
5c9590
+        mask = 0xFF;
5c9590
+    }
5c9590
+    if ( pcm_val > CLIP ) pcm_val = CLIP;           /* clip the magnitude */
5c9590
+    pcm_val += (BIAS >> 2);
5c9590
+
5c9590
+    /* Convert the scaled magnitude to segment number. */
5c9590
+    seg = search(pcm_val, seg_uend, 8);
5c9590
+
5c9590
+    /*
5c9590
+     * Combine the sign, segment, quantization bits;
5c9590
+     * and complement the code word.
5c9590
+     */
5c9590
+    if (seg >= 8)           /* out of range, return maximum value. */
5c9590
+        return (unsigned char) (0x7F ^ mask);
5c9590
+    else {
5c9590
+        uval = (unsigned char) (seg << 4) | ((pcm_val >> (seg + 1)) & 0xF);
5c9590
+        return (uval ^ mask);
5c9590
+    }
5c9590
 
5c9590
 }
5c9590
 
5c9590
@@ -234,59 +234,59 @@
5c9590
  * John Wiley & Sons, pps 98-111 and 472-476.
5c9590
  */
5c9590
 static unsigned char
5c9590
-st_linear2alaw(PyInt16 pcm_val)	/* 2's complement (13-bit range) */
5c9590
+st_linear2alaw(PyInt16 pcm_val) /* 2's complement (13-bit range) */
5c9590
 {
5c9590
-        PyInt16         mask;
5c9590
-        short           seg;
5c9590
-        unsigned char   aval;
5c9590
-
5c9590
-        /* The original sox code does this in the calling function, not here */
5c9590
-        pcm_val = pcm_val >> 3;
5c9590
-
5c9590
-        /* A-law using even bit inversion */
5c9590
-        if (pcm_val >= 0) {
5c9590
-                mask = 0xD5;            /* sign (7th) bit = 1 */
5c9590
-        } else {
5c9590
-                mask = 0x55;            /* sign bit = 0 */
5c9590
-                pcm_val = -pcm_val - 1;
5c9590
-        }
5c9590
-
5c9590
-        /* Convert the scaled magnitude to segment number. */
5c9590
-        seg = search(pcm_val, seg_aend, 8);
5c9590
-
5c9590
-        /* Combine the sign, segment, and quantization bits. */
5c9590
-
5c9590
-        if (seg >= 8)           /* out of range, return maximum value. */
5c9590
-                return (unsigned char) (0x7F ^ mask);
5c9590
-        else {
5c9590
-                aval = (unsigned char) seg << SEG_SHIFT;
5c9590
-                if (seg < 2)
5c9590
-                        aval |= (pcm_val >> 1) & QUANT_MASK;
5c9590
-                else
5c9590
-                        aval |= (pcm_val >> seg) & QUANT_MASK;
5c9590
-                return (aval ^ mask);
5c9590
-        }
5c9590
+    PyInt16         mask;
5c9590
+    short           seg;
5c9590
+    unsigned char   aval;
5c9590
+
5c9590
+    /* The original sox code does this in the calling function, not here */
5c9590
+    pcm_val = pcm_val >> 3;
5c9590
+
5c9590
+    /* A-law using even bit inversion */
5c9590
+    if (pcm_val >= 0) {
5c9590
+        mask = 0xD5;            /* sign (7th) bit = 1 */
5c9590
+    } else {
5c9590
+        mask = 0x55;            /* sign bit = 0 */
5c9590
+        pcm_val = -pcm_val - 1;
5c9590
+    }
5c9590
+
5c9590
+    /* Convert the scaled magnitude to segment number. */
5c9590
+    seg = search(pcm_val, seg_aend, 8);
5c9590
+
5c9590
+    /* Combine the sign, segment, and quantization bits. */
5c9590
+
5c9590
+    if (seg >= 8)           /* out of range, return maximum value. */
5c9590
+        return (unsigned char) (0x7F ^ mask);
5c9590
+    else {
5c9590
+        aval = (unsigned char) seg << SEG_SHIFT;
5c9590
+        if (seg < 2)
5c9590
+            aval |= (pcm_val >> 1) & QUANT_MASK;
5c9590
+        else
5c9590
+            aval |= (pcm_val >> seg) & QUANT_MASK;
5c9590
+        return (aval ^ mask);
5c9590
+    }
5c9590
 }
5c9590
 /* End of code taken from sox */
5c9590
 
5c9590
 /* Intel ADPCM step variation table */
5c9590
 static int indexTable[16] = {
5c9590
-        -1, -1, -1, -1, 2, 4, 6, 8,
5c9590
-        -1, -1, -1, -1, 2, 4, 6, 8,
5c9590
+    -1, -1, -1, -1, 2, 4, 6, 8,
5c9590
+    -1, -1, -1, -1, 2, 4, 6, 8,
5c9590
 };
5c9590
 
5c9590
 static int stepsizeTable[89] = {
5c9590
-        7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
5c9590
-        19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
5c9590
-        50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
5c9590
-        130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
5c9590
-        337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
5c9590
-        876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
5c9590
-        2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
5c9590
-        5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
5c9590
-        15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
5c9590
+    7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
5c9590
+    19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
5c9590
+    50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
5c9590
+    130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
5c9590
+    337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
5c9590
+    876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
5c9590
+    2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
5c9590
+    5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
5c9590
+    15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
5c9590
 };
5c9590
-    
5c9590
+
5c9590
 #define CHARP(cp, i) ((signed char *)(cp+i))
5c9590
 #define SHORTP(cp, i) ((short *)(cp+i))
5c9590
 #define LONGP(cp, i) ((Py_Int32 *)(cp+i))
5c9590
@@ -298,137 +298,137 @@
5c9590
 static PyObject *
5c9590
 audioop_getsample(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp;
5c9590
-        int len, size, val = 0;
5c9590
-        int i;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#ii:getsample", &cp, &len, &size, &i) )
5c9590
-                return 0;
5c9590
-        if ( size != 1 && size != 2 && size != 4 ) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        if ( i < 0 || i >= len/size ) {
5c9590
-                PyErr_SetString(AudioopError, "Index out of range");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
-        else if ( size == 2 ) val = (int)*SHORTP(cp, i*2);
5c9590
-        else if ( size == 4 ) val = (int)*LONGP(cp, i*4);
5c9590
-        return PyLong_FromLong(val);
5c9590
+    signed char *cp;
5c9590
+    int len, size, val = 0;
5c9590
+    int i;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#ii:getsample", &cp, &len, &size, &i) )
5c9590
+        return 0;
5c9590
+    if ( size != 1 && size != 2 && size != 4 ) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    if ( i < 0 || i >= len/size ) {
5c9590
+        PyErr_SetString(AudioopError, "Index out of range");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
+    else if ( size == 2 ) val = (int)*SHORTP(cp, i*2);
5c9590
+    else if ( size == 4 ) val = (int)*LONGP(cp, i*4);
5c9590
+    return PyLong_FromLong(val);
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_max(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp;
5c9590
-        int len, size, val = 0;
5c9590
-        int i;
5c9590
-        int max = 0;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#i:max", &cp, &len, &size) )
5c9590
-                return 0;
5c9590
-        if ( size != 1 && size != 2 && size != 4 ) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        for ( i=0; i
5c9590
-                if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
-                else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
-                else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
-                if ( val < 0 ) val = (-val);
5c9590
-                if ( val > max ) max = val;
5c9590
-        }
5c9590
-        return PyLong_FromLong(max);
5c9590
+    signed char *cp;
5c9590
+    int len, size, val = 0;
5c9590
+    int i;
5c9590
+    int max = 0;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#i:max", &cp, &len, &size) )
5c9590
+        return 0;
5c9590
+    if ( size != 1 && size != 2 && size != 4 ) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    for ( i=0; i
5c9590
+        if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
+        else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
+        else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
+        if ( val < 0 ) val = (-val);
5c9590
+        if ( val > max ) max = val;
5c9590
+    }
5c9590
+    return PyLong_FromLong(max);
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_minmax(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp;
5c9590
-        int len, size, val = 0;
5c9590
-        int i;
5c9590
-        int min = 0x7fffffff, max = -0x7fffffff;
5c9590
-
5c9590
-        if (!PyArg_ParseTuple(args, "s#i:minmax", &cp, &len, &size))
5c9590
-                return NULL;
5c9590
-        if (size != 1 && size != 2 && size != 4) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return NULL;
5c9590
-        }
5c9590
-        for (i = 0; i < len; i += size) {
5c9590
-                if (size == 1) val = (int) *CHARP(cp, i);
5c9590
-                else if (size == 2) val = (int) *SHORTP(cp, i);
5c9590
-                else if (size == 4) val = (int) *LONGP(cp, i);
5c9590
-                if (val > max) max = val;
5c9590
-                if (val < min) min = val;
5c9590
-        }
5c9590
-        return Py_BuildValue("(ii)", min, max);
5c9590
+    signed char *cp;
5c9590
+    int len, size, val = 0;
5c9590
+    int i;
5c9590
+    int min = 0x7fffffff, max = -0x7fffffff;
5c9590
+
5c9590
+    if (!PyArg_ParseTuple(args, "s#i:minmax", &cp, &len, &size))
5c9590
+        return NULL;
5c9590
+    if (size != 1 && size != 2 && size != 4) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return NULL;
5c9590
+    }
5c9590
+    for (i = 0; i < len; i += size) {
5c9590
+        if (size == 1) val = (int) *CHARP(cp, i);
5c9590
+        else if (size == 2) val = (int) *SHORTP(cp, i);
5c9590
+        else if (size == 4) val = (int) *LONGP(cp, i);
5c9590
+        if (val > max) max = val;
5c9590
+        if (val < min) min = val;
5c9590
+    }
5c9590
+    return Py_BuildValue("(ii)", min, max);
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_avg(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp;
5c9590
-        int len, size, val = 0;
5c9590
-        int i;
5c9590
-        double avg = 0.0;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#i:avg", &cp, &len, &size) )
5c9590
-                return 0;
5c9590
-        if ( size != 1 && size != 2 && size != 4 ) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        for ( i=0; i
5c9590
-                if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
-                else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
-                else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
-                avg += val;
5c9590
-        }
5c9590
-        if ( len == 0 )
5c9590
-                val = 0;
5c9590
-        else
5c9590
-                val = (int)(avg / (double)(len/size));
5c9590
-        return PyLong_FromLong(val);
5c9590
+    signed char *cp;
5c9590
+    int len, size, val = 0;
5c9590
+    int i;
5c9590
+    double avg = 0.0;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#i:avg", &cp, &len, &size) )
5c9590
+        return 0;
5c9590
+    if ( size != 1 && size != 2 && size != 4 ) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    for ( i=0; i
5c9590
+        if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
+        else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
+        else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
+        avg += val;
5c9590
+    }
5c9590
+    if ( len == 0 )
5c9590
+        val = 0;
5c9590
+    else
5c9590
+        val = (int)(avg / (double)(len/size));
5c9590
+    return PyLong_FromLong(val);
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_rms(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp;
5c9590
-        int len, size, val = 0;
5c9590
-        int i;
5c9590
-        double sum_squares = 0.0;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#i:rms", &cp, &len, &size) )
5c9590
-                return 0;
5c9590
-        if ( size != 1 && size != 2 && size != 4 ) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        for ( i=0; i
5c9590
-                if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
-                else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
-                else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
-                sum_squares += (double)val*(double)val;
5c9590
-        }
5c9590
-        if ( len == 0 )
5c9590
-                val = 0;
5c9590
-        else
5c9590
-                val = (int)sqrt(sum_squares / (double)(len/size));
5c9590
-        return PyLong_FromLong(val);
5c9590
+    signed char *cp;
5c9590
+    int len, size, val = 0;
5c9590
+    int i;
5c9590
+    double sum_squares = 0.0;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#i:rms", &cp, &len, &size) )
5c9590
+        return 0;
5c9590
+    if ( size != 1 && size != 2 && size != 4 ) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    for ( i=0; i
5c9590
+        if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
+        else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
+        else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
+        sum_squares += (double)val*(double)val;
5c9590
+    }
5c9590
+    if ( len == 0 )
5c9590
+        val = 0;
5c9590
+    else
5c9590
+        val = (int)sqrt(sum_squares / (double)(len/size));
5c9590
+    return PyLong_FromLong(val);
5c9590
 }
5c9590
 
5c9590
 static double _sum2(short *a, short *b, int len)
5c9590
 {
5c9590
-        int i;
5c9590
-        double sum = 0.0;
5c9590
+    int i;
5c9590
+    double sum = 0.0;
5c9590
 
5c9590
-        for( i=0; i
5c9590
-                sum = sum + (double)a[i]*(double)b[i];
5c9590
-        }
5c9590
-        return sum;
5c9590
+    for( i=0; i
5c9590
+        sum = sum + (double)a[i]*(double)b[i];
5c9590
+    }
5c9590
+    return sum;
5c9590
 }
5c9590
 
5c9590
 /*
5c9590
@@ -466,60 +466,60 @@
5c9590
 static PyObject *
5c9590
 audioop_findfit(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        short *cp1, *cp2;
5c9590
-        int len1, len2;
5c9590
-        int j, best_j;
5c9590
-        double aj_m1, aj_lm1;
5c9590
-        double sum_ri_2, sum_aij_2, sum_aij_ri, result, best_result, factor;
5c9590
-
5c9590
-	/* Passing a short** for an 's' argument is correct only
5c9590
-	   if the string contents is aligned for interpretation
5c9590
-	   as short[]. Due to the definition of PyBytesObject,
5c9590
-	   this is currently (Python 2.6) the case. */
5c9590
-        if ( !PyArg_ParseTuple(args, "s#s#:findfit",
5c9590
-	                       (char**)&cp1, &len1, (char**)&cp2, &len2) )
5c9590
-                return 0;
5c9590
-        if ( len1 & 1 || len2 & 1 ) {
5c9590
-                PyErr_SetString(AudioopError, "Strings should be even-sized");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        len1 >>= 1;
5c9590
-        len2 >>= 1;
5c9590
-    
5c9590
-        if ( len1 < len2 ) {
5c9590
-                PyErr_SetString(AudioopError, "First sample should be longer");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        sum_ri_2 = _sum2(cp2, cp2, len2);
5c9590
-        sum_aij_2 = _sum2(cp1, cp1, len2);
5c9590
-        sum_aij_ri = _sum2(cp1, cp2, len2);
5c9590
-
5c9590
-        result = (sum_ri_2*sum_aij_2 - sum_aij_ri*sum_aij_ri) / sum_aij_2;
5c9590
-
5c9590
-        best_result = result;
5c9590
-        best_j = 0;
5c9590
-        j = 0;
5c9590
-
5c9590
-        for ( j=1; j<=len1-len2; j++) {
5c9590
-                aj_m1 = (double)cp1[j-1];
5c9590
-                aj_lm1 = (double)cp1[j+len2-1];
5c9590
-
5c9590
-                sum_aij_2 = sum_aij_2 + aj_lm1*aj_lm1 - aj_m1*aj_m1;
5c9590
-                sum_aij_ri = _sum2(cp1+j, cp2, len2);
5c9590
-
5c9590
-                result = (sum_ri_2*sum_aij_2 - sum_aij_ri*sum_aij_ri)
5c9590
-                        / sum_aij_2;
5c9590
-
5c9590
-                if ( result < best_result ) {
5c9590
-                        best_result = result;
5c9590
-                        best_j = j;
5c9590
-                }
5c9590
-        
5c9590
+    short *cp1, *cp2;
5c9590
+    int len1, len2;
5c9590
+    int j, best_j;
5c9590
+    double aj_m1, aj_lm1;
5c9590
+    double sum_ri_2, sum_aij_2, sum_aij_ri, result, best_result, factor;
5c9590
+
5c9590
+    /* Passing a short** for an 's' argument is correct only
5c9590
+       if the string contents is aligned for interpretation
5c9590
+       as short[]. Due to the definition of PyBytesObject,
5c9590
+       this is currently (Python 2.6) the case. */
5c9590
+    if ( !PyArg_ParseTuple(args, "s#s#:findfit",
5c9590
+                           (char**)&cp1, &len1, (char**)&cp2, &len2) )
5c9590
+        return 0;
5c9590
+    if ( len1 & 1 || len2 & 1 ) {
5c9590
+        PyErr_SetString(AudioopError, "Strings should be even-sized");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    len1 >>= 1;
5c9590
+    len2 >>= 1;
5c9590
+
5c9590
+    if ( len1 < len2 ) {
5c9590
+        PyErr_SetString(AudioopError, "First sample should be longer");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    sum_ri_2 = _sum2(cp2, cp2, len2);
5c9590
+    sum_aij_2 = _sum2(cp1, cp1, len2);
5c9590
+    sum_aij_ri = _sum2(cp1, cp2, len2);
5c9590
+
5c9590
+    result = (sum_ri_2*sum_aij_2 - sum_aij_ri*sum_aij_ri) / sum_aij_2;
5c9590
+
5c9590
+    best_result = result;
5c9590
+    best_j = 0;
5c9590
+    j = 0;
5c9590
+
5c9590
+    for ( j=1; j<=len1-len2; j++) {
5c9590
+        aj_m1 = (double)cp1[j-1];
5c9590
+        aj_lm1 = (double)cp1[j+len2-1];
5c9590
+
5c9590
+        sum_aij_2 = sum_aij_2 + aj_lm1*aj_lm1 - aj_m1*aj_m1;
5c9590
+        sum_aij_ri = _sum2(cp1+j, cp2, len2);
5c9590
+
5c9590
+        result = (sum_ri_2*sum_aij_2 - sum_aij_ri*sum_aij_ri)
5c9590
+            / sum_aij_2;
5c9590
+
5c9590
+        if ( result < best_result ) {
5c9590
+            best_result = result;
5c9590
+            best_j = j;
5c9590
         }
5c9590
 
5c9590
-        factor = _sum2(cp1+best_j, cp2, len2) / sum_ri_2;
5c9590
-    
5c9590
-        return Py_BuildValue("(if)", best_j, factor);
5c9590
+    }
5c9590
+
5c9590
+    factor = _sum2(cp1+best_j, cp2, len2) / sum_ri_2;
5c9590
+
5c9590
+    return Py_BuildValue("(if)", best_j, factor);
5c9590
 }
5c9590
 
5c9590
 /*
5c9590
@@ -529,28 +529,28 @@
5c9590
 static PyObject *
5c9590
 audioop_findfactor(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        short *cp1, *cp2;
5c9590
-        int len1, len2;
5c9590
-        double sum_ri_2, sum_aij_ri, result;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#s#:findfactor",
5c9590
-	                       (char**)&cp1, &len1, (char**)&cp2, &len2) )
5c9590
-                return 0;
5c9590
-        if ( len1 & 1 || len2 & 1 ) {
5c9590
-                PyErr_SetString(AudioopError, "Strings should be even-sized");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        if ( len1 != len2 ) {
5c9590
-                PyErr_SetString(AudioopError, "Samples should be same size");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        len2 >>= 1;
5c9590
-        sum_ri_2 = _sum2(cp2, cp2, len2);
5c9590
-        sum_aij_ri = _sum2(cp1, cp2, len2);
5c9590
+    short *cp1, *cp2;
5c9590
+    int len1, len2;
5c9590
+    double sum_ri_2, sum_aij_ri, result;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#s#:findfactor",
5c9590
+                           (char**)&cp1, &len1, (char**)&cp2, &len2) )
5c9590
+        return 0;
5c9590
+    if ( len1 & 1 || len2 & 1 ) {
5c9590
+        PyErr_SetString(AudioopError, "Strings should be even-sized");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    if ( len1 != len2 ) {
5c9590
+        PyErr_SetString(AudioopError, "Samples should be same size");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    len2 >>= 1;
5c9590
+    sum_ri_2 = _sum2(cp2, cp2, len2);
5c9590
+    sum_aij_ri = _sum2(cp1, cp2, len2);
5c9590
 
5c9590
-        result = sum_aij_ri / sum_ri_2;
5c9590
+    result = sum_aij_ri / sum_ri_2;
5c9590
 
5c9590
-        return PyFloat_FromDouble(result);
5c9590
+    return PyFloat_FromDouble(result);
5c9590
 }
5c9590
 
5c9590
 /*
5c9590
@@ -560,1114 +560,1114 @@
5c9590
 static PyObject *
5c9590
 audioop_findmax(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        short *cp1;
5c9590
-        int len1, len2;
5c9590
-        int j, best_j;
5c9590
-        double aj_m1, aj_lm1;
5c9590
-        double result, best_result;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#i:findmax", 
5c9590
-			       (char**)&cp1, &len1, &len2) )
5c9590
-                return 0;
5c9590
-        if ( len1 & 1 ) {
5c9590
-                PyErr_SetString(AudioopError, "Strings should be even-sized");
5c9590
-                return 0;
5c9590
+    short *cp1;
5c9590
+    int len1, len2;
5c9590
+    int j, best_j;
5c9590
+    double aj_m1, aj_lm1;
5c9590
+    double result, best_result;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#i:findmax",
5c9590
+                           (char**)&cp1, &len1, &len2) )
5c9590
+        return 0;
5c9590
+    if ( len1 & 1 ) {
5c9590
+        PyErr_SetString(AudioopError, "Strings should be even-sized");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    len1 >>= 1;
5c9590
+
5c9590
+    if ( len2 < 0 || len1 < len2 ) {
5c9590
+        PyErr_SetString(AudioopError, "Input sample should be longer");
5c9590
+        return 0;
5c9590
+    }
5c9590
+
5c9590
+    result = _sum2(cp1, cp1, len2);
5c9590
+
5c9590
+    best_result = result;
5c9590
+    best_j = 0;
5c9590
+    j = 0;
5c9590
+
5c9590
+    for ( j=1; j<=len1-len2; j++) {
5c9590
+        aj_m1 = (double)cp1[j-1];
5c9590
+        aj_lm1 = (double)cp1[j+len2-1];
5c9590
+
5c9590
+        result = result + aj_lm1*aj_lm1 - aj_m1*aj_m1;
5c9590
+
5c9590
+        if ( result > best_result ) {
5c9590
+            best_result = result;
5c9590
+            best_j = j;
5c9590
         }
5c9590
-        len1 >>= 1;
5c9590
-    
5c9590
-        if ( len2 < 0 || len1 < len2 ) {
5c9590
-                PyErr_SetString(AudioopError, "Input sample should be longer");
5c9590
-                return 0;
5c9590
-        }
5c9590
-
5c9590
-        result = _sum2(cp1, cp1, len2);
5c9590
 
5c9590
-        best_result = result;
5c9590
-        best_j = 0;
5c9590
-        j = 0;
5c9590
-
5c9590
-        for ( j=1; j<=len1-len2; j++) {
5c9590
-                aj_m1 = (double)cp1[j-1];
5c9590
-                aj_lm1 = (double)cp1[j+len2-1];
5c9590
-
5c9590
-                result = result + aj_lm1*aj_lm1 - aj_m1*aj_m1;
5c9590
-
5c9590
-                if ( result > best_result ) {
5c9590
-                        best_result = result;
5c9590
-                        best_j = j;
5c9590
-                }
5c9590
-        
5c9590
-        }
5c9590
+    }
5c9590
 
5c9590
-        return PyLong_FromLong(best_j);
5c9590
+    return PyLong_FromLong(best_j);
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_avgpp(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp;
5c9590
-        int len, size, val = 0, prevval = 0, prevextremevalid = 0,
5c9590
-                prevextreme = 0;
5c9590
-        int i;
5c9590
-        double avg = 0.0;
5c9590
-        int diff, prevdiff, extremediff, nextreme = 0;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#i:avgpp", &cp, &len, &size) )
5c9590
-                return 0;
5c9590
-        if ( size != 1 && size != 2 && size != 4 ) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        /* Compute first delta value ahead. Also automatically makes us
5c9590
-        ** skip the first extreme value
5c9590
-        */
5c9590
-        if ( size == 1 )      prevval = (int)*CHARP(cp, 0);
5c9590
-        else if ( size == 2 ) prevval = (int)*SHORTP(cp, 0);
5c9590
-        else if ( size == 4 ) prevval = (int)*LONGP(cp, 0);
5c9590
-        if ( size == 1 )      val = (int)*CHARP(cp, size);
5c9590
-        else if ( size == 2 ) val = (int)*SHORTP(cp, size);
5c9590
-        else if ( size == 4 ) val = (int)*LONGP(cp, size);
5c9590
-        prevdiff = val - prevval;
5c9590
-    
5c9590
-        for ( i=size; i
5c9590
-                if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
-                else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
-                else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
-                diff = val - prevval;
5c9590
-                if ( diff*prevdiff < 0 ) {
5c9590
-                        /* Derivative changed sign. Compute difference to last
5c9590
-                        ** extreme value and remember.
5c9590
-                        */
5c9590
-                        if ( prevextremevalid ) {
5c9590
-                                extremediff = prevval - prevextreme;
5c9590
-                                if ( extremediff < 0 )
5c9590
-                                        extremediff = -extremediff;
5c9590
-                                avg += extremediff;
5c9590
-                                nextreme++;
5c9590
-                        }
5c9590
-                        prevextremevalid = 1;
5c9590
-                        prevextreme = prevval;
5c9590
-                }
5c9590
-                prevval = val;
5c9590
-                if ( diff != 0 )
5c9590
-                        prevdiff = diff;        
5c9590
-        }
5c9590
-        if ( nextreme == 0 )
5c9590
-                val = 0;
5c9590
-        else
5c9590
-                val = (int)(avg / (double)nextreme);
5c9590
-        return PyLong_FromLong(val);
5c9590
+    signed char *cp;
5c9590
+    int len, size, val = 0, prevval = 0, prevextremevalid = 0,
5c9590
+        prevextreme = 0;
5c9590
+    int i;
5c9590
+    double avg = 0.0;
5c9590
+    int diff, prevdiff, extremediff, nextreme = 0;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#i:avgpp", &cp, &len, &size) )
5c9590
+        return 0;
5c9590
+    if ( size != 1 && size != 2 && size != 4 ) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    /* Compute first delta value ahead. Also automatically makes us
5c9590
+    ** skip the first extreme value
5c9590
+    */
5c9590
+    if ( size == 1 )      prevval = (int)*CHARP(cp, 0);
5c9590
+    else if ( size == 2 ) prevval = (int)*SHORTP(cp, 0);
5c9590
+    else if ( size == 4 ) prevval = (int)*LONGP(cp, 0);
5c9590
+    if ( size == 1 )      val = (int)*CHARP(cp, size);
5c9590
+    else if ( size == 2 ) val = (int)*SHORTP(cp, size);
5c9590
+    else if ( size == 4 ) val = (int)*LONGP(cp, size);
5c9590
+    prevdiff = val - prevval;
5c9590
+
5c9590
+    for ( i=size; i
5c9590
+        if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
+        else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
+        else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
+        diff = val - prevval;
5c9590
+        if ( diff*prevdiff < 0 ) {
5c9590
+            /* Derivative changed sign. Compute difference to last
5c9590
+            ** extreme value and remember.
5c9590
+            */
5c9590
+            if ( prevextremevalid ) {
5c9590
+                extremediff = prevval - prevextreme;
5c9590
+                if ( extremediff < 0 )
5c9590
+                    extremediff = -extremediff;
5c9590
+                avg += extremediff;
5c9590
+                nextreme++;
5c9590
+            }
5c9590
+            prevextremevalid = 1;
5c9590
+            prevextreme = prevval;
5c9590
+        }
5c9590
+        prevval = val;
5c9590
+        if ( diff != 0 )
5c9590
+            prevdiff = diff;
5c9590
+    }
5c9590
+    if ( nextreme == 0 )
5c9590
+        val = 0;
5c9590
+    else
5c9590
+        val = (int)(avg / (double)nextreme);
5c9590
+    return PyLong_FromLong(val);
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_maxpp(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp;
5c9590
-        int len, size, val = 0, prevval = 0, prevextremevalid = 0,
5c9590
-                prevextreme = 0;
5c9590
-        int i;
5c9590
-        int max = 0;
5c9590
-        int diff, prevdiff, extremediff;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#i:maxpp", &cp, &len, &size) )
5c9590
-                return 0;
5c9590
-        if ( size != 1 && size != 2 && size != 4 ) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        /* Compute first delta value ahead. Also automatically makes us
5c9590
-        ** skip the first extreme value
5c9590
-        */
5c9590
-        if ( size == 1 )      prevval = (int)*CHARP(cp, 0);
5c9590
-        else if ( size == 2 ) prevval = (int)*SHORTP(cp, 0);
5c9590
-        else if ( size == 4 ) prevval = (int)*LONGP(cp, 0);
5c9590
-        if ( size == 1 )      val = (int)*CHARP(cp, size);
5c9590
-        else if ( size == 2 ) val = (int)*SHORTP(cp, size);
5c9590
-        else if ( size == 4 ) val = (int)*LONGP(cp, size);
5c9590
-        prevdiff = val - prevval;
5c9590
-
5c9590
-        for ( i=size; i
5c9590
-                if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
-                else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
-                else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
-                diff = val - prevval;
5c9590
-                if ( diff*prevdiff < 0 ) {
5c9590
-                        /* Derivative changed sign. Compute difference to
5c9590
-                        ** last extreme value and remember.
5c9590
-                        */
5c9590
-                        if ( prevextremevalid ) {
5c9590
-                                extremediff = prevval - prevextreme;
5c9590
-                                if ( extremediff < 0 )
5c9590
-                                        extremediff = -extremediff;
5c9590
-                                if ( extremediff > max )
5c9590
-                                        max = extremediff;
5c9590
-                        }
5c9590
-                        prevextremevalid = 1;
5c9590
-                        prevextreme = prevval;
5c9590
-                }
5c9590
-                prevval = val;
5c9590
-                if ( diff != 0 )
5c9590
-                        prevdiff = diff;
5c9590
-        }
5c9590
-        return PyLong_FromLong(max);
5c9590
+    signed char *cp;
5c9590
+    int len, size, val = 0, prevval = 0, prevextremevalid = 0,
5c9590
+        prevextreme = 0;
5c9590
+    int i;
5c9590
+    int max = 0;
5c9590
+    int diff, prevdiff, extremediff;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#i:maxpp", &cp, &len, &size) )
5c9590
+        return 0;
5c9590
+    if ( size != 1 && size != 2 && size != 4 ) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    /* Compute first delta value ahead. Also automatically makes us
5c9590
+    ** skip the first extreme value
5c9590
+    */
5c9590
+    if ( size == 1 )      prevval = (int)*CHARP(cp, 0);
5c9590
+    else if ( size == 2 ) prevval = (int)*SHORTP(cp, 0);
5c9590
+    else if ( size == 4 ) prevval = (int)*LONGP(cp, 0);
5c9590
+    if ( size == 1 )      val = (int)*CHARP(cp, size);
5c9590
+    else if ( size == 2 ) val = (int)*SHORTP(cp, size);
5c9590
+    else if ( size == 4 ) val = (int)*LONGP(cp, size);
5c9590
+    prevdiff = val - prevval;
5c9590
+
5c9590
+    for ( i=size; i
5c9590
+        if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
+        else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
+        else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
+        diff = val - prevval;
5c9590
+        if ( diff*prevdiff < 0 ) {
5c9590
+            /* Derivative changed sign. Compute difference to
5c9590
+            ** last extreme value and remember.
5c9590
+            */
5c9590
+            if ( prevextremevalid ) {
5c9590
+                extremediff = prevval - prevextreme;
5c9590
+                if ( extremediff < 0 )
5c9590
+                    extremediff = -extremediff;
5c9590
+                if ( extremediff > max )
5c9590
+                    max = extremediff;
5c9590
+            }
5c9590
+            prevextremevalid = 1;
5c9590
+            prevextreme = prevval;
5c9590
+        }
5c9590
+        prevval = val;
5c9590
+        if ( diff != 0 )
5c9590
+            prevdiff = diff;
5c9590
+    }
5c9590
+    return PyLong_FromLong(max);
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_cross(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp;
5c9590
-        int len, size, val = 0;
5c9590
-        int i;
5c9590
-        int prevval, ncross;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#i:cross", &cp, &len, &size) )
5c9590
-                return 0;
5c9590
-        if ( size != 1 && size != 2 && size != 4 ) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        ncross = -1;
5c9590
-        prevval = 17; /* Anything <> 0,1 */
5c9590
-        for ( i=0; i
5c9590
-                if ( size == 1 )      val = ((int)*CHARP(cp, i)) >> 7;
5c9590
-                else if ( size == 2 ) val = ((int)*SHORTP(cp, i)) >> 15;
5c9590
-                else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 31;
5c9590
-                val = val & 1;
5c9590
-                if ( val != prevval ) ncross++;
5c9590
-                prevval = val;
5c9590
-        }
5c9590
-        return PyLong_FromLong(ncross);
5c9590
+    signed char *cp;
5c9590
+    int len, size, val = 0;
5c9590
+    int i;
5c9590
+    int prevval, ncross;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#i:cross", &cp, &len, &size) )
5c9590
+        return 0;
5c9590
+    if ( size != 1 && size != 2 && size != 4 ) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    ncross = -1;
5c9590
+    prevval = 17; /* Anything <> 0,1 */
5c9590
+    for ( i=0; i
5c9590
+        if ( size == 1 )      val = ((int)*CHARP(cp, i)) >> 7;
5c9590
+        else if ( size == 2 ) val = ((int)*SHORTP(cp, i)) >> 15;
5c9590
+        else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 31;
5c9590
+        val = val & 1;
5c9590
+        if ( val != prevval ) ncross++;
5c9590
+        prevval = val;
5c9590
+    }
5c9590
+    return PyLong_FromLong(ncross);
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_mul(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp, *ncp;
5c9590
-        int len, size, val = 0;
5c9590
-        double factor, fval, maxval;
5c9590
-        PyObject *rv;
5c9590
-        int i;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#id:mul", &cp, &len, &size, &factor ) )
5c9590
-                return 0;
5c9590
-    
5c9590
-        if ( size == 1 ) maxval = (double) 0x7f;
5c9590
-        else if ( size == 2 ) maxval = (double) 0x7fff;
5c9590
-        else if ( size == 4 ) maxval = (double) 0x7fffffff;
5c9590
-        else {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-    
5c9590
-        rv = PyBytes_FromStringAndSize(NULL, len);
5c9590
-        if ( rv == 0 )
5c9590
-                return 0;
5c9590
-        ncp = (signed char *)PyBytes_AsString(rv);
5c9590
-    
5c9590
-    
5c9590
-        for ( i=0; i < len; i += size ) {
5c9590
-                if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
-                else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
-                else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
-                fval = (double)val*factor;
5c9590
-                if ( fval > maxval ) fval = maxval;
5c9590
-                else if ( fval < -maxval ) fval = -maxval;
5c9590
-                val = (int)fval;
5c9590
-                if ( size == 1 )      *CHARP(ncp, i) = (signed char)val;
5c9590
-                else if ( size == 2 ) *SHORTP(ncp, i) = (short)val;
5c9590
-                else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)val;
5c9590
-        }
5c9590
-        return rv;
5c9590
+    signed char *cp, *ncp;
5c9590
+    int len, size, val = 0;
5c9590
+    double factor, fval, maxval;
5c9590
+    PyObject *rv;
5c9590
+    int i;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#id:mul", &cp, &len, &size, &factor ) )
5c9590
+        return 0;
5c9590
+
5c9590
+    if ( size == 1 ) maxval = (double) 0x7f;
5c9590
+    else if ( size == 2 ) maxval = (double) 0x7fff;
5c9590
+    else if ( size == 4 ) maxval = (double) 0x7fffffff;
5c9590
+    else {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+
5c9590
+    rv = PyBytes_FromStringAndSize(NULL, len);
5c9590
+    if ( rv == 0 )
5c9590
+        return 0;
5c9590
+    ncp = (signed char *)PyBytes_AsString(rv);
5c9590
+
5c9590
+
5c9590
+    for ( i=0; i < len; i += size ) {
5c9590
+        if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
+        else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
+        else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
+        fval = (double)val*factor;
5c9590
+        if ( fval > maxval ) fval = maxval;
5c9590
+        else if ( fval < -maxval ) fval = -maxval;
5c9590
+        val = (int)fval;
5c9590
+        if ( size == 1 )      *CHARP(ncp, i) = (signed char)val;
5c9590
+        else if ( size == 2 ) *SHORTP(ncp, i) = (short)val;
5c9590
+        else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)val;
5c9590
+    }
5c9590
+    return rv;
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_tomono(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-	Py_buffer pcp;
5c9590
-        signed char *cp, *ncp;
5c9590
-        int len, size, val1 = 0, val2 = 0;
5c9590
-        double fac1, fac2, fval, maxval;
5c9590
-        PyObject *rv;
5c9590
-        int i;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s*idd:tomono",
5c9590
-	                       &pcp, &size, &fac1, &fac2 ) )
5c9590
-                return 0;
5c9590
-	cp = pcp.buf;
5c9590
-	len = pcp.len;
5c9590
-    
5c9590
-        if ( size == 1 ) maxval = (double) 0x7f;
5c9590
-        else if ( size == 2 ) maxval = (double) 0x7fff;
5c9590
-        else if ( size == 4 ) maxval = (double) 0x7fffffff;
5c9590
-        else {
5c9590
-		PyBuffer_Release(&pcp);
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-    
5c9590
-        rv = PyBytes_FromStringAndSize(NULL, len/2);
5c9590
-        if ( rv == 0 )
5c9590
-                return 0;
5c9590
-        ncp = (signed char *)PyBytes_AsString(rv);
5c9590
-    
5c9590
-    
5c9590
-        for ( i=0; i < len; i += size*2 ) {
5c9590
-                if ( size == 1 )      val1 = (int)*CHARP(cp, i);
5c9590
-                else if ( size == 2 ) val1 = (int)*SHORTP(cp, i);
5c9590
-                else if ( size == 4 ) val1 = (int)*LONGP(cp, i);
5c9590
-                if ( size == 1 )      val2 = (int)*CHARP(cp, i+1);
5c9590
-                else if ( size == 2 ) val2 = (int)*SHORTP(cp, i+2);
5c9590
-                else if ( size == 4 ) val2 = (int)*LONGP(cp, i+4);
5c9590
-                fval = (double)val1*fac1 + (double)val2*fac2;
5c9590
-                if ( fval > maxval ) fval = maxval;
5c9590
-                else if ( fval < -maxval ) fval = -maxval;
5c9590
-                val1 = (int)fval;
5c9590
-                if ( size == 1 )      *CHARP(ncp, i/2) = (signed char)val1;
5c9590
-                else if ( size == 2 ) *SHORTP(ncp, i/2) = (short)val1;
5c9590
-                else if ( size == 4 ) *LONGP(ncp, i/2)= (Py_Int32)val1;
5c9590
-        }
5c9590
-	PyBuffer_Release(&pcp);
5c9590
-        return rv;
5c9590
+    Py_buffer pcp;
5c9590
+    signed char *cp, *ncp;
5c9590
+    int len, size, val1 = 0, val2 = 0;
5c9590
+    double fac1, fac2, fval, maxval;
5c9590
+    PyObject *rv;
5c9590
+    int i;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s*idd:tomono",
5c9590
+                           &pcp, &size, &fac1, &fac2 ) )
5c9590
+        return 0;
5c9590
+    cp = pcp.buf;
5c9590
+    len = pcp.len;
5c9590
+
5c9590
+    if ( size == 1 ) maxval = (double) 0x7f;
5c9590
+    else if ( size == 2 ) maxval = (double) 0x7fff;
5c9590
+    else if ( size == 4 ) maxval = (double) 0x7fffffff;
5c9590
+    else {
5c9590
+        PyBuffer_Release(&pcp);
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+
5c9590
+    rv = PyBytes_FromStringAndSize(NULL, len/2);
5c9590
+    if ( rv == 0 )
5c9590
+        return 0;
5c9590
+    ncp = (signed char *)PyBytes_AsString(rv);
5c9590
+
5c9590
+
5c9590
+    for ( i=0; i < len; i += size*2 ) {
5c9590
+        if ( size == 1 )      val1 = (int)*CHARP(cp, i);
5c9590
+        else if ( size == 2 ) val1 = (int)*SHORTP(cp, i);
5c9590
+        else if ( size == 4 ) val1 = (int)*LONGP(cp, i);
5c9590
+        if ( size == 1 )      val2 = (int)*CHARP(cp, i+1);
5c9590
+        else if ( size == 2 ) val2 = (int)*SHORTP(cp, i+2);
5c9590
+        else if ( size == 4 ) val2 = (int)*LONGP(cp, i+4);
5c9590
+        fval = (double)val1*fac1 + (double)val2*fac2;
5c9590
+        if ( fval > maxval ) fval = maxval;
5c9590
+        else if ( fval < -maxval ) fval = -maxval;
5c9590
+        val1 = (int)fval;
5c9590
+        if ( size == 1 )      *CHARP(ncp, i/2) = (signed char)val1;
5c9590
+        else if ( size == 2 ) *SHORTP(ncp, i/2) = (short)val1;
5c9590
+        else if ( size == 4 ) *LONGP(ncp, i/2)= (Py_Int32)val1;
5c9590
+    }
5c9590
+    PyBuffer_Release(&pcp);
5c9590
+    return rv;
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_tostereo(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp, *ncp;
5c9590
-        int len, new_len, size, val1, val2, val = 0;
5c9590
-        double fac1, fac2, fval, maxval;
5c9590
-        PyObject *rv;
5c9590
-        int i;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#idd:tostereo",
5c9590
-	                       &cp, &len, &size, &fac1, &fac2 ) )
5c9590
-                return 0;
5c9590
-    
5c9590
-        if ( size == 1 ) maxval = (double) 0x7f;
5c9590
-        else if ( size == 2 ) maxval = (double) 0x7fff;
5c9590
-        else if ( size == 4 ) maxval = (double) 0x7fffffff;
5c9590
-        else {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-    
5c9590
-        new_len = len*2;
5c9590
-        if (new_len < 0) {
5c9590
-                PyErr_SetString(PyExc_MemoryError,
5c9590
-                                "not enough memory for output buffer");
5c9590
-                return 0;
5c9590
-        }
5c9590
+    signed char *cp, *ncp;
5c9590
+    int len, new_len, size, val1, val2, val = 0;
5c9590
+    double fac1, fac2, fval, maxval;
5c9590
+    PyObject *rv;
5c9590
+    int i;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#idd:tostereo",
5c9590
+                           &cp, &len, &size, &fac1, &fac2 ) )
5c9590
+        return 0;
5c9590
+
5c9590
+    if ( size == 1 ) maxval = (double) 0x7f;
5c9590
+    else if ( size == 2 ) maxval = (double) 0x7fff;
5c9590
+    else if ( size == 4 ) maxval = (double) 0x7fffffff;
5c9590
+    else {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+
5c9590
+    new_len = len*2;
5c9590
+    if (new_len < 0) {
5c9590
+        PyErr_SetString(PyExc_MemoryError,
5c9590
+                        "not enough memory for output buffer");
5c9590
+        return 0;
5c9590
+    }
5c9590
+
5c9590
+    rv = PyBytes_FromStringAndSize(NULL, new_len);
5c9590
+    if ( rv == 0 )
5c9590
+        return 0;
5c9590
+    ncp = (signed char *)PyBytes_AsString(rv);
5c9590
 
5c9590
-        rv = PyBytes_FromStringAndSize(NULL, new_len);
5c9590
-        if ( rv == 0 )
5c9590
-                return 0;
5c9590
-        ncp = (signed char *)PyBytes_AsString(rv);
5c9590
-    
5c9590
-    
5c9590
-        for ( i=0; i < len; i += size ) {
5c9590
-                if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
-                else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
-                else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
-
5c9590
-                fval = (double)val*fac1;
5c9590
-                if ( fval > maxval ) fval = maxval;
5c9590
-                else if ( fval < -maxval ) fval = -maxval;
5c9590
-                val1 = (int)fval;
5c9590
-
5c9590
-                fval = (double)val*fac2;
5c9590
-                if ( fval > maxval ) fval = maxval;
5c9590
-                else if ( fval < -maxval ) fval = -maxval;
5c9590
-                val2 = (int)fval;
5c9590
-
5c9590
-                if ( size == 1 )      *CHARP(ncp, i*2) = (signed char)val1;
5c9590
-                else if ( size == 2 ) *SHORTP(ncp, i*2) = (short)val1;
5c9590
-                else if ( size == 4 ) *LONGP(ncp, i*2) = (Py_Int32)val1;
5c9590
-
5c9590
-                if ( size == 1 )      *CHARP(ncp, i*2+1) = (signed char)val2;
5c9590
-                else if ( size == 2 ) *SHORTP(ncp, i*2+2) = (short)val2;
5c9590
-                else if ( size == 4 ) *LONGP(ncp, i*2+4) = (Py_Int32)val2;
5c9590
-        }
5c9590
-        return rv;
5c9590
+
5c9590
+    for ( i=0; i < len; i += size ) {
5c9590
+        if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
+        else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
+        else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
+
5c9590
+        fval = (double)val*fac1;
5c9590
+        if ( fval > maxval ) fval = maxval;
5c9590
+        else if ( fval < -maxval ) fval = -maxval;
5c9590
+        val1 = (int)fval;
5c9590
+
5c9590
+        fval = (double)val*fac2;
5c9590
+        if ( fval > maxval ) fval = maxval;
5c9590
+        else if ( fval < -maxval ) fval = -maxval;
5c9590
+        val2 = (int)fval;
5c9590
+
5c9590
+        if ( size == 1 )      *CHARP(ncp, i*2) = (signed char)val1;
5c9590
+        else if ( size == 2 ) *SHORTP(ncp, i*2) = (short)val1;
5c9590
+        else if ( size == 4 ) *LONGP(ncp, i*2) = (Py_Int32)val1;
5c9590
+
5c9590
+        if ( size == 1 )      *CHARP(ncp, i*2+1) = (signed char)val2;
5c9590
+        else if ( size == 2 ) *SHORTP(ncp, i*2+2) = (short)val2;
5c9590
+        else if ( size == 4 ) *LONGP(ncp, i*2+4) = (Py_Int32)val2;
5c9590
+    }
5c9590
+    return rv;
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_add(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp1, *cp2, *ncp;
5c9590
-        int len1, len2, size, val1 = 0, val2 = 0, maxval, newval;
5c9590
-        PyObject *rv;
5c9590
-        int i;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#s#i:add",
5c9590
-                          &cp1, &len1, &cp2, &len2, &size ) )
5c9590
-                return 0;
5c9590
-
5c9590
-        if ( len1 != len2 ) {
5c9590
-                PyErr_SetString(AudioopError, "Lengths should be the same");
5c9590
-                return 0;
5c9590
-        }
5c9590
-    
5c9590
-        if ( size == 1 ) maxval = 0x7f;
5c9590
-        else if ( size == 2 ) maxval = 0x7fff;
5c9590
-        else if ( size == 4 ) maxval = 0x7fffffff;
5c9590
-        else {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-
5c9590
-        rv = PyBytes_FromStringAndSize(NULL, len1);
5c9590
-        if ( rv == 0 )
5c9590
-                return 0;
5c9590
-        ncp = (signed char *)PyBytes_AsString(rv);
5c9590
-
5c9590
-        for ( i=0; i < len1; i += size ) {
5c9590
-                if ( size == 1 )      val1 = (int)*CHARP(cp1, i);
5c9590
-                else if ( size == 2 ) val1 = (int)*SHORTP(cp1, i);
5c9590
-                else if ( size == 4 ) val1 = (int)*LONGP(cp1, i);
5c9590
-        
5c9590
-                if ( size == 1 )      val2 = (int)*CHARP(cp2, i);
5c9590
-                else if ( size == 2 ) val2 = (int)*SHORTP(cp2, i);
5c9590
-                else if ( size == 4 ) val2 = (int)*LONGP(cp2, i);
5c9590
-
5c9590
-                newval = val1 + val2;
5c9590
-                /* truncate in case of overflow */
5c9590
-                if (newval > maxval) newval = maxval;
5c9590
-                else if (newval < -maxval) newval = -maxval;
5c9590
-                else if (size == 4 && (newval^val1) < 0 && (newval^val2) < 0)
5c9590
-                        newval = val1 > 0 ? maxval : - maxval;
5c9590
-
5c9590
-                if ( size == 1 )      *CHARP(ncp, i) = (signed char)newval;
5c9590
-                else if ( size == 2 ) *SHORTP(ncp, i) = (short)newval;
5c9590
-                else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)newval;
5c9590
-        }
5c9590
-        return rv;
5c9590
+    signed char *cp1, *cp2, *ncp;
5c9590
+    int len1, len2, size, val1 = 0, val2 = 0, maxval, newval;
5c9590
+    PyObject *rv;
5c9590
+    int i;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#s#i:add",
5c9590
+                      &cp1, &len1, &cp2, &len2, &size ) )
5c9590
+        return 0;
5c9590
+
5c9590
+    if ( len1 != len2 ) {
5c9590
+        PyErr_SetString(AudioopError, "Lengths should be the same");
5c9590
+        return 0;
5c9590
+    }
5c9590
+
5c9590
+    if ( size == 1 ) maxval = 0x7f;
5c9590
+    else if ( size == 2 ) maxval = 0x7fff;
5c9590
+    else if ( size == 4 ) maxval = 0x7fffffff;
5c9590
+    else {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+
5c9590
+    rv = PyBytes_FromStringAndSize(NULL, len1);
5c9590
+    if ( rv == 0 )
5c9590
+        return 0;
5c9590
+    ncp = (signed char *)PyBytes_AsString(rv);
5c9590
+
5c9590
+    for ( i=0; i < len1; i += size ) {
5c9590
+        if ( size == 1 )      val1 = (int)*CHARP(cp1, i);
5c9590
+        else if ( size == 2 ) val1 = (int)*SHORTP(cp1, i);
5c9590
+        else if ( size == 4 ) val1 = (int)*LONGP(cp1, i);
5c9590
+
5c9590
+        if ( size == 1 )      val2 = (int)*CHARP(cp2, i);
5c9590
+        else if ( size == 2 ) val2 = (int)*SHORTP(cp2, i);
5c9590
+        else if ( size == 4 ) val2 = (int)*LONGP(cp2, i);
5c9590
+
5c9590
+        newval = val1 + val2;
5c9590
+        /* truncate in case of overflow */
5c9590
+        if (newval > maxval) newval = maxval;
5c9590
+        else if (newval < -maxval) newval = -maxval;
5c9590
+        else if (size == 4 && (newval^val1) < 0 && (newval^val2) < 0)
5c9590
+            newval = val1 > 0 ? maxval : - maxval;
5c9590
+
5c9590
+        if ( size == 1 )      *CHARP(ncp, i) = (signed char)newval;
5c9590
+        else if ( size == 2 ) *SHORTP(ncp, i) = (short)newval;
5c9590
+        else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)newval;
5c9590
+    }
5c9590
+    return rv;
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_bias(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp, *ncp;
5c9590
-        int len, size, val = 0;
5c9590
-        PyObject *rv;
5c9590
-        int i;
5c9590
-        int bias;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#ii:bias",
5c9590
-                          &cp, &len, &size , &bias) )
5c9590
-                return 0;
5c9590
-
5c9590
-        if ( size != 1 && size != 2 && size != 4) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-    
5c9590
-        rv = PyBytes_FromStringAndSize(NULL, len);
5c9590
-        if ( rv == 0 )
5c9590
-                return 0;
5c9590
-        ncp = (signed char *)PyBytes_AsString(rv);
5c9590
-    
5c9590
-    
5c9590
-        for ( i=0; i < len; i += size ) {
5c9590
-                if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
-                else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
-                else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
-        
5c9590
-                if ( size == 1 )      *CHARP(ncp, i) = (signed char)(val+bias);
5c9590
-                else if ( size == 2 ) *SHORTP(ncp, i) = (short)(val+bias);
5c9590
-                else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)(val+bias);
5c9590
-        }
5c9590
-        return rv;
5c9590
+    signed char *cp, *ncp;
5c9590
+    int len, size, val = 0;
5c9590
+    PyObject *rv;
5c9590
+    int i;
5c9590
+    int bias;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#ii:bias",
5c9590
+                      &cp, &len, &size , &bias) )
5c9590
+        return 0;
5c9590
+
5c9590
+    if ( size != 1 && size != 2 && size != 4) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+
5c9590
+    rv = PyBytes_FromStringAndSize(NULL, len);
5c9590
+    if ( rv == 0 )
5c9590
+        return 0;
5c9590
+    ncp = (signed char *)PyBytes_AsString(rv);
5c9590
+
5c9590
+
5c9590
+    for ( i=0; i < len; i += size ) {
5c9590
+        if ( size == 1 )      val = (int)*CHARP(cp, i);
5c9590
+        else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
+        else if ( size == 4 ) val = (int)*LONGP(cp, i);
5c9590
+
5c9590
+        if ( size == 1 )      *CHARP(ncp, i) = (signed char)(val+bias);
5c9590
+        else if ( size == 2 ) *SHORTP(ncp, i) = (short)(val+bias);
5c9590
+        else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)(val+bias);
5c9590
+    }
5c9590
+    return rv;
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_reverse(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp;
5c9590
-        unsigned char *ncp;
5c9590
-        int len, size, val = 0;
5c9590
-        PyObject *rv;
5c9590
-        int i, j;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#i:reverse",
5c9590
-                          &cp, &len, &size) )
5c9590
-                return 0;
5c9590
-
5c9590
-        if ( size != 1 && size != 2 && size != 4 ) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-    
5c9590
-        rv = PyBytes_FromStringAndSize(NULL, len);
5c9590
-        if ( rv == 0 )
5c9590
-                return 0;
5c9590
-        ncp = (unsigned char *)PyBytes_AsString(rv);
5c9590
-    
5c9590
-        for ( i=0; i < len; i += size ) {
5c9590
-                if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
5c9590
-                else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
-                else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16;
5c9590
-
5c9590
-                j = len - i - size;
5c9590
-        
5c9590
-                if ( size == 1 )      *CHARP(ncp, j) = (signed char)(val >> 8);
5c9590
-                else if ( size == 2 ) *SHORTP(ncp, j) = (short)(val);
5c9590
-                else if ( size == 4 ) *LONGP(ncp, j) = (Py_Int32)(val<<16);
5c9590
-        }
5c9590
-        return rv;
5c9590
+    signed char *cp;
5c9590
+    unsigned char *ncp;
5c9590
+    int len, size, val = 0;
5c9590
+    PyObject *rv;
5c9590
+    int i, j;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#i:reverse",
5c9590
+                      &cp, &len, &size) )
5c9590
+        return 0;
5c9590
+
5c9590
+    if ( size != 1 && size != 2 && size != 4 ) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+
5c9590
+    rv = PyBytes_FromStringAndSize(NULL, len);
5c9590
+    if ( rv == 0 )
5c9590
+        return 0;
5c9590
+    ncp = (unsigned char *)PyBytes_AsString(rv);
5c9590
+
5c9590
+    for ( i=0; i < len; i += size ) {
5c9590
+        if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
5c9590
+        else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
+        else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16;
5c9590
+
5c9590
+        j = len - i - size;
5c9590
+
5c9590
+        if ( size == 1 )      *CHARP(ncp, j) = (signed char)(val >> 8);
5c9590
+        else if ( size == 2 ) *SHORTP(ncp, j) = (short)(val);
5c9590
+        else if ( size == 4 ) *LONGP(ncp, j) = (Py_Int32)(val<<16);
5c9590
+    }
5c9590
+    return rv;
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_lin2lin(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp;
5c9590
-        unsigned char *ncp;
5c9590
-        int len, new_len, size, size2, val = 0;
5c9590
-        PyObject *rv;
5c9590
-        int i, j;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#ii:lin2lin",
5c9590
-                          &cp, &len, &size, &size2) )
5c9590
-                return 0;
5c9590
-
5c9590
-        if ( (size != 1 && size != 2 && size != 4) ||
5c9590
-             (size2 != 1 && size2 != 2 && size2 != 4)) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-    
5c9590
-        new_len = (len/size)*size2;
5c9590
-        if (new_len < 0) {
5c9590
-                PyErr_SetString(PyExc_MemoryError,
5c9590
-                                "not enough memory for output buffer");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        rv = PyBytes_FromStringAndSize(NULL, new_len);
5c9590
-        if ( rv == 0 )
5c9590
-                return 0;
5c9590
-        ncp = (unsigned char *)PyBytes_AsString(rv);
5c9590
-    
5c9590
-        for ( i=0, j=0; i < len; i += size, j += size2 ) {
5c9590
-                if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
5c9590
-                else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
-                else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16;
5c9590
-
5c9590
-                if ( size2 == 1 )  *CHARP(ncp, j) = (signed char)(val >> 8);
5c9590
-                else if ( size2 == 2 ) *SHORTP(ncp, j) = (short)(val);
5c9590
-                else if ( size2 == 4 ) *LONGP(ncp, j) = (Py_Int32)(val<<16);
5c9590
-        }
5c9590
-        return rv;
5c9590
+    signed char *cp;
5c9590
+    unsigned char *ncp;
5c9590
+    int len, new_len, size, size2, val = 0;
5c9590
+    PyObject *rv;
5c9590
+    int i, j;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#ii:lin2lin",
5c9590
+                      &cp, &len, &size, &size2) )
5c9590
+        return 0;
5c9590
+
5c9590
+    if ( (size != 1 && size != 2 && size != 4) ||
5c9590
+         (size2 != 1 && size2 != 2 && size2 != 4)) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+
5c9590
+    new_len = (len/size)*size2;
5c9590
+    if (new_len < 0) {
5c9590
+        PyErr_SetString(PyExc_MemoryError,
5c9590
+                        "not enough memory for output buffer");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    rv = PyBytes_FromStringAndSize(NULL, new_len);
5c9590
+    if ( rv == 0 )
5c9590
+        return 0;
5c9590
+    ncp = (unsigned char *)PyBytes_AsString(rv);
5c9590
+
5c9590
+    for ( i=0, j=0; i < len; i += size, j += size2 ) {
5c9590
+        if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
5c9590
+        else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
+        else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16;
5c9590
+
5c9590
+        if ( size2 == 1 )  *CHARP(ncp, j) = (signed char)(val >> 8);
5c9590
+        else if ( size2 == 2 ) *SHORTP(ncp, j) = (short)(val);
5c9590
+        else if ( size2 == 4 ) *LONGP(ncp, j) = (Py_Int32)(val<<16);
5c9590
+    }
5c9590
+    return rv;
5c9590
 }
5c9590
 
5c9590
 static int
5c9590
 gcd(int a, int b)
5c9590
 {
5c9590
-        while (b > 0) {
5c9590
-                int tmp = a % b;
5c9590
-                a = b;
5c9590
-                b = tmp;
5c9590
-        }
5c9590
-        return a;
5c9590
+    while (b > 0) {
5c9590
+        int tmp = a % b;
5c9590
+        a = b;
5c9590
+        b = tmp;
5c9590
+    }
5c9590
+    return a;
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_ratecv(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        char *cp, *ncp;
5c9590
-        int len, size, nchannels, inrate, outrate, weightA, weightB;
5c9590
-        int chan, d, *prev_i, *cur_i, cur_o;
5c9590
-        PyObject *state, *samps, *str, *rv = NULL;
5c9590
-        int bytes_per_frame;
5c9590
-        size_t alloc_size;
5c9590
-
5c9590
-        weightA = 1;
5c9590
-        weightB = 0;
5c9590
-        if (!PyArg_ParseTuple(args, "s#iiiiO|ii:ratecv", &cp, &len, &size,
5c9590
-	                      &nchannels, &inrate, &outrate, &state,
5c9590
-			      &weightA, &weightB))
5c9590
-                return NULL;
5c9590
-        if (size != 1 && size != 2 && size != 4) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return NULL;
5c9590
-        }
5c9590
-        if (nchannels < 1) {
5c9590
-                PyErr_SetString(AudioopError, "# of channels should be >= 1");
5c9590
-                return NULL;
5c9590
-        }
5c9590
-        bytes_per_frame = size * nchannels;
5c9590
-        if (bytes_per_frame / nchannels != size) {
5c9590
-                /* This overflow test is rigorously correct because
5c9590
-                   both multiplicands are >= 1.  Use the argument names
5c9590
-                   from the docs for the error msg. */
5c9590
-                PyErr_SetString(PyExc_OverflowError,
5c9590
-                                "width * nchannels too big for a C int");
5c9590
-                return NULL;
5c9590
-        }
5c9590
-        if (weightA < 1 || weightB < 0) {
5c9590
-                PyErr_SetString(AudioopError,
5c9590
-                        "weightA should be >= 1, weightB should be >= 0");
5c9590
-                return NULL;
5c9590
-        }
5c9590
-        if (len % bytes_per_frame != 0) {
5c9590
-                PyErr_SetString(AudioopError, "not a whole number of frames");
5c9590
-                return NULL;
5c9590
-        }
5c9590
-        if (inrate <= 0 || outrate <= 0) {
5c9590
-                PyErr_SetString(AudioopError, "sampling rate not > 0");
5c9590
-                return NULL;
5c9590
-        }
5c9590
-        /* divide inrate and outrate by their greatest common divisor */
5c9590
-        d = gcd(inrate, outrate);
5c9590
-        inrate /= d;
5c9590
-        outrate /= d;
5c9590
-
5c9590
-        alloc_size = sizeof(int) * (unsigned)nchannels;
5c9590
-        if (alloc_size < (unsigned)nchannels) {
5c9590
-                PyErr_SetString(PyExc_MemoryError,
5c9590
-                                "not enough memory for output buffer");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        prev_i = (int *) malloc(alloc_size);
5c9590
-        cur_i = (int *) malloc(alloc_size);
5c9590
-        if (prev_i == NULL || cur_i == NULL) {
5c9590
-                (void) PyErr_NoMemory();
5c9590
+    char *cp, *ncp;
5c9590
+    int len, size, nchannels, inrate, outrate, weightA, weightB;
5c9590
+    int chan, d, *prev_i, *cur_i, cur_o;
5c9590
+    PyObject *state, *samps, *str, *rv = NULL;
5c9590
+    int bytes_per_frame;
5c9590
+    size_t alloc_size;
5c9590
+
5c9590
+    weightA = 1;
5c9590
+    weightB = 0;
5c9590
+    if (!PyArg_ParseTuple(args, "s#iiiiO|ii:ratecv", &cp, &len, &size,
5c9590
+                          &nchannels, &inrate, &outrate, &state,
5c9590
+                          &weightA, &weightB))
5c9590
+        return NULL;
5c9590
+    if (size != 1 && size != 2 && size != 4) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return NULL;
5c9590
+    }
5c9590
+    if (nchannels < 1) {
5c9590
+        PyErr_SetString(AudioopError, "# of channels should be >= 1");
5c9590
+        return NULL;
5c9590
+    }
5c9590
+    bytes_per_frame = size * nchannels;
5c9590
+    if (bytes_per_frame / nchannels != size) {
5c9590
+        /* This overflow test is rigorously correct because
5c9590
+           both multiplicands are >= 1.  Use the argument names
5c9590
+           from the docs for the error msg. */
5c9590
+        PyErr_SetString(PyExc_OverflowError,
5c9590
+                        "width * nchannels too big for a C int");
5c9590
+        return NULL;
5c9590
+    }
5c9590
+    if (weightA < 1 || weightB < 0) {
5c9590
+        PyErr_SetString(AudioopError,
5c9590
+            "weightA should be >= 1, weightB should be >= 0");
5c9590
+        return NULL;
5c9590
+    }
5c9590
+    if (len % bytes_per_frame != 0) {
5c9590
+        PyErr_SetString(AudioopError, "not a whole number of frames");
5c9590
+        return NULL;
5c9590
+    }
5c9590
+    if (inrate <= 0 || outrate <= 0) {
5c9590
+        PyErr_SetString(AudioopError, "sampling rate not > 0");
5c9590
+        return NULL;
5c9590
+    }
5c9590
+    /* divide inrate and outrate by their greatest common divisor */
5c9590
+    d = gcd(inrate, outrate);
5c9590
+    inrate /= d;
5c9590
+    outrate /= d;
5c9590
+
5c9590
+    alloc_size = sizeof(int) * (unsigned)nchannels;
5c9590
+    if (alloc_size < (unsigned)nchannels) {
5c9590
+        PyErr_SetString(PyExc_MemoryError,
5c9590
+                        "not enough memory for output buffer");
5c9590
+        return 0;
5c9590
+    }
5c9590
+    prev_i = (int *) malloc(alloc_size);
5c9590
+    cur_i = (int *) malloc(alloc_size);
5c9590
+    if (prev_i == NULL || cur_i == NULL) {
5c9590
+        (void) PyErr_NoMemory();
5c9590
+        goto exit;
5c9590
+    }
5c9590
+
5c9590
+    len /= bytes_per_frame; /* # of frames */
5c9590
+
5c9590
+    if (state == Py_None) {
5c9590
+        d = -outrate;
5c9590
+        for (chan = 0; chan < nchannels; chan++)
5c9590
+            prev_i[chan] = cur_i[chan] = 0;
5c9590
+    }
5c9590
+    else {
5c9590
+        if (!PyArg_ParseTuple(state,
5c9590
+                        "iO!;audioop.ratecv: illegal state argument",
5c9590
+                        &d, &PyTuple_Type, &samps))
5c9590
+            goto exit;
5c9590
+        if (PyTuple_Size(samps) != nchannels) {
5c9590
+            PyErr_SetString(AudioopError,
5c9590
+                            "illegal state argument");
5c9590
+            goto exit;
5c9590
+        }
5c9590
+        for (chan = 0; chan < nchannels; chan++) {
5c9590
+            if (!PyArg_ParseTuple(PyTuple_GetItem(samps, chan),
5c9590
+                                  "ii:ratecv", &prev_i[chan],
5c9590
+                                               &cur_i[chan]))
5c9590
                 goto exit;
5c9590
         }
5c9590
+    }
5c9590
 
5c9590
-        len /= bytes_per_frame; /* # of frames */
5c9590
+    /* str <- Space for the output buffer. */
5c9590
+    {
5c9590
+        /* There are len input frames, so we need (mathematically)
5c9590
+           ceiling(len*outrate/inrate) output frames, and each frame
5c9590
+           requires bytes_per_frame bytes.  Computing this
5c9590
+           without spurious overflow is the challenge; we can
5c9590
+           settle for a reasonable upper bound, though. */
5c9590
+        int ceiling;   /* the number of output frames */
5c9590
+        int nbytes;    /* the number of output bytes needed */
5c9590
+        int q = len / inrate;
5c9590
+        /* Now len = q * inrate + r exactly (with r = len % inrate),
5c9590
+           and this is less than q * inrate + inrate = (q+1)*inrate.
5c9590
+           So a reasonable upper bound on len*outrate/inrate is
5c9590
+           ((q+1)*inrate)*outrate/inrate =
5c9590
+           (q+1)*outrate.
5c9590
+        */
5c9590
+        ceiling = (q+1) * outrate;
5c9590
+        nbytes = ceiling * bytes_per_frame;
5c9590
+        /* See whether anything overflowed; if not, get the space. */
5c9590
+        if (q+1 < 0 ||
5c9590
+            ceiling / outrate != q+1 ||
5c9590
+            nbytes / bytes_per_frame != ceiling)
5c9590
+            str = NULL;
5c9590
+        else
5c9590
+            str = PyBytes_FromStringAndSize(NULL, nbytes);
5c9590
 
5c9590
-        if (state == Py_None) {
5c9590
-                d = -outrate;
5c9590
+        if (str == NULL) {
5c9590
+            PyErr_SetString(PyExc_MemoryError,
5c9590
+                "not enough memory for output buffer");
5c9590
+            goto exit;
5c9590
+        }
5c9590
+    }
5c9590
+    ncp = PyBytes_AsString(str);
5c9590
+
5c9590
+    for (;;) {
5c9590
+        while (d < 0) {
5c9590
+            if (len == 0) {
5c9590
+                samps = PyTuple_New(nchannels);
5c9590
+                if (samps == NULL)
5c9590
+                    goto exit;
5c9590
                 for (chan = 0; chan < nchannels; chan++)
5c9590
-                        prev_i[chan] = cur_i[chan] = 0;
5c9590
-        }
5c9590
-        else {
5c9590
-                if (!PyArg_ParseTuple(state,
5c9590
-                                "iO!;audioop.ratecv: illegal state argument",
5c9590
-                                &d, &PyTuple_Type, &samps))
5c9590
-                        goto exit;
5c9590
-                if (PyTuple_Size(samps) != nchannels) {
5c9590
-                        PyErr_SetString(AudioopError,
5c9590
-                                        "illegal state argument");
5c9590
-                        goto exit;
5c9590
-                }
5c9590
-                for (chan = 0; chan < nchannels; chan++) {
5c9590
-                        if (!PyArg_ParseTuple(PyTuple_GetItem(samps, chan),
5c9590
-                                              "ii:ratecv", &prev_i[chan], 
5c9590
-					                   &cur_i[chan]))
5c9590
-                                goto exit;
5c9590
-                }
5c9590
-        }
5c9590
-
5c9590
-        /* str <- Space for the output buffer. */
5c9590
-        {
5c9590
-                /* There are len input frames, so we need (mathematically)
5c9590
-                   ceiling(len*outrate/inrate) output frames, and each frame
5c9590
-                   requires bytes_per_frame bytes.  Computing this
5c9590
-                   without spurious overflow is the challenge; we can
5c9590
-                   settle for a reasonable upper bound, though. */
5c9590
-                int ceiling;   /* the number of output frames */
5c9590
-                int nbytes;    /* the number of output bytes needed */
5c9590
-                int q = len / inrate;
5c9590
-                /* Now len = q * inrate + r exactly (with r = len % inrate),
5c9590
-                   and this is less than q * inrate + inrate = (q+1)*inrate.
5c9590
-                   So a reasonable upper bound on len*outrate/inrate is
5c9590
-                   ((q+1)*inrate)*outrate/inrate =
5c9590
-                   (q+1)*outrate.
5c9590
-                */
5c9590
-                ceiling = (q+1) * outrate;
5c9590
-                nbytes = ceiling * bytes_per_frame;
5c9590
-                /* See whether anything overflowed; if not, get the space. */
5c9590
-                if (q+1 < 0 ||
5c9590
-                    ceiling / outrate != q+1 ||
5c9590
-                    nbytes / bytes_per_frame != ceiling)
5c9590
-                        str = NULL;
5c9590
-                else
5c9590
-                        str = PyBytes_FromStringAndSize(NULL, nbytes);
5c9590
-
5c9590
-                if (str == NULL) {
5c9590
-                        PyErr_SetString(PyExc_MemoryError,
5c9590
-                                "not enough memory for output buffer");
5c9590
-                        goto exit;
5c9590
-                }
5c9590
-        }
5c9590
-        ncp = PyBytes_AsString(str);
5c9590
-
5c9590
-        for (;;) {
5c9590
-                while (d < 0) {
5c9590
-                        if (len == 0) {
5c9590
-                                samps = PyTuple_New(nchannels);
5c9590
-                                if (samps == NULL)
5c9590
-                                        goto exit;
5c9590
-                                for (chan = 0; chan < nchannels; chan++)
5c9590
-                                        PyTuple_SetItem(samps, chan,
5c9590
-                                                Py_BuildValue("(ii)",
5c9590
-                                                              prev_i[chan],
5c9590
-                                                              cur_i[chan]));
5c9590
-                                if (PyErr_Occurred())
5c9590
-                                        goto exit;
5c9590
-                                /* We have checked before that the length
5c9590
-                                 * of the string fits into int. */
5c9590
-                                len = (int)(ncp - PyBytes_AsString(str));
5c9590
-				rv = PyBytes_FromStringAndSize
5c9590
-					(PyBytes_AsString(str), len);
5c9590
-				Py_DECREF(str);
5c9590
-				str = rv;
5c9590
-				if (str == NULL)
5c9590
-                                        goto exit;
5c9590
-                                rv = Py_BuildValue("(O(iO))", str, d, samps);
5c9590
-                                Py_DECREF(samps);
5c9590
-                                Py_DECREF(str);
5c9590
-                                goto exit; /* return rv */
5c9590
-                        }
5c9590
-                        for (chan = 0; chan < nchannels; chan++) {
5c9590
-                                prev_i[chan] = cur_i[chan];
5c9590
-                                if (size == 1)
5c9590
-                                    cur_i[chan] = ((int)*CHARP(cp, 0)) << 8;
5c9590
-                                else if (size == 2)
5c9590
-                                    cur_i[chan] = (int)*SHORTP(cp, 0);
5c9590
-                                else if (size == 4)
5c9590
-                                    cur_i[chan] = ((int)*LONGP(cp, 0)) >> 16;
5c9590
-                                cp += size;
5c9590
-                                /* implements a simple digital filter */
5c9590
-                                cur_i[chan] =
5c9590
-                                        (weightA * cur_i[chan] +
5c9590
-                                         weightB * prev_i[chan]) /
5c9590
-                                        (weightA + weightB);
5c9590
-                        }
5c9590
-                        len--;
5c9590
-                        d += outrate;
5c9590
-                }
5c9590
-                while (d >= 0) {
5c9590
-                        for (chan = 0; chan < nchannels; chan++) {
5c9590
-                                cur_o = (prev_i[chan] * d +
5c9590
-                                         cur_i[chan] * (outrate - d)) /
5c9590
-                                        outrate;
5c9590
-                                if (size == 1)
5c9590
-                                    *CHARP(ncp, 0) = (signed char)(cur_o >> 8);
5c9590
-                                else if (size == 2)
5c9590
-                                    *SHORTP(ncp, 0) = (short)(cur_o);
5c9590
-                                else if (size == 4)
5c9590
-                                    *LONGP(ncp, 0) = (Py_Int32)(cur_o<<16);
5c9590
-                                ncp += size;
5c9590
-                        }
5c9590
-                        d -= inrate;
5c9590
-                }
5c9590
+                    PyTuple_SetItem(samps, chan,
5c9590
+                        Py_BuildValue("(ii)",
5c9590
+                                      prev_i[chan],
5c9590
+                                      cur_i[chan]));
5c9590
+                if (PyErr_Occurred())
5c9590
+                    goto exit;
5c9590
+                /* We have checked before that the length
5c9590
+                 * of the string fits into int. */
5c9590
+                len = (int)(ncp - PyBytes_AsString(str));
5c9590
+                rv = PyBytes_FromStringAndSize
5c9590
+                    (PyBytes_AsString(str), len);
5c9590
+                Py_DECREF(str);
5c9590
+                str = rv;
5c9590
+                if (str == NULL)
5c9590
+                    goto exit;
5c9590
+                rv = Py_BuildValue("(O(iO))", str, d, samps);
5c9590
+                Py_DECREF(samps);
5c9590
+                Py_DECREF(str);
5c9590
+                goto exit; /* return rv */
5c9590
+            }
5c9590
+            for (chan = 0; chan < nchannels; chan++) {
5c9590
+                prev_i[chan] = cur_i[chan];
5c9590
+                if (size == 1)
5c9590
+                    cur_i[chan] = ((int)*CHARP(cp, 0)) << 8;
5c9590
+                else if (size == 2)
5c9590
+                    cur_i[chan] = (int)*SHORTP(cp, 0);
5c9590
+                else if (size == 4)
5c9590
+                    cur_i[chan] = ((int)*LONGP(cp, 0)) >> 16;
5c9590
+                cp += size;
5c9590
+                /* implements a simple digital filter */
5c9590
+                cur_i[chan] =
5c9590
+                    (weightA * cur_i[chan] +
5c9590
+                     weightB * prev_i[chan]) /
5c9590
+                    (weightA + weightB);
5c9590
+            }
5c9590
+            len--;
5c9590
+            d += outrate;
5c9590
+        }
5c9590
+        while (d >= 0) {
5c9590
+            for (chan = 0; chan < nchannels; chan++) {
5c9590
+                cur_o = (prev_i[chan] * d +
5c9590
+                         cur_i[chan] * (outrate - d)) /
5c9590
+                    outrate;
5c9590
+                if (size == 1)
5c9590
+                    *CHARP(ncp, 0) = (signed char)(cur_o >> 8);
5c9590
+                else if (size == 2)
5c9590
+                    *SHORTP(ncp, 0) = (short)(cur_o);
5c9590
+                else if (size == 4)
5c9590
+                    *LONGP(ncp, 0) = (Py_Int32)(cur_o<<16);
5c9590
+                ncp += size;
5c9590
+            }
5c9590
+            d -= inrate;
5c9590
         }
5c9590
+    }
5c9590
   exit:
5c9590
-        if (prev_i != NULL)
5c9590
-                free(prev_i);
5c9590
-        if (cur_i != NULL)
5c9590
-                free(cur_i);
5c9590
-        return rv;
5c9590
+    if (prev_i != NULL)
5c9590
+        free(prev_i);
5c9590
+    if (cur_i != NULL)
5c9590
+        free(cur_i);
5c9590
+    return rv;
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_lin2ulaw(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        signed char *cp;
5c9590
-        unsigned char *ncp;
5c9590
-        int len, size, val = 0;
5c9590
-        PyObject *rv;
5c9590
-        int i;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#i:lin2ulaw",
5c9590
-                               &cp, &len, &size) )
5c9590
-                return 0 ;
5c9590
-
5c9590
-        if ( size != 1 && size != 2 && size != 4) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-    
5c9590
-        rv = PyBytes_FromStringAndSize(NULL, len/size);
5c9590
-        if ( rv == 0 )
5c9590
-                return 0;
5c9590
-        ncp = (unsigned char *)PyBytes_AsString(rv);
5c9590
-    
5c9590
-        for ( i=0; i < len; i += size ) {
5c9590
-                if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
5c9590
-                else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
-                else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16;
5c9590
-
5c9590
-                *ncp++ = st_14linear2ulaw(val);
5c9590
-        }
5c9590
-        return rv;
5c9590
+    signed char *cp;
5c9590
+    unsigned char *ncp;
5c9590
+    int len, size, val = 0;
5c9590
+    PyObject *rv;
5c9590
+    int i;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#i:lin2ulaw",
5c9590
+                           &cp, &len, &size) )
5c9590
+        return 0 ;
5c9590
+
5c9590
+    if ( size != 1 && size != 2 && size != 4) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }
5c9590
+
5c9590
+    rv = PyBytes_FromStringAndSize(NULL, len/size);
5c9590
+    if ( rv == 0 )
5c9590
+        return 0;
5c9590
+    ncp = (unsigned char *)PyBytes_AsString(rv);
5c9590
+
5c9590
+    for ( i=0; i < len; i += size ) {
5c9590
+        if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
5c9590
+        else if ( size == 2 ) val = (int)*SHORTP(cp, i);
5c9590
+        else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16;
5c9590
+
5c9590
+        *ncp++ = st_14linear2ulaw(val);
5c9590
+    }
5c9590
+    return rv;
5c9590
 }
5c9590
 
5c9590
 static PyObject *
5c9590
 audioop_ulaw2lin(PyObject *self, PyObject *args)
5c9590
 {
5c9590
-        unsigned char *cp;
5c9590
-        unsigned char cval;
5c9590
-        signed char *ncp;
5c9590
-        int len, new_len, size, val;
5c9590
-        PyObject *rv;
5c9590
-        int i;
5c9590
-
5c9590
-        if ( !PyArg_ParseTuple(args, "s#i:ulaw2lin",
5c9590
-                               &cp, &len, &size) )
5c9590
-                return 0;
5c9590
-
5c9590
-        if ( size != 1 && size != 2 && size != 4) {
5c9590
-                PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
-                return 0;
5c9590
-        }
5c9590
-    
5c9590
-        new_len = len*size;
5c9590
-        if (new_len < 0) {
5c9590
-                PyErr_SetString(PyExc_MemoryError,
5c9590
-                                "not enough memory for output buffer");
5c9590
-                return 0;
5c9590
-        }
5c9590
-        rv = PyBytes_FromStringAndSize(NULL, new_len);
5c9590
-        if ( rv == 0 )
5c9590
-                return 0;
5c9590
-        ncp = (signed char *)PyBytes_AsString(rv);
5c9590
-    
5c9590
-        for ( i=0; i < new_len; i += size ) {
5c9590
-                cval = *cp++;
5c9590
-                val = st_ulaw2linear16(cval);
5c9590
-        
5c9590
-                if ( size == 1 )      *CHARP(ncp, i) = (signed char)(val >> 8);
5c9590
-                else if ( size == 2 ) *SHORTP(ncp, i) = (short)(val);
5c9590
-                else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)(val<<16);
5c9590
-        }
5c9590
-        return rv;
5c9590
+    unsigned char *cp;
5c9590
+    unsigned char cval;
5c9590
+    signed char *ncp;
5c9590
+    int len, new_len, size, val;
5c9590
+    PyObject *rv;
5c9590
+    int i;
5c9590
+
5c9590
+    if ( !PyArg_ParseTuple(args, "s#i:ulaw2lin",
5c9590
+                           &cp, &len, &size) )
5c9590
+        return 0;
5c9590
+
5c9590
+    if ( size != 1 && size != 2 && size != 4) {
5c9590
+        PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
5c9590
+        return 0;
5c9590
+    }