Add casts to the speex resampler.

Try to fix

speex/resample.c:294: warning: implicit conversion shortens 64-bit value into a 32-bit value
speex/resample.c:294: warning: implicit conversion shortens 64-bit value into a 32-bit value
speex/resample.c:324: warning: implicit conversion shortens 64-bit value into a 32-bit value
speex/resample.c:419: warning: implicit conversion shortens 64-bit value into a 32-bit value
speex/resample.c:536: warning: implicit conversion shortens 64-bit value into a 32-bit value
speex/resample.c:632: warning: implicit conversion shortens 64-bit value into a 32-bit value
speex/resample.c:638: warning: implicit conversion shortens 64-bit value into a 32-bit value
speex/resample.c:645: warning: implicit conversion shortens 64-bit value into a 32-bit value
speex/resample.c:697: warning: implicit conversion shortens 64-bit value into a 32-bit value
speex/resample.c:699: warning: implicit conversion shortens 64-bit value into a 32-bit value
speex/resample.c:817: warning: implicit conversion shortens 64-bit value into a 32-bit value
speex/resample.c:818: warning: implicit conversion shortens 64-bit value into a 32-bit value
speex/resample.c:819: warning: implicit conversion shortens 64-bit value into a 32-bit value

on the 64-bit OS X builder.

Change-Id: Ifad32f5cd6ffe1186c8f9db593cc1c34e67357ce
Reviewed-on: https://code.wireshark.org/review/10752
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2015-10-02 13:23:08 -07:00
parent be41ebccfe
commit 93d8bbd586
2 changed files with 9 additions and 9 deletions

View File

@ -161,7 +161,7 @@ typedef float spx_word32_t;
#define SHR32(a,shift) (a)
#define SHL32(a,shift) (a)
#define PSHR16(a,shift) (a)
#define PSHR32(a,shift) (a)
#define PSHR32(a,shift) ((spx_word16_t)(a))
#define VSHR32(a,shift) (a)
#define SATURATE16(x,a) (x)
#define SATURATE32(x,a) (x)
@ -183,7 +183,7 @@ typedef float spx_word32_t;
#define MULT16_32_Q11(a,b) ((a)*(b))
#define MULT16_32_Q13(a,b) ((a)*(b))
#define MULT16_32_Q14(a,b) ((a)*(b))
#define MULT16_32_Q15(a,b) ((a)*(b))
#define MULT16_32_Q15(a,b) ((spx_word32_t)((a)*(b)))
#define MULT16_32_P15(a,b) ((a)*(b))
#define MAC16_32_Q11(c,a,b) ((c)+(a)*(b))

View File

@ -64,8 +64,8 @@
#ifdef OUTSIDE_SPEEX
#include <stdlib.h>
static void *speex_alloc (int size) {return calloc(size,1);}
static void *speex_realloc (void *ptr, int size) {return realloc(ptr, size);}
static void *speex_alloc (size_t size) {return calloc(size,1);}
static void *speex_realloc (void *ptr, size_t size) {return realloc(ptr, size);}
static void speex_free (void *ptr) {free(ptr);}
#include "speex_resampler.h"
#include "arch.h"
@ -291,7 +291,7 @@ static spx_word16_t sinc(float cutoff, float x, int N, const struct FuncDef *win
else if (fabs(x) > .5*N)
return 0;
/*FIXME: Can it really be any slower than this? */
return cutoff*sin(M_PI*xx)/(M_PI*xx) * compute_func(fabs(2.*x/N), window_func);
return (spx_word16_t)(cutoff*sin(M_PI*xx)/(M_PI*xx) * compute_func((float)fabs(2.*x/N), window_func));
}
#endif
@ -321,7 +321,7 @@ static void cubic_coef(spx_word16_t frac, spx_word16_t interp[4])
/*interp[2] = 1.f - 0.5f*frac - frac*frac + 0.5f*frac*frac*frac;*/
interp[3] = -0.33333f*frac + 0.5f*frac*frac - 0.16667f*frac*frac*frac;
/* Just to make sure we don't have rounding problems */
interp[2] = 1.-interp[0]-interp[1]-interp[3];
interp[2] = (spx_word16_t)(1.-interp[0]-interp[1]-interp[3]);
}
#endif
@ -629,13 +629,13 @@ static int update_filter(SpeexResamplerState *st)
goto fail;
#else
use_direct = st->filt_len*st->den_rate <= st->filt_len*st->oversample+8
&& INT_MAX/sizeof(spx_word16_t)/st->den_rate >= st->filt_len;
&& INT_MAX/(spx_uint32_t)sizeof(spx_word16_t)/st->den_rate >= st->filt_len;
#endif
if (use_direct)
{
min_sinc_table_length = st->filt_len*st->den_rate;
} else {
if ((INT_MAX/sizeof(spx_word16_t)-8)/st->oversample < st->filt_len)
if ((INT_MAX/(spx_uint32_t)sizeof(spx_word16_t)-8)/st->oversample < st->filt_len)
goto fail;
min_sinc_table_length = st->filt_len*st->oversample+8;
@ -694,7 +694,7 @@ static int update_filter(SpeexResamplerState *st)
if (min_alloc_size > st->mem_alloc_size)
{
spx_word16_t *mem;
if (INT_MAX/sizeof(spx_word16_t)/st->nb_channels < min_alloc_size)
if (INT_MAX/(spx_uint32_t)sizeof(spx_word16_t)/st->nb_channels < min_alloc_size)
goto fail;
else if (!(mem = (spx_word16_t*)speex_realloc(st->mem, st->nb_channels*min_alloc_size * sizeof(*mem))))
goto fail;