Fixing some opus_int vs opus_int32 mismatches
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Wed, 5 Oct 2016 02:07:52 +0000 (22:07 -0400)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Wed, 5 Oct 2016 04:09:00 +0000 (00:09 -0400)
Reported by Mark Warner.

silk/fixed/pitch_analysis_core_FIX.c
silk/quant_LTP_gains.c
src/opus_decoder.c
src/opus_demo.c
src/opus_multistream_decoder.c
tests/test_opus_decode.c
tests/test_opus_encode.c

index 03ea28d..8df109e 100644 (file)
@@ -103,8 +103,8 @@ opus_int silk_pitch_analysis_core(                  /* O    Voicing estimate: 0
     VARDECL( opus_int16, C );
     VARDECL( opus_int32, xcorr32 );
     const opus_int16 *target_ptr, *basis_ptr;
-    opus_int32 cross_corr, normalizer, energy, shift, energy_basis, energy_target;
-    opus_int   d_srch[ PE_D_SRCH_LENGTH ], Cmax, length_d_srch, length_d_comp;
+    opus_int32 cross_corr, normalizer, energy, energy_basis, energy_target;
+    opus_int   d_srch[ PE_D_SRCH_LENGTH ], Cmax, length_d_srch, length_d_comp, shift;
     VARDECL( opus_int16, d_comp );
     opus_int32 sum, threshold, lag_counter;
     opus_int   CBimax, CBimax_new, CBimax_old, lag, start_lag, end_lag, lag_new;
index 19f555a..d6b8eff 100644 (file)
@@ -52,7 +52,8 @@ void silk_quant_LTP_gains(
     const opus_uint8     *cbk_gain_ptr_Q7;
     const opus_int32     *XX_Q17_ptr, *xX_Q17_ptr;
     opus_int32           res_nrg_Q15_subfr, res_nrg_Q15, rate_dist_Q7_subfr, rate_dist_Q7, min_rate_dist_Q7;
-    opus_int32           sum_log_gain_tmp_Q7, best_sum_log_gain_Q7, max_gain_Q7, gain_Q7;
+    opus_int32           sum_log_gain_tmp_Q7, best_sum_log_gain_Q7, max_gain_Q7;
+    opus_int             gain_Q7;
 
     /***************************************************/
     /* iterate over different codebooks with different */
index af46d82..149ae7f 100644 (file)
@@ -891,7 +891,7 @@ int opus_decoder_ctl(OpusDecoder *st, int request, ...)
    break;
    case OPUS_GET_LAST_PACKET_DURATION_REQUEST:
    {
-      opus_uint32 *value = va_arg(ap, opus_uint32*);
+      opus_int32 *value = va_arg(ap, opus_int32*);
       if (!value)
       {
          goto bad_arg;
index a330bb5..c8135c2 100644 (file)
@@ -765,7 +765,7 @@ int main(int argc, char *argv[])
             }
             tot_samples += nb_encoded;
         } else {
-            int output_samples;
+            opus_int32 output_samples;
             lost = len[toggle]==0 || (packet_loss_perc>0 && rand()%100 < packet_loss_perc);
             if (lost)
                opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_samples));
index 30cc54b..e421726 100644 (file)
@@ -237,7 +237,8 @@ static int opus_multistream_decode_native(
    for (s=0;s<st->layout.nb_streams;s++)
    {
       OpusDecoder *dec;
-      int packet_offset, ret;
+      opus_int32 packet_offset;
+      int ret;
 
       dec = (OpusDecoder*)ptr;
       ptr += (s < st->layout.nb_coupled_streams) ? align(coupled_size) : align(mono_size);
index 14a8eef..e703682 100644 (file)
@@ -104,7 +104,7 @@ int test_decoder_code0(int no_fuzz)
       int factor=48000/fsv[t>>1];
       for(fec=0;fec<2;fec++)
       {
-         int dur;
+         opus_int32 dur;
          /*Test PLC on a fresh decoder*/
          out_samples = opus_decode(dec[t], 0, 0, outbuf, 120/factor, fec);
          if(out_samples!=120/factor)test_failed();
@@ -160,7 +160,7 @@ int test_decoder_code0(int no_fuzz)
    /*Count code 0 tests*/
    for(i=0;i<64;i++)
    {
-      int dur;
+      opus_int32 dur;
       int j,expected[5*2];
       packet[0]=i<<2;
       packet[1]=255;
@@ -314,7 +314,7 @@ int test_decoder_code0(int no_fuzz)
       if(opus_decode(decbak,  0, 0, outbuf, MAX_FRAME_SAMP, 0)<20)test_failed();
       for(t=0;t<5*2;t++)
       {
-         int dur;
+         opus_int32 dur;
          out_samples = opus_decode(dec[t], packet, plen+1, outbuf, MAX_FRAME_SAMP, 0);
          if(out_samples!=expected[t])test_failed();
          if(t==0)dec_final_range2=dec_final_range1;
index 4e7ccf7..c49a2ad 100644 (file)
@@ -265,8 +265,8 @@ int run_test1(int no_fuzz)
    static const char *mstrings[3] = {"    LP","Hybrid","  MDCT"};
    unsigned char mapping[256] = {0,1,255};
    unsigned char db62[36];
-   opus_int32 i;
-   int rc,j,err;
+   opus_int32 i,j;
+   int rc,err;
    OpusEncoder *enc;
    OpusMSEncoder *MSenc;
    OpusDecoder *dec;
@@ -482,7 +482,8 @@ int run_test1(int no_fuzz)
          if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_BITRATE(rate))!=OPUS_OK)test_failed();
          count=i=0;
          do {
-            int pred,len,out_samples,frame_size,loss;
+            int len,out_samples,frame_size,loss;
+            opus_int32 pred;
             if(opus_multistream_encoder_ctl(MSenc, OPUS_GET_PREDICTION_DISABLED(&pred))!=OPUS_OK)test_failed();
             if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_PREDICTION_DISABLED((int)(fast_rand()&15)<(pred?11:4)))!=OPUS_OK)test_failed();
             frame_size=frame[j];