Index: Source/core/platform/audio/UpSampler.h |
diff --git a/Source/core/animation/Animation.h b/Source/core/platform/audio/UpSampler.h |
similarity index 56% |
copy from Source/core/animation/Animation.h |
copy to Source/core/platform/audio/UpSampler.h |
index f72d57ac5e5fd993ea4f360163ee7e351343b920..ebd3993509884052d508a8aff0702ea64d6e19ba 100644 |
--- a/Source/core/animation/Animation.h |
+++ b/Source/core/platform/audio/UpSampler.h |
@@ -28,43 +28,49 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef Animation_h |
-#define Animation_h |
+#ifndef UpSampler_h |
+#define UpSampler_h |
-#include "core/animation/AnimationEffect.h" |
-#include "core/animation/TimedItem.h" |
-#include "wtf/RefPtr.h" |
+#include "core/platform/audio/AudioArray.h" |
+#include "core/platform/audio/DirectConvolver.h" |
namespace WebCore { |
-class Element; |
- |
-class Animation FINAL : public TimedItem { |
+// UpSampler up-samples the source stream by a factor of 2x. |
+class UpSampler { |
public: |
- static PassRefPtr<Animation> create(PassRefPtr<Element>, PassRefPtr<AnimationEffect>, const Timing&); |
- virtual ~Animation(); |
+ UpSampler(size_t inputBlockSize); |
+ |
+ // The destination buffer |destP| is of size sourceFramesToProcess * 2. |
+ void process(const float* sourceP, float* destP, size_t sourceFramesToProcess); |
- const AnimationEffect::CompositableValueMap* compositableValues() const |
- { |
- ASSERT(m_compositableValues); |
- return m_compositableValues.get(); |
- } |
+ void reset(); |
-protected: |
- virtual void applyEffects(bool previouslyActiveOrInEffect); |
- virtual void clearEffects(); |
- virtual void updateChildrenAndEffects(bool) const OVERRIDE FINAL; |
+ // Latency based on the source sample-rate. |
+ size_t latencyFrames() const; |
private: |
- Animation(PassRefPtr<Element>, PassRefPtr<AnimationEffect>, const Timing&); |
+ enum { DefaultKernelSize = 128 }; |
+ |
+ size_t m_inputBlockSize; |
+ |
+ // 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; |
- RefPtr<Element> m_target; |
- RefPtr<AnimationEffect> m_effect; |
- bool m_isInTargetActiveAnimationsList; |
- OwnPtr<AnimationEffect::CompositableValueMap> m_compositableValues; |
+ // Delay line for generating the even sample-frames of the output. |
+ // The source samples are delayed exactly to match the linear phase delay of the FIR filter (convolution) |
+ // used to generate the odd sample-frames of the output. |
+ AudioFloatArray m_inputBuffer; |
}; |
} // namespace WebCore |
-#endif |
+#endif // UpSampler_h |