Index: Source/core/platform/audio/UpSampler.h |
diff --git a/Source/core/platform/audio/DirectConvolver.h b/Source/core/platform/audio/UpSampler.h |
similarity index 63% |
copy from Source/core/platform/audio/DirectConvolver.h |
copy to Source/core/platform/audio/UpSampler.h |
index 0528d7cb6ce66e12fdcfda6cd25da8ed98f32ebf..1b1287a88dd4e0ea4a9b4c040e25537ad3381364 100644 |
--- a/Source/core/platform/audio/DirectConvolver.h |
+++ b/Source/core/platform/audio/UpSampler.h |
@@ -1,5 +1,5 @@ |
/* |
- * Copyright (C) 2012 Intel Inc. All rights reserved. |
+ * Copyright (C) 2013 Google Inc. All rights reserved. |
* |
* 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 UpSampler_h |
+#define UpSampler_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 { |
+// UpSampler up-samples the source stream by a factor of 2x. |
+ |
+class UpSampler { |
public: |
- DirectConvolver(size_t inputBlockSize); |
+ UpSampler(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 source sample-rate. |
+ size_t latencyFrames() const; |
+ |
private: |
+ enum { DefaultKernelSize = 128 }; |
+ |
size_t m_inputBlockSize; |
-#if USE(WEBAUDIO_IPP) |
- AudioFloatArray m_overlayBuffer; |
-#endif // USE(WEBAUDIO_IPP) |
- AudioFloatArray m_buffer; |
+ // Computes ideal band-limited filter coefficients to sample in between each source sample-frame. |
+ // This filter will be used to compute the odd sample-frames of the output. |
+ void initializeKernel(); |
+ AudioFloatArray m_kernel; |
+ |
+ // Computes the odd sample-frames of the output. |
+ DirectConvolver m_convolver; |
+ |
+ AudioFloatArray m_tempBuffer; |
+ AudioFloatArray m_inputBuffer; |
}; |
} // namespace WebCore |
-#endif // DirectConvolver_h |
+#endif // UpSampler_h |