OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "media/base/audio_buffer.h" | 5 #include "media/base/audio_buffer.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 AudioBus* dest) { | 238 AudioBus* dest) { |
239 // Deinterleave each channel (if necessary) and convert to 32bit | 239 // Deinterleave each channel (if necessary) and convert to 32bit |
240 // floating-point with nominal range -1.0 -> +1.0 (if necessary). | 240 // floating-point with nominal range -1.0 -> +1.0 (if necessary). |
241 | 241 |
242 // |dest| must have the same number of channels, and the number of frames | 242 // |dest| must have the same number of channels, and the number of frames |
243 // specified must be in range. | 243 // specified must be in range. |
244 DCHECK(!end_of_stream()); | 244 DCHECK(!end_of_stream()); |
245 DCHECK_EQ(dest->channels(), channel_count_); | 245 DCHECK_EQ(dest->channels(), channel_count_); |
246 DCHECK_LE(source_frame_offset + frames_to_copy, adjusted_frame_count_); | 246 DCHECK_LE(source_frame_offset + frames_to_copy, adjusted_frame_count_); |
247 | 247 |
248 dest->set_is_bitstream_format(IsBitstreamFormat()); | |
DaleCurtis
2017/06/15 21:46:32
Move into l.251 as set_is_bitstream_format(true);
AndyWu
2017/08/02 01:43:40
Not really sure it's a good idea to assume the sta
| |
249 | |
248 if (IsBitstreamFormat()) { | 250 if (IsBitstreamFormat()) { |
249 // TODO(tsunghung): Implement it along with AudioBus changes. | 251 DCHECK(!source_frame_offset); |
250 NOTREACHED() << "Invalid sample format!"; | 252 uint8_t* dest_data = |
253 reinterpret_cast<uint8_t*>(dest->channel(0)) + dest->data_size(); | |
254 | |
255 memcpy(dest_data, channel_data_[0], data_size()); | |
256 dest->set_data_size(dest_frame_offset + data_size()); | |
257 dest->set_frames(dest->frames() + frame_count()); | |
258 return; | |
251 } | 259 } |
252 | 260 |
253 DCHECK_LE(dest_frame_offset + frames_to_copy, dest->frames()); | 261 DCHECK_LE(dest_frame_offset + frames_to_copy, dest->frames()); |
254 | 262 |
255 if (!data_) { | 263 if (!data_) { |
256 // Special case for an empty buffer. | 264 // Special case for an empty buffer. |
257 dest->ZeroFramesPartial(dest_frame_offset, frames_to_copy); | 265 dest->ZeroFramesPartial(dest_frame_offset, frames_to_copy); |
258 return; | 266 return; |
259 } | 267 } |
260 | 268 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 | 395 |
388 // Trim the leftover data off the end of the buffer and update duration. | 396 // Trim the leftover data off the end of the buffer and update duration. |
389 TrimEnd(frames_to_trim); | 397 TrimEnd(frames_to_trim); |
390 } | 398 } |
391 | 399 |
392 bool AudioBuffer::IsBitstreamFormat() { | 400 bool AudioBuffer::IsBitstreamFormat() { |
393 return IsBitstream(sample_format_); | 401 return IsBitstream(sample_format_); |
394 } | 402 } |
395 | 403 |
396 } // namespace media | 404 } // namespace media |
OLD | NEW |