mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
Optimise read/write loops by removing a redundant variable.
This commit is contained in:
parent
7ac2e64c0f
commit
1f11db8200
@ -1,3 +1,8 @@
|
||||
2004-07-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/(pcm|float|double64|ulaw|alaw|xi).c
|
||||
Optimise read/write loops by removing a redundant variable.
|
||||
|
||||
2004-07-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/file_io.c
|
||||
|
126
src/alaw.c
126
src/alaw.c
@ -108,7 +108,7 @@ short alaw_decode [256] =
|
||||
1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184,
|
||||
1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696,
|
||||
688, 656, 752, 720, 560, 528, 624, 592,
|
||||
944, 912, 1008, 976, 816, 784, 880, 848
|
||||
944, 912, 1008, 976, 816, 784, 880, 848
|
||||
} ; /* alaw_decode */
|
||||
|
||||
static
|
||||
@ -355,19 +355,20 @@ d2alaw_array (double *ptr, int count, unsigned char *buffer, double normfact)
|
||||
|
||||
static sf_count_t
|
||||
alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->ucbuf, 1, readcount, psf) ;
|
||||
alaw2s_array (psf->ucbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
alaw2s_array (psf->ucbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -375,19 +376,20 @@ alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->ucbuf, 1, readcount, psf) ;
|
||||
alaw2i_array (psf->ucbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
alaw2i_array (psf->ucbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -395,7 +397,7 @@ alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
@ -404,13 +406,14 @@ alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->ucbuf, 1, readcount, psf) ;
|
||||
alaw2f_array (psf->ucbuf, thisread, ptr + total, normfact) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
alaw2f_array (psf->ucbuf, readcount, ptr + total, normfact) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -418,7 +421,7 @@ alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
@ -426,13 +429,14 @@ alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->ucbuf, 1, readcount, psf) ;
|
||||
alaw2d_array (psf->ucbuf, thisread, ptr + total, normfact) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
alaw2d_array (psf->ucbuf, readcount, ptr + total, normfact) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -443,20 +447,20 @@ alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
alaw_write_s2alaw (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
s2alaw_array (ptr + total, writecount, psf->ucbuf) ;
|
||||
thiswrite = psf_fwrite (psf->ucbuf, 1, writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
s2alaw_array (ptr + total, bufferlen, psf->ucbuf) ;
|
||||
writecount = psf_fwrite (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -464,20 +468,20 @@ alaw_write_s2alaw (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
alaw_write_i2alaw (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2alaw_array (ptr + total, writecount, psf->ucbuf) ;
|
||||
thiswrite = psf_fwrite (psf->ucbuf, 1, writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2alaw_array (ptr + total, bufferlen, psf->ucbuf) ;
|
||||
writecount = psf_fwrite (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -485,7 +489,7 @@ alaw_write_i2alaw (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
alaw_write_f2alaw (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
@ -494,14 +498,14 @@ alaw_write_f2alaw (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
f2alaw_array (ptr + total, writecount, psf->ucbuf, normfact) ;
|
||||
thiswrite = psf_fwrite (psf->ucbuf, 1, writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
f2alaw_array (ptr + total, bufferlen, psf->ucbuf, normfact) ;
|
||||
writecount = psf_fwrite (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -509,7 +513,7 @@ alaw_write_f2alaw (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
alaw_write_d2alaw (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
@ -518,14 +522,14 @@ alaw_write_d2alaw (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
d2alaw_array (ptr + total, writecount, psf->ucbuf, normfact) ;
|
||||
thiswrite = psf_fwrite (psf->ucbuf, 1, writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
d2alaw_array (ptr + total, bufferlen, psf->ucbuf, normfact) ;
|
||||
writecount = psf_fwrite (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
|
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#define LOG_PUTCHAR(a,b) \
|
||||
{ if ((a)->logindex < SIGNED_SIZEOF ((a)->logbuffer) - 1)\
|
||||
{ if ((a)->logindex < SIGNED_SIZEOF ((a)->logbuffer) - 1) \
|
||||
{ (a)->logbuffer [(a)->logindex++] = (b) ; \
|
||||
(a)->logbuffer [(a)->logindex] = 0 ; \
|
||||
} \
|
||||
|
326
src/double64.c
326
src/double64.c
@ -485,22 +485,23 @@ double64_get_capability (SF_PRIVATE *psf)
|
||||
|
||||
static sf_count_t
|
||||
host_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->dbuf, sizeof (double), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, readcount) ;
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
d2s_array (psf->dbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
d2s_array (psf->dbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
len -= readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
@ -509,22 +510,23 @@ host_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->dbuf, sizeof (double), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, readcount) ;
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
d2i_array (psf->dbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
d2i_array (psf->dbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
len -= readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
@ -533,22 +535,23 @@ host_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->dbuf, sizeof (double), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, readcount) ;
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
d2f_array (psf->dbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
d2f_array (psf->dbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
len -= readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
@ -557,7 +560,7 @@ host_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->float_endswap != SF_TRUE)
|
||||
@ -566,14 +569,15 @@ host_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->dbuf, sizeof (double), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
|
||||
endswap_long_copy ((long*) (ptr + total), psf->lbuf, thisread) ;
|
||||
endswap_long_copy ((long*) (ptr + total), psf->lbuf, readcount) ;
|
||||
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
total += readcount ;
|
||||
len -= readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
} ;
|
||||
|
||||
@ -582,27 +586,28 @@ host_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_write_s2d (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
|
||||
s2d_array (ptr + total, psf->dbuf, writecount) ;
|
||||
s2d_array (ptr + total, psf->dbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
double64_peak_update (psf, psf->dbuf, writecount, (int) (total / psf->sf.channels)) ;
|
||||
double64_peak_update (psf, psf->dbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, writecount) ;
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->dbuf, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -610,26 +615,27 @@ host_write_s2d (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_write_i2d (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2d_array (ptr + total, psf->dbuf, writecount) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2d_array (ptr + total, psf->dbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
double64_peak_update (psf, psf->dbuf, writecount, (int) (total / psf->sf.channels)) ;
|
||||
double64_peak_update (psf, psf->dbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, writecount) ;
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->dbuf, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -637,26 +643,27 @@ host_write_i2d (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_write_f2d (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
f2d_array (ptr + total, psf->dbuf, writecount) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
f2d_array (ptr + total, psf->dbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
double64_peak_update (psf, psf->dbuf, writecount, (int) (total / psf->sf.channels)) ;
|
||||
double64_peak_update (psf, psf->dbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, writecount) ;
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->dbuf, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -664,7 +671,7 @@ host_write_f2d (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->has_peak)
|
||||
@ -676,15 +683,16 @@ host_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
|
||||
endswap_long_copy (psf->lbuf, (long*) (ptr + total), writecount) ;
|
||||
endswap_long_copy (psf->lbuf, (long*) (ptr + total), bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->dbuf, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -741,25 +749,26 @@ f2d_array (float *src, double *dest, int count)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->dbuf, sizeof (double), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, readcount) ;
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
d2bd_read (psf->dbuf, readcount) ;
|
||||
d2bd_read (psf->dbuf, bufferlen) ;
|
||||
|
||||
d2s_array (psf->dbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
d2s_array (psf->dbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -767,25 +776,26 @@ replace_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->dbuf, sizeof (double), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, readcount) ;
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
d2bd_read (psf->dbuf, readcount) ;
|
||||
d2bd_read (psf->dbuf, bufferlen) ;
|
||||
|
||||
d2i_array (psf->dbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
d2i_array (psf->dbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -793,14 +803,44 @@ replace_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->dbuf, sizeof (double), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
d2bd_read (psf->dbuf, bufferlen) ;
|
||||
|
||||
memcpy (ptr + total, psf->dbuf, bufferlen * sizeof (double)) ;
|
||||
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* replace_read_d2f */
|
||||
|
||||
static sf_count_t
|
||||
replace_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
/* FIXME : This is probably nowhere near optimal. */
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, readcount) ;
|
||||
@ -809,38 +849,10 @@ replace_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
memcpy (ptr + total, psf->dbuf, readcount * sizeof (double)) ;
|
||||
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
} /* replace_read_d2f */
|
||||
|
||||
static sf_count_t
|
||||
replace_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
/* FIXME : This is probably nowhere near optimal. */
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->dbuf, sizeof (double), readcount, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, thisread) ;
|
||||
|
||||
d2bd_read (psf->dbuf, thisread) ;
|
||||
|
||||
memcpy (ptr + total, psf->dbuf, thisread * sizeof (double)) ;
|
||||
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -848,28 +860,29 @@ replace_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_write_s2d (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
s2d_array (ptr + total, psf->dbuf, writecount) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
s2d_array (ptr + total, psf->dbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
double64_peak_update (psf, psf->dbuf, writecount, (int) (total / psf->sf.channels)) ;
|
||||
double64_peak_update (psf, psf->dbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
bd2d_write (psf->dbuf, writecount) ;
|
||||
bd2d_write (psf->dbuf, bufferlen) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, writecount) ;
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->dbuf, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -877,28 +890,29 @@ replace_write_s2d (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_write_i2d (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2d_array (ptr + total, psf->dbuf, writecount) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2d_array (ptr + total, psf->dbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
double64_peak_update (psf, psf->dbuf, writecount, (int) (total / psf->sf.channels)) ;
|
||||
double64_peak_update (psf, psf->dbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
bd2d_write (psf->dbuf, writecount) ;
|
||||
bd2d_write (psf->dbuf, bufferlen) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, writecount) ;
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->dbuf, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -906,25 +920,26 @@ replace_write_i2d (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_write_f2d (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
f2d_array (ptr + total, psf->dbuf, writecount) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
f2d_array (ptr + total, psf->dbuf, bufferlen) ;
|
||||
|
||||
bd2d_write (psf->dbuf, writecount) ;
|
||||
bd2d_write (psf->dbuf, bufferlen) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, writecount) ;
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->dbuf, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -932,7 +947,7 @@ replace_write_f2d (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
/* FIXME : This is probably nowhere near optimal. */
|
||||
@ -942,20 +957,21 @@ replace_write_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->dbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
|
||||
memcpy (psf->dbuf, ptr + total, writecount * sizeof (double)) ;
|
||||
memcpy (psf->dbuf, ptr + total, bufferlen * sizeof (double)) ;
|
||||
|
||||
bd2d_write (psf->dbuf, writecount) ;
|
||||
bd2d_write (psf->dbuf, bufferlen) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_long_array (psf->lbuf, writecount) ;
|
||||
endswap_long_array (psf->lbuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->dbuf, sizeof (double), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->dbuf, sizeof (double), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
|
296
src/float32.c
296
src/float32.c
@ -437,24 +437,25 @@ float32_get_capability (SF_PRIVATE *psf)
|
||||
|
||||
static sf_count_t
|
||||
host_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->fbuf, sizeof (float), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
|
||||
/* Fix me : Need lef2s_array */
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, readcount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
f2s_array (psf->fbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
f2s_array (psf->fbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -462,23 +463,24 @@ host_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->fbuf, sizeof (float), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, readcount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
f2i_array (psf->fbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
f2i_array (psf->fbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -486,7 +488,7 @@ host_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->float_endswap != SF_TRUE)
|
||||
@ -495,15 +497,16 @@ host_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->fbuf, sizeof (float), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
|
||||
endswap_int_copy ((int*) (ptr + total), psf->ibuf, thisread) ;
|
||||
endswap_int_copy ((int*) (ptr + total), psf->ibuf, readcount) ;
|
||||
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -511,24 +514,25 @@ host_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->fbuf, sizeof (float), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, readcount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
/* Fix me : Need lef2d_array */
|
||||
f2d_array (psf->fbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
f2d_array (psf->fbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -536,26 +540,27 @@ host_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_write_s2f (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
s2f_array (ptr + total, psf->fbuf, writecount) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
s2f_array (ptr + total, psf->fbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, psf->fbuf, writecount, (int) (total / psf->sf.channels)) ;
|
||||
float32_peak_update (psf, psf->fbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, writecount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->fbuf, sizeof (float), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -563,26 +568,27 @@ host_write_s2f (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_write_i2f (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2f_array (ptr + total, psf->fbuf, writecount) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2f_array (ptr + total, psf->fbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, psf->fbuf, writecount, (int) (total / psf->sf.channels)) ;
|
||||
float32_peak_update (psf, psf->fbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, writecount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->fbuf, sizeof (float) , writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->fbuf, sizeof (float) , bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -590,7 +596,7 @@ host_write_i2f (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->has_peak)
|
||||
@ -602,15 +608,16 @@ host_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
|
||||
endswap_int_copy (psf->ibuf, (int*) (ptr + total), writecount) ;
|
||||
endswap_int_copy (psf->ibuf, (int*) (ptr + total), bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->fbuf, sizeof (float), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -618,27 +625,28 @@ host_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
host_write_d2f (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
|
||||
d2f_array (ptr + total, psf->fbuf, writecount) ;
|
||||
d2f_array (ptr + total, psf->fbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, psf->fbuf, writecount, (int) (total / psf->sf.channels)) ;
|
||||
float32_peak_update (psf, psf->fbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, writecount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->fbuf, sizeof (float), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -695,25 +703,26 @@ d2f_array (double *src, float *dest, int count)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->fbuf, sizeof (float), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, readcount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
bf2f_array (psf->fbuf, readcount) ;
|
||||
bf2f_array (psf->fbuf, bufferlen) ;
|
||||
|
||||
f2s_array (psf->fbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
f2s_array (psf->fbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -721,25 +730,26 @@ replace_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->fbuf, sizeof (float), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, readcount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
bf2f_array (psf->fbuf, readcount) ;
|
||||
bf2f_array (psf->fbuf, bufferlen) ;
|
||||
|
||||
f2i_array (psf->fbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
f2i_array (psf->fbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -747,7 +757,7 @@ replace_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
/* FIX THIS */
|
||||
@ -755,20 +765,21 @@ replace_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->fbuf, sizeof (float), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, readcount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
bf2f_array (psf->fbuf, readcount) ;
|
||||
bf2f_array (psf->fbuf, bufferlen) ;
|
||||
|
||||
memcpy (ptr + total, psf->fbuf, readcount * sizeof (float)) ;
|
||||
memcpy (ptr + total, psf->fbuf, bufferlen * sizeof (float)) ;
|
||||
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -776,25 +787,26 @@ replace_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->fbuf, sizeof (float), readcount, psf) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, readcount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
bf2f_array (psf->fbuf, readcount) ;
|
||||
bf2f_array (psf->fbuf, bufferlen) ;
|
||||
|
||||
f2d_array (psf->fbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
f2d_array (psf->fbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -802,28 +814,29 @@ replace_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_write_s2f (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
s2f_array (ptr + total, psf->fbuf, writecount) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
s2f_array (ptr + total, psf->fbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, psf->fbuf, writecount, (int) (total / psf->sf.channels)) ;
|
||||
float32_peak_update (psf, psf->fbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
f2bf_array (psf->fbuf, writecount) ;
|
||||
f2bf_array (psf->fbuf, bufferlen) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, writecount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->fbuf, sizeof (float), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -831,28 +844,29 @@ replace_write_s2f (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_write_i2f (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2f_array (ptr + total, psf->fbuf, writecount) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2f_array (ptr + total, psf->fbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, psf->fbuf, writecount, (int) (total / psf->sf.channels)) ;
|
||||
float32_peak_update (psf, psf->fbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
f2bf_array (psf->fbuf, writecount) ;
|
||||
f2bf_array (psf->fbuf, bufferlen) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, writecount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->fbuf, sizeof (float), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -860,7 +874,7 @@ replace_write_i2f (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
/* FIX THIS */
|
||||
@ -870,20 +884,21 @@ replace_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
|
||||
memcpy (psf->fbuf, ptr + total, writecount * sizeof (float)) ;
|
||||
memcpy (psf->fbuf, ptr + total, bufferlen * sizeof (float)) ;
|
||||
|
||||
f2bf_array (psf->fbuf, writecount) ;
|
||||
f2bf_array (psf->fbuf, bufferlen) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, writecount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->fbuf, sizeof (float) , writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->fbuf, sizeof (float) , bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -891,28 +906,29 @@ replace_write_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
replace_write_d2f (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int writecount, bufferlen, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->fbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
d2f_array (ptr + total, psf->fbuf, writecount) ;
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
d2f_array (ptr + total, psf->fbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
float32_peak_update (psf, psf->fbuf, writecount, (int) (total / psf->sf.channels)) ;
|
||||
float32_peak_update (psf, psf->fbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
f2bf_array (psf->fbuf, writecount) ;
|
||||
f2bf_array (psf->fbuf, bufferlen) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
endswap_int_array (psf->ibuf, writecount) ;
|
||||
endswap_int_array (psf->ibuf, bufferlen) ;
|
||||
|
||||
thiswrite = psf_fwrite (psf->fbuf, sizeof (float), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
writecount = psf_fwrite (psf->fbuf, sizeof (float), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
|
1370
src/missing.c
1370
src/missing.c
File diff suppressed because it is too large
Load Diff
120
src/ulaw.c
120
src/ulaw.c
@ -856,19 +856,20 @@ d2ulaw_array (double *ptr, int count, unsigned char *buffer, double normfact)
|
||||
|
||||
static sf_count_t
|
||||
ulaw_read_ulaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->ucbuf, 1, readcount, psf) ;
|
||||
ulaw2s_array (psf->ucbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
ulaw2s_array (psf->ucbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -876,19 +877,20 @@ ulaw_read_ulaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
ulaw_read_ulaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->ucbuf, 1, readcount, psf) ;
|
||||
ulaw2i_array (psf->ucbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
ulaw2i_array (psf->ucbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -896,7 +898,7 @@ ulaw_read_ulaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
ulaw_read_ulaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
@ -905,13 +907,14 @@ ulaw_read_ulaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->ucbuf, 1, readcount, psf) ;
|
||||
ulaw2f_array (psf->ucbuf, thisread, ptr + total, normfact) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
ulaw2f_array (psf->ucbuf, readcount, ptr + total, normfact) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -919,7 +922,7 @@ ulaw_read_ulaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
ulaw_read_ulaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, readcount, thisread ;
|
||||
{ int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
@ -927,13 +930,14 @@ ulaw_read_ulaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->ucbuf, 1, readcount, psf) ;
|
||||
ulaw2d_array (psf->ucbuf, thisread, ptr + total, normfact) ;
|
||||
total += thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
ulaw2d_array (psf->ucbuf, readcount, ptr + total, normfact) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= thisread ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -944,19 +948,20 @@ ulaw_read_ulaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
ulaw_write_s2ulaw (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
s2ulaw_array (ptr + total, writecount, psf->ucbuf) ;
|
||||
thiswrite = psf_fwrite (psf->ucbuf, 1, writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
s2ulaw_array (ptr + total, bufferlen, psf->ucbuf) ;
|
||||
writecount = psf_fwrite (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -964,19 +969,20 @@ ulaw_write_s2ulaw (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
ulaw_write_i2ulaw (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2ulaw_array (ptr + total, writecount, psf->ucbuf) ;
|
||||
thiswrite = psf_fwrite (psf->ucbuf, 1, writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2ulaw_array (ptr + total, bufferlen, psf->ucbuf) ;
|
||||
writecount = psf_fwrite (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -984,7 +990,7 @@ ulaw_write_i2ulaw (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
ulaw_write_f2ulaw (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
@ -993,13 +999,14 @@ ulaw_write_f2ulaw (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
f2ulaw_array (ptr + total, writecount, psf->ucbuf, normfact) ;
|
||||
thiswrite = psf_fwrite (psf->ucbuf, 1, writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
f2ulaw_array (ptr + total, bufferlen, psf->ucbuf, normfact) ;
|
||||
writecount = psf_fwrite (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -1007,7 +1014,7 @@ ulaw_write_f2ulaw (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
|
||||
static sf_count_t
|
||||
ulaw_write_d2ulaw (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount, thiswrite ;
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
@ -1016,13 +1023,14 @@ ulaw_write_d2ulaw (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
d2ulaw_array (ptr + total, writecount, psf->ucbuf, normfact) ;
|
||||
thiswrite = psf_fwrite (psf->ucbuf, 1, writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
d2ulaw_array (ptr + total, bufferlen, psf->ucbuf, normfact) ;
|
||||
writecount = psf_fwrite (psf->ucbuf, 1, bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= thiswrite ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
|
240
src/xi.c
240
src/xi.c
@ -483,7 +483,7 @@ static void dles2d_array (XI_PRIVATE *pxi, short *src, int count, double *dest,
|
||||
static sf_count_t
|
||||
dpcm_read_dsc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, readcount, thisread ;
|
||||
int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if ((pxi = psf->fdata) == NULL)
|
||||
@ -492,13 +492,14 @@ dpcm_read_dsc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->scbuf, sizeof (signed char), readcount, psf) ;
|
||||
dsc2s_array (pxi, psf->scbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->scbuf, sizeof (signed char), bufferlen, psf) ;
|
||||
dsc2s_array (pxi, psf->scbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -507,7 +508,7 @@ dpcm_read_dsc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_read_dsc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, readcount, thisread ;
|
||||
int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if ((pxi = psf->fdata) == NULL)
|
||||
@ -516,13 +517,14 @@ dpcm_read_dsc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->scbuf, sizeof (signed char), readcount, psf) ;
|
||||
dsc2i_array (pxi, psf->scbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->scbuf, sizeof (signed char), bufferlen, psf) ;
|
||||
dsc2i_array (pxi, psf->scbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -531,7 +533,7 @@ dpcm_read_dsc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_read_dsc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, readcount, thisread ;
|
||||
int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
@ -543,13 +545,14 @@ dpcm_read_dsc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->scbuf, sizeof (signed char), readcount, psf) ;
|
||||
dsc2f_array (pxi, psf->scbuf, thisread, ptr + total, normfact) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->scbuf, sizeof (signed char), bufferlen, psf) ;
|
||||
dsc2f_array (pxi, psf->scbuf, readcount, ptr + total, normfact) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -558,7 +561,7 @@ dpcm_read_dsc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_read_dsc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, readcount, thisread ;
|
||||
int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
@ -570,13 +573,14 @@ dpcm_read_dsc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->scbuf, sizeof (signed char), readcount, psf) ;
|
||||
dsc2d_array (pxi, psf->scbuf, thisread, ptr + total, normfact) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->scbuf, sizeof (signed char), bufferlen, psf) ;
|
||||
dsc2d_array (pxi, psf->scbuf, readcount, ptr + total, normfact) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -588,7 +592,7 @@ dpcm_read_dsc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_read_dles2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, readcount, thisread ;
|
||||
int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if ((pxi = psf->fdata) == NULL)
|
||||
@ -597,13 +601,14 @@ dpcm_read_dles2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->sbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->sbuf, sizeof (short), readcount, psf) ;
|
||||
dles2s_array (pxi, psf->sbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->sbuf, sizeof (short), bufferlen, psf) ;
|
||||
dles2s_array (pxi, psf->sbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -612,7 +617,7 @@ dpcm_read_dles2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_read_dles2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, readcount, thisread ;
|
||||
int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if ((pxi = psf->fdata) == NULL)
|
||||
@ -621,13 +626,14 @@ dpcm_read_dles2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->sbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->sbuf, sizeof (short), readcount, psf) ;
|
||||
dles2i_array (pxi, psf->sbuf, thisread, ptr + total) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->sbuf, sizeof (short), bufferlen, psf) ;
|
||||
dles2i_array (pxi, psf->sbuf, readcount, ptr + total) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -636,7 +642,7 @@ dpcm_read_dles2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_read_dles2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, readcount, thisread ;
|
||||
int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
@ -648,13 +654,14 @@ dpcm_read_dles2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->sbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->sbuf, sizeof (short), readcount, psf) ;
|
||||
dles2f_array (pxi, psf->sbuf, thisread, ptr + total, normfact) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->sbuf, sizeof (short), bufferlen, psf) ;
|
||||
dles2f_array (pxi, psf->sbuf, readcount, ptr + total, normfact) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -663,7 +670,7 @@ dpcm_read_dles2f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_read_dles2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, readcount, thisread ;
|
||||
int bufferlen, readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
@ -675,13 +682,14 @@ dpcm_read_dles2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->sbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ readcount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
thisread = psf_fread (psf->sbuf, sizeof (short), readcount, psf) ;
|
||||
dles2d_array (pxi, psf->sbuf, thisread, ptr + total, normfact) ;
|
||||
total += thisread ;
|
||||
len -= thisread ;
|
||||
if (thisread < readcount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
readcount = psf_fread (psf->sbuf, sizeof (short), bufferlen, psf) ;
|
||||
dles2d_array (pxi, psf->sbuf, readcount, ptr + total, normfact) ;
|
||||
total += readcount ;
|
||||
if (readcount < bufferlen)
|
||||
break ;
|
||||
len -= readcount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -704,7 +712,7 @@ static void d2dles_array (XI_PRIVATE *pxi, double *src, short *dest, int count,
|
||||
static sf_count_t
|
||||
dpcm_write_s2dsc (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, writecount, thiswrite ;
|
||||
int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if ((pxi = psf->fdata) == NULL)
|
||||
@ -713,13 +721,14 @@ dpcm_write_s2dsc (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
s2dsc_array (pxi, ptr + total, psf->scbuf, writecount) ;
|
||||
thiswrite = psf_fwrite (psf->scbuf, sizeof (signed char), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
s2dsc_array (pxi, ptr + total, psf->scbuf, bufferlen) ;
|
||||
writecount = psf_fwrite (psf->scbuf, sizeof (signed char), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -728,7 +737,7 @@ dpcm_write_s2dsc (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_write_i2dsc (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, writecount, thiswrite ;
|
||||
int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if ((pxi = psf->fdata) == NULL)
|
||||
@ -737,13 +746,14 @@ dpcm_write_i2dsc (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2dsc_array (pxi, ptr + total, psf->scbuf, writecount) ;
|
||||
thiswrite = psf_fwrite (psf->scbuf, sizeof (signed char), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2dsc_array (pxi, ptr + total, psf->scbuf, bufferlen) ;
|
||||
writecount = psf_fwrite (psf->scbuf, sizeof (signed char), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -752,7 +762,7 @@ dpcm_write_i2dsc (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_write_f2dsc (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, writecount, thiswrite ;
|
||||
int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
@ -764,13 +774,14 @@ dpcm_write_f2dsc (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
f2dsc_array (pxi, ptr + total, psf->scbuf, writecount, normfact) ;
|
||||
thiswrite = psf_fwrite (psf->scbuf, sizeof (signed char), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
f2dsc_array (pxi, ptr + total, psf->scbuf, bufferlen, normfact) ;
|
||||
writecount = psf_fwrite (psf->scbuf, sizeof (signed char), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -779,7 +790,7 @@ dpcm_write_f2dsc (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_write_d2dsc (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, writecount, thiswrite ;
|
||||
int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
@ -791,13 +802,14 @@ dpcm_write_d2dsc (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->ucbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
d2dsc_array (pxi, ptr + total, psf->scbuf, writecount, normfact) ;
|
||||
thiswrite = psf_fwrite (psf->scbuf, sizeof (signed char), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
d2dsc_array (pxi, ptr + total, psf->scbuf, bufferlen, normfact) ;
|
||||
writecount = psf_fwrite (psf->scbuf, sizeof (signed char), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -807,7 +819,7 @@ dpcm_write_d2dsc (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_write_s2dles (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, writecount, thiswrite ;
|
||||
int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if ((pxi = psf->fdata) == NULL)
|
||||
@ -816,13 +828,14 @@ dpcm_write_s2dles (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->sbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
s2dles_array (pxi, ptr + total, psf->sbuf, writecount) ;
|
||||
thiswrite = psf_fwrite (psf->sbuf, sizeof (short), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
s2dles_array (pxi, ptr + total, psf->sbuf, bufferlen) ;
|
||||
writecount = psf_fwrite (psf->sbuf, sizeof (short), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -831,7 +844,7 @@ dpcm_write_s2dles (SF_PRIVATE *psf, short *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_write_i2dles (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, writecount, thiswrite ;
|
||||
int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if ((pxi = psf->fdata) == NULL)
|
||||
@ -840,13 +853,14 @@ dpcm_write_i2dles (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->sbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
i2dles_array (pxi, ptr + total, psf->sbuf, writecount) ;
|
||||
thiswrite = psf_fwrite (psf->sbuf, sizeof (short), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
i2dles_array (pxi, ptr + total, psf->sbuf, bufferlen) ;
|
||||
writecount = psf_fwrite (psf->sbuf, sizeof (short), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -855,7 +869,7 @@ dpcm_write_i2dles (SF_PRIVATE *psf, int *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_write_f2dles (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, writecount, thiswrite ;
|
||||
int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
float normfact ;
|
||||
|
||||
@ -867,13 +881,14 @@ dpcm_write_f2dles (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->sbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
f2dles_array (pxi, ptr + total, psf->sbuf, writecount, normfact) ;
|
||||
thiswrite = psf_fwrite (psf->sbuf, sizeof (short), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
f2dles_array (pxi, ptr + total, psf->sbuf, bufferlen, normfact) ;
|
||||
writecount = psf_fwrite (psf->sbuf, sizeof (short), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
@ -882,7 +897,7 @@ dpcm_write_f2dles (SF_PRIVATE *psf, float *ptr, sf_count_t len)
|
||||
static sf_count_t
|
||||
dpcm_write_d2dles (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
{ XI_PRIVATE *pxi ;
|
||||
int bufferlen, writecount, thiswrite ;
|
||||
int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
double normfact ;
|
||||
|
||||
@ -894,13 +909,14 @@ dpcm_write_d2dles (SF_PRIVATE *psf, double *ptr, sf_count_t len)
|
||||
bufferlen = ARRAY_LEN (psf->sbuf) ;
|
||||
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
d2dles_array (pxi, ptr + total, psf->sbuf, writecount, normfact) ;
|
||||
thiswrite = psf_fwrite (psf->sbuf, sizeof (short), writecount, psf) ;
|
||||
total += thiswrite ;
|
||||
len -= thiswrite ;
|
||||
if (thiswrite < writecount)
|
||||
{ if (len < bufferlen)
|
||||
bufferlen = (int) len ;
|
||||
d2dles_array (pxi, ptr + total, psf->sbuf, bufferlen, normfact) ;
|
||||
writecount = psf_fwrite (psf->sbuf, sizeof (short), bufferlen, psf) ;
|
||||
total += writecount ;
|
||||
if (writecount < bufferlen)
|
||||
break ;
|
||||
len -= writecount ;
|
||||
} ;
|
||||
|
||||
return total ;
|
||||
|
Loading…
Reference in New Issue
Block a user