X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fthird_party%2Fwebrtc%2Fcommon_audio%2Fresampler%2Fsinc_resampler.cc;h=165cb356cc4970469752559347fb3cae8e31a626;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=84f8125b59daa050d65f38ddba00a4708fcb59f4;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/third_party/webrtc/common_audio/resampler/sinc_resampler.cc b/src/third_party/webrtc/common_audio/resampler/sinc_resampler.cc index 84f8125..165cb35 100644 --- a/src/third_party/webrtc/common_audio/resampler/sinc_resampler.cc +++ b/src/third_party/webrtc/common_audio/resampler/sinc_resampler.cc @@ -222,23 +222,22 @@ void SincResampler::InitializeKernel() { 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(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(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(window * + ((pre_sinc == 0) ? + sinc_scale_factor : + (sin(sinc_scale_factor * pre_sinc) / pre_sinc))); } } } @@ -260,12 +259,10 @@ void SincResampler::SetRatio(double io_sample_rate_ratio) { 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(window * + ((pre_sinc == 0) ? + sinc_scale_factor : + (sin(sinc_scale_factor * pre_sinc) / pre_sinc))); } } } @@ -289,18 +286,19 @@ void SincResampler::Resample(int frames, float* destination) { // // 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( + 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(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(virtual_offset_idx); // We'll compute "convolutions" for the two kernels which straddle // |virtual_source_idx_|. @@ -347,7 +345,7 @@ void SincResampler::Resample(int frames, float* destination) { #undef CONVOLVE_FUNC int SincResampler::ChunkSize() const { - return block_size_ / io_sample_rate_ratio_; + return static_cast(block_size_ / io_sample_rate_ratio_); } void SincResampler::Flush() { @@ -373,8 +371,8 @@ float SincResampler::Convolve_C(const float* input_ptr, const float* k1, } // Linearly interpolate the two "convolutions". - return (1.0 - kernel_interpolation_factor) * sum1 - + kernel_interpolation_factor * sum2; + return static_cast((1.0 - kernel_interpolation_factor) * sum1 + + kernel_interpolation_factor * sum2); } } // namespace webrtc