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

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: Comments! 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
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 // Sanity check to ensure that ProvideInput() retrieves the same number of
39 // frames for every channel.
40 int last_frame_count_;
41
42 // Sanity check to ensure ProvideInput() is only called once per channel.
43 int callback_count_;
44
45 // Source of data for resampling.
46 ReadCB read_cb_;
47
48 // Each channel has its own high quality resampler.
49 ScopedVector<SincResampler> resamplers_;
50
51 // Buffer for audio data going into SincResampler from ReadCB. Owned by this
52 // class and only temporarily passed out to ReadCB when data is required.
53 std::vector<float*> resampler_audio_data_;
54
55 // SincResampler::ReadCB implementation. ProvideInput() will be called for
56 // each channel (in channel order) as SincResampler needs more data.
57 void ProvideInput(int channel, float* destination, int frames);
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') | media/base/multi_channel_resampler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698