Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xiph/speex.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Matthews <tmatth@videolan.org>2019-03-02 08:50:35 +0300
committerTristan Matthews <tmatth@videolan.org>2019-06-19 05:33:44 +0300
commitc1f82d214872cae4a60c2594cc8c53d11246e3a9 (patch)
tree48095c340df7804d9e27ca4b88c11f119fa84b5b
parenta5ab348fc6e9dd54eb6ad11a3fd02faba624b470 (diff)
math_approx: use unsigned int for LCG pseudorandom generator
This avoids an integer overflow.
-rw-r--r--libspeex/cb_search.c4
-rw-r--r--libspeex/cb_search.h4
-rw-r--r--libspeex/math_approx.h4
-rw-r--r--libspeex/modes.h2
-rw-r--r--libspeex/nb_celp.h2
-rw-r--r--libspeex/sb_celp.h2
6 files changed, 9 insertions, 9 deletions
diff --git a/libspeex/cb_search.c b/libspeex/cb_search.c
index a170fd6..537d964 100644
--- a/libspeex/cb_search.c
+++ b/libspeex/cb_search.c
@@ -524,7 +524,7 @@ const void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
char *stack,
-spx_int32_t *seed
+spx_uint32_t *seed
)
{
int i,j;
@@ -612,7 +612,7 @@ const void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
char *stack,
-spx_int32_t *seed
+spx_uint32_t *seed
)
{
int i;
diff --git a/libspeex/cb_search.h b/libspeex/cb_search.h
index 50b530a..b9b4acc 100644
--- a/libspeex/cb_search.h
+++ b/libspeex/cb_search.h
@@ -70,7 +70,7 @@ const void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
char *stack,
-spx_int32_t *seed
+spx_uint32_t *seed
);
@@ -97,7 +97,7 @@ const void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
char *stack,
-spx_int32_t *seed
+spx_uint32_t *seed
);
#endif
diff --git a/libspeex/math_approx.h b/libspeex/math_approx.h
index 9ca8307..6573113 100644
--- a/libspeex/math_approx.h
+++ b/libspeex/math_approx.h
@@ -46,7 +46,7 @@
#define spx_atan atan
/** Generate a pseudo-random number */
-static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
+static inline spx_word16_t speex_rand(spx_word16_t std, spx_uint32_t *seed)
{
const unsigned int jflone = 0x3f800000;
const unsigned int jflmsk = 0x007fffff;
@@ -119,7 +119,7 @@ static inline spx_int16_t spx_ilog4(spx_uint32_t x)
#ifdef FIXED_POINT
/** Generate a pseudo-random number */
-static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
+static inline spx_word16_t speex_rand(spx_word16_t std, spx_uint32_t *seed)
{
spx_word32_t res;
*seed = 1664525 * *seed + 1013904223;
diff --git a/libspeex/modes.h b/libspeex/modes.h
index 0977a57..cc8cad7 100644
--- a/libspeex/modes.h
+++ b/libspeex/modes.h
@@ -85,7 +85,7 @@ typedef void (*innovation_quant_func)(spx_word16_t *, spx_coef_t *, spx_coef_t *
spx_sig_t *, spx_word16_t *, SpeexBits *, char *, int, int);
/** Innovation unquantization function */
-typedef void (*innovation_unquant_func)(spx_sig_t *, const void *, int, SpeexBits*, char *, spx_int32_t *);
+typedef void (*innovation_unquant_func)(spx_sig_t *, const void *, int, SpeexBits*, char *, spx_uint32_t *);
/** Description of a Speex sub-mode (wither narrowband or wideband */
typedef struct SpeexSubmode {
diff --git a/libspeex/nb_celp.h b/libspeex/nb_celp.h
index a8d3088..1d2f205 100644
--- a/libspeex/nb_celp.h
+++ b/libspeex/nb_celp.h
@@ -149,7 +149,7 @@ typedef struct DecState {
spx_word16_t last_pitch_gain; /**< Pitch gain of last correctly decoded frame */
spx_word16_t pitch_gain_buf[3]; /**< Pitch gain of last decoded frames */
int pitch_gain_buf_idx; /**< Tail of the buffer */
- spx_int32_t seed; /** Seed used for random number generation */
+ spx_uint32_t seed; /** Seed used for random number generation */
int encode_submode;
const SpeexSubmode * const *submodes; /**< Sub-mode data */
diff --git a/libspeex/sb_celp.h b/libspeex/sb_celp.h
index 141d0c2..0474d82 100644
--- a/libspeex/sb_celp.h
+++ b/libspeex/sb_celp.h
@@ -120,7 +120,7 @@ typedef struct SBDecState {
spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */
spx_word16_t last_ener;
- spx_int32_t seed;
+ spx_uint32_t seed;
int encode_submode;
const SpeexSubmode * const *submodes;