mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
Remove had_peak field of SF_PRIVATE, use pchunk != NULL instead.
This commit is contained in:
parent
53c996b794
commit
5751ad0e64
@ -2,8 +2,9 @@
|
||||
|
||||
* src/common.h
|
||||
Move the peak_loc field of SF_PRIVATE to the PEAK_CHUNK struct.
|
||||
Remove had_peak field of SF_PRIVATE, use pchunk != NULL instead.
|
||||
|
||||
* src/aiff.c src/caf.c src/wav.c
|
||||
* src/aiff.c src/caf.c src/wav.c src/float32.c src/double64.c
|
||||
Fix knock on effects from above.
|
||||
|
||||
2005-07-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
@ -214,7 +214,6 @@ aiff_open (SF_PRIVATE *psf)
|
||||
{ psf->pchunk = calloc (1, sizeof (PEAK_CHUNK) * psf->sf.channels * sizeof (PEAK_POS)) ;
|
||||
if (psf->pchunk == NULL)
|
||||
return SFE_MALLOC_FAILED ;
|
||||
psf->has_peak = SF_TRUE ;
|
||||
psf->pchunk->peak_loc = SF_PEAK_START ;
|
||||
} ;
|
||||
|
||||
@ -433,7 +432,6 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
|
||||
psf_log_printf (psf, cptr) ;
|
||||
} ;
|
||||
|
||||
psf->has_peak = SF_TRUE ; /* Found PEAK chunk. */
|
||||
break ;
|
||||
|
||||
case SSND_MARKER :
|
||||
@ -1066,7 +1064,7 @@ aiff_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
if (psf->str_flags & SF_STR_LOCATE_START)
|
||||
aiff_write_strings (psf, SF_STR_LOCATE_START) ;
|
||||
|
||||
if (psf->has_peak && psf->pchunk->peak_loc == SF_PEAK_START)
|
||||
if (psf->pchunk != NULL && psf->pchunk->peak_loc == SF_PEAK_START)
|
||||
{ psf_binheader_writef (psf, "Em4", PEAK_MARKER,
|
||||
sizeof (PEAK_CHUNK) + psf->sf.channels * sizeof (PEAK_POS)) ;
|
||||
psf_binheader_writef (psf, "E44", 1, time (NULL)) ;
|
||||
@ -1103,7 +1101,7 @@ aiff_write_tailer (SF_PRIVATE *psf)
|
||||
|
||||
psf->dataend = psf_fseek (psf, 0, SEEK_END) ;
|
||||
|
||||
if (psf->has_peak && psf->pchunk->peak_loc == SF_PEAK_END)
|
||||
if (psf->pchunk != NULL && psf->pchunk->peak_loc == SF_PEAK_END)
|
||||
{ psf_binheader_writef (psf, "Em4", PEAK_MARKER,
|
||||
sizeof (PEAK_CHUNK) + psf->sf.channels * sizeof (PEAK_POS)) ;
|
||||
psf_binheader_writef (psf, "E44", 1, time (NULL)) ;
|
||||
|
@ -129,7 +129,6 @@ caf_open (SF_PRIVATE *psf)
|
||||
{ psf->pchunk = calloc (1, sizeof (PEAK_CHUNK) * psf->sf.channels * sizeof (PEAK_POS)) ;
|
||||
if (psf->pchunk == NULL)
|
||||
return SFE_MALLOC_FAILED ;
|
||||
psf->has_peak = SF_TRUE ;
|
||||
psf->pchunk->peak_loc = SF_PEAK_START ;
|
||||
} ;
|
||||
|
||||
@ -504,7 +503,7 @@ caf_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
if (psf->str_flags & SF_STR_LOCATE_START)
|
||||
caf_write_strings (psf, SF_STR_LOCATE_START) ;
|
||||
|
||||
if (psf->has_peak && psf->pchunk->peak_loc == SF_PEAK_START)
|
||||
if (psf->pchunk != NULL && psf->pchunk->peak_loc == SF_PEAK_START)
|
||||
{ psf_binheader_writef (psf, "em4", PEAK_MARKER,
|
||||
sizeof (PEAK_CHUNK) + psf->sf.channels * sizeof (PEAK_POS)) ;
|
||||
psf_binheader_writef (psf, "e44", 1, time (NULL)) ;
|
||||
|
@ -241,7 +241,6 @@ typedef struct sf_private_tag
|
||||
SF_INFO sf ;
|
||||
|
||||
int have_written ; /* Has a single write been done to the file? */
|
||||
int has_peak ; /* Has a PEAK chunk (AIFF and WAVE) been read? */
|
||||
PEAK_CHUNK *pchunk ;
|
||||
|
||||
/* Loop Info */
|
||||
|
@ -643,7 +643,7 @@ host_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
|
||||
s2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
double64_peak_update (psf, psf->u.dbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
@ -671,7 +671,7 @@ host_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
bufferlen = (int) len ;
|
||||
i2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
double64_peak_update (psf, psf->u.dbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
@ -699,7 +699,7 @@ host_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
bufferlen = (int) len ;
|
||||
f2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
double64_peak_update (psf, psf->u.dbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
@ -720,7 +720,7 @@ host_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
double64_peak_update (psf, ptr, len, 0) ;
|
||||
|
||||
if (psf->float_endswap != SF_TRUE)
|
||||
@ -874,7 +874,7 @@ replace_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
bufferlen = (int) len ;
|
||||
s2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
double64_peak_update (psf, psf->u.dbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
bd2d_write (psf->u.dbuf, bufferlen) ;
|
||||
@ -904,7 +904,7 @@ replace_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
bufferlen = (int) len ;
|
||||
i2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
double64_peak_update (psf, psf->u.dbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
bd2d_write (psf->u.dbuf, bufferlen) ;
|
||||
@ -955,7 +955,7 @@ replace_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
/* FIXME : This is probably nowhere near optimal. */
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
double64_peak_update (psf, ptr, len, 0) ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
|
||||
|
@ -592,7 +592,7 @@ host_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
bufferlen = (int) len ;
|
||||
s2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
float32_peak_update (psf, psf->u.fbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
@ -620,7 +620,7 @@ host_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
bufferlen = (int) len ;
|
||||
i2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
float32_peak_update (psf, psf->u.fbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
@ -641,7 +641,7 @@ host_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
{ int bufferlen, writecount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
float32_peak_update (psf, ptr, len, 0) ;
|
||||
|
||||
if (psf->float_endswap != SF_TRUE)
|
||||
@ -678,7 +678,7 @@ host_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
|
||||
d2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
float32_peak_update (psf, psf->u.fbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
if (psf->float_endswap == SF_TRUE)
|
||||
@ -824,7 +824,7 @@ replace_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
bufferlen = (int) len ;
|
||||
s2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
float32_peak_update (psf, psf->u.fbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
f2bf_array (psf->u.fbuf, bufferlen) ;
|
||||
@ -854,7 +854,7 @@ replace_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
bufferlen = (int) len ;
|
||||
i2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
float32_peak_update (psf, psf->u.fbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
f2bf_array (psf->u.fbuf, bufferlen) ;
|
||||
@ -878,7 +878,7 @@ replace_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
/* FIX THIS */
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
float32_peak_update (psf, ptr, len, 0) ;
|
||||
|
||||
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
|
||||
@ -916,7 +916,7 @@ replace_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
bufferlen = (int) len ;
|
||||
d2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
|
||||
|
||||
if (psf->has_peak)
|
||||
if (psf->pchunk)
|
||||
float32_peak_update (psf, psf->u.fbuf, bufferlen, (int) (total / psf->sf.channels)) ;
|
||||
|
||||
f2bf_array (psf->u.fbuf, bufferlen) ;
|
||||
|
@ -899,12 +899,13 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
|
||||
return SF_FALSE ;
|
||||
/* If data has already been written this must fail. */
|
||||
if (psf->have_written)
|
||||
return psf->has_peak ;
|
||||
return SF_FALSE ;
|
||||
/* Everything seems OK, so set psf->has_peak and re-write header. */
|
||||
psf->has_peak = (datasize) ? SF_TRUE : SF_FALSE ;
|
||||
if (datasize)
|
||||
return SF_FALSE ;
|
||||
if (psf->write_header)
|
||||
psf->write_header (psf, SF_TRUE) ;
|
||||
return psf->has_peak ;
|
||||
return SF_TRUE ;
|
||||
|
||||
case SFC_GET_LOG_INFO :
|
||||
if (data == NULL)
|
||||
|
@ -189,7 +189,6 @@ wav_open (SF_PRIVATE *psf)
|
||||
{ psf->pchunk = calloc (1, sizeof (PEAK_CHUNK) * psf->sf.channels * sizeof (PEAK_POS)) ;
|
||||
if (psf->pchunk == NULL)
|
||||
return SFE_MALLOC_FAILED ;
|
||||
psf->has_peak = SF_TRUE ;
|
||||
psf->pchunk->peak_loc = SF_PEAK_START ;
|
||||
} ;
|
||||
|
||||
@ -423,7 +422,6 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
|
||||
psf_log_printf (psf, cptr) ;
|
||||
} ;
|
||||
|
||||
psf->has_peak = SF_TRUE ; /* Found PEAK chunk. */
|
||||
psf->pchunk->peak_loc = ((parsestage & HAVE_data) == 0) ? SF_PEAK_START : SF_PEAK_END ;
|
||||
break ;
|
||||
|
||||
@ -792,7 +790,7 @@ wav_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
if (psf->str_flags & SF_STR_LOCATE_START)
|
||||
wav_write_strings (psf, SF_STR_LOCATE_START) ;
|
||||
|
||||
if (psf->has_peak && psf->pchunk->peak_loc == SF_PEAK_START)
|
||||
if (psf->pchunk != NULL && psf->pchunk->peak_loc == SF_PEAK_START)
|
||||
{ psf_binheader_writef (psf, "em4", PEAK_MARKER,
|
||||
sizeof (PEAK_CHUNK) + psf->sf.channels * sizeof (PEAK_POS)) ;
|
||||
psf_binheader_writef (psf, "e44", 1, time (NULL)) ;
|
||||
@ -969,7 +967,7 @@ wavex_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
if (psf->str_flags & SF_STR_LOCATE_START)
|
||||
wav_write_strings (psf, SF_STR_LOCATE_START) ;
|
||||
|
||||
if (psf->has_peak && psf->pchunk->peak_loc == SF_PEAK_START)
|
||||
if (psf->pchunk != NULL && psf->pchunk->peak_loc == SF_PEAK_START)
|
||||
{ psf_binheader_writef (psf, "em4", PEAK_MARKER,
|
||||
sizeof (PEAK_CHUNK) + psf->sf.channels * sizeof (PEAK_POS)) ;
|
||||
psf_binheader_writef (psf, "e44", 1, time (NULL)) ;
|
||||
@ -1005,7 +1003,7 @@ wav_write_tailer (SF_PRIVATE *psf)
|
||||
psf->dataend = psf_fseek (psf, 0, SEEK_END) ;
|
||||
|
||||
/* Add a PEAK chunk if requested. */
|
||||
if (psf->has_peak && psf->pchunk->peak_loc == SF_PEAK_END)
|
||||
if (psf->pchunk != NULL && psf->pchunk->peak_loc == SF_PEAK_END)
|
||||
{ psf_binheader_writef (psf, "em4", PEAK_MARKER,
|
||||
sizeof (PEAK_CHUNK) + psf->sf.channels * sizeof (PEAK_POS)) ;
|
||||
psf_binheader_writef (psf, "e44", 1, time (NULL)) ;
|
||||
|
Loading…
Reference in New Issue
Block a user