shithub: opus

Download patch

ref: 16ba19a95b520aa20c9815cbb1aebc21e3b77349
parent: 1975eeadd2bc0f80d60401093f25c167aff21a1f
author: Jean-Marc Valin <[email protected]>
date: Wed Jun 26 23:40:44 EDT 2013

Fixes MSVC warnings

--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -1181,7 +1181,7 @@
 
    if (has_surround_mask&&!lfe)
    {
-      opus_int32 surround_target = target + SHR32(MULT16_16(surround_masking,coded_bins<<BITRES), DB_SHIFT);
+      opus_int32 surround_target = target + (opus_int32)SHR32(MULT16_16(surround_masking,coded_bins<<BITRES), DB_SHIFT);
       /*printf("%f %d %d %d %d %d %d ", surround_masking, coded_bins, st->end, st->intensity, surround_target, target, st->bitrate);*/
       target = IMAX(target/4, surround_target);
    }
@@ -1591,7 +1591,7 @@
          /* Compensate for the scaling of short vs long mdcts */
          for (i=0;i<C*nbEBands;i++)
             bandLogE2[i] += HALF16(SHL16(LM, DB_SHIFT));
-         tf_estimate = QCONST16(.2,14);
+         tf_estimate = QCONST16(.2f,14);
       }
    }
 
--- a/src/analysis.c
+++ b/src/analysis.c
@@ -480,7 +480,7 @@
     /* Curve fitting between the MLP probability and the actual probability */
     frame_probs[0] = .01f + 1.21f*frame_probs[0]*frame_probs[0] - .23f*(float)pow(frame_probs[0], 10);
     frame_probs[1] = .5*frame_probs[1]+.5;
-    frame_probs[0] = frame_probs[1]*frame_probs[0] + (1-frame_probs[1])*.5;
+    frame_probs[0] = frame_probs[1]*frame_probs[0] + (1-frame_probs[1])*.5f;
 
     /*printf("%f %f ", frame_probs[0], frame_probs[1]);*/
     {
@@ -499,7 +499,7 @@
           float p, q;
           p = MAX16(.05f,MIN16(.95f,frame_probs[0]));
           q = MAX16(.05f,MIN16(.95f,tonal->music_prob));
-          beta = .01+.05*ABS16(p-q)/(p*(1-q)+q*(1-p));
+          beta = .01f+.05f*ABS16(p-q)/(p*(1-q)+q*(1-p));
        }
        p0 = (1-tonal->music_prob)*(1-tau) +    tonal->music_prob *tau;
        p1 =    tonal->music_prob *(1-tau) + (1-tonal->music_prob)*tau;
@@ -508,7 +508,7 @@
        tonal->music_prob = p1/(p0+p1);
        info->music_prob = tonal->music_prob;
 
-       psum=1e-20;
+       psum=1e-20f;
        speech0 = (float)pow(1-frame_probs[0], beta);
        music0  = (float)pow(frame_probs[0], beta);
        if (tonal->count==1)
@@ -559,9 +559,9 @@
           }
        } else {
           if (tonal->music_confidence_count==0)
-             tonal->music_confidence = .9;
+             tonal->music_confidence = .9f;
           if (tonal->speech_confidence_count==0)
-             tonal->speech_confidence = .1;
+             tonal->speech_confidence = .1f;
        }
        psum = MAX16(tonal->speech_confidence, MIN16(tonal->music_confidence, psum));
     }
--- a/src/mlp_data.c
+++ b/src/mlp_data.c
@@ -88,13 +88,13 @@
 3.95279f, 1.89068f, 0.486087f, -11.3343f, 3.9416e+06f,
 
 /* output layer */
--0.381439, 0.12115, -0.906927, 2.93878, 1.6388,
-0.882811, 0.874344, 1.21726, -0.874545, 0.321706,
-0.785055, 0.946558, -0.575066, -3.46553, 0.884905,
-0.0924047, -9.90712, 0.391338, 0.160103, -2.04954,
-4.1455, 0.0684029, -0.144761, -0.285282, 0.379244,
--1.1584, -0.0277241, -9.85, -4.82386, 3.71333,
-3.87308, 3.52558, };
+-0.381439f, 0.12115f, -0.906927f, 2.93878f, 1.6388f,
+0.882811f, 0.874344f, 1.21726f, -0.874545f, 0.321706f,
+0.785055f, 0.946558f, -0.575066f, -3.46553f, 0.884905f,
+0.0924047f, -9.90712f, 0.391338f, 0.160103f, -2.04954f,
+4.1455f, 0.0684029f, -0.144761f, -0.285282f, 0.379244f,
+-1.1584f, -0.0277241f, -9.85f, -4.82386f, 3.71333f,
+3.87308f, 3.52558f};
 
 static const int topo[3] = {25, 15, 2};
 
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -573,7 +573,7 @@
       printf("%f\n", metric);*/
    /*return metric>10 ? 1 : 0;*/
    /*return MAX16(0,1-exp(-.25*(metric-2.)));*/
-   return MIN16(1,sqrt(MAX16(0,.05*(metric-2))));
+   return MIN16(1,sqrt(MAX16(0,.05f*(metric-2))));
 }
 
 /* Viterbi decoding trying to find the best frame size combination using look-ahead
@@ -728,7 +728,7 @@
    subframe = Fs/400;
    ALLOC(sub, subframe, opus_val16);
    e[0]=mem[0];
-   e_1[0]=1./(EPSILON+mem[0]);
+   e_1[0]=1.f/(EPSILON+mem[0]);
    if (buffering)
    {
       /* Consider the CELT delay when not in restricted-lowdelay */
@@ -738,9 +738,9 @@
       x += C*offset;
       len -= offset;
       e[1]=mem[1];
-      e_1[1]=1./(EPSILON+mem[1]);
+      e_1[1]=1.f/(EPSILON+mem[1]);
       e[2]=mem[2];
-      e_1[2]=1./(EPSILON+mem[2]);
+      e_1[2]=1.f/(EPSILON+mem[2]);
       pos = 3;
    } else {
       pos=1;
@@ -772,7 +772,7 @@
    e[i+pos] = e[i+pos-1];
    if (buffering)
       N=IMIN(MAX_DYNAMIC_FRAMESIZE, N+2);
-   bestLM = transient_viterbi(e, e_1, N, (1.f+.5*tonality)*(60*C+40), bitrate/400);
+   bestLM = transient_viterbi(e, e_1, N, (1.f+.5f*tonality)*(60*C+40), bitrate/400);
    mem[0] = e[1<<bestLM];
    if (buffering)
    {
@@ -1072,8 +1072,10 @@
        opus_int32 threshold;
 
        /* Interpolate based on stereo width */
-       mode_voice = MULT16_32_Q15(Q15ONE-stereo_width,mode_thresholds[0][0]) + MULT16_32_Q15(stereo_width,mode_thresholds[1][0]);
-       mode_music = MULT16_32_Q15(Q15ONE-stereo_width,mode_thresholds[1][1]) + MULT16_32_Q15(stereo_width,mode_thresholds[1][1]);
+       mode_voice = (opus_int32)(MULT16_32_Q15(Q15ONE-stereo_width,mode_thresholds[0][0])
+             + MULT16_32_Q15(stereo_width,mode_thresholds[1][0]));
+       mode_music = (opus_int32)(MULT16_32_Q15(Q15ONE-stereo_width,mode_thresholds[1][1])
+             + MULT16_32_Q15(stereo_width,mode_thresholds[1][1]));
        /* Interpolate based on speech/music probability */
        threshold = mode_music + ((voice_est*voice_est*(mode_voice-mode_music))>>14);
        /* Bias towards SILK for VoIP because of some useful features */
@@ -1592,7 +1594,7 @@
                 {
                    bonus = (60*st->stream_channels+40)*(st->Fs/frame_size-50);
                    if (analysis_info->valid)
-                      bonus = bonus*(1.f+.5*analysis_info->tonality);
+                      bonus = bonus*(1.f+.5f*analysis_info->tonality);
                 }
 #endif
                 celt_encoder_ctl(celt_enc, OPUS_SET_VBR(1));