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

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: Initial Commit! 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/memory/scoped_ptr.h"
11 #include "media/base/sinc_resampler.h"
12
13 namespace media {
14
15 class MEDIA_EXPORT MultiChannelResampler
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 Add a class-level comment (what this does, how it'
DaleCurtis 2012/07/03 03:02:57 Done.
16 : public SincResampler::AudioSourceProvider {
17 public:
18 // Abstract base-class for a pulling data into the resampler.
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 english
DaleCurtis 2012/07/03 03:02:57 Removed.
19 class MultiChannelAudioSourceProvider {
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 Is this a provider of "audio source"s or a provide
DaleCurtis 2012/07/03 03:02:57 Just ReadCB now.
20 public:
21 // ProvideInput() is called repeatedly to render time-slices of a continuous
22 // multi channel audio stream.
23 virtual void ProvideInput(const std::vector<float*>& audio_data,
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 |audio_data|'s format needs description. My guess
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 When your interface is just one (or just a few) me
DaleCurtis 2012/07/01 23:27:46 I'm keeping style with AudioRendererSink::RenderCa
DaleCurtis 2012/07/03 03:02:57 Converted to Callback, kept RenderCallback style.
24 int number_of_frames) = 0;
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 fwiw, with a type of int, I think |frames| is clea
DaleCurtis 2012/07/01 23:27:46 Ditto. I prefer frames as well, but am going for c
Ami GONE FROM CHROMIUM 2012/07/01 23:44:44 Yep, in this case. (note, also, consistency can wo
DaleCurtis 2012/07/02 17:43:45 sgtm.
DaleCurtis 2012/07/03 03:02:57 Done.
25
26 protected:
27 virtual ~MultiChannelAudioSourceProvider() {}
28 };
29
30 // Constructs a MultiChannelResampler with the specified |provider|, which is
31 // used to acquire data for all channels during resampling. |scale_factor| is
32 // input_sample_rate / output_sample_rate.
33 // TODO(dalecurtis): Should provider be a const ref? Need to make ProvideInput
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 TODO goes away with my callback suggestion above.
DaleCurtis 2012/07/03 03:02:57 Removed.
34 // const if so... Following the RenderCallback model currently.
35 MultiChannelResampler(MultiChannelAudioSourceProvider* provider,
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 generally output params follow input params, so th
DaleCurtis 2012/07/03 03:02:57 These are all input parameters? I moved the CB to
36 double scale_factor, int number_of_channels);
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 s/scale_factor/io_sample_rate_ratio/ is clearer?
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 FWIW, number_of_channels is implicit in the Provid
DaleCurtis 2012/07/03 03:02:57 Doesn't really save anything and makes the already
37 virtual ~MultiChannelResampler();
38
39 // Resample |number_of_frames| of data from |provider_| into |audio_data|.
40 void Resample(const std::vector<float*>& audio_data, int number_of_frames);
41
42 private:
43 int number_of_channels_;
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 const
DaleCurtis 2012/07/03 03:02:57 Removed.
44
45 // Index of the channel currently being processed.
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 This and the next two members are used mostly for
DaleCurtis 2012/07/03 03:02:57 I was able to bind away channel_index_, but I don'
46 size_t channel_index_;
47
48 // Number of frames requested by SincResampler from ProvideInput() when the
49 // |channel_index_| was 0.
50 int last_frame_count_;
51
52 // Sanity check to ensure ProvideInput() is only called once per channel.
53 size_t callback_count_;
54
55 // Source of data for resampling.
56 MultiChannelAudioSourceProvider* provider_;
57
58 // Each channel has its own high quality resampler.
59 std::vector<SincResampler*> resamplers_;
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 ScopedVector
DaleCurtis 2012/07/03 03:02:57 Done.
60
61 // Staging area for data between the MultiChannelAudioSourceProvider and the
62 // SincResampler.
63 std::vector<float*> resampler_audio_data_;
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 vector<scoped_array<float> > would be clearer abou
DaleCurtis 2012/07/01 23:27:46 I don't think I can pass that along via RenderCall
Ami GONE FROM CHROMIUM 2012/07/01 23:44:44 Ouch (great example of how API choices propagate..
DaleCurtis 2012/07/02 17:43:45 Actually, I don't know what I was talking about. I
DaleCurtis 2012/07/03 03:02:57 Actually, that's not true, I remember what I was t
64
65 // SincResampler::AudioSourceProvider implementation. ProvideInput() will be
66 // called once for each channel, starting with the first channel. Each time
Ami GONE FROM CHROMIUM 2012/06/30 20:12:14 s/starting with the first channel/in channel order
DaleCurtis 2012/07/03 03:02:57 Done.
67 // it's called, it will provide the next channel of data.
68 virtual void ProvideInput(float* destination, int number_of_frames) OVERRIDE;
69 };
70
71 } // namespace media
72
73 #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