| Index: Source/core/platform/audio/DownSampler.h
|
| diff --git a/Source/core/animation/Animation.h b/Source/core/platform/audio/DownSampler.h
|
| similarity index 60%
|
| copy from Source/core/animation/Animation.h
|
| copy to Source/core/platform/audio/DownSampler.h
|
| index f72d57ac5e5fd993ea4f360163ee7e351343b920..afd5d98cf2de7d7220f22ce5bee1421961dcdf70 100644
|
| --- a/Source/core/animation/Animation.h
|
| +++ b/Source/core/platform/audio/DownSampler.h
|
| @@ -28,43 +28,47 @@
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| -#ifndef Animation_h
|
| -#define Animation_h
|
| +#ifndef DownSampler_h
|
| +#define DownSampler_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 {
|
| +// DownSampler down-samples the source stream by a factor of 2x.
|
|
|
| +class DownSampler {
|
| public:
|
| - static PassRefPtr<Animation> create(PassRefPtr<Element>, PassRefPtr<AnimationEffect>, const Timing&);
|
| - virtual ~Animation();
|
| + DownSampler(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 destination sample-rate.
|
| + size_t latencyFrames() const;
|
|
|
| private:
|
| - Animation(PassRefPtr<Element>, PassRefPtr<AnimationEffect>, const Timing&);
|
| + enum { DefaultKernelSize = 256 };
|
| +
|
| + size_t m_inputBlockSize;
|
| +
|
| + // 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;
|
|
|
| - RefPtr<Element> m_target;
|
| - RefPtr<AnimationEffect> m_effect;
|
| - bool m_isInTargetActiveAnimationsList;
|
| - OwnPtr<AnimationEffect::CompositableValueMap> m_compositableValues;
|
| + // Used as delay-line (FIR filter history) for the input samples to account for the 0.5 term right in the middle of the kernel.
|
| + AudioFloatArray m_inputBuffer;
|
| };
|
|
|
| } // namespace WebCore
|
|
|
| -#endif
|
| +#endif // DownSampler_h
|
|
|