mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 01:49:53 +00:00
Whitespace and cstyle fixes.
This commit is contained in:
parent
a6c099e9b6
commit
18c1105981
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2001-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2001-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -7,15 +7,15 @@
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
@ -35,8 +35,8 @@
|
||||
/* Include this header file to use functions from libsndfile. */
|
||||
#include <sndfile.h>
|
||||
|
||||
/* This will be the length of the buffer used to hold.frames while
|
||||
** we process them.
|
||||
/* This will be the length of the buffer used to hold.frames while
|
||||
** we process them.
|
||||
*/
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
@ -49,31 +49,31 @@ static void process_data (double *data, int count, int channels) ;
|
||||
|
||||
int
|
||||
main (void)
|
||||
{ /* This is a buffer of double precision floating point values
|
||||
** which will hold our data while we process it.
|
||||
*/
|
||||
static double data [BUFFER_LEN] ;
|
||||
{ /* This is a buffer of double precision floating point values
|
||||
** which will hold our data while we process it.
|
||||
*/
|
||||
static double data [BUFFER_LEN] ;
|
||||
|
||||
/* A SNDFILE is very much like a FILE in the Standard C library. The
|
||||
** sf_open function return an SNDFILE* pointer when they sucessfully
|
||||
/* A SNDFILE is very much like a FILE in the Standard C library. The
|
||||
** sf_open function return an SNDFILE* pointer when they sucessfully
|
||||
** open the specified file.
|
||||
*/
|
||||
SNDFILE *infile, *outfile ;
|
||||
*/
|
||||
SNDFILE *infile, *outfile ;
|
||||
|
||||
/* A pointer to an SF_INFO stutct is passed to sf_open.
|
||||
** On read, the library fills this struct with information about the file.
|
||||
** On write, the struct must be filled in before calling sf_open.
|
||||
*/
|
||||
SF_INFO sfinfo ;
|
||||
int readcount ;
|
||||
const char *infilename = "input.wav" ;
|
||||
const char *outfilename = "output.wav" ;
|
||||
/* A pointer to an SF_INFO stutct is passed to sf_open.
|
||||
** On read, the library fills this struct with information about the file.
|
||||
** On write, the struct must be filled in before calling sf_open.
|
||||
*/
|
||||
SF_INFO sfinfo ;
|
||||
int readcount ;
|
||||
const char *infilename = "input.wav" ;
|
||||
const char *outfilename = "output.wav" ;
|
||||
|
||||
/* Here's where we open the input file. We pass sf_open the file name and
|
||||
** a pointer to an SF_INFO struct.
|
||||
** On successful open, sf_open returns a SNDFILE* pointer which is used
|
||||
** for all subsequent operations on that file.
|
||||
** If an error occurs during sf_open, the function returns a NULL pointer.
|
||||
/* Here's where we open the input file. We pass sf_open the file name and
|
||||
** a pointer to an SF_INFO struct.
|
||||
** On successful open, sf_open returns a SNDFILE* pointer which is used
|
||||
** for all subsequent operations on that file.
|
||||
** If an error occurs during sf_open, the function returns a NULL pointer.
|
||||
**
|
||||
** If you are trying to open a raw headerless file you will need to set the
|
||||
** format and channels fields of sfinfo before calling sf_open(). For
|
||||
@ -82,56 +82,56 @@ main (void)
|
||||
**
|
||||
** sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16 ;
|
||||
** sfinfo.channels = 2 ;
|
||||
*/
|
||||
if (! (infile = sf_open (infilename, SFM_READ, &sfinfo)))
|
||||
{ /* Open failed so print an error message. */
|
||||
printf ("Not able to open input file %s.\n", infilename) ;
|
||||
/* Print the error message from libsndfile. */
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
*/
|
||||
if (! (infile = sf_open (infilename, SFM_READ, &sfinfo)))
|
||||
{ /* Open failed so print an error message. */
|
||||
printf ("Not able to open input file %s.\n", infilename) ;
|
||||
/* Print the error message from libsndfile. */
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels > MAX_CHANNELS)
|
||||
{ printf ("Not able to process more than %d channels\n", MAX_CHANNELS) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
/* Open the output file. */
|
||||
if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Not able to open output file %s.\n", outfilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
if (sfinfo.channels > MAX_CHANNELS)
|
||||
{ printf ("Not able to process more than %d channels\n", MAX_CHANNELS) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
/* Open the output file. */
|
||||
if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Not able to open output file %s.\n", outfilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* While there are.frames in the input file, read them, process
|
||||
** them and write them to the output file.
|
||||
*/
|
||||
while ((readcount = sf_read_double (infile, data, BUFFER_LEN)))
|
||||
{ process_data (data, readcount, sfinfo.channels) ;
|
||||
sf_write_double (outfile, data, readcount) ;
|
||||
} ;
|
||||
/* While there are.frames in the input file, read them, process
|
||||
** them and write them to the output file.
|
||||
*/
|
||||
while ((readcount = sf_read_double (infile, data, BUFFER_LEN)))
|
||||
{ process_data (data, readcount, sfinfo.channels) ;
|
||||
sf_write_double (outfile, data, readcount) ;
|
||||
} ;
|
||||
|
||||
/* Close input and output files. */
|
||||
sf_close (infile) ;
|
||||
sf_close (outfile) ;
|
||||
/* Close input and output files. */
|
||||
sf_close (infile) ;
|
||||
sf_close (outfile) ;
|
||||
|
||||
return 0 ;
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
static void
|
||||
process_data (double *data, int count, int channels)
|
||||
{ double channel_gain [MAX_CHANNELS] = { 0.5, 0.8, 0.1, 0.4, 0.4, 0.9 } ;
|
||||
int k, chan ;
|
||||
int k, chan ;
|
||||
|
||||
/* Process the data here.
|
||||
** If the soundfile contains more then 1 channel you need to take care of
|
||||
** the data interleaving youself.
|
||||
** Current we just apply a channel dependant gain.
|
||||
*/
|
||||
/* Process the data here.
|
||||
** If the soundfile contains more then 1 channel you need to take care of
|
||||
** the data interleaving youself.
|
||||
** Current we just apply a channel dependant gain.
|
||||
*/
|
||||
|
||||
for (chan = 0 ; chan < channels ; chan ++)
|
||||
for (k = chan ; k < count ; k+= channels)
|
||||
data [k] *= channel_gain [chan] ;
|
||||
for (chan = 0 ; chan < channels ; chan ++)
|
||||
for (k = chan ; k < count ; k+= channels)
|
||||
data [k] *= channel_gain [chan] ;
|
||||
|
||||
return ;
|
||||
return ;
|
||||
} /* process_data */
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -39,7 +39,7 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define BUFFER_LEN (1<<16)
|
||||
#define BUFFER_LEN (1 << 16)
|
||||
|
||||
|
||||
static void concat_data_fp (SNDFILE *wfile, SNDFILE *rofile, int channels) ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -444,7 +444,7 @@ opensoundsys_open_device (int channels, int srate)
|
||||
if (ioctl (fd, SNDCTL_DSP_SETFMT, &fmt) != 0)
|
||||
{ perror ("opensoundsys_open_device : set format ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_CHANNELS, &channels) != 0)
|
||||
{ perror ("opensoundsys_open_device : channels ") ;
|
||||
@ -645,7 +645,7 @@ macosx_play (int argc, char *argv [])
|
||||
|
||||
#if (OS_IS_WIN32 == 1)
|
||||
|
||||
#define WIN32_BUFFER_LEN (1<<15)
|
||||
#define WIN32_BUFFER_LEN (1 << 15)
|
||||
|
||||
typedef struct
|
||||
{ HWAVEOUT hwave ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2010-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2010-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@ -240,7 +240,7 @@ find_data_offset (int fd, int format)
|
||||
|
||||
cptr = memchr (buffer, target [0], rlen - slen) ;
|
||||
if (cptr && memcmp (cptr, target, slen) == 0)
|
||||
offset = cptr - buffer ;
|
||||
offset = cptr - buffer ;
|
||||
else
|
||||
{ printf ("Error : Could not find data offset.\n") ;
|
||||
exit (1) ;
|
||||
|
@ -371,10 +371,10 @@ static unsigned int
|
||||
marker_to_position (const MARK_ID_POS *m, unsigned short n, int marksize)
|
||||
{ int i ;
|
||||
|
||||
for (i = 0 ; i < marksize ; i++)
|
||||
for (i = 0 ; i < marksize ; i++)
|
||||
if (m [i].markerID == n)
|
||||
return m [i].position ;
|
||||
return 0 ;
|
||||
return 0 ;
|
||||
} /* marker_to_position */
|
||||
|
||||
static int
|
||||
@ -876,13 +876,13 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
|
||||
if (instr_found && mark_found)
|
||||
{ int j ;
|
||||
|
||||
for (j = 0 ; j<psf->instrument->loop_count ; j ++)
|
||||
for (j = 0 ; j < psf->instrument->loop_count ; j ++)
|
||||
{ if (j < ARRAY_LEN (psf->instrument->loops))
|
||||
{ psf->instrument->loops [j].start = marker_to_position (paiff->markstr, psf->instrument->loops [j].start, mark_count) ;
|
||||
psf->instrument->loops [j].end = marker_to_position (paiff->markstr, psf->instrument->loops [j].end, mark_count) ;
|
||||
psf->instrument->loops [j].mode = SF_LOOP_FORWARD ;
|
||||
} ;
|
||||
} ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
if (! (found_chunk & HAVE_FORM))
|
||||
|
6
src/au.c
6
src/au.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -81,8 +81,8 @@ typedef struct
|
||||
{ int dataoffset ;
|
||||
int datasize ;
|
||||
int encoding ;
|
||||
int samplerate ;
|
||||
int channels ;
|
||||
int samplerate ;
|
||||
int channels ;
|
||||
} AU_FMT ;
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2003 Ross Bencina <rbencina@iprimus.com.au>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
@ -589,10 +589,10 @@ void
|
||||
psf_fsync (SF_PRIVATE *psf)
|
||||
{
|
||||
#if HAVE_FSYNC
|
||||
if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
|
||||
fsync (psf->file.filedes) ;
|
||||
if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
|
||||
fsync (psf->file.filedes) ;
|
||||
#else
|
||||
psf = NULL ;
|
||||
psf = NULL ;
|
||||
#endif
|
||||
} /* psf_fsync */
|
||||
|
||||
@ -672,7 +672,7 @@ psf_open_rsrc (SF_PRIVATE *psf)
|
||||
psf->error = SFE_NO_ERROR ;
|
||||
if ((psf->rsrc.handle = psf_open_handle (&psf->rsrc)) != NULL)
|
||||
{ psf->rsrclength = psf_get_filelen_handle (psf->rsrc.handle) ;
|
||||
return SFE_NO_ERROR ;
|
||||
return SFE_NO_ERROR ;
|
||||
} ;
|
||||
|
||||
/* No resource file found. */
|
||||
|
49
src/flac.c
49
src/flac.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2004-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2004-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2004 Tobias Gehrig <tgehrig@ira.uka.de>
|
||||
**
|
||||
** This program is free software ; you can redistribute it and/or modify
|
||||
@ -147,8 +147,8 @@ i2flac8_array (const int *src, FLAC__int32 *dest, int count)
|
||||
static void
|
||||
i2flac16_array (const int *src, FLAC__int32 *dest, int count)
|
||||
{
|
||||
while (--count >= 0)
|
||||
dest [count] = src [count] >> 16 ;
|
||||
while (--count >= 0)
|
||||
dest [count] = src [count] >> 16 ;
|
||||
} /* i2flac16_array */
|
||||
|
||||
static void
|
||||
@ -300,7 +300,7 @@ sf_flac_read_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__byte
|
||||
if (*bytes > 0 && psf->error == 0)
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE ;
|
||||
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_ABORT ;
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_ABORT ;
|
||||
} /* sf_flac_read_callback */
|
||||
|
||||
static FLAC__StreamDecoderSeekStatus
|
||||
@ -342,7 +342,7 @@ sf_flac_eof_callback (const FLAC__StreamDecoder *UNUSED (decoder), void *client_
|
||||
if (psf_ftell (psf) == psf->filelength)
|
||||
return SF_TRUE ;
|
||||
|
||||
return SF_FALSE ;
|
||||
return SF_FALSE ;
|
||||
} /* sf_flac_eof_callback */
|
||||
|
||||
static FLAC__StreamDecoderWriteStatus
|
||||
@ -504,7 +504,7 @@ sf_flac_enc_seek_callback (const FLAC__StreamEncoder * UNUSED (encoder), FLAC__u
|
||||
if (psf->error)
|
||||
return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR ;
|
||||
|
||||
return FLAC__STREAM_ENCODER_SEEK_STATUS_OK ;
|
||||
return FLAC__STREAM_ENCODER_SEEK_STATUS_OK ;
|
||||
} /* sf_flac_enc_seek_callback */
|
||||
|
||||
static FLAC__StreamEncoderTellStatus
|
||||
@ -962,7 +962,7 @@ flac_write_s2flac (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
convert (ptr + total, buffer, writecount) ;
|
||||
if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
|
||||
if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount / psf->sf.channels))
|
||||
thiswrite = writecount ;
|
||||
else
|
||||
break ;
|
||||
@ -1004,7 +1004,7 @@ flac_write_i2flac (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
convert (ptr + total, buffer, writecount) ;
|
||||
if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
|
||||
if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount / psf->sf.channels))
|
||||
thiswrite = writecount ;
|
||||
else
|
||||
break ;
|
||||
@ -1046,7 +1046,7 @@ flac_write_f2flac (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
convert (ptr + total, buffer, writecount, psf->norm_float) ;
|
||||
if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
|
||||
if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount / psf->sf.channels))
|
||||
thiswrite = writecount ;
|
||||
else
|
||||
break ;
|
||||
@ -1084,23 +1084,22 @@ f2flac8_clip_array (const float *src, FLAC__int32 *dest, int count, int normaliz
|
||||
|
||||
static void
|
||||
f2flac16_clip_array (const float *src, FLAC__int32 *dest, int count, int normalize)
|
||||
{
|
||||
float normfact, scaled_value ;
|
||||
{ float normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x1000) : 1.0 ;
|
||||
normfact = normalize ? (8.0 * 0x1000) : 1.0 ;
|
||||
|
||||
while (--count >= 0) {
|
||||
scaled_value = src [count] * normfact ;
|
||||
if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFF)) {
|
||||
dest [count] = 0x7FFF ;
|
||||
continue ;
|
||||
}
|
||||
if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x1000)) {
|
||||
dest [count] = 0x8000 ;
|
||||
continue ;
|
||||
}
|
||||
dest [count] = lrintf (scaled_value) ;
|
||||
}
|
||||
while (--count >= 0)
|
||||
{ scaled_value = src [count] * normfact ;
|
||||
if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFF))
|
||||
{ dest [count] = 0x7FFF ;
|
||||
continue ;
|
||||
} ;
|
||||
if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x1000))
|
||||
{ dest [count] = 0x8000 ;
|
||||
continue ;
|
||||
} ;
|
||||
dest [count] = lrintf (scaled_value) ;
|
||||
} ;
|
||||
} /* f2flac16_clip_array */
|
||||
|
||||
static void
|
||||
@ -1178,7 +1177,7 @@ flac_write_d2flac (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
||||
while (len > 0)
|
||||
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
||||
convert (ptr + total, buffer, writecount, psf->norm_double) ;
|
||||
if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
|
||||
if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount / psf->sf.channels))
|
||||
thiswrite = writecount ;
|
||||
else
|
||||
break ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -452,7 +452,7 @@ gsm610_wav_encode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610)
|
||||
|
||||
/* Encode the samples. */
|
||||
gsm_encode (pgsm610->gsm_data, pgsm610->samples, pgsm610->block) ;
|
||||
gsm_encode (pgsm610->gsm_data, pgsm610->samples+WAV_W64_GSM610_SAMPLES/2, pgsm610->block+WAV_W64_GSM610_BLOCKSIZE/2) ;
|
||||
gsm_encode (pgsm610->gsm_data, pgsm610->samples+WAV_W64_GSM610_SAMPLES / 2, pgsm610->block+WAV_W64_GSM610_BLOCKSIZE / 2) ;
|
||||
|
||||
/* Write the block to disk. */
|
||||
if ((k = psf_fwrite (pgsm610->block, 1, WAV_W64_GSM610_BLOCKSIZE, psf)) != WAV_W64_GSM610_BLOCKSIZE)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -50,9 +50,9 @@ typedef struct IMA_ADPCM_PRIVATE_tag
|
||||
|
||||
static int ima_indx_adjust [16] =
|
||||
{ -1, -1, -1, -1, /* +0 - +3, decrease the step size */
|
||||
2, 4, 6, 8, /* +4 - +7, increase the step size */
|
||||
-1, -1, -1, -1, /* -0 - -3, decrease the step size */
|
||||
2, 4, 6, 8, /* -4 - -7, increase the step size */
|
||||
+2, +4, +6, +8, /* +4 - +7, increase the step size */
|
||||
-1, -1, -1, -1, /* -0 - -3, decrease the step size */
|
||||
+2, +4, +6, +8, /* -4 - -7, increase the step size */
|
||||
} ;
|
||||
|
||||
static int ima_step_size [89] =
|
||||
@ -202,7 +202,7 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
|
||||
psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset :
|
||||
psf->filelength - psf->dataoffset ;
|
||||
|
||||
if (pima->blocksize == 0)
|
||||
if (pima->blocksize == 0)
|
||||
{ psf_log_printf (psf, "*** Error : pima->blocksize should not be zero.\n") ;
|
||||
return SFE_INTERNAL ;
|
||||
} ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2007-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (c) 2007 <robs@users.sourceforge.net>
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or modify it
|
||||
@ -77,7 +77,7 @@ adpcm_decode (IMA_OKI_ADPCM * state, int code)
|
||||
s = ((state->steps [state->step_index] * s) >> 3) & state->mask ;
|
||||
|
||||
if (code & 8)
|
||||
s = -s ;
|
||||
s = -s ;
|
||||
s += state->last_output ;
|
||||
|
||||
if (s < MIN_SAMPLE || s > MAX_SAMPLE)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -206,9 +206,9 @@ msadpcm_decode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms)
|
||||
{ int chan, k, blockindx, sampleindx ;
|
||||
short bytecode, bpred [2], chan_idelta [2] ;
|
||||
|
||||
int predict ;
|
||||
int current ;
|
||||
int idelta ;
|
||||
int predict ;
|
||||
int current ;
|
||||
int idelta ;
|
||||
|
||||
pms->blockcount ++ ;
|
||||
pms->samplecount = 0 ;
|
||||
@ -277,7 +277,7 @@ msadpcm_decode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms)
|
||||
sampleindx = 2 * pms->channels ;
|
||||
while (blockindx < pms->blocksize)
|
||||
{ bytecode = pms->block [blockindx++] ;
|
||||
pms->samples [sampleindx++] = (bytecode >> 4) & 0x0F ;
|
||||
pms->samples [sampleindx++] = (bytecode >> 4) & 0x0F ;
|
||||
pms->samples [sampleindx++] = bytecode & 0x0F ;
|
||||
} ;
|
||||
|
||||
@ -296,7 +296,7 @@ msadpcm_decode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms)
|
||||
if (bytecode & 0x8)
|
||||
bytecode -= 0x10 ;
|
||||
|
||||
predict = ((pms->samples [k - pms->channels] * AdaptCoeff1 [bpred [chan]])
|
||||
predict = ((pms->samples [k - pms->channels] * AdaptCoeff1 [bpred [chan]])
|
||||
+ (pms->samples [k - 2 * pms->channels] * AdaptCoeff2 [bpred [chan]])) >> 8 ; /* => / 256 => FIXED_POINT_COEFF_BASE == 256 */
|
||||
current = (bytecode * idelta) + predict ;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2008-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software ; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -310,7 +310,7 @@ spx_header_read (SF_PRIVATE * psf, ogg_packet *op, spx_int32_t enh_enabled, int
|
||||
if (!psf->sf.samplerate)
|
||||
psf->sf.samplerate = spx->header.rate ;
|
||||
/* Adjust rate if --force-* options are used */
|
||||
if (force_mode!=-1)
|
||||
if (force_mode != -1)
|
||||
{ if (spx->header.mode < force_mode)
|
||||
{ psf->sf.samplerate <<= (force_mode - spx->header.mode) ;
|
||||
spx->granule_frame_size >>= (force_mode - spx->header.mode) ;
|
||||
@ -360,7 +360,7 @@ spx_print_comments (const char *c, int length)
|
||||
int len, i, nb_fields ;
|
||||
|
||||
printf ("%s %d\n", __func__, __LINE__) ;
|
||||
if (length<8)
|
||||
if (length < 8)
|
||||
{ fprintf (stderr, "Invalid/corrupted comments\n") ;
|
||||
return ;
|
||||
}
|
||||
@ -381,7 +381,7 @@ printf ("%s %d\n", __func__, __LINE__) ;
|
||||
nb_fields = readint (c, 0) ;
|
||||
c += 4 ;
|
||||
for (i = 0 ; i < nb_fields ; i++)
|
||||
{ if (c+4>end)
|
||||
{ if (c + 4 > end)
|
||||
{ fprintf (stderr, "Invalid/corrupted comments\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002-2005 Michael Smith <msmith@xiph.org>
|
||||
** Copyright (C) 2007 John ffitch
|
||||
**
|
||||
@ -670,14 +670,15 @@ vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *t
|
||||
{ /* we have a packet. Decode it */
|
||||
if (vorbis_synthesis (&vdata->vblock, &odata->opacket) == 0) /* test for success! */
|
||||
vorbis_synthesis_blockin (&vdata->vdsp, &vdata->vblock) ;
|
||||
/*
|
||||
**pcm is a multichannel float vector. In stereo, for
|
||||
example, pcm [0] is left, and pcm [1] is right. samples is
|
||||
the size of each channel. Convert the float values
|
||||
(-1.<=range<=1.) to whatever PCM format and write it out */
|
||||
/*
|
||||
** pcm is a multichannel float vector. In stereo, for
|
||||
** example, pcm [0] is left, and pcm [1] is right. samples is
|
||||
** the size of each channel. Convert the float values
|
||||
** (-1.<=range<=1.) to whatever PCM format and write it out.
|
||||
*/
|
||||
|
||||
while ((samples = vorbis_synthesis_pcmout (&vdata->vdsp, &pcm)) > 0)
|
||||
{ if (samples>len) samples = len ;
|
||||
{ if (samples > len) samples = len ;
|
||||
i += transfn (samples, ptr, i, psf->sf.channels, pcm) ;
|
||||
len -= samples ;
|
||||
/* tell libvorbis how many samples we actually consumed */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -52,8 +52,8 @@
|
||||
typedef struct
|
||||
{ int version ;
|
||||
int endianness ;
|
||||
int samplerate ;
|
||||
int format ;
|
||||
int samplerate ;
|
||||
int format ;
|
||||
int channels ;
|
||||
int source ;
|
||||
} PAF_FMT ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2008-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2009 Uli Franke <cls@nebadje.org>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
@ -632,7 +632,7 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
{ int type ;
|
||||
|
||||
type = psf->instrument->loops [tmp].mode ;
|
||||
type = (type == SF_LOOP_FORWARD ? 0 : type==SF_LOOP_BACKWARD ? 2 : type == SF_LOOP_ALTERNATING ? 1 : 32) ;
|
||||
type = (type == SF_LOOP_FORWARD ? 0 : type == SF_LOOP_BACKWARD ? 2 : type == SF_LOOP_ALTERNATING ? 1 : 32) ;
|
||||
|
||||
psf_binheader_writef (psf, "44", tmp, type) ;
|
||||
psf_binheader_writef (psf, "44", psf->instrument->loops [tmp].start, psf->instrument->loops [tmp].end) ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
enum
|
||||
{
|
||||
/* keep sorted for wav_w64_format_str() */
|
||||
/* keep sorted for wav_w64_format_str() */
|
||||
WAVE_FORMAT_UNKNOWN = 0x0000, /* Microsoft Corporation */
|
||||
WAVE_FORMAT_PCM = 0x0001, /* Microsoft PCM format */
|
||||
WAVE_FORMAT_MS_ADPCM = 0x0002, /* Microsoft ADPCM */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -189,48 +189,48 @@ unsigned char alaw_encode (int sample)
|
||||
7, 7, 7, 7, 7, 7, 7, 7
|
||||
} ;
|
||||
|
||||
int sign, exponent, mantissa ;
|
||||
unsigned char Alawbyte ;
|
||||
int sign, exponent, mantissa ;
|
||||
unsigned char Alawbyte ;
|
||||
|
||||
/* Get the sample into sign-magnitude. */
|
||||
sign = ((~sample) >> 8) & 0x80 ; /* set aside the sign */
|
||||
if (sign == 0)
|
||||
/* Get the sample into sign-magnitude. */
|
||||
sign = ((~sample) >> 8) & 0x80 ; /* set aside the sign */
|
||||
if (sign == 0)
|
||||
sample = -sample ; /* get magnitude */
|
||||
if (sample > ACLIP)
|
||||
if (sample > ACLIP)
|
||||
sample = ACLIP ; /* clip the magnitude */
|
||||
|
||||
/* Convert from 16 bit linear to ulaw. */
|
||||
if (sample >= 256)
|
||||
/* Convert from 16 bit linear to ulaw. */
|
||||
if (sample >= 256)
|
||||
{ exponent = exp_lut [(sample >> 8) & 0x7F] ;
|
||||
mantissa = ( sample >> ( exponent + 3 ) ) & 0x0F ;
|
||||
Alawbyte = ((exponent << 4) | mantissa) ;
|
||||
}
|
||||
else
|
||||
else
|
||||
Alawbyte = (sample >> 4) ;
|
||||
|
||||
Alawbyte ^= (sign ^ 0x55) ;
|
||||
|
||||
return Alawbyte ;
|
||||
return Alawbyte ;
|
||||
} /* alaw_encode */
|
||||
|
||||
static
|
||||
int alaw_decode (unsigned int Alawbyte)
|
||||
{ static int exp_lut [8] = { 0, 264, 528, 1056, 2112, 4224, 8448, 16896 } ;
|
||||
int sign, exponent, mantissa, sample ;
|
||||
int sign, exponent, mantissa, sample ;
|
||||
|
||||
Alawbyte ^= 0x55 ;
|
||||
sign = (Alawbyte & 0x80) ;
|
||||
Alawbyte &= 0x7f ; /* get magnitude */
|
||||
if (Alawbyte >= 16)
|
||||
Alawbyte ^= 0x55 ;
|
||||
sign = (Alawbyte & 0x80) ;
|
||||
Alawbyte &= 0x7f ; /* get magnitude */
|
||||
if (Alawbyte >= 16)
|
||||
{ exponent = (Alawbyte >> 4 ) & 0x07 ;
|
||||
mantissa = Alawbyte & 0x0F ;
|
||||
sample = exp_lut [exponent] + (mantissa << ( exponent + 3 )) ;
|
||||
}
|
||||
else
|
||||
else
|
||||
sample = (Alawbyte << 4) + 8 ;
|
||||
if (sign == 0)
|
||||
if (sign == 0)
|
||||
sample = -sample ;
|
||||
|
||||
return sample ;
|
||||
return sample ;
|
||||
} /* alaw_decode */
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2001-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2001-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define BUFFER_LEN (1<<10)
|
||||
#define BUFFER_LEN (1 << 10)
|
||||
#define LOG_BUFFER_SIZE 1024
|
||||
|
||||
static void float_norm_test (const char *filename) ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2003-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2003-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define BUFFER_LEN (1<<16)
|
||||
#define BUFFER_LEN (1 << 16)
|
||||
#define LOG_BUFFER_SIZE 1024
|
||||
|
||||
static void dither_test (const char *filename, int filetype) ;
|
||||
@ -52,7 +52,7 @@ main (int argc, char *argv [])
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
do_all=!strcmp (argv [1], "all") ;
|
||||
do_all =! strcmp (argv [1], "all") ;
|
||||
|
||||
if (do_all || ! strcmp (argv [1], "wav"))
|
||||
{ dither_test ("dither.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8) ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define BUFFER_SIZE (1<<15)
|
||||
#define BUFFER_SIZE (1 << 15)
|
||||
#define SHORT_BUFFER (256)
|
||||
|
||||
static void
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define BUFFER_SIZE (1<<14) /* Should be (1<<14) */
|
||||
#define BUFFER_SIZE (1 << 14)
|
||||
#define SAMPLE_RATE (11025)
|
||||
|
||||
#ifndef M_PI
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define BUFFER_SIZE (1<<14) /* Should be (1<<14) */
|
||||
#define BUFFER_SIZE (1 << 14)
|
||||
#define SAMPLE_RATE 11025
|
||||
|
||||
#ifndef M_PI
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2001-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2001-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software ; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -43,7 +43,7 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define BUFFER_LEN (1<<10)
|
||||
#define BUFFER_LEN (1 << 10)
|
||||
#define LOG_BUFFER_SIZE 1024
|
||||
|
||||
static void zero_data_test (const char *filename, int format) ;
|
||||
@ -65,7 +65,7 @@ main (int argc, char *argv [])
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
do_all=!strcmp (argv [1], "all") ;
|
||||
do_all =! strcmp (argv [1], "all") ;
|
||||
|
||||
if (do_all || ! strcmp (argv [1], "wav"))
|
||||
{ zero_data_test ("zerolen.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2007-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -266,7 +266,7 @@ ogg_stereo_seek_test (const char * filename, int format)
|
||||
gen_windowed_sine_float (data, ARRAY_LEN (data), 0.95) ;
|
||||
for (k = 0 ; k < ARRAY_LEN (data) ; k++)
|
||||
{ stereo_out [2 * k] = data [k] ;
|
||||
stereo_out [2 * k + 1] = data [ARRAY_LEN (data) - k - 1] ;
|
||||
stereo_out [2 * k + 1] = data [ARRAY_LEN (data) - k - 1] ;
|
||||
} ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
@ -1,6 +1,6 @@
|
||||
[+ AutoGen5 template c +]
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define BUFFER_SIZE (1<<12)
|
||||
#define BUFFER_SIZE (1 << 12)
|
||||
|
||||
static void lrintf_test (void) ;
|
||||
|
||||
@ -403,7 +403,7 @@ pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_f
|
||||
int sign ;
|
||||
double *data, error ;
|
||||
|
||||
print_test_name (replace_float ? "pcm_test_float (replace)" : "pcm_test_float", filename) ;
|
||||
print_test_name (replace_float ? "pcm_test_float (replace)" : "pcm_test_float", filename) ;
|
||||
|
||||
items = BUFFER_SIZE ;
|
||||
|
||||
@ -659,7 +659,7 @@ pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_
|
||||
|
||||
/* This is the best test routine. Other should be brought up to this standard. */
|
||||
|
||||
print_test_name (replace_float ? "pcm_test_double (replace)" : "pcm_test_double", filename) ;
|
||||
print_test_name (replace_float ? "pcm_test_double (replace)" : "pcm_test_double", filename) ;
|
||||
|
||||
items = BUFFER_SIZE ;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2001-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2001-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define BUFFER_LEN (1<<15)
|
||||
#define BUFFER_LEN (1 << 15)
|
||||
#define LOG_BUFFER_SIZE 1024
|
||||
|
||||
|
||||
@ -305,56 +305,55 @@ check_logged_peaks (char *buffer)
|
||||
static void
|
||||
read_write_peak_test (const char *filename, int filetype)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
double small_data [10] ;
|
||||
double max_peak = 0.0 ;
|
||||
unsigned k ;
|
||||
double small_data [10], max_peak = 0.0 ;
|
||||
unsigned k ;
|
||||
|
||||
print_test_name (__func__, filename) ;
|
||||
|
||||
for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++)
|
||||
small_data [k] = 0.1 ;
|
||||
for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++)
|
||||
small_data [k] = 0.1 ;
|
||||
|
||||
sfinfo.samplerate = 44100 ;
|
||||
sfinfo.channels = 2 ;
|
||||
sfinfo.format = filetype ;
|
||||
sfinfo.frames = 0 ;
|
||||
sfinfo.samplerate = 44100 ;
|
||||
sfinfo.channels = 2 ;
|
||||
sfinfo.format = filetype ;
|
||||
sfinfo.frames = 0 ;
|
||||
|
||||
/* Open the file, add peak chunk and write samples with value 0.1. */
|
||||
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
|
||||
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
|
||||
|
||||
sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ;
|
||||
sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ;
|
||||
|
||||
test_write_double_or_die (file, 0, small_data, ARRAY_LEN (small_data), __LINE__) ;
|
||||
|
||||
sf_close (file) ;
|
||||
sf_close (file) ;
|
||||
|
||||
/* Open the fiel RDWR, write sample valied 1.25. */
|
||||
file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
|
||||
/* Open the fiel RDWR, write sample valied 1.25. */
|
||||
file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
|
||||
|
||||
for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++)
|
||||
small_data [k] = 1.0 ;
|
||||
for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++)
|
||||
small_data [k] = 1.0 ;
|
||||
|
||||
test_write_double_or_die (file, 0, small_data, ARRAY_LEN (small_data), __LINE__) ;
|
||||
|
||||
sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (max_peak)) ;
|
||||
sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (max_peak)) ;
|
||||
|
||||
sf_close (file) ;
|
||||
sf_close (file) ;
|
||||
|
||||
exit_if_true (max_peak < 0.1, "\n\nLine %d : max peak (%5.3f) should not be 0.1.\n\n", __LINE__, max_peak) ;
|
||||
exit_if_true (max_peak < 0.1, "\n\nLine %d : max peak (%5.3f) should not be 0.1.\n\n", __LINE__, max_peak) ;
|
||||
|
||||
/* Open the file and test the values written to the PEAK chunk. */
|
||||
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
|
||||
/* Open the file and test the values written to the PEAK chunk. */
|
||||
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
|
||||
|
||||
exit_if_true (sfinfo.channels * sfinfo.frames != 2 * ARRAY_LEN (small_data),
|
||||
"Line %d : frame count is %ld, should be %d\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * ARRAY_LEN (small_data)) ;
|
||||
|
||||
sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (double)) ;
|
||||
sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (double)) ;
|
||||
|
||||
sf_close (file) ;
|
||||
sf_close (file) ;
|
||||
|
||||
exit_if_true (max_peak < 1.0, "\n\nLine %d : max peak (%5.3f) should be 1.0.\n\n", __LINE__, max_peak) ;
|
||||
exit_if_true (max_peak < 1.0, "\n\nLine %d : max peak (%5.3f) should be 1.0.\n\n", __LINE__, max_peak) ;
|
||||
|
||||
unlink (filename) ;
|
||||
puts ("ok") ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define BUFFER_LEN (1<<10)
|
||||
#define BUFFER_LEN (1 << 10)
|
||||
#define LOG_BUFFER_SIZE 1024
|
||||
|
||||
static void raw_offset_test (const char *filename, int typeminor) ;
|
||||
|
@ -1,6 +1,6 @@
|
||||
[+ AutoGen5 template c +]
|
||||
/*
|
||||
** Copyright (C) 2010-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2010-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software ; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -70,8 +70,8 @@ main (void)
|
||||
rdwr_[+ (get "name") +]_test (const char *filename)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
sf_count_t frames ;
|
||||
[+ (get "type") +] buffer [160] ;
|
||||
sf_count_t frames ;
|
||||
[+ (get "type") +] buffer [160] ;
|
||||
|
||||
print_test_name ("rdwr_[+ (get "name") +]_test", filename) ;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2001-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2001-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define BUFFER_LEN (1<<16)
|
||||
#define BUFFER_LEN (1 << 16)
|
||||
|
||||
static void stdin_test (int typemajor, int count) ;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -203,21 +203,21 @@ unsigned char ulaw_encode (int sample)
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
|
||||
} ;
|
||||
|
||||
int sign, exponent, mantissa ;
|
||||
unsigned char ulawbyte ;
|
||||
int sign, exponent, mantissa ;
|
||||
unsigned char ulawbyte ;
|
||||
|
||||
/* Get the sample into sign-magnitude. */
|
||||
sign = (sample >> 8) & 0x80 ; /* set aside the sign */
|
||||
if ( sign != 0 )
|
||||
/* Get the sample into sign-magnitude. */
|
||||
sign = (sample >> 8) & 0x80 ; /* set aside the sign */
|
||||
if ( sign != 0 )
|
||||
sample = -sample ; /* get magnitude */
|
||||
if ( sample > uCLIP )
|
||||
if ( sample > uCLIP )
|
||||
sample = uCLIP ; /* clip the magnitude */
|
||||
|
||||
/* Convert from 16 bit linear to ulaw. */
|
||||
sample = sample + uBIAS ;
|
||||
exponent = exp_lut [( sample >> 7 ) & 0xFF] ;
|
||||
mantissa = (sample >> ( exponent + 3 ) ) & 0x0F ;
|
||||
ulawbyte = ~ (sign | ( exponent << 4 ) | mantissa) ;
|
||||
/* Convert from 16 bit linear to ulaw. */
|
||||
sample = sample + uBIAS ;
|
||||
exponent = exp_lut [( sample >> 7 ) & 0xFF] ;
|
||||
mantissa = (sample >> ( exponent + 3 ) ) & 0x0F ;
|
||||
ulawbyte = ~ (sign | ( exponent << 4 ) | mantissa) ;
|
||||
|
||||
return ulawbyte ;
|
||||
} /* ulaw_encode */
|
||||
@ -242,16 +242,16 @@ unsigned char ulaw_encode (int sample)
|
||||
static
|
||||
int ulaw_decode (unsigned int ulawbyte)
|
||||
{ static int exp_lut [8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 } ;
|
||||
int sign, exponent, mantissa, sample ;
|
||||
int sign, exponent, mantissa, sample ;
|
||||
|
||||
ulawbyte = ~ ulawbyte ;
|
||||
sign = (ulawbyte & 0x80) ;
|
||||
exponent = (ulawbyte >> 4) & 0x07 ;
|
||||
mantissa = ulawbyte & 0x0F ;
|
||||
sample = exp_lut [exponent] + (mantissa << (exponent + 3)) ;
|
||||
if (sign != 0)
|
||||
ulawbyte = ~ ulawbyte ;
|
||||
sign = (ulawbyte & 0x80) ;
|
||||
exponent = (ulawbyte >> 4) & 0x07 ;
|
||||
mantissa = ulawbyte & 0x0F ;
|
||||
sample = exp_lut [exponent] + (mantissa << (exponent + 3)) ;
|
||||
if (sign != 0)
|
||||
sample = -sample ;
|
||||
|
||||
return sample ;
|
||||
return sample ;
|
||||
} /* ulaw_decode */
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[+ AutoGen5 template h c +]
|
||||
/*
|
||||
** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -725,7 +725,7 @@ compare_[+ (get "io_element") +]_or_die (const [+ (get "io_element") +] *left, c
|
||||
{
|
||||
unsigned k ;
|
||||
|
||||
for (k = 0 ; k < count ;k++)
|
||||
for (k = 0 ; k < count ; k++)
|
||||
if (left [k] != right [k])
|
||||
{ printf ("\n\nLine %d : Error at index %d, " [+ (get "format_str") +] " should be " [+ (get "format_str") +] ".\n\n", line_num, k, left [k], right [k]) ;
|
||||
exit (1) ;
|
||||
|
@ -1,6 +1,6 @@
|
||||
[+ AutoGen5 template c +]
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
@ -35,7 +35,7 @@
|
||||
#include "generate.h"
|
||||
|
||||
#define SAMPLE_RATE 11025
|
||||
#define DATA_LENGTH (1<<12)
|
||||
#define DATA_LENGTH (1 << 12)
|
||||
|
||||
#define SILLY_WRITE_COUNT (234)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user