# HG changeset patch # User Matti Hamalainen # Date 1349036422 -10800 # Node ID 048536ad01e0afb5c6cec97f23428bd70a20c065 # Parent f47011b06d5c586829398385fc1559f4811fb881 Cleanups. diff -r f47011b06d5c -r 048536ad01e0 jssmod.c --- a/jssmod.c Sun Sep 30 19:38:17 2012 +0300 +++ b/jssmod.c Sun Sep 30 23:20:22 2012 +0300 @@ -32,14 +32,14 @@ /* Encodes a given 8-bit sample */ -BOOL jssEncodeSample8(Uint8 * sdata, const size_t srcSize, const int ops) +BOOL jssEncodeSample8(Uint8 * data, const size_t len, const int ops) { - size_t ssize = srcSize; + size_t count = len; Sint8 t, value = 0; - while (ssize--) + while (count--) { - t = *sdata; + t = *data; if (ops & jsampFlipSign) t ^= 0x80; @@ -51,7 +51,7 @@ t = n; } - *(sdata++) = t; + *(data++) = t; } return TRUE; @@ -60,40 +60,40 @@ /* Decodes a given 16-bit sample */ -BOOL jssEncodeSample16(Uint16 * srcData, const size_t srcSize, const int ops) +BOOL jssEncodeSample16(Uint16 * data, const size_t len, const int ops) { // "Split" the 16-bit samples into 8-bit halves if (ops & jsampSplit) { // Allocate temporary processing buffer - size_t ssize, bufSize = srcSize * sizeof(Sint16); + size_t count, bufSize = len * sizeof(Sint16); Uint8 *bp1, *bp2; - Sint16 t, *sdata, *tmpBuf = dmMalloc(bufSize); + Sint16 *sdata, *tmpBuf = dmMalloc(bufSize); if (tmpBuf == NULL) return FALSE; sdata = tmpBuf; - bp1 = (Uint8 *) srcData; - bp2 = bp1 + srcSize; - ssize = srcSize; + bp1 = (Uint8 *) data; + bp2 = bp1 + len; + count = len; - while (ssize--) + while (count--) { - t = (*sdata++); + Sint16 t = (*sdata++); *bp1++ = t >> 8; *bp2++ = t & 0xff; } - memcpy(srcData, tmpBuf, bufSize); + memcpy(data, tmpBuf, bufSize); dmFree(tmpBuf); - return jssEncodeSample8((Uint8 *) srcData, bufSize, ops); + return jssEncodeSample8((Uint8 *) data, bufSize, ops); } else { - Sint16 t, p, value = 0, *sdata = (Sint16 *) srcData; - size_t ssize = srcSize; + Sint16 t, p, value = 0, *sdata = (Sint16 *) data; + size_t count = len; - while (ssize--) + while (count--) { if (ops & jsampSwapEndianess) { @@ -122,14 +122,14 @@ /* Decodes a given 8-bit sample */ -BOOL jssDecodeSample8(Uint8 * sdata, const size_t srcSize, const int ops) +BOOL jssDecodeSample8(Uint8 * data, const size_t len, const int ops) { - size_t ssize = srcSize; + size_t count = len; Sint8 t, value = 0; - while (ssize--) + while (count--) { - t = *sdata; + t = *data; if (ops & jsampDelta) t = value = t + value; @@ -137,7 +137,7 @@ if (ops & jsampFlipSign) t ^= 0x80; - *(sdata++) = t; + *(data++) = t; } return TRUE; } @@ -145,26 +145,26 @@ /* Decodes a given 16-bit sample */ -BOOL jssDecodeSample16(Uint16 * srcData, const size_t srcSize, const int ops) +BOOL jssDecodeSample16(Uint16 * data, const size_t len, const int ops) { if (ops & jsampSplit) { - size_t ssize, bufSize = srcSize * sizeof(Uint16); + size_t count, bufSize = len * sizeof(Uint16); Uint8 *bp1, *bp2; Sint16 *tmpBuf, *sdata; - if (!jssDecodeSample8((Uint8 *) srcData, bufSize, ops)) + if (!jssDecodeSample8((Uint8 *) data, bufSize, ops)) return FALSE; tmpBuf = dmMalloc(bufSize); if (tmpBuf == NULL) return FALSE; - memcpy(tmpBuf, srcData, bufSize); + memcpy(tmpBuf, data, bufSize); - sdata = (Sint16 *) srcData; + sdata = (Sint16 *) data; bp1 = (Uint8 *) tmpBuf; - bp2 = bp1 + srcSize; - ssize = srcSize; - while (ssize--) + bp2 = bp1 + len; + count = len; + while (count--) { *sdata++ = (*bp1++ << 8) | (*bp2++ & 0xff); } @@ -173,9 +173,9 @@ } else { - Sint16 t, p, value = 0, *sdata = (Sint16 *) srcData; - size_t ssize = srcSize; - while (ssize--) + Sint16 t, p, value = 0, *sdata = (Sint16 *) data; + size_t count = len; + while (count--) { if (ops & jsampSwapEndianess) {