Fix MSVC warnings about value truncations, webrtc/common_audio/ edition.

This changes some method signatures to better reflect how callers are actually
using them.  This also has the tendency to make signatures more consistent about
e.g. using int (instead of int16_t) for lengths of things like vectors, and
using int16_t (instead of int) for e.g. counts of bits in a value.

This also removes a couple of functions that were only called in unittests.

BUG=3353,chromium:81439
TEST=none
R=andrew@webrtc.org, bjornv@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/23389004

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@7060 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/common_audio/fir_filter.cc b/common_audio/fir_filter.cc
index a5411b8..a5160fd 100644
--- a/common_audio/fir_filter.cc
+++ b/common_audio/fir_filter.cc
@@ -85,7 +85,7 @@
   for (size_t i = 0; i < coefficients_length_; ++i) {
     coefficients_[i] = coefficients[coefficients_length_ - i - 1];
   }
-  memset(state_.get(), 0.f, state_length_ * sizeof(state_[0]));
+  memset(state_.get(), 0, state_length_ * sizeof(state_[0]));
 }
 
 void FIRFilterC::Filter(const float* in, size_t length, float* out) {
diff --git a/common_audio/fir_filter_sse.cc b/common_audio/fir_filter_sse.cc
index 7d873a7..6e7ae70 100644
--- a/common_audio/fir_filter_sse.cc
+++ b/common_audio/fir_filter_sse.cc
@@ -31,14 +31,14 @@
                         16))) {
   // Add zeros at the end of the coefficients.
   size_t padding = coefficients_length_ - coefficients_length;
-  memset(coefficients_.get(), 0.f, padding * sizeof(coefficients_[0]));
+  memset(coefficients_.get(), 0, padding * sizeof(coefficients_[0]));
   // The coefficients are reversed to compensate for the order in which the
   // input samples are acquired (most recent last).
   for (size_t i = 0; i < coefficients_length; ++i) {
     coefficients_[i + padding] = coefficients[coefficients_length - i - 1];
   }
   memset(state_.get(),
-         0.f,
+         0,
          (max_input_length + state_length_) * sizeof(state_[0]));
 }
 
diff --git a/common_audio/resampler/sinc_resampler.cc b/common_audio/resampler/sinc_resampler.cc
index 84f8125..165cb35 100644
--- a/common_audio/resampler/sinc_resampler.cc
+++ b/common_audio/resampler/sinc_resampler.cc
@@ -222,23 +222,22 @@
 
     for (int i = 0; i < kKernelSize; ++i) {
       const int idx = i + offset_idx * kKernelSize;
-      const float pre_sinc = M_PI * (i - kKernelSize / 2 - subsample_offset);
+      const float pre_sinc =
+          static_cast<float>(M_PI * (i - kKernelSize / 2 - subsample_offset));
       kernel_pre_sinc_storage_[idx] = pre_sinc;
 
       // Compute Blackman window, matching the offset of the sinc().
       const float x = (i - subsample_offset) / kKernelSize;
-      const float window = kA0 - kA1 * cos(2.0 * M_PI * x) + kA2
-          * cos(4.0 * M_PI * x);
+      const float window = static_cast<float>(kA0 - kA1 * cos(2.0 * M_PI * x) +
+          kA2 * cos(4.0 * M_PI * x));
       kernel_window_storage_[idx] = window;
 
       // Compute the sinc with offset, then window the sinc() function and store
       // at the correct offset.
-      if (pre_sinc == 0) {
-        kernel_storage_[idx] = sinc_scale_factor * window;
-      } else {
-        kernel_storage_[idx] =
-            window * sin(sinc_scale_factor * pre_sinc) / pre_sinc;
-      }
+      kernel_storage_[idx] = static_cast<float>(window *
+          ((pre_sinc == 0) ?
+              sinc_scale_factor :
+              (sin(sinc_scale_factor * pre_sinc) / pre_sinc)));
     }
   }
 }
@@ -260,12 +259,10 @@
       const float window = kernel_window_storage_[idx];
       const float pre_sinc = kernel_pre_sinc_storage_[idx];
 
-      if (pre_sinc == 0) {
-        kernel_storage_[idx] = sinc_scale_factor * window;
-      } else {
-        kernel_storage_[idx] =
-            window * sin(sinc_scale_factor * pre_sinc) / pre_sinc;
-      }
+      kernel_storage_[idx] = static_cast<float>(window *
+          ((pre_sinc == 0) ?
+              sinc_scale_factor :
+              (sin(sinc_scale_factor * pre_sinc) / pre_sinc)));
     }
   }
 }
@@ -289,18 +286,19 @@
     //
     // Note: The loop construct here can severely impact performance on ARM
     // or when built with clang.  See https://codereview.chromium.org/18566009/
-    for (int i = ceil((block_size_ - virtual_source_idx_) / current_io_ratio);
+    for (int i = static_cast<int>(
+             ceil((block_size_ - virtual_source_idx_) / current_io_ratio));
          i > 0; --i) {
       assert(virtual_source_idx_ < block_size_);
 
       // |virtual_source_idx_| lies in between two kernel offsets so figure out
       // what they are.
-      const int source_idx = virtual_source_idx_;
+      const int source_idx = static_cast<int>(virtual_source_idx_);
       const double subsample_remainder = virtual_source_idx_ - source_idx;
 
       const double virtual_offset_idx =
           subsample_remainder * kKernelOffsetCount;
-      const int offset_idx = virtual_offset_idx;
+      const int offset_idx = static_cast<int>(virtual_offset_idx);
 
       // We'll compute "convolutions" for the two kernels which straddle
       // |virtual_source_idx_|.
@@ -347,7 +345,7 @@
 #undef CONVOLVE_FUNC
 
 int SincResampler::ChunkSize() const {
-  return block_size_ / io_sample_rate_ratio_;
+  return static_cast<int>(block_size_ / io_sample_rate_ratio_);
 }
 
 void SincResampler::Flush() {
@@ -373,8 +371,8 @@
   }
 
   // Linearly interpolate the two "convolutions".
-  return (1.0 - kernel_interpolation_factor) * sum1
-      + kernel_interpolation_factor * sum2;
+  return static_cast<float>((1.0 - kernel_interpolation_factor) * sum1 +
+      kernel_interpolation_factor * sum2);
 }
 
 }  // namespace webrtc
diff --git a/common_audio/resampler/sinc_resampler_sse.cc b/common_audio/resampler/sinc_resampler_sse.cc
index bdbe7b1..e00e0e5 100644
--- a/common_audio/resampler/sinc_resampler_sse.cc
+++ b/common_audio/resampler/sinc_resampler_sse.cc
@@ -41,8 +41,10 @@
   }
 
   // Linearly interpolate the two "convolutions".
-  m_sums1 = _mm_mul_ps(m_sums1, _mm_set_ps1(1.0 - kernel_interpolation_factor));
-  m_sums2 = _mm_mul_ps(m_sums2, _mm_set_ps1(kernel_interpolation_factor));
+  m_sums1 = _mm_mul_ps(m_sums1, _mm_set_ps1(
+      static_cast<float>(1.0 - kernel_interpolation_factor)));
+  m_sums2 = _mm_mul_ps(m_sums2, _mm_set_ps1(
+      static_cast<float>(kernel_interpolation_factor)));
   m_sums1 = _mm_add_ps(m_sums1, m_sums2);
 
   // Sum components together.
diff --git a/common_audio/signal_processing/copy_set_operations.c b/common_audio/signal_processing/copy_set_operations.c
index 0c2493b..84d3bc4 100644
--- a/common_audio/signal_processing/copy_set_operations.c
+++ b/common_audio/signal_processing/copy_set_operations.c
@@ -17,8 +17,6 @@
  * WebRtcSpl_CopyFromEndW16()
  * WebRtcSpl_ZerosArrayW16()
  * WebRtcSpl_ZerosArrayW32()
- * WebRtcSpl_OnesArrayW16()
- * WebRtcSpl_OnesArrayW32()
  *
  * The description header can be found in signal_processing_library.h
  *
@@ -62,47 +60,21 @@
     }
 }
 
-int16_t WebRtcSpl_CopyFromEndW16(const int16_t *vector_in,
-                                 int16_t length,
-                                 int16_t samples,
-                                 int16_t *vector_out)
+void WebRtcSpl_CopyFromEndW16(const int16_t *vector_in,
+                              int length,
+                              int samples,
+                              int16_t *vector_out)
 {
     // Copy the last <samples> of the input vector to vector_out
     WEBRTC_SPL_MEMCPY_W16(vector_out, &vector_in[length - samples], samples);
-
-    return samples;
 }
 
-int16_t WebRtcSpl_ZerosArrayW16(int16_t *vector, int16_t length)
+void WebRtcSpl_ZerosArrayW16(int16_t *vector, int length)
 {
     WebRtcSpl_MemSetW16(vector, 0, length);
-    return length;
 }
 
-int16_t WebRtcSpl_ZerosArrayW32(int32_t *vector, int16_t length)
+void WebRtcSpl_ZerosArrayW32(int32_t *vector, int length)
 {
     WebRtcSpl_MemSetW32(vector, 0, length);
-    return length;
-}
-
-int16_t WebRtcSpl_OnesArrayW16(int16_t *vector, int16_t length)
-{
-    int16_t i;
-    int16_t *tmpvec = vector;
-    for (i = 0; i < length; i++)
-    {
-        *tmpvec++ = 1;
-    }
-    return length;
-}
-
-int16_t WebRtcSpl_OnesArrayW32(int32_t *vector, int16_t length)
-{
-    int16_t i;
-    int32_t *tmpvec = vector;
-    for (i = 0; i < length; i++)
-    {
-        *tmpvec++ = 1;
-    }
-    return length;
 }
diff --git a/common_audio/signal_processing/get_scaling_square.c b/common_audio/signal_processing/get_scaling_square.c
index 606902d..9b6049c 100644
--- a/common_audio/signal_processing/get_scaling_square.c
+++ b/common_audio/signal_processing/get_scaling_square.c
@@ -17,14 +17,16 @@
 
 #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
 
-int WebRtcSpl_GetScalingSquare(int16_t *in_vector, int in_vector_length, int times)
+int16_t WebRtcSpl_GetScalingSquare(int16_t* in_vector,
+                                   int in_vector_length,
+                                   int times)
 {
-    int nbits = WebRtcSpl_GetSizeInBits(times);
+    int16_t nbits = WebRtcSpl_GetSizeInBits(times);
     int i;
     int16_t smax = -1;
     int16_t sabs;
     int16_t *sptr = in_vector;
-    int t;
+    int16_t t;
     int looptimes = in_vector_length;
 
     for (i = looptimes; i > 0; i--)
diff --git a/common_audio/signal_processing/include/signal_processing_library.h b/common_audio/signal_processing/include/signal_processing_library.h
index 56bbbe6..21c5663 100644
--- a/common_audio/signal_processing/include/signal_processing_library.h
+++ b/common_audio/signal_processing/include/signal_processing_library.h
@@ -123,9 +123,9 @@
 // Get SPL Version
 int16_t WebRtcSpl_get_version(char* version, int16_t length_in_bytes);
 
-int WebRtcSpl_GetScalingSquare(int16_t* in_vector,
-                               int in_vector_length,
-                               int times);
+int16_t WebRtcSpl_GetScalingSquare(int16_t* in_vector,
+                                   int in_vector_length,
+                                   int times);
 
 // Copy and set operations. Implementation in copy_set_operations.c.
 // Descriptions at bottom of file.
@@ -138,18 +138,14 @@
 void WebRtcSpl_MemCpyReversedOrder(int16_t* out_vector,
                                    int16_t* in_vector,
                                    int vector_length);
-int16_t WebRtcSpl_CopyFromEndW16(const int16_t* in_vector,
-                                 int16_t in_vector_length,
-                                 int16_t samples,
-                                 int16_t* out_vector);
-int16_t WebRtcSpl_ZerosArrayW16(int16_t* vector,
-                                int16_t vector_length);
-int16_t WebRtcSpl_ZerosArrayW32(int32_t* vector,
-                                int16_t vector_length);
-int16_t WebRtcSpl_OnesArrayW16(int16_t* vector,
-                               int16_t vector_length);
-int16_t WebRtcSpl_OnesArrayW32(int32_t* vector,
-                               int16_t vector_length);
+void WebRtcSpl_CopyFromEndW16(const int16_t* in_vector,
+                              int in_vector_length,
+                              int samples,
+                              int16_t* out_vector);
+void WebRtcSpl_ZerosArrayW16(int16_t* vector,
+                             int vector_length);
+void WebRtcSpl_ZerosArrayW32(int32_t* vector,
+                             int vector_length);
 // End: Copy and set operations.
 
 
@@ -931,10 +927,10 @@
  *
  ******************************************************************/
 
-void WebRtcSpl_DownsampleBy2(const int16_t* in, int16_t len,
+void WebRtcSpl_DownsampleBy2(const int16_t* in, int len,
                              int16_t* out, int32_t* filtState);
 
-void WebRtcSpl_UpsampleBy2(const int16_t* in, int16_t len,
+void WebRtcSpl_UpsampleBy2(const int16_t* in, int len,
                            int16_t* out, int32_t* filtState);
 
 /************************************************************
@@ -1110,8 +1106,6 @@
 // Output:
 //      - out_vector        : Vector with the requested samples
 //
-// Return value             : Number of copied samples in |out_vector|
-//
 
 //
 // WebRtcSpl_ZerosArrayW16(...)
@@ -1126,24 +1120,6 @@
 // Output:
 //      - vector        : Vector containing all zeros
 //
-// Return value         : Number of samples in vector
-//
-
-//
-// WebRtcSpl_OnesArrayW16(...)
-// WebRtcSpl_OnesArrayW32(...)
-//
-// Inserts the value "one" in all positions of a w16 and a w32 vector
-// respectively.
-//
-// Input:
-//      - vector_length : Number of samples in vector
-//
-// Output:
-//      - vector        : Vector containing all ones
-//
-// Return value         : Number of samples in vector
-//
 
 //
 // WebRtcSpl_VectorBitShiftW16(...)
diff --git a/common_audio/signal_processing/include/spl_inl.h b/common_audio/signal_processing/include/spl_inl.h
index 8bf452f..d3cc6de 100644
--- a/common_audio/signal_processing/include/spl_inl.h
+++ b/common_audio/signal_processing/include/spl_inl.h
@@ -84,7 +84,7 @@
 
 #if !defined(MIPS32_LE)
 static __inline int16_t WebRtcSpl_GetSizeInBits(uint32_t n) {
-  int bits;
+  int16_t bits;
 
   if (0xFFFF0000 & n) {
     bits = 16;
@@ -100,8 +100,8 @@
   return bits;
 }
 
-static __inline int WebRtcSpl_NormW32(int32_t a) {
-  int zeros;
+static __inline int16_t WebRtcSpl_NormW32(int32_t a) {
+  int16_t zeros;
 
   if (a == 0) {
     return 0;
@@ -123,8 +123,8 @@
   return zeros;
 }
 
-static __inline int WebRtcSpl_NormU32(uint32_t a) {
-  int zeros;
+static __inline int16_t WebRtcSpl_NormU32(uint32_t a) {
+  int16_t zeros;
 
   if (a == 0) return 0;
 
@@ -141,8 +141,8 @@
   return zeros;
 }
 
-static __inline int WebRtcSpl_NormW16(int16_t a) {
-  int zeros;
+static __inline int16_t WebRtcSpl_NormW16(int16_t a) {
+  int16_t zeros;
 
   if (a == 0) {
     return 0;
diff --git a/common_audio/signal_processing/include/spl_inl_armv7.h b/common_audio/signal_processing/include/spl_inl_armv7.h
index 3854715..0d10129 100644
--- a/common_audio/signal_processing/include/spl_inl_armv7.h
+++ b/common_audio/signal_processing/include/spl_inl_armv7.h
@@ -83,7 +83,7 @@
   return (int16_t)(32 - tmp);
 }
 
-static __inline int WebRtcSpl_NormW32(int32_t a) {
+static __inline int16_t WebRtcSpl_NormW32(int32_t a) {
   int32_t tmp = 0;
 
   if (a == 0) {
@@ -95,20 +95,20 @@
 
   __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a));
 
-  return tmp - 1;
+  return (int16_t)(tmp - 1);
 }
 
-static __inline int WebRtcSpl_NormU32(uint32_t a) {
+static __inline int16_t WebRtcSpl_NormU32(uint32_t a) {
   int tmp = 0;
 
   if (a == 0) return 0;
 
   __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a));
 
-  return tmp;
+  return (int16_t)tmp;
 }
 
-static __inline int WebRtcSpl_NormW16(int16_t a) {
+static __inline int16_t WebRtcSpl_NormW16(int16_t a) {
   int32_t tmp = 0;
 
   if (a == 0) {
@@ -120,7 +120,7 @@
 
   __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a));
 
-  return tmp - 17;
+  return (int16_t)(tmp - 17);
 }
 
 // TODO(kma): add unit test.
diff --git a/common_audio/signal_processing/include/spl_inl_mips.h b/common_audio/signal_processing/include/spl_inl_mips.h
index ab9a60d..cd04bdd 100644
--- a/common_audio/signal_processing/include/spl_inl_mips.h
+++ b/common_audio/signal_processing/include/spl_inl_mips.h
@@ -137,10 +137,10 @@
     : [n] "r" (n), [i32] "r" (i32)
   );
 
-  return bits;
+  return (int16_t)bits;
 }
 
-static __inline int WebRtcSpl_NormW32(int32_t a) {
+static __inline int16_t WebRtcSpl_NormW32(int32_t a) {
   int zeros = 0;
 
   __asm __volatile(
@@ -160,10 +160,10 @@
     : [a] "r" (a)
   );
 
-  return zeros;
+  return (int16_t)zeros;
 }
 
-static __inline int WebRtcSpl_NormU32(uint32_t a) {
+static __inline int16_t WebRtcSpl_NormU32(uint32_t a) {
   int zeros = 0;
 
   __asm __volatile(
@@ -172,10 +172,10 @@
     : [a] "r" (a)
   );
 
-  return (zeros & 0x1f);
+  return (int16_t)(zeros & 0x1f);
 }
 
-static __inline int WebRtcSpl_NormW16(int16_t a) {
+static __inline int16_t WebRtcSpl_NormW16(int16_t a) {
   int zeros = 0;
   int a0 = a << 16;
 
@@ -196,7 +196,7 @@
     : [a0] "r" (a0)
   );
 
-  return zeros;
+  return (int16_t)zeros;
 }
 
 static __inline int32_t WebRtc_MulAccumW16(int16_t a,
diff --git a/common_audio/signal_processing/resample_by_2.c b/common_audio/signal_processing/resample_by_2.c
index eab091b..9c0784e 100644
--- a/common_audio/signal_processing/resample_by_2.c
+++ b/common_audio/signal_processing/resample_by_2.c
@@ -67,10 +67,10 @@
 
 // decimator
 #if !defined(MIPS32_LE)
-void WebRtcSpl_DownsampleBy2(const int16_t* in, int16_t len,
+void WebRtcSpl_DownsampleBy2(const int16_t* in, int len,
                              int16_t* out, int32_t* filtState) {
   int32_t tmp1, tmp2, diff, in32, out32;
-  int16_t i;
+  int i;
 
   register int32_t state0 = filtState[0];
   register int32_t state1 = filtState[1];
@@ -125,10 +125,10 @@
 #endif  // #if defined(MIPS32_LE)
 
 
-void WebRtcSpl_UpsampleBy2(const int16_t* in, int16_t len,
+void WebRtcSpl_UpsampleBy2(const int16_t* in, int len,
                            int16_t* out, int32_t* filtState) {
   int32_t tmp1, tmp2, diff, in32, out32;
-  int16_t i;
+  int i;
 
   register int32_t state0 = filtState[0];
   register int32_t state1 = filtState[1];
diff --git a/common_audio/signal_processing/resample_by_2_mips.c b/common_audio/signal_processing/resample_by_2_mips.c
index 8e840bb..6ffce55 100644
--- a/common_audio/signal_processing/resample_by_2_mips.c
+++ b/common_audio/signal_processing/resample_by_2_mips.c
@@ -29,11 +29,11 @@
 
 // decimator
 void WebRtcSpl_DownsampleBy2(const int16_t* in,
-                             int16_t len,
+                             int len,
                              int16_t* out,
                              int32_t* filtState) {
   int32_t out32;
-  int16_t i, len1;
+  int i, len1;
 
   register int32_t state0 = filtState[0];
   register int32_t state1 = filtState[1];
diff --git a/common_audio/signal_processing/signal_processing_unittest.cc b/common_audio/signal_processing/signal_processing_unittest.cc
index 6a70a02..3fa3d2e 100644
--- a/common_audio/signal_processing/signal_processing_unittest.cc
+++ b/common_audio/signal_processing/signal_processing_unittest.cc
@@ -172,26 +172,18 @@
     for (int kk = 0; kk < kVectorSize; ++kk) {
         EXPECT_EQ(3, b16[kk]);
     }
-    EXPECT_EQ(kVectorSize, WebRtcSpl_ZerosArrayW16(b16, kVectorSize));
+    WebRtcSpl_ZerosArrayW16(b16, kVectorSize);
     for (int kk = 0; kk < kVectorSize; ++kk) {
         EXPECT_EQ(0, b16[kk]);
     }
-    EXPECT_EQ(kVectorSize, WebRtcSpl_OnesArrayW16(b16, kVectorSize));
-    for (int kk = 0; kk < kVectorSize; ++kk) {
-        EXPECT_EQ(1, b16[kk]);
-    }
     WebRtcSpl_MemSetW32(b32, 3, kVectorSize);
     for (int kk = 0; kk < kVectorSize; ++kk) {
         EXPECT_EQ(3, b32[kk]);
     }
-    EXPECT_EQ(kVectorSize, WebRtcSpl_ZerosArrayW32(b32, kVectorSize));
+    WebRtcSpl_ZerosArrayW32(b32, kVectorSize);
     for (int kk = 0; kk < kVectorSize; ++kk) {
         EXPECT_EQ(0, b32[kk]);
     }
-    EXPECT_EQ(kVectorSize, WebRtcSpl_OnesArrayW32(b32, kVectorSize));
-    for (int kk = 0; kk < kVectorSize; ++kk) {
-        EXPECT_EQ(1, b32[kk]);
-    }
     for (int kk = 0; kk < kVectorSize; ++kk) {
         bTmp16[kk] = (int16_t)kk;
         bTmp32[kk] = (int32_t)kk;
@@ -204,7 +196,7 @@
 //    for (int kk = 0; kk < kVectorSize; ++kk) {
 //        EXPECT_EQ(b32[kk], bTmp32[kk]);
 //    }
-    EXPECT_EQ(2, WebRtcSpl_CopyFromEndW16(b16, kVectorSize, 2, bTmp16));
+    WebRtcSpl_CopyFromEndW16(b16, kVectorSize, 2, bTmp16);
     for (int kk = 0; kk < 2; ++kk) {
         EXPECT_EQ(kk+2, bTmp16[kk]);
     }
diff --git a/common_audio/signal_processing/splitting_filter.c b/common_audio/signal_processing/splitting_filter.c
index 966eef7..4f6430c 100644
--- a/common_audio/signal_processing/splitting_filter.c
+++ b/common_audio/signal_processing/splitting_filter.c
@@ -45,7 +45,7 @@
 //                            |data_length|
 //
 
-void WebRtcSpl_AllPassQMF(int32_t* in_data, int16_t data_length,
+void WebRtcSpl_AllPassQMF(int32_t* in_data, int data_length,
                           int32_t* out_data, const uint16_t* filter_coefficients,
                           int32_t* filter_state)
 {
@@ -65,7 +65,7 @@
     // filter operation takes the |in_data| (which is the output from the previous cascade
     // filter) and store the output in |out_data|.
     // Note that the input vector values are changed during the process.
-    int16_t k;
+    int k;
     int32_t diff;
     // First all-pass cascade; filter from in_data to out_data.
 
diff --git a/common_audio/signal_processing/vector_scaling_operations.c b/common_audio/signal_processing/vector_scaling_operations.c
index d839206..c3eaa28 100644
--- a/common_audio/signal_processing/vector_scaling_operations.c
+++ b/common_audio/signal_processing/vector_scaling_operations.c
@@ -75,7 +75,7 @@
       (*out++) = WebRtcSpl_SatW32ToW16(tmp_w32);
     }
   } else {
-    int16_t left_shifts = -right_shifts;
+    int left_shifts = -right_shifts;
     for (i = length; i > 0; i--) {
       tmp_w32 = (*in++) << left_shifts;
       (*out++) = WebRtcSpl_SatW32ToW16(tmp_w32);