shithub: opus

Download patch

ref: 386883179a68467ec35dd1c481100ad5915081f0
parent: ae5f5cc1c5d9919cc66efec2eea97f673228da44
author: Jean-Marc Valin <[email protected]>
date: Tue Oct 4 18:07:52 EDT 2016

Fixing some opus_int vs opus_int32 mismatches

Reported by Mark Warner.

--- a/silk/fixed/pitch_analysis_core_FIX.c
+++ b/silk/fixed/pitch_analysis_core_FIX.c
@@ -103,8 +103,8 @@
     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;
--- a/silk/quant_LTP_gains.c
+++ b/silk/quant_LTP_gains.c
@@ -52,7 +52,8 @@
     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 */
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -891,7 +891,7 @@
    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;
--- a/src/opus_demo.c
+++ b/src/opus_demo.c
@@ -765,7 +765,7 @@
             }
             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));
--- a/src/opus_multistream_decoder.c
+++ b/src/opus_multistream_decoder.c
@@ -237,7 +237,8 @@
    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);
--- a/tests/test_opus_decode.c
+++ b/tests/test_opus_decode.c
@@ -104,7 +104,7 @@
       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 @@
    /*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 @@
       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;
--- a/tests/test_opus_encode.c
+++ b/tests/test_opus_encode.c
@@ -265,8 +265,8 @@
    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 @@
          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];