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

Unified 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: Switched to templated method approach 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 side-by-side diff with in-line comments
Download patch
Index: media/cast/sender/audio_encoder.cc
diff --git a/media/cast/sender/audio_encoder.cc b/media/cast/sender/audio_encoder.cc
index 9c6c6f44b5e40e34b0d883f0cc18ab07c0e8be1b..9a353435c4f5cc84c6db17558fca2a1fa63c17f3 100644
--- a/media/cast/sender/audio_encoder.cc
+++ b/media/cast/sender/audio_encoder.cc
@@ -19,6 +19,7 @@
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
+#include "media/base/audio_sample_types.h"
#include "media/cast/common/rtp_time.h"
#include "media/cast/constants.h"
@@ -281,14 +282,10 @@ class AudioEncoder::OpusImpl : public AudioEncoder::ImplBase {
int source_offset,
int buffer_fill_offset,
int num_samples) final {
- // Opus requires channel-interleaved samples in a single array.
- for (int ch = 0; ch < audio_bus->channels(); ++ch) {
- const float* src = audio_bus->channel(ch) + source_offset;
- const float* const src_end = src + num_samples;
- float* dest = buffer_.get() + buffer_fill_offset * num_channels_ + ch;
- for (; src < src_end; ++src, dest += num_channels_)
- *dest = *src;
- }
+ DCHECK_EQ(audio_bus->channels(), num_channels_);
+ float* dest = buffer_.get() + (buffer_fill_offset * num_channels_);
+ audio_bus->ToInterleavedPartial<Float32SampleTypeTraits>(source_offset,
+ num_samples, dest);
}
bool EncodeFromFilledBuffer(std::string* out) final {

Powered by Google App Engine
This is Rietveld 408576698