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

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

Issue 2466463005: Support (E)AC3 passthrough
Patch Set: Add unit tests Created 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_AUDIO_BUS_H_ 5 #ifndef MEDIA_BASE_AUDIO_BUS_H_
6 #define MEDIA_BASE_AUDIO_BUS_H_ 6 #define MEDIA_BASE_AUDIO_BUS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // Uses channels() and frames_per_buffer() from AudioParameters if given. 62 // Uses channels() and frames_per_buffer() from AudioParameters if given.
63 static int CalculateMemorySize(int channels, int frames); 63 static int CalculateMemorySize(int channels, int frames);
64 static int CalculateMemorySize(const AudioParameters& params); 64 static int CalculateMemorySize(const AudioParameters& params);
65 65
66 // Methods that are expected to be called after AudioBus::CreateWrapper() in 66 // Methods that are expected to be called after AudioBus::CreateWrapper() in
67 // order to wrap externally allocated memory. Note: It is illegal to call 67 // order to wrap externally allocated memory. Note: It is illegal to call
68 // these methods when using a factory method other than CreateWrapper(). 68 // these methods when using a factory method other than CreateWrapper().
69 void SetChannelData(int channel, float* data); 69 void SetChannelData(int channel, float* data);
70 void set_frames(int frames); 70 void set_frames(int frames);
71 71
72 int data_size() const { return data_size_; }
DaleCurtis 2017/06/15 21:46:32 this should be GetBitstreamDataSize() and DCHECK(i
AndyWu 2017/08/02 01:43:40 Done.
73 void set_data_size(int data_size) { data_size_ = data_size; }
74
75 int is_bitstream_format() const { return is_bitstream_format_; }
76 void set_is_bitstream_format(bool is_bitstream_format) {
77 is_bitstream_format_ = is_bitstream_format;
78 }
79
72 // Overwrites the sample values stored in this AudioBus instance with values 80 // Overwrites the sample values stored in this AudioBus instance with values
73 // from a given interleaved |source_buffer| with expected layout 81 // from a given interleaved |source_buffer| with expected layout
74 // [ch0, ch1, ..., chN, ch0, ch1, ...] and sample values in the format 82 // [ch0, ch1, ..., chN, ch0, ch1, ...] and sample values in the format
75 // corresponding to the given SourceSampleTypeTraits. 83 // corresponding to the given SourceSampleTypeTraits.
76 // The sample values are converted to float values by means of the method 84 // The sample values are converted to float values by means of the method
77 // convert_to_float32() provided by the SourceSampleTypeTraits. For a list of 85 // convert_to_float32() provided by the SourceSampleTypeTraits. For a list of
78 // ready-to-use SampleTypeTraits, see file audio_sample_types.h. 86 // ready-to-use SampleTypeTraits, see file audio_sample_types.h.
79 // If |num_frames_to_write| is less than frames(), the remaining frames are 87 // If |num_frames_to_write| is less than frames(), the remaining frames are
80 // zeroed out. If |num_frames_to_write| is more than frames(), this results in 88 // zeroed out. If |num_frames_to_write| is more than frames(), this results in
81 // undefined behavior. 89 // undefined behavior.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 207
200 template <class TargetSampleTypeTraits> 208 template <class TargetSampleTypeTraits>
201 static void CopyConvertFromAudioBusToInterleavedTarget( 209 static void CopyConvertFromAudioBusToInterleavedTarget(
202 const AudioBus* source, 210 const AudioBus* source,
203 int read_offset_in_frames, 211 int read_offset_in_frames,
204 int num_frames_to_read, 212 int num_frames_to_read,
205 typename TargetSampleTypeTraits::ValueType* dest_buffer); 213 typename TargetSampleTypeTraits::ValueType* dest_buffer);
206 214
207 // Contiguous block of channel memory. 215 // Contiguous block of channel memory.
208 std::unique_ptr<float, base::AlignedFreeDeleter> data_; 216 std::unique_ptr<float, base::AlignedFreeDeleter> data_;
217 int data_size_;
218 bool is_bitstream_format_;
209 219
210 // One float pointer per channel pointing to a contiguous block of memory for 220 // One float pointer per channel pointing to a contiguous block of memory for
211 // that channel. If the memory is owned by this instance, this will 221 // that channel. If the memory is owned by this instance, this will
212 // point to the memory in |data_|. Otherwise, it may point to memory provided 222 // point to the memory in |data_|. Otherwise, it may point to memory provided
213 // by the client. 223 // by the client.
214 std::vector<float*> channel_data_; 224 std::vector<float*> channel_data_;
215 int frames_; 225 int frames_;
216 226
217 // Protect SetChannelData() and set_frames() for use by CreateWrapper(). 227 // Protect SetChannelData() and set_frames() for use by CreateWrapper().
218 bool can_set_channel_data_; 228 bool can_set_channel_data_;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 float sourceSampleValue = channel_data[source_frame_index]; 309 float sourceSampleValue = channel_data[source_frame_index];
300 dest_buffer[write_pos_in_dest] = 310 dest_buffer[write_pos_in_dest] =
301 TargetSampleTypeTraits::FromFloat(sourceSampleValue); 311 TargetSampleTypeTraits::FromFloat(sourceSampleValue);
302 } 312 }
303 } 313 }
304 } 314 }
305 315
306 } // namespace media 316 } // namespace media
307 317
308 #endif // MEDIA_BASE_AUDIO_BUS_H_ 318 #endif // MEDIA_BASE_AUDIO_BUS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698