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

Side by Side Diff: media/cast/sender/audio_encoder.cc

Issue 2024993004: AudioBus: Add a ToInterleavedFloat() method to AudioBus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revise comments/names in code Created 4 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
« media/base/audio_bus.cc ('K') | « media/base/audio_bus_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/cast/sender/audio_encoder.h" 5 #include "media/cast/sender/audio_encoder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 OPUS_OK); 274 OPUS_OK);
275 } 275 }
276 276
277 private: 277 private:
278 ~OpusImpl() final {} 278 ~OpusImpl() final {}
279 279
280 void TransferSamplesIntoBuffer(const AudioBus* audio_bus, 280 void TransferSamplesIntoBuffer(const AudioBus* audio_bus,
281 int source_offset, 281 int source_offset,
282 int buffer_fill_offset, 282 int buffer_fill_offset,
283 int num_samples) final { 283 int num_samples) final {
284 DCHECK_EQ(audio_bus->channels(), num_channels_);
284 // Opus requires channel-interleaved samples in a single array. 285 // Opus requires channel-interleaved samples in a single array.
miu 2016/06/02 20:40:21 nit: You can remove this comment now. The call to
chfremer 2016/06/07 21:21:39 Done.
285 for (int ch = 0; ch < audio_bus->channels(); ++ch) { 286 audio_bus->ToInterleavedFloat(source_offset,
286 const float* src = audio_bus->channel(ch) + source_offset; 287 buffer_fill_offset * num_channels_,
287 const float* const src_end = src + num_samples; 288 num_samples, buffer_.get());
288 float* dest = buffer_.get() + buffer_fill_offset * num_channels_ + ch;
289 for (; src < src_end; ++src, dest += num_channels_)
290 *dest = *src;
291 }
292 } 289 }
293 290
294 bool EncodeFromFilledBuffer(std::string* out) final { 291 bool EncodeFromFilledBuffer(std::string* out) final {
295 out->resize(kOpusMaxPayloadSize); 292 out->resize(kOpusMaxPayloadSize);
296 const opus_int32 result = opus_encode_float( 293 const opus_int32 result = opus_encode_float(
297 opus_encoder_, buffer_.get(), samples_per_frame_, 294 opus_encoder_, buffer_.get(), samples_per_frame_,
298 reinterpret_cast<uint8_t*>(string_as_array(out)), kOpusMaxPayloadSize); 295 reinterpret_cast<uint8_t*>(string_as_array(out)), kOpusMaxPayloadSize);
299 if (result > 1) { 296 if (result > 1) {
300 out->resize(result); 297 out->resize(result);
301 return true; 298 return true;
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 cast_environment_->PostTask(CastEnvironment::AUDIO, 835 cast_environment_->PostTask(CastEnvironment::AUDIO,
839 FROM_HERE, 836 FROM_HERE,
840 base::Bind(&AudioEncoder::ImplBase::EncodeAudio, 837 base::Bind(&AudioEncoder::ImplBase::EncodeAudio,
841 impl_, 838 impl_,
842 base::Passed(&audio_bus), 839 base::Passed(&audio_bus),
843 recorded_time)); 840 recorded_time));
844 } 841 }
845 842
846 } // namespace cast 843 } // namespace cast
847 } // namespace media 844 } // namespace media
OLDNEW
« media/base/audio_bus.cc ('K') | « media/base/audio_bus_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698