OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 10 matching lines...) Expand all Loading... |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef Animation_h | 31 #ifndef UpSampler_h |
32 #define Animation_h | 32 #define UpSampler_h |
33 | 33 |
34 #include "core/animation/AnimationEffect.h" | 34 #include "core/platform/audio/AudioArray.h" |
35 #include "core/animation/TimedItem.h" | 35 #include "core/platform/audio/DirectConvolver.h" |
36 #include "wtf/RefPtr.h" | |
37 | 36 |
38 namespace WebCore { | 37 namespace WebCore { |
39 | 38 |
40 class Element; | 39 // UpSampler up-samples the source stream by a factor of 2x. |
41 | 40 |
42 class Animation FINAL : public TimedItem { | 41 class UpSampler { |
| 42 public: |
| 43 UpSampler(size_t inputBlockSize); |
43 | 44 |
44 public: | 45 // The destination buffer |destP| is of size sourceFramesToProcess * 2. |
45 static PassRefPtr<Animation> create(PassRefPtr<Element>, PassRefPtr<Animatio
nEffect>, const Timing&); | 46 void process(const float* sourceP, float* destP, size_t sourceFramesToProces
s); |
46 virtual ~Animation(); | |
47 | 47 |
48 const AnimationEffect::CompositableValueMap* compositableValues() const | 48 void reset(); |
49 { | |
50 ASSERT(m_compositableValues); | |
51 return m_compositableValues.get(); | |
52 } | |
53 | 49 |
54 protected: | 50 // Latency based on the source sample-rate. |
55 virtual void applyEffects(bool previouslyActiveOrInEffect); | 51 size_t latencyFrames() const; |
56 virtual void clearEffects(); | |
57 virtual void updateChildrenAndEffects(bool) const OVERRIDE FINAL; | |
58 | 52 |
59 private: | 53 private: |
60 Animation(PassRefPtr<Element>, PassRefPtr<AnimationEffect>, const Timing&); | 54 enum { DefaultKernelSize = 128 }; |
61 | 55 |
62 RefPtr<Element> m_target; | 56 size_t m_inputBlockSize; |
63 RefPtr<AnimationEffect> m_effect; | 57 |
64 bool m_isInTargetActiveAnimationsList; | 58 // Computes ideal band-limited filter coefficients to sample in between each
source sample-frame. |
65 OwnPtr<AnimationEffect::CompositableValueMap> m_compositableValues; | 59 // This filter will be used to compute the odd sample-frames of the output. |
| 60 void initializeKernel(); |
| 61 AudioFloatArray m_kernel; |
| 62 |
| 63 // Computes the odd sample-frames of the output. |
| 64 DirectConvolver m_convolver; |
| 65 |
| 66 AudioFloatArray m_tempBuffer; |
| 67 |
| 68 // Delay line for generating the even sample-frames of the output. |
| 69 // The source samples are delayed exactly to match the linear phase delay of
the FIR filter (convolution) |
| 70 // used to generate the odd sample-frames of the output. |
| 71 AudioFloatArray m_inputBuffer; |
66 }; | 72 }; |
67 | 73 |
68 } // namespace WebCore | 74 } // namespace WebCore |
69 | 75 |
70 #endif | 76 #endif // UpSampler_h |
OLD | NEW |