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

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

Issue 10701049: Add MultiChannelResampler wrapper for SincResampler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. 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/multi_channel_resampler.cc » ('j') | no next file with comments »
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.
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_MULTI_CHANNEL_RESAMPLER_H_
6 #define MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_
7
8 #include <vector>
9
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h"
13 #include "media/base/sinc_resampler.h"
14
15 namespace media {
16
17 // MultiChannelResampler is a multi channel wrapper for SincResampler; allowing
18 // high quality sample rate conversion of multiple channels at once.
19 class MEDIA_EXPORT MultiChannelResampler {
20 public:
21 // Callback type for providing more data into the resampler. Expects |frames|
22 // of data for all channels to be rendered into |destination|; zero padded if
23 // not enough frames are available to satisfy the request.
24 typedef base::Callback<void(const std::vector<float*>& destination,
25 int frames)> ReadCB;
26
27 // Constructs a MultiChannelResampler with the specified |read_cb|, which is
28 // used to acquire audio data for resampling. |io_sample_rate_ratio| is the
29 // ratio of input / output sample rates.
30 MultiChannelResampler(int channels, double io_sample_rate_ratio,
31 const ReadCB& read_cb);
32 virtual ~MultiChannelResampler();
33
34 // Resample |frames| of data from |read_cb_| into |destination|.
35 void Resample(const std::vector<float*>& destination, int frames);
36
37 private:
38 // SincResampler::ReadCB implementation. ProvideInput() will be called for
39 // each channel (in channel order) as SincResampler needs more data.
40 void ProvideInput(int channel, float* destination, int frames);
41
42 // Sanity check to ensure that ProvideInput() retrieves the same number of
43 // frames for every channel.
44 int last_frame_count_;
45
46 // Sanity check to ensure |resampler_audio_data_| is properly allocated.
47 int first_frame_count_;
48
49 // Source of data for resampling.
50 ReadCB read_cb_;
51
52 // Each channel has its own high quality resampler.
53 ScopedVector<SincResampler> resamplers_;
54
55 // Buffer for audio data going into SincResampler from ReadCB. Owned by this
56 // class and only temporarily passed out to ReadCB when data is required.
57 std::vector<float*> resampler_audio_data_;
58 };
59
60 } // namespace media
61
62 #endif // MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/multi_channel_resampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698