Index: media/base/sinc_resampler.h |
diff --git a/media/base/sinc_resampler.h b/media/base/sinc_resampler.h |
index 3ccb85c5d8e8b2a325f17ec9aa26dbd36da45375..12a73a697b70b7eb868b8026ec1f317d0a749313 100644 |
--- a/media/base/sinc_resampler.h |
+++ b/media/base/sinc_resampler.h |
@@ -23,23 +23,15 @@ class MEDIA_EXPORT SincResampler { |
// TODO(dalecurtis): Test performance to see if we can jack this up to 64+. |
kKernelSize = 32, |
- // The number of destination frames generated per processing pass. Affects |
- // how often and for how much SincResampler calls back for input. Must be |
- // greater than kKernelSize. |
- kBlockSize = 512, |
+ // Default block size. Affects how often and for how much SincResampler |
+ // calls back for input. Must be greater than kKernelSize. |
+ kDefaultBlockSize = 512, |
// The kernel offset count is used for interpolation and is the number of |
// sub-sample kernel shifts. Can be adjusted for quality (higher is better) |
// at the expense of allocating more memory. |
kKernelOffsetCount = 32, |
kKernelStorageSize = kKernelSize * (kKernelOffsetCount + 1), |
- |
- // The size (in samples) of the internal buffer used by the resampler. |
- kBufferSize = kBlockSize + kKernelSize, |
- |
- // The maximum number of samples that may be requested from the callback |
- // ahead of the current position in the stream. |
- kMaximumLookAheadSize = kBufferSize |
}; |
// Callback type for providing more data into the resampler. Expects |frames| |
@@ -49,8 +41,11 @@ class MEDIA_EXPORT SincResampler { |
// Constructs a SincResampler with the specified |read_cb|, which is used to |
// acquire audio data for resampling. |io_sample_rate_ratio| is the ratio of |
- // input / output sample rates. |
- SincResampler(double io_sample_rate_ratio, const ReadCB& read_cb); |
+ // input / output sample rates. |request_size| controls the size of the |
+ // buffer requested by each |read_cb| call. The value must be greater than |
+ // kKernelSize. |
+ SincResampler(double io_sample_rate_ratio, size_t request_size, |
+ const ReadCB& read_cb); |
virtual ~SincResampler(); |
// Resample |frames| of data from |read_cb_| into |destination|. |
@@ -76,6 +71,7 @@ class MEDIA_EXPORT SincResampler { |
FRIEND_TEST_ALL_PREFIXES(SincResamplerTest, ConvolveBenchmark); |
void InitializeKernel(); |
+ void UpdateRegions(); |
// Compute convolution of |k1| and |k2| over |input_ptr|, resultant sums are |
// linearly interpolated using |kernel_interpolation_factor|. On x86, the |
@@ -104,7 +100,16 @@ class MEDIA_EXPORT SincResampler { |
bool buffer_primed_; |
// Source of data for resampling. |
- ReadCB read_cb_; |
+ const ReadCB read_cb_; |
+ |
+ // The size (in samples) to request from each |read_cb_| execution. |
+ const size_t request_size_; |
+ |
+ // The number of source frames processed per pass. |
+ size_t block_size_; |
+ |
+ // The size (in samples) of the internal buffer used by the resampler. |
+ const size_t input_buffer_size_; |
// Contains kKernelOffsetCount kernels back-to-back, each of size kKernelSize. |
// The kernel offsets are sub-sample shifts of a windowed sinc shifted from |
@@ -125,12 +130,12 @@ class MEDIA_EXPORT SincResampler { |
// Pointers to the various regions inside |input_buffer_|. See the diagram at |
// the top of the .cc file for more information. |
- float* const r0_; |
- float* const r1_; |
- float* const r2_; |
- float* const r3_; |
- float* const r4_; |
- float* const r5_; |
+ bool reinitialize_regions_; |
+ float* r0_; |
+ float* r1_; |
+ float* r2_; |
+ float* r3_; |
+ float* r4_; |
DISALLOW_COPY_AND_ASSIGN(SincResampler); |
}; |