ref: a4ca679a65c0aae752f67d0bf97963a61401816c
parent: 189350727fa00559c1a81114595234b3bc1d9713
author: robs <robs>
date: Sat Apr 25 06:29:45 EDT 2009
const correctness
--- a/src/amr-nb.c
+++ b/src/amr-nb.c
@@ -51,5 +51,5 @@
#define E_IF_encode Encoder_Interface_Encode
#define E_IF_exit Encoder_Interface_exit
#define E_IF_init() Encoder_Interface_init(1)
-static unsigned block_size[] = {13,14,16,18,20,21,27,32,6,1,1,1,1,1,1,1};
+static const unsigned block_size[] = {13,14,16,18,20,21,27,32,6,1,1,1,1,1,1,1};
#include "amr.h"
--- a/src/cvsd.c
+++ b/src/cvsd.c
@@ -47,7 +47,7 @@
/* ---------------------------------------------------------------------- */
-static float float_conv(float *fp1, float *fp2,int n)
+static float float_conv(float const *fp1, float const *fp2,int n)
{
float res = 0;
for(; n > 0; n--)
--- a/src/cvsdfilt.h
+++ b/src/cvsdfilt.h
@@ -23,7 +23,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-static float dec_filter_16[48] = {
+static const float dec_filter_16[48] = {
0.001102, 0.001159, 0.000187, -0.000175,
0.002097, 0.006543, 0.009384, 0.008004,
0.006562, 0.013569, 0.030745, 0.047053,
@@ -40,7 +40,7 @@
/* ---------------------------------------------------------------------- */
-static float dec_filter_32[48] = {
+static const float dec_filter_32[48] = {
0.001950, 0.004180, 0.006331, 0.007907,
0.008510, 0.008342, 0.008678, 0.011827,
0.020282, 0.035231, 0.055200, 0.075849,
@@ -57,7 +57,7 @@
/* ---------------------------------------------------------------------- */
-static float enc_filter_16_0[16] = {
+static const float enc_filter_16_0[16] = {
-0.000362, 0.004648, 0.001381, 0.008312,
0.041490, -0.001410, 0.124061, 0.247446,
-0.106761, -0.236326, -0.023798, -0.023506,
@@ -64,7 +64,7 @@
-0.030097, 0.001493, -0.005363, -0.001672
};
-static float enc_filter_16_1[16] = {
+static const float enc_filter_16_1[16] = {
0.001672, 0.005363, -0.001493, 0.030097,
0.023506, 0.023798, 0.236326, 0.106761,
-0.247446, -0.124061, 0.001410, -0.041490,
@@ -71,13 +71,13 @@
-0.008312, -0.001381, -0.004648, 0.000362
};
-static float *enc_filter_16[2] = {
+static const float *enc_filter_16[2] = {
enc_filter_16_0, enc_filter_16_1
};
/* ---------------------------------------------------------------------- */
-static float enc_filter_32_0[16] = {
+static const float enc_filter_32_0[16] = {
-0.000289, 0.002112, 0.001421, 0.002235,
0.021003, 0.001237, 0.047132, 0.129636,
-0.027328, -0.126462, -0.021456, -0.008069,
@@ -84,7 +84,7 @@
-0.017959, 0.000301, -0.002538, -0.001278
};
-static float enc_filter_32_1[16] = {
+static const float enc_filter_32_1[16] = {
-0.000010, 0.002787, 0.000055, 0.006813,
0.020249, -0.000995, 0.077912, 0.112870,
-0.076980, -0.106971, -0.005096, -0.015449,
@@ -91,7 +91,7 @@
-0.012591, 0.000813, -0.003003, -0.000527
};
-static float enc_filter_32_2[16] = {
+static const float enc_filter_32_2[16] = {
0.000527, 0.003003, -0.000813, 0.012591,
0.015449, 0.005096, 0.106971, 0.076980,
-0.112870, -0.077912, 0.000995, -0.020249,
@@ -98,7 +98,7 @@
-0.006813, -0.000055, -0.002787, 0.000010
};
-static float enc_filter_32_3[16] = {
+static const float enc_filter_32_3[16] = {
0.001278, 0.002538, -0.000301, 0.017959,
0.008069, 0.021456, 0.126462, 0.027328,
-0.129636, -0.047132, -0.001237, -0.021003,
@@ -105,7 +105,7 @@
-0.002235, -0.001421, -0.002112, 0.000289
};
-static float *enc_filter_32[4] = {
+static const float *enc_filter_32[4] = {
enc_filter_32_0, enc_filter_32_1, enc_filter_32_2, enc_filter_32_3
};
--- a/src/fft4g.c
+++ b/src/fft4g.c
@@ -308,16 +308,16 @@
static void bitrv2conj(int n, int *ip, double *a);
static void bitrv2(int n, int *ip, double *a);
-static void cft1st(int n, double *a, double *w);
-static void cftbsub(int n, double *a, double *w);
-static void cftfsub(int n, double *a, double *w);
-static void cftmdl(int n, int l, double *a, double *w);
-static void dctsub(int n, double *a, int nc, double *c);
-static void dstsub(int n, double *a, int nc, double *c);
+static void cft1st(int n, double *a, double const *w);
+static void cftbsub(int n, double *a, double const *w);
+static void cftfsub(int n, double *a, double const *w);
+static void cftmdl(int n, int l, double *a, double const *w);
+static void dctsub(int n, double *a, int nc, double const *c);
+static void dstsub(int n, double *a, int nc, double const *c);
static void makect(int nc, int *ip, double *c);
static void makewt(int nw, int *ip, double *w);
-static void rftbsub(int n, double *a, int nc, double *c);
-static void rftfsub(int n, double *a, int nc, double *c);
+static void rftbsub(int n, double *a, int nc, double const *c);
+static void rftfsub(int n, double *a, int nc, double const *c);
void cdft(int n, int isgn, double *a, int *ip, double *w)
@@ -915,7 +915,7 @@
}
-static void cftfsub(int n, double *a, double *w)
+static void cftfsub(int n, double *a, double const *w)
{
int j, j1, j2, j3, l;
double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
@@ -965,7 +965,7 @@
}
-static void cftbsub(int n, double *a, double *w)
+static void cftbsub(int n, double *a, double const *w)
{
int j, j1, j2, j3, l;
double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
@@ -1015,7 +1015,7 @@
}
-static void cft1st(int n, double *a, double *w)
+static void cft1st(int n, double *a, double const *w)
{
int j, k1, k2;
double wk1r, wk1i, wk2r, wk2i, wk3r, wk3i;
@@ -1120,7 +1120,7 @@
}
-static void cftmdl(int n, int l, double *a, double *w)
+static void cftmdl(int n, int l, double *a, double const *w)
{
int j, j1, j2, j3, k, k1, k2, m, m2;
double wk1r, wk1i, wk2r, wk2i, wk3r, wk3i;
@@ -1247,7 +1247,7 @@
}
-static void rftfsub(int n, double *a, int nc, double *c)
+static void rftfsub(int n, double *a, int nc, double const *c)
{
int j, k, kk, ks, m;
double wkr, wki, xr, xi, yr, yi;
@@ -1272,7 +1272,7 @@
}
-static void rftbsub(int n, double *a, int nc, double *c)
+static void rftbsub(int n, double *a, int nc, double const *c)
{
int j, k, kk, ks, m;
double wkr, wki, xr, xi, yr, yi;
@@ -1299,7 +1299,7 @@
}
-static void dctsub(int n, double *a, int nc, double *c)
+static void dctsub(int n, double *a, int nc, double const *c)
{
int j, k, kk, ks, m;
double wkr, wki, xr;
@@ -1320,7 +1320,7 @@
}
-static void dstsub(int n, double *a, int nc, double *c)
+static void dstsub(int n, double *a, int nc, double const *c)
{
int j, k, kk, ks, m;
double wkr, wki, xr;
--- a/src/g711.c
+++ b/src/g711.c
@@ -13,7 +13,7 @@
#include "sox_i.h"
#include "g711.h"
-int16_t lsx_alaw2linear16[256] = {
+const int16_t lsx_alaw2linear16[256] = {
-5504, -5248, -6016, -5760, -4480, -4224, -4992,
-4736, -7552, -7296, -8064, -7808, -6528, -6272,
-7040, -6784, -2752, -2624, -3008, -2880, -2240,
@@ -53,7 +53,7 @@
816, 784, 880, 848
};
-uint8_t lsx_13linear2alaw[0x2000] = {
+const uint8_t lsx_13linear2alaw[0x2000] = {
0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
@@ -739,7 +739,7 @@
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
};
-int16_t lsx_ulaw2linear16[256] = {
+const int16_t lsx_ulaw2linear16[256] = {
-32124, -31100, -30076, -29052, -28028, -27004, -25980,
-24956, -23932, -22908, -21884, -20860, -19836, -18812,
-17788, -16764, -15996, -15484, -14972, -14460, -13948,
@@ -779,7 +779,7 @@
24, 16, 8, 0
};
-uint8_t lsx_14linear2ulaw[0x4000] = {
+const uint8_t lsx_14linear2ulaw[0x4000] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -2157,9 +2157,9 @@
#define SEG_SHIFT (4) /* Left shift for segment number. */
#define SEG_MASK (0x70) /* Segment field mask. */
-static int16_t seg_aend[8] = {0x1F, 0x3F, 0x7F, 0xFF,
+static const int16_t seg_aend[8] = {0x1F, 0x3F, 0x7F, 0xFF,
0x1FF, 0x3FF, 0x7FF, 0xFFF};
-static int16_t seg_uend[8] = {0x3F, 0x7F, 0xFF, 0x1FF,
+static const int16_t seg_uend[8] = {0x3F, 0x7F, 0xFF, 0x1FF,
0x3FF, 0x7FF, 0xFFF, 0x1FFF};
static int16_t search(
--- a/src/g711.h
+++ b/src/g711.h
@@ -10,12 +10,12 @@
* implied warranty.
*/
-extern uint8_t lsx_13linear2alaw[0x2000];
-extern int16_t lsx_alaw2linear16[256];
+extern const uint8_t lsx_13linear2alaw[0x2000];
+extern const int16_t lsx_alaw2linear16[256];
#define sox_13linear2alaw(sw) (lsx_13linear2alaw[((sw) + 0x1000)])
#define sox_alaw2linear16(uc) (lsx_alaw2linear16[uc])
-extern uint8_t lsx_14linear2ulaw[0x4000];
-extern int16_t lsx_ulaw2linear16[256];
+extern const uint8_t lsx_14linear2ulaw[0x4000];
+extern const int16_t lsx_ulaw2linear16[256];
#define sox_14linear2ulaw(sw) (lsx_14linear2ulaw[((sw) + 0x2000)])
#define sox_ulaw2linear16(uc) (lsx_ulaw2linear16[uc])
--- a/src/g721.c
+++ b/src/g721.c
@@ -52,16 +52,16 @@
#include "g72x.h"
#include "g711.h"
-static short qtab_721[7] = {-124, 80, 178, 246, 300, 349, 400};
+static const short qtab_721[7] = {-124, 80, 178, 246, 300, 349, 400};
/*
* Maps G.721 code word to reconstructed scale factor normalized log
* magnitude values.
*/
-static short _dqlntab[16] = {-2048, 4, 135, 213, 273, 323, 373, 425,
+static const short _dqlntab[16] = {-2048, 4, 135, 213, 273, 323, 373, 425,
425, 373, 323, 273, 213, 135, 4, -2048};
/* Maps G.721 code word to log of scale factor multiplier. */
-static short _witab[16] = {-12, 18, 41, 64, 112, 198, 355, 1122,
+static const short _witab[16] = {-12, 18, 41, 64, 112, 198, 355, 1122,
1122, 355, 198, 112, 64, 41, 18, -12};
/*
* Maps G.721 code words to a set of values whose long and short
@@ -68,7 +68,7 @@
* term averages are computed and then compared to give an indication
* how stationary (steady state) the signal is.
*/
-static short _fitab[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00,
+static const short _fitab[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00,
0xE00, 0x600, 0x200, 0x200, 0x200, 0, 0, 0};
/*
--- a/src/g723_24.c
+++ b/src/g723_24.c
@@ -44,10 +44,10 @@
* Maps G.723_24 code word to reconstructed scale factor normalized log
* magnitude values.
*/
-static short _dqlntab[8] = {-2048, 135, 273, 373, 373, 273, 135, -2048};
+static const short _dqlntab[8] = {-2048, 135, 273, 373, 373, 273, 135, -2048};
/* Maps G.723_24 code word to log of scale factor multiplier. */
-static short _witab[8] = {-128, 960, 4384, 18624, 18624, 4384, 960, -128};
+static const short _witab[8] = {-128, 960, 4384, 18624, 18624, 4384, 960, -128};
/*
* Maps G.723_24 code words to a set of values whose long and short
@@ -54,9 +54,9 @@
* term averages are computed and then compared to give an indication
* how stationary (steady state) the signal is.
*/
-static short _fitab[8] = {0, 0x200, 0x400, 0xE00, 0xE00, 0x400, 0x200, 0};
+static const short _fitab[8] = {0, 0x200, 0x400, 0xE00, 0xE00, 0x400, 0x200, 0};
-static short qtab_723_24[3] = {8, 218, 331};
+static const short qtab_723_24[3] = {8, 218, 331};
/*
* g723_24_encoder()
--- a/src/g723_40.c
+++ b/src/g723_40.c
@@ -52,13 +52,13 @@
* Maps G.723_40 code word to ructeconstructed scale factor normalized log
* magnitude values.
*/
-static short _dqlntab[32] = {-2048, -66, 28, 104, 169, 224, 274, 318,
+static const short _dqlntab[32] = {-2048, -66, 28, 104, 169, 224, 274, 318,
358, 395, 429, 459, 488, 514, 539, 566,
566, 539, 514, 488, 459, 429, 395, 358,
318, 274, 224, 169, 104, 28, -66, -2048};
/* Maps G.723_40 code word to log of scale factor multiplier. */
-static short _witab[32] = {448, 448, 768, 1248, 1280, 1312, 1856, 3200,
+static const short _witab[32] = {448, 448, 768, 1248, 1280, 1312, 1856, 3200,
4512, 5728, 7008, 8960, 11456, 14080, 16928, 22272,
22272, 16928, 14080, 11456, 8960, 7008, 5728, 4512,
3200, 1856, 1312, 1280, 1248, 768, 448, 448};
@@ -68,12 +68,12 @@
* term averages are computed and then compared to give an indication
* how stationary (steady state) the signal is.
*/
-static short _fitab[32] = {0, 0, 0, 0, 0, 0x200, 0x200, 0x200,
+static const short _fitab[32] = {0, 0, 0, 0, 0, 0x200, 0x200, 0x200,
0x200, 0x200, 0x400, 0x600, 0x800, 0xA00, 0xC00, 0xC00,
0xC00, 0xC00, 0xA00, 0x800, 0x600, 0x400, 0x200, 0x200,
0x200, 0x200, 0x200, 0, 0, 0, 0, 0};
-static short qtab_723_40[15] = {-122, -16, 68, 139, 198, 250, 298, 339,
+static const short qtab_723_40[15] = {-122, -16, 68, 139, 198, 250, 298, 339,
378, 413, 445, 475, 502, 528, 553};
/*
--- a/src/g72x.c
+++ b/src/g72x.c
@@ -97,7 +97,7 @@
*
* Using linear search for simple coding.
*/
-static int quan(int val, short *table, int size)
+static int quan(int val, short const *table, int size)
{
int i;
@@ -222,7 +222,7 @@
* size scale factor division operation is done in the log base 2 domain
* as a subtraction.
*/
-int quantize(int d, int y, short *table, int size)
+int quantize(int d, int y, short const *table, int size)
{
short dqm; /* Magnitude of 'd' */
short exp; /* Integer part of base 2 log of 'd' */
@@ -496,7 +496,7 @@
* Return:
* adjusted A-law or u-law compressed sample.
*/
-int tandem_adjust_alaw(int sr, int se, int y, int i, int sign, short *qtab)
+int tandem_adjust_alaw(int sr, int se, int y, int i, int sign, short const *qtab)
{
unsigned char sp; /* A-law compressed 8-bit code */
short dx; /* prediction error */
@@ -538,7 +538,7 @@
}
}
-int tandem_adjust_ulaw(int sr, int se, int y, int i, int sign, short *qtab)
+int tandem_adjust_ulaw(int sr, int se, int y, int i, int sign, short const *qtab)
{
unsigned char sp; /* u-law compressed 8-bit code */
short dx; /* prediction error */
--- a/src/g72x.h
+++ b/src/g72x.h
@@ -129,7 +129,7 @@
int step_size(struct g72x_state *state_ptr);
int quantize(int d,
int y,
- short *table,
+ short const *table,
int size);
int reconstruct(int sign,
int dqln,
@@ -147,11 +147,11 @@
int y,
int i,
int sign,
- short *qtab);
+ short const *qtab);
int tandem_adjust_ulaw(int sr,
int se,
int y,
int i,
int sign,
- short *qtab);
+ short const *qtab);
#endif /* !_G72X_H */
--- a/src/skelform.c
+++ b/src/skelform.c
@@ -196,7 +196,7 @@
static const char *names[] = {"skel",NULL };
/* Encoding types and sizes that this handler can write */
- static unsigned encodings[] = {
+ static const unsigned encodings[] = {
SOX_ENCODING_SIGN2, 16, 0,
SOX_ENCODING_UNSIGNED, 8, 0,
0};
--- a/src/smp.c
+++ b/src/smp.c
@@ -66,7 +66,7 @@
char comment[COMMENTLEN + NAMELEN + 3];
} priv_t;
-static char *SVmagic = "SOUND SAMPLE DATA ", *SVvers = "2.1 ";
+static char const *SVmagic = "SOUND SAMPLE DATA ", *SVvers = "2.1 ";
/*
* Read the SampleVision trailer structure.
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -393,7 +393,7 @@
LSX_FORMAT_HANDLER(vorbis)
{
static const char *names[] = {"vorbis", "ogg", NULL};
- static unsigned encodings[] = {SOX_ENCODING_VORBIS, 0, 0};
+ static const unsigned encodings[] = {SOX_ENCODING_VORBIS, 0, 0};
static sox_format_handler_t handler = {SOX_LIB_VERSION_CODE,
"Xiph.org's ogg-vorbis lossy compression", names, 0,
startread, read_samples, stopread,
--- a/src/wav.c
+++ b/src/wav.c
@@ -61,7 +61,7 @@
#define WAVE_FORMAT_EXTENSIBLE (0xfffeU)
/* To allow padding to samplesPerBlock. Works, but currently never true. */
-static size_t pad_nsamps = sox_false;
+static const size_t pad_nsamps = sox_false;
/* Private data for .wav file */
typedef struct {
--- a/src/xa.c
+++ b/src/xa.c
@@ -62,7 +62,7 @@
} priv_t;
/* coefficients for EA ADPCM */
-static int32_t EA_ADPCM_Table[]= {
+static const int32_t EA_ADPCM_Table[]= {
0, 240, 460, 392,
0, 0, -208, -220,
0, 1, 3, 4,