Index: Source/core/platform/audio/DownSampler.h |
diff --git a/Source/core/platform/audio/DirectConvolver.h b/Source/core/platform/audio/DownSampler.h |
similarity index 64% |
copy from Source/core/platform/audio/DirectConvolver.h |
copy to Source/core/platform/audio/DownSampler.h |
index 0528d7cb6ce66e12fdcfda6cd25da8ed98f32ebf..2766ba79cbca30c5d42c07be8899a7b6a910b398 100644 |
--- a/Source/core/platform/audio/DirectConvolver.h |
+++ b/Source/core/platform/audio/DownSampler.h |
@@ -1,5 +1,5 @@ |
/* |
- * Copyright (C) 2012 Intel Inc. All rights reserved. |
+ * Copyright (C) 2013 Google Inc. All rights reserved. |
Ken Russell (switch to Gerrit)
2013/05/23 02:29:25
The copyright notice on these new files is the wro
Chris Rogers
2013/05/24 20:09:04
Done.
|
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
@@ -26,34 +26,45 @@ |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef DirectConvolver_h |
-#define DirectConvolver_h |
+#ifndef DownSampler_h |
+#define DownSampler_h |
#include "core/platform/audio/AudioArray.h" |
- |
-#if USE(WEBAUDIO_IPP) |
-#include <ipps.h> |
-#endif // USE(WEBAUDIO_IPP) |
+#include "core/platform/audio/DirectConvolver.h" |
namespace WebCore { |
-class DirectConvolver { |
+// DownSampler down-samples the source stream by a factor of 2x. |
+ |
+class DownSampler { |
public: |
- DirectConvolver(size_t inputBlockSize); |
+ DownSampler(size_t inputBlockSize); |
- void process(AudioFloatArray* convolutionKernel, const float* sourceP, float* destP, size_t framesToProcess); |
+ // The destination buffer |destP| is of size sourceFramesToProcess / 2. |
+ void process(const float* sourceP, float* destP, size_t sourceFramesToProcess); |
void reset(); |
+ // Latency based on the destination sample-rate. |
+ size_t latencyFrames() const; |
+ |
private: |
+ enum { DefaultKernelSize = 256 }; |
+ |
size_t m_inputBlockSize; |
-#if USE(WEBAUDIO_IPP) |
- AudioFloatArray m_overlayBuffer; |
-#endif // USE(WEBAUDIO_IPP) |
- AudioFloatArray m_buffer; |
+ // Computes ideal band-limited half-band filter coefficients. |
+ // In other words, filter out all frequencies higher than 0.25 * Nyquist. |
+ void initializeKernel(); |
+ AudioFloatArray m_reducedKernel; |
+ |
+ // Half-band filter. |
+ DirectConvolver m_convolver; |
+ |
+ AudioFloatArray m_tempBuffer; |
+ AudioFloatArray m_inputBuffer; |
}; |
} // namespace WebCore |
-#endif // DirectConvolver_h |
+#endif // DownSampler_h |