Revert "Fixes a number of double promotions and missing casts."

This reverts commit 43279728cd.
This commit is contained in:
Gregory Maxwell 2013-07-15 15:51:24 -07:00
parent 4effd30882
commit 5280c71883
6 changed files with 32 additions and 32 deletions

View file

@ -327,7 +327,7 @@ static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int
/* Costs two sqrt() to avoid overflows */ /* Costs two sqrt() to avoid overflows */
mean = MULT16_16(celt_sqrt(mean), celt_sqrt(MULT16_16(maxE,len2>>1))); mean = MULT16_16(celt_sqrt(mean), celt_sqrt(MULT16_16(maxE,len2>>1)));
#else #else
mean = celt_sqrt(mean * maxE*.5f*len2); mean = celt_sqrt(mean * maxE*.5*len2);
#endif #endif
/* Inverse of the mean energy in Q15+6 */ /* Inverse of the mean energy in Q15+6 */
norm = SHL32(EXTEND32(len2),6+14)/ADD32(EPSILON,SHR32(mean,1)); norm = SHL32(EXTEND32(len2),6+14)/ADD32(EPSILON,SHR32(mean,1));
@ -1139,7 +1139,7 @@ static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32
/*printf("%f %f %f %f %d %d ", st->analysis.activity, st->analysis.tonality, tf_estimate, st->stereo_saving, tot_boost, coded_bands);*/ /*printf("%f %f %f %f %d %d ", st->analysis.activity, st->analysis.tonality, tf_estimate, st->stereo_saving, tot_boost, coded_bands);*/
#ifndef FIXED_POINT #ifndef FIXED_POINT
if (analysis->valid && analysis->activity<.4f) if (analysis->valid && analysis->activity<.4)
target -= (opus_int32)((coded_bins<<BITRES)*(.4f-analysis->activity)); target -= (opus_int32)((coded_bins<<BITRES)*(.4f-analysis->activity));
#endif #endif
/* Stereo savings */ /* Stereo savings */
@ -1457,8 +1457,8 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
prefilter_tapset = st->tapset_decision; prefilter_tapset = st->tapset_decision;
pf_on = run_prefilter(st, in, prefilter_mem, CC, N, prefilter_tapset, &pitch_index, &gain1, &qg, enabled, nbAvailableBytes); pf_on = run_prefilter(st, in, prefilter_mem, CC, N, prefilter_tapset, &pitch_index, &gain1, &qg, enabled, nbAvailableBytes);
if ((gain1 > QCONST16(.4f,15) || st->prefilter_gain > QCONST16(.4f,15)) && (!st->analysis.valid || st->analysis.tonality > .3f) if ((gain1 > QCONST16(.4f,15) || st->prefilter_gain > QCONST16(.4f,15)) && (!st->analysis.valid || st->analysis.tonality > .3)
&& (pitch_index > 1.26f*st->prefilter_period || pitch_index < .79f*st->prefilter_period)) && (pitch_index > 1.26*st->prefilter_period || pitch_index < .79*st->prefilter_period))
pitch_change = 1; pitch_change = 1;
if (pf_on==0) if (pf_on==0)
{ {

View file

@ -65,11 +65,11 @@ void testdiv(void)
opus_val32 val; opus_val32 val;
val = celt_rcp(i); val = celt_rcp(i);
#ifdef FIXED_POINT #ifdef FIXED_POINT
prod = (1.f/32768.f/65526.f)*val*i; prod = (1./32768./65526.)*val*i;
#else #else
prod = val*i; prod = val*i;
#endif #endif
if (fabs(prod-1) > .00025f) if (fabs(prod-1) > .00025)
{ {
fprintf (stderr, "div failed: 1/%d="WORD" (product = %f)\n", i, val, prod); fprintf (stderr, "div failed: 1/%d="WORD" (product = %f)\n", i, val, prod);
ret = 1; ret = 1;
@ -86,7 +86,7 @@ void testsqrt(void)
opus_val16 val; opus_val16 val;
val = celt_sqrt(i); val = celt_sqrt(i);
ratio = val/sqrt(i); ratio = val/sqrt(i);
if (fabs(ratio - 1) > .0005f && fabs(val-sqrt(i)) > 2) if (fabs(ratio - 1) > .0005 && fabs(val-sqrt(i)) > 2)
{ {
fprintf (stderr, "sqrt failed: sqrt(%d)="WORD" (ratio = %f)\n", i, val, ratio); fprintf (stderr, "sqrt failed: sqrt(%d)="WORD" (ratio = %f)\n", i, val, ratio);
ret = 1; ret = 1;
@ -152,10 +152,10 @@ void testbitexactlog2tan(void)
void testlog2(void) void testlog2(void)
{ {
float x; float x;
for (x=0.001f;x<1677700.0f;x+=(x/8.0f)) for (x=0.001;x<1677700.0;x+=(x/8.0))
{ {
float error = fabs((1.442695040888963387*log(x))-celt_log2(x)); float error = fabs((1.442695040888963387*log(x))-celt_log2(x));
if (error>0.0009f) if (error>0.0009)
{ {
fprintf (stderr, "celt_log2 failed: fabs((1.442695040888963387*log(x))-celt_log2(x))>0.001 (x = %f, error = %f)\n", x,error); fprintf (stderr, "celt_log2 failed: fabs((1.442695040888963387*log(x))-celt_log2(x))>0.001 (x = %f, error = %f)\n", x,error);
ret = 1; ret = 1;
@ -166,10 +166,10 @@ void testlog2(void)
void testexp2(void) void testexp2(void)
{ {
float x; float x;
for (x=-11.0f;x<24.0f;x+=0.0007f) for (x=-11.0;x<24.0;x+=0.0007)
{ {
float error = fabs(x-(1.442695040888963387*log(celt_exp2(x)))); float error = fabs(x-(1.442695040888963387*log(celt_exp2(x))));
if (error>0.0002f) if (error>0.0002)
{ {
fprintf (stderr, "celt_exp2 failed: fabs(x-(1.442695040888963387*log(celt_exp2(x))))>0.0005 (x = %f, error = %f)\n", x,error); fprintf (stderr, "celt_exp2 failed: fabs(x-(1.442695040888963387*log(celt_exp2(x))))>0.0005 (x = %f, error = %f)\n", x,error);
ret = 1; ret = 1;
@ -180,10 +180,10 @@ void testexp2(void)
void testexp2log2(void) void testexp2log2(void)
{ {
float x; float x;
for (x=-11.0f;x<24.0f;x+=0.0007f) for (x=-11.0;x<24.0;x+=0.0007)
{ {
float error = fabs(x-(celt_log2(celt_exp2(x)))); float error = fabs(x-(celt_log2(celt_exp2(x))));
if (error>0.001f) if (error>0.001)
{ {
fprintf (stderr, "celt_log2/celt_exp2 failed: fabs(x-(celt_log2(celt_exp2(x))))>0.001 (x = %f, error = %f)\n", x,error); fprintf (stderr, "celt_log2/celt_exp2 failed: fabs(x-(celt_log2(celt_exp2(x))))>0.001 (x = %f, error = %f)\n", x,error);
ret = 1; ret = 1;
@ -196,8 +196,8 @@ void testlog2(void)
opus_val32 x; opus_val32 x;
for (x=8;x<1073741824;x+=(x>>3)) for (x=8;x<1073741824;x+=(x>>3))
{ {
float error = fabs((1.442695040888963387*log(x/16384.0f))-celt_log2(x)/1024.0f); float error = fabs((1.442695040888963387*log(x/16384.0))-celt_log2(x)/1024.0);
if (error>0.003f) if (error>0.003)
{ {
fprintf (stderr, "celt_log2 failed: x = %ld, error = %f\n", (long)x,error); fprintf (stderr, "celt_log2 failed: x = %ld, error = %f\n", (long)x,error);
ret = 1; ret = 1;
@ -210,9 +210,9 @@ void testexp2(void)
opus_val16 x; opus_val16 x;
for (x=-32768;x<15360;x++) for (x=-32768;x<15360;x++)
{ {
float error1 = fabs(x/1024.0f-(1.442695040888963387*log(celt_exp2(x)/65536.0f))); float error1 = fabs(x/1024.0-(1.442695040888963387*log(celt_exp2(x)/65536.0)));
float error2 = fabs(exp(0.6931471805599453094f*x/1024.0f)-celt_exp2(x)/65536.0f); float error2 = fabs(exp(0.6931471805599453094*x/1024.0)-celt_exp2(x)/65536.0);
if (error1>0.0002f&&error2>0.00004f) if (error1>0.0002&&error2>0.00004)
{ {
fprintf (stderr, "celt_exp2 failed: x = "WORD", error1 = %f, error2 = %f\n", x,error1,error2); fprintf (stderr, "celt_exp2 failed: x = "WORD", error1 = %f, error2 = %f\n", x,error1,error2);
ret = 1; ret = 1;
@ -225,8 +225,8 @@ void testexp2log2(void)
opus_val32 x; opus_val32 x;
for (x=8;x<65536;x+=(x>>3)) for (x=8;x<65536;x+=(x>>3))
{ {
float error = fabs(x-0.25f*celt_exp2(celt_log2(x)))/16384; float error = fabs(x-0.25*celt_exp2(celt_log2(x)))/16384;
if (error>0.004f) if (error>0.004)
{ {
fprintf (stderr, "celt_log2/celt_exp2 failed: fabs(x-(celt_exp2(celt_log2(x))))>0.001 (x = %ld, error = %f)\n", (long)x,error); fprintf (stderr, "celt_log2/celt_exp2 failed: fabs(x-(celt_exp2(celt_log2(x))))>0.001 (x = %ld, error = %f)\n", (long)x,error);
ret = 1; ret = 1;

View file

@ -163,7 +163,7 @@ void silk_NLSF2A(
} }
for( i = 0; i < MAX_LPC_STABILIZE_ITERATIONS; i++ ) { for( i = 0; i < MAX_LPC_STABILIZE_ITERATIONS; i++ ) {
if( silk_LPC_inverse_pred_gain( a_Q12, d ) < SILK_FIX_CONST( 1.0f / MAX_PREDICTION_POWER_GAIN, 30 ) ) { if( silk_LPC_inverse_pred_gain( a_Q12, d ) < SILK_FIX_CONST( 1.0 / MAX_PREDICTION_POWER_GAIN, 30 ) ) {
/* Prediction coefficients are (too close to) unstable; apply bandwidth expansion */ /* Prediction coefficients are (too close to) unstable; apply bandwidth expansion */
/* on the unscaled coefficients, convert to Q12 and measure again */ /* on the unscaled coefficients, convert to Q12 and measure again */
silk_bwexpander_32( a32_QA1, d, 65536 - silk_LSHIFT( 2, i ) ); silk_bwexpander_32( a32_QA1, d, 65536 - silk_LSHIFT( 2, i ) );

View file

@ -283,12 +283,12 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, con
d_angle2 = angle2 - angle; d_angle2 = angle2 - angle;
d2_angle2 = d_angle2 - d_angle; d2_angle2 = d_angle2 - d_angle;
mod1 = d2_angle - (float)floor(.5f+d2_angle); mod1 = d2_angle - (float)floor(.5+d2_angle);
noisiness[i] = ABS16(mod1); noisiness[i] = ABS16(mod1);
mod1 *= mod1; mod1 *= mod1;
mod1 *= mod1; mod1 *= mod1;
mod2 = d2_angle2 - (float)floor(.5f+d2_angle2); mod2 = d2_angle2 - (float)floor(.5+d2_angle2);
noisiness[i] += ABS16(mod2); noisiness[i] += ABS16(mod2);
mod2 *= mod2; mod2 *= mod2;
mod2 *= mod2; mod2 *= mod2;
@ -404,7 +404,7 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, con
both the ATH and the loudness-dependent slope of the spreading function) both the ATH and the loudness-dependent slope of the spreading function)
3) above the PCM quantization noise floor 3) above the PCM quantization noise floor
*/ */
if (E>.1f*bandwidth_mask && E*1e9f > maxE && E > noise_floor*(band_end-band_start)) if (E>.1*bandwidth_mask && E*1e9f > maxE && E > noise_floor*(band_end-band_start))
bandwidth = b; bandwidth = b;
} }
if (tonal->count<=2) if (tonal->count<=2)
@ -568,16 +568,16 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, con
psum += tonal->pspeech[i]; psum += tonal->pspeech[i];
/* Estimate our confidence in the speech/music decisions */ /* Estimate our confidence in the speech/music decisions */
if (frame_probs[1]>.75f) if (frame_probs[1]>.75)
{ {
if (tonal->music_prob>.9f) if (tonal->music_prob>.9)
{ {
float adapt; float adapt;
adapt = 1.f/(++tonal->music_confidence_count); adapt = 1.f/(++tonal->music_confidence_count);
tonal->music_confidence_count = IMIN(tonal->music_confidence_count, 500); tonal->music_confidence_count = IMIN(tonal->music_confidence_count, 500);
tonal->music_confidence += adapt*MAX16(-.2f,frame_probs[0]-tonal->music_confidence); tonal->music_confidence += adapt*MAX16(-.2f,frame_probs[0]-tonal->music_confidence);
} }
if (tonal->music_prob<.1f) if (tonal->music_prob<.1)
{ {
float adapt; float adapt;
adapt = 1.f/(++tonal->speech_confidence_count); adapt = 1.f/(++tonal->speech_confidence_count);

View file

@ -75,7 +75,7 @@ static size_t read_pcm16(float **_samples,FILE *_fin,int _nchannels){
int s; int s;
s=buf[2*(xi*_nchannels+ci)+1]<<8|buf[2*(xi*_nchannels+ci)]; s=buf[2*(xi*_nchannels+ci)+1]<<8|buf[2*(xi*_nchannels+ci)];
s=((s&0xFFFF)^0x8000)-0x8000; s=((s&0xFFFF)^0x8000)-0x8000;
samples[(nsamples+xi)*_nchannels+ci]=(float)s; samples[(nsamples+xi)*_nchannels+ci]=s;
} }
} }
nsamples+=nread; nsamples+=nread;
@ -230,7 +230,7 @@ int main(int _argc,const char **_argv){
/*Read in the data and allocate scratch space.*/ /*Read in the data and allocate scratch space.*/
xlength=read_pcm16(&x,fin1,2); xlength=read_pcm16(&x,fin1,2);
if(nchannels==1){ if(nchannels==1){
for(xi=0;xi<xlength;xi++)x[xi]=.5f*(x[2*xi]+x[2*xi+1]); for(xi=0;xi<xlength;xi++)x[xi]=.5*(x[2*xi]+x[2*xi+1]);
} }
fclose(fin1); fclose(fin1);
ylength=read_pcm16(&y,fin2,nchannels); ylength=read_pcm16(&y,fin2,nchannels);
@ -346,7 +346,7 @@ int main(int _argc,const char **_argv){
float re; float re;
float im; float im;
re=Y[(xi*yfreqs+xj)*nchannels+ci]/X[(xi*NFREQS+xj)*nchannels+ci]; re=Y[(xi*yfreqs+xj)*nchannels+ci]/X[(xi*NFREQS+xj)*nchannels+ci];
im=re-(float)log(re)-1; im=re-log(re)-1;
/*Make comparison less sensitive around the SILK/CELT cross-over to /*Make comparison less sensitive around the SILK/CELT cross-over to
allow for mode freedom in the filters.*/ allow for mode freedom in the filters.*/
if(xj>=79&&xj<=81)im*=0.1F; if(xj>=79&&xj<=81)im*=0.1F;
@ -364,7 +364,7 @@ int main(int _argc,const char **_argv){
err+=Ef*Ef; err+=Ef*Ef;
} }
err=pow(err/nframes,1.0/16); err=pow(err/nframes,1.0/16);
Q=100*(1-0.5f*(float)log(1+err)/log(1.13f)); Q=100*(1-0.5*log(1+err)/log(1.13));
if(Q<0){ if(Q<0){
fprintf(stderr,"Test vector FAILS\n"); fprintf(stderr,"Test vector FAILS\n");
fprintf(stderr,"Internal weighted error is %f\n",err); fprintf(stderr,"Internal weighted error is %f\n",err);

View file

@ -949,7 +949,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
{ {
int analysis_bandwidth; int analysis_bandwidth;
if (st->signal_type == OPUS_AUTO) if (st->signal_type == OPUS_AUTO)
st->voice_ratio = (int)floor(.5f+100*(1-analysis_info->music_prob)); st->voice_ratio = (int)floor(.5+100*(1-analysis_info->music_prob));
analysis_bandwidth = analysis_info->bandwidth; analysis_bandwidth = analysis_info->bandwidth;
if (analysis_bandwidth<=12) if (analysis_bandwidth<=12)