Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: Source/core/platform/audio/DownSampler.h

Issue 15619003: Add support for WaveShaperNode.oversample (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: change TestExpectations in middle of file Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/platform/audio/DownSampler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 DownSampler_h
32 #define Animation_h 32 #define DownSampler_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 // DownSampler down-samples the source stream by a factor of 2x.
41 40
42 class Animation FINAL : public TimedItem { 41 class DownSampler {
42 public:
43 DownSampler(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 destination 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 = 256 };
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 half-band filter coefficients.
65 OwnPtr<AnimationEffect::CompositableValueMap> m_compositableValues; 59 // In other words, filter out all frequencies higher than 0.25 * Nyquist.
60 void initializeKernel();
61 AudioFloatArray m_reducedKernel;
62
63 // Half-band filter.
64 DirectConvolver m_convolver;
65
66 AudioFloatArray m_tempBuffer;
67
68 // 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.
69 AudioFloatArray m_inputBuffer;
66 }; 70 };
67 71
68 } // namespace WebCore 72 } // namespace WebCore
69 73
70 #endif 74 #endif // DownSampler_h
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/platform/audio/DownSampler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698