Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: media/base/sinc_resampler.cc

Issue 11189047: Add opus audio codec support in remoting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Input buffer layout, dividing the total buffer into regions (r0_ - r5_): 5 // Input buffer layout, dividing the total buffer into regions (r0_ - r5_):
6 // 6 //
7 // |----------------|-----------------------------------------|----------------| 7 // |----------------|-----------------------------------------|----------------|
8 // 8 //
9 // kBlockSize + kKernelSize / 2 9 // kBlockSize + kKernelSize / 2
10 // <---------------------------------------------------------> 10 // <--------------------------------------------------------->
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #if defined(ARCH_CPU_X86_FAMILY) && defined(__SSE__) 45 #if defined(ARCH_CPU_X86_FAMILY) && defined(__SSE__)
46 #include <xmmintrin.h> 46 #include <xmmintrin.h>
47 #endif 47 #endif
48 48
49 #if defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) 49 #if defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON)
50 #include <arm_neon.h> 50 #include <arm_neon.h>
51 #endif 51 #endif
52 52
53 namespace media { 53 namespace media {
54 54
55 namespace {
56
55 enum { 57 enum {
56 // The kernel size can be adjusted for quality (higher is better) at the 58 // The kernel size can be adjusted for quality (higher is better) at the
57 // expense of performance. Must be a multiple of 32. 59 // expense of performance. Must be a multiple of 32.
58 // TODO(dalecurtis): Test performance to see if we can jack this up to 64+. 60 // TODO(dalecurtis): Test performance to see if we can jack this up to 64+.
59 kKernelSize = 32, 61 kKernelSize = 32,
60 62
61 // The number of destination frames generated per processing pass. Affects 63 // The number of destination frames generated per processing pass. Affects
62 // how often and for how much SincResampler calls back for input. Must be 64 // how often and for how much SincResampler calls back for input. Must be
63 // greater than kKernelSize. 65 // greater than kKernelSize.
64 kBlockSize = 512, 66 kBlockSize = 512,
65 67
66 // The kernel offset count is used for interpolation and is the number of 68 // The kernel offset count is used for interpolation and is the number of
67 // sub-sample kernel shifts. Can be adjusted for quality (higher is better) 69 // sub-sample kernel shifts. Can be adjusted for quality (higher is better)
68 // at the expense of allocating more memory. 70 // at the expense of allocating more memory.
69 kKernelOffsetCount = 32, 71 kKernelOffsetCount = 32,
70 kKernelStorageSize = kKernelSize * (kKernelOffsetCount + 1), 72 kKernelStorageSize = kKernelSize * (kKernelOffsetCount + 1),
71 73
72 // The size (in samples) of the internal buffer used by the resampler. 74 // The size (in samples) of the internal buffer used by the resampler.
73 kBufferSize = kBlockSize + kKernelSize 75 kBufferSize = kBlockSize + kKernelSize
74 }; 76 };
75 77
78 } // namespace
79
80 const int SincResampler::kLookAheadSize = kBufferSize;
81
76 SincResampler::SincResampler(double io_sample_rate_ratio, const ReadCB& read_cb) 82 SincResampler::SincResampler(double io_sample_rate_ratio, const ReadCB& read_cb)
77 : io_sample_rate_ratio_(io_sample_rate_ratio), 83 : io_sample_rate_ratio_(io_sample_rate_ratio),
78 virtual_source_idx_(0), 84 virtual_source_idx_(0),
79 buffer_primed_(false), 85 buffer_primed_(false),
80 read_cb_(read_cb), 86 read_cb_(read_cb),
81 // Create input buffers with a 16-byte alignment for SSE optimizations. 87 // Create input buffers with a 16-byte alignment for SSE optimizations.
82 kernel_storage_(static_cast<float*>( 88 kernel_storage_(static_cast<float*>(
83 base::AlignedAlloc(sizeof(float) * kKernelStorageSize, 16))), 89 base::AlignedAlloc(sizeof(float) * kKernelStorageSize, 16))),
84 input_buffer_(static_cast<float*>( 90 input_buffer_(static_cast<float*>(
85 base::AlignedAlloc(sizeof(float) * kBufferSize, 16))), 91 base::AlignedAlloc(sizeof(float) * kBufferSize, 16))),
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 vmulq_f32(m_sums1, vmovq_n_f32(1.0 - kernel_interpolation_factor)), 338 vmulq_f32(m_sums1, vmovq_n_f32(1.0 - kernel_interpolation_factor)),
333 m_sums2, vmovq_n_f32(kernel_interpolation_factor)); 339 m_sums2, vmovq_n_f32(kernel_interpolation_factor));
334 340
335 // Sum components together. 341 // Sum components together.
336 float32x2_t m_half = vadd_f32(vget_high_f32(m_sums1), vget_low_f32(m_sums1)); 342 float32x2_t m_half = vadd_f32(vget_high_f32(m_sums1), vget_low_f32(m_sums1));
337 return vget_lane_f32(vpadd_f32(m_half, m_half), 0); 343 return vget_lane_f32(vpadd_f32(m_half, m_half), 0);
338 } 344 }
339 #endif 345 #endif
340 346
341 } // namespace media 347 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698