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

Side by Side Diff: media/base/sinc_resampler.h

Issue 10702050: Add SincResampler ported from WebKit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Zero-Initialize Arrays + Check Max Error. Created 8 years, 5 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 | « no previous file | media/base/sinc_resampler.cc » ('j') | media/base/sinc_resampler.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
Ami GONE FROM CHROMIUM 2012/06/30 20:29:30 Visual plot link should include a bit of explanati
DaleCurtis 2012/07/03 00:36:34 Moved to imgur and updated description.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_SINC_RESAMPLER_H_
6 #define MEDIA_BASE_SINC_RESAMPLER_H_
7
8 #include "media/base/media_export.h"
9
10 namespace media {
11
12 // SincResampler is a high-quality single-channel sample-rate converter.
13 class MEDIA_EXPORT SincResampler {
14 public:
15 // The number of destination frames generated per processing pass.
16 static const int kBlockSize;
Ami GONE FROM CHROMIUM 2012/06/30 20:29:30 enum turns this into a compile-time constant, avoi
DaleCurtis 2012/07/03 00:36:34 With the changes to multichannel resampler, these
DaleCurtis 2012/07/03 01:53:07 Actually this is more complicated than I thought,
17
18 // The size of the internal buffer used by the resampler.
19 static const int kBufferSize;
Ami GONE FROM CHROMIUM 2012/06/30 20:29:30 ditto
DaleCurtis 2012/07/03 00:36:34 Ditto.
20
21 // Abstract base-class for a pulling data into SincResampler.
Ami GONE FROM CHROMIUM 2012/06/30 20:29:30 Ditto to comment from other CL; make this a typede
DaleCurtis 2012/07/03 00:36:34 Done.
22 class AudioSourceProvider {
23 public:
24 // ProvideInput() is called repeatedly to render time-slices of a continuous
25 // audio stream.
26 virtual void ProvideInput(float* destination, int number_of_frames) = 0;
27
28 protected:
29 virtual ~AudioSourceProvider() {}
30 };
31
32 // Constructs a SincResampler with the specified |provider|, which is used to
33 // acquire audio data for resampling. |scale_factor| is input_sample_rate /
34 // output_sample_rate.
35 // TODO(dalecurtis): Should provider be a const ref? Need to make ProvideInput
36 // const if so... Following the RenderCallback model currently.
37 SincResampler(AudioSourceProvider* provider, double scale_factor);
38 virtual ~SincResampler();
39
40 // Resample |number_of_frames| of data from |provider_| into |destination|.
41 // If |number_of_frames| < kBlockSize AudioSourceProvider::ProvideInput() will
42 // be called at most once depending on if data remains in the internal buffer.
43 void Resample(float* destination, int number_of_frames);
44
45 private:
46 double scale_factor_;
47
48 // |virtual_source_idx_| is an index on the source input buffer with
49 // sub-sample precision. It must be double precision to avoid drift.
50 double virtual_source_idx_;
51
52 // The buffer is primed once at the very beginning of processing.
53 bool buffer_primed_;
54
55 // |provider_| is used to provide the audio input stream to the resampler.
56 AudioSourceProvider* provider_;
57
58 // |kernel_storage_| has kKernelOffsetCount kernels back-to-back, each of size
59 // kKernelSize. The kernel offsets are sub-sample shifts of a windowed sinc
60 // shifted from 0.0 to 1.0 sample.
61 float* kernel_storage_;
Ami GONE FROM CHROMIUM 2012/06/30 20:29:30 scoped
DaleCurtis 2012/07/03 00:36:34 Done.
62
63 // Data from the source is copied into this buffer for each processing pass.
64 float* input_buffer_;
Ami GONE FROM CHROMIUM 2012/06/30 20:29:30 scoped
DaleCurtis 2012/07/03 00:36:34 Done.
65
66 void InitializeKernel();
67 };
68
69 } // namespace media
70
71 #endif // MEDIA_BASE_SINC_RESAMPLER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/sinc_resampler.cc » ('j') | media/base/sinc_resampler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698