diff options
author | Mark Harris <mark.hsj@gmail.com> | 2017-02-20 19:51:40 -0800 |
---|---|---|
committer | Mark Harris <mark.hsj@gmail.com> | 2017-02-26 19:10:45 -0800 |
commit | d6d70371e85ec83307f6df0e067d353daa8e6f33 (patch) | |
tree | 9e118ef0267e2e0734cc9db4c5bbd6016aa0e089 /src | |
parent | 8056706f48880bbf0bb7ee842f1067b85f613353 (diff) | |
download | opus-d6d70371e85ec83307f6df0e067d353daa8e6f33.tar.gz |
Fix compiler warnings
- celt/modes.c:430:14: warning: cast from 'const unsigned char *' to
'opus_int16 *' increases required alignment from 1 to 2 [-Wcast-align]
- 'C[0][1]' may be used uninitialized [-Wmaybe-uninitialized]
- Unused variable/parameter
- Value stored is never read
- MSVC warnings about "possible loss of data" due to type conversions
- MSVC warning C4146: unary minus operator applied to unsigned type
- silk/NLSF_del_dec_quant.c:137:20: warning: array subscript is above
array bounds [-Warray-bounds] (gcc -O3 false positive)
- src/mlp_train.h:39:20: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
- Remove SMALL_FOOTPRINT code from SSE 4.1 FIR implementation, matching
the C implementation.
The clang -Wcast-align warnings with SSE intrinsics are a known
clang issue: https://llvm.org/bugs/show_bug.cgi?id=20670
Diffstat (limited to 'src')
-rw-r--r-- | src/analysis.c | 50 | ||||
-rw-r--r-- | src/mlp_data.c | 20 | ||||
-rw-r--r-- | src/mlp_train.c | 8 | ||||
-rw-r--r-- | src/mlp_train.h | 4 | ||||
-rw-r--r-- | src/opus.c | 2 | ||||
-rw-r--r-- | src/opus_demo.c | 21 | ||||
-rw-r--r-- | src/opus_encoder.c | 2 |
7 files changed, 56 insertions, 51 deletions
diff --git a/src/analysis.c b/src/analysis.c index 3e8a23bd..63d3b732 100644 --- a/src/analysis.c +++ b/src/analysis.c @@ -48,6 +48,8 @@ #define M_PI 3.141592653 #endif +#ifndef DISABLE_FLOAT_API + static const float dct_table[128] = { 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, @@ -151,7 +153,7 @@ static opus_val32 silk_resampler_down2_hp( /* len2 can be up to 480, so we shift by 8 more to make it fit. */ hp_ener = hp_ener >> (2*SIG_SHIFT + 8); #endif - return hp_ener; + return (opus_val32)hp_ener; } static opus_val32 downmix_and_resample(downmix_func downmix, const void *_x, opus_val32 *y, opus_val32 S[3], int subframe, int offset, int c1, int c2, int C, int Fs) @@ -256,7 +258,7 @@ void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int pos = 0; if (pos == tonal->write_pos) break; - info_out->tonality = MAX32(0, -.03 + MAX32(info_out->tonality, tonal->info[pos].tonality-.05)); + info_out->tonality = MAX32(0, -.03f + MAX32(info_out->tonality, tonal->info[pos].tonality-.05f)); } tonal->read_subframe += len/(tonal->Fs/400); while (tonal->read_subframe>=8) @@ -284,8 +286,8 @@ void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int } static const float std_feature_bias[9] = { - 5.684947, 3.475288, 1.770634, 1.599784, 3.773215, - 2.163313, 1.260756, 1.116868, 1.918795 + 5.684947f, 3.475288f, 1.770634f, 1.599784f, 3.773215f, + 2.163313f, 1.260756f, 1.116868f, 1.918795f }; static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix) @@ -346,7 +348,8 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt kfft = celt_mode->mdct.kfft[0]; if (tonal->count==0) tonal->mem_fill = 240; - tonal->hp_ener_accum += downmix_and_resample(downmix, x, &tonal->inmem[tonal->mem_fill], tonal->downmix_state, + tonal->hp_ener_accum += (float)downmix_and_resample(downmix, x, + &tonal->inmem[tonal->mem_fill], tonal->downmix_state, IMIN(len, ANALYSIS_BUF_SIZE-tonal->mem_fill), offset, c1, c2, C, tonal->Fs); if (tonal->mem_fill+len < ANALYSIS_BUF_SIZE) { @@ -374,8 +377,9 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt } OPUS_MOVE(tonal->inmem, tonal->inmem+ANALYSIS_BUF_SIZE-240, 240); remaining = len - (ANALYSIS_BUF_SIZE-tonal->mem_fill); - tonal->hp_ener_accum = downmix_and_resample(downmix, x, &tonal->inmem[240], tonal->downmix_state, - remaining, offset+ANALYSIS_BUF_SIZE-tonal->mem_fill, c1, c2, C, tonal->Fs); + tonal->hp_ener_accum = (float)downmix_and_resample(downmix, x, + &tonal->inmem[240], tonal->downmix_state, remaining, + offset+ANALYSIS_BUF_SIZE-tonal->mem_fill, c1, c2, C, tonal->Fs); tonal->mem_fill = 240 + remaining; opus_fft(kfft, in, out, tonal->arch); #ifndef FIXED_POINT @@ -430,7 +434,7 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt for (i=2;i<N2-1;i++) { float tt = MIN32(tonality2[i], MAX32(tonality2[i-1], tonality2[i+1])); - tonality[i] = .9*MAX32(tonality[i], tt-.1); + tonality[i] = .9f*MAX32(tonality[i], tt-.1f); } frame_tonality = 0; max_frame_tonality = 0; @@ -486,9 +490,9 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt if (tonal->highE[b] > tonal->lowE[b] + 7.5) { if (tonal->highE[b] - logE[b] > logE[b] - tonal->lowE[b]) - tonal->highE[b] -= .01; + tonal->highE[b] -= .01f; else - tonal->lowE[b] += .01; + tonal->lowE[b] += .01f; } if (logE[b] > tonal->highE[b]) { @@ -534,7 +538,7 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt for (i=0;i<NB_FRAMES;i++) { int j; - float mindist = 1e15; + float mindist = 1e15f; for (j=0;j<NB_FRAMES;j++) { int k; @@ -550,7 +554,7 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt } spec_variability += mindist; } - spec_variability = sqrt(spec_variability/NB_FRAMES/NB_TBANDS); + spec_variability = (float)sqrt(spec_variability/NB_FRAMES/NB_TBANDS); bandwidth_mask = 0; bandwidth = 0; maxE = 0; @@ -590,7 +594,7 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt /* Special case for the last two bands, for which we don't have spectrum but only the energy above 12 kHz. */ { - float E = hp_ener*(1./(240*240)); + float E = hp_ener*(1.f/(240*240)); #ifdef FIXED_POINT /* silk_resampler_down2_hp() shifted right by an extra 8 bits. */ E *= ((opus_int32)1 << 2*SIG_SHIFT)*256.f; @@ -622,7 +626,7 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt { float sum=0; for (b=0;b<16;b++) - sum += dct_table[i*16+b]*.5*(tonal->highE[b]+tonal->lowE[b]); + sum += dct_table[i*16+b]*.5f*(tonal->highE[b]+tonal->lowE[b]); midE[i] = sum; } @@ -675,14 +679,13 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt } for (i=0;i<9;i++) features[11+i] = (float)sqrt(tonal->std[i]) - std_feature_bias[i]; - features[18] = spec_variability-.78;; - features[20] = info->tonality - 0.154723; - features[21] = info->activity - 0.724643; - features[22] = frame_stationarity - 0.743717; - features[23] = info->tonality_slope + 0.069216; - features[24] = tonal->lowECount - 0.067930; + features[18] = spec_variability - 0.78f; + features[20] = info->tonality - 0.154723f; + features[21] = info->activity - 0.724643f; + features[22] = frame_stationarity - 0.743717f; + features[23] = info->tonality_slope + 0.069216f; + features[24] = tonal->lowECount - 0.067930f; -#ifndef DISABLE_FLOAT_API mlp_process(&net, features, frame_probs); frame_probs[0] = .5f*(frame_probs[0]+1); /* Curve fitting between the MLP probability and the actual probability */ @@ -818,9 +821,6 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt } } tonal->last_music = tonal->music_prob>.5f; -#else - info->music_prob = 0; -#endif #ifdef MLP_TRAINING for (i=0;i<25;i++) printf("%f ", features[i]); @@ -862,3 +862,5 @@ void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, co analysis_info->valid = 0; tonality_get_info(analysis, analysis_info, frame_size); } + +#endif /* DISABLE_FLOAT_API */ diff --git a/src/mlp_data.c b/src/mlp_data.c index 6e15dc5a..a819880b 100644 --- a/src/mlp_data.c +++ b/src/mlp_data.c @@ -95,18 +95,18 @@ static const float weights[450] = { -0.222056f, -0.508859f, -0.473369f, 0.484958f, -2.28411f, 0.0139516f, /* output layer */ -3.90017, 1.71789, -1.43372, -2.70839, 1.77107, -5.48006, 1.44661, 2.01134, -1.88383, -3.64958, --1.26351, 0.779421, 2.11357, 3.10409, 1.68846, --4.46197, -1.61455, 3.59832, 2.43531, -1.26458, -0.417941, 1.47437, 2.16635, -1.909, -0.828869, -1.38805, -2.67975, -0.110044, 1.95596, 0.697931, --0.313226, -0.889315, 0.283236, 0.946102, }; +3.90017f, 1.71789f, -1.43372f, -2.70839f, 1.77107f, +5.48006f, 1.44661f, 2.01134f, -1.88383f, -3.64958f, +-1.26351f, 0.779421f, 2.11357f, 3.10409f, 1.68846f, +-4.46197f, -1.61455f, 3.59832f, 2.43531f, -1.26458f, +0.417941f, 1.47437f, 2.16635f, -1.909f, -0.828869f, +1.38805f, -2.67975f, -0.110044f, 1.95596f, 0.697931f, +-0.313226f, -0.889315f, 0.283236f, 0.946102f, }; static const int topo[3] = {25, 16, 2}; const MLP net = { - 3, - topo, - weights + 3, + topo, + weights }; diff --git a/src/mlp_train.c b/src/mlp_train.c index a41f9271..8d9d127a 100644 --- a/src/mlp_train.c +++ b/src/mlp_train.c @@ -485,7 +485,7 @@ int main(int argc, char **argv) printf ("\n/* output layer */\n"); for (i=0;i<(topo[1]+1)*topo[2];i++) { - printf ("%g,", net->weights[1][i]); + printf ("%gf,", net->weights[1][i]); if (i%5==4) printf("\n"); else @@ -494,8 +494,8 @@ int main(int argc, char **argv) printf ("};\n\n"); printf ("static const int topo[3] = {%d, %d, %d};\n\n", topo[0], topo[1], topo[2]); printf ("const MLP net = {\n"); - printf ("\t3,\n"); - printf ("\ttopo,\n"); - printf ("\tweights\n};\n"); + printf (" 3,\n"); + printf (" topo,\n"); + printf (" weights\n};\n"); return 0; } diff --git a/src/mlp_train.h b/src/mlp_train.h index 2786b40d..49404158 100644 --- a/src/mlp_train.h +++ b/src/mlp_train.h @@ -36,7 +36,7 @@ static inline double tansig_double(double x) { return 2./(1.+exp(-2.*x)) - 1.; } -static inline void build_tansig_table() +static inline void build_tansig_table(void) { int i; for (i=0;i<501;i++) @@ -59,7 +59,7 @@ static inline double tansig_approx(double x) return y; } -inline float randn(float sd) +static inline float randn(float sd) { float U1, U2, S, x; do { @@ -107,7 +107,7 @@ OPUS_EXPORT void opus_pcm_soft_clip(float *_x, int N, int C, float *declip_mem) /* Slightly boost "a" by 2^-22. This is just enough to ensure -ffast-math does not cause output values larger than +/-1, but small enough not to matter even for 24-bit output. */ - a += a*2.4e-7; + a += a*2.4e-7f; if (x[i*C]>0) a = -a; /* Apply soft clipping */ diff --git a/src/opus_demo.c b/src/opus_demo.c index 9bd02947..50987c96 100644 --- a/src/opus_demo.c +++ b/src/opus_demo.c @@ -253,6 +253,7 @@ int main(int argc, char *argv[]) opus_uint32 dec_final_range; int encode_only=0, decode_only=0; int max_frame_size = 48000*2; + size_t num_read; int curr_read=0; int sweep_bps = 0; int random_framesize=0, newsize=0, delayed_celt=0; @@ -657,8 +658,8 @@ int main(int argc, char *argv[]) if (decode_only) { unsigned char ch[4]; - err = fread(ch, 1, 4, fin); - if (feof(fin)) + num_read = fread(ch, 1, 4, fin); + if (num_read!=4) break; len[toggle] = char_to_int(ch); if (len[toggle]>max_payload_bytes || len[toggle]<0) @@ -666,14 +667,16 @@ int main(int argc, char *argv[]) fprintf(stderr, "Invalid payload length: %d\n",len[toggle]); break; } - err = fread(ch, 1, 4, fin); + num_read = fread(ch, 1, 4, fin); + if (num_read!=4) + break; enc_final_range[toggle] = char_to_int(ch); - err = fread(data[toggle], 1, len[toggle], fin); - if (err<len[toggle]) + num_read = fread(data[toggle], 1, len[toggle], fin); + if (num_read!=(size_t)len[toggle]) { fprintf(stderr, "Ran out of input, " "expecting %d bytes got %d\n", - len[toggle],err); + len[toggle],(int)num_read); break; } } else { @@ -685,8 +688,8 @@ int main(int argc, char *argv[]) opus_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(mode_list[curr_mode][3])); frame_size = mode_list[curr_mode][2]; } - err = fread(fbytes, sizeof(short)*channels, frame_size-remaining, fin); - curr_read = err; + num_read = fread(fbytes, sizeof(short)*channels, frame_size-remaining, fin); + curr_read = (int)num_read; tot_in += curr_read; for(i=0;i<curr_read*channels;i++) { @@ -795,7 +798,7 @@ int main(int argc, char *argv[]) if (!decode_only && tot_out + output_samples > tot_in) { stop=1; - output_samples = tot_in-tot_out; + output_samples = (opus_int32)(tot_in - tot_out); } if (output_samples>skip) { int i; diff --git a/src/opus_encoder.c b/src/opus_encoder.c index ddeaf05d..10bb62d5 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -1130,7 +1130,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ /* Track the peak signal energy */ if (!is_silence && analysis_info.activity_probability > DTX_ACTIVITY_THRESHOLD) - st->peak_signal_energy = MAX32(MULT16_32_Q15(QCONST16(0.999, 15), st->peak_signal_energy), + st->peak_signal_energy = MAX32(MULT16_32_Q15(QCONST16(0.999f, 15), st->peak_signal_energy), compute_frame_energy(pcm, frame_size, st->channels, st->arch)); } #else |