Index: media/filters/audio_file_reader.cc |
diff --git a/media/filters/audio_file_reader.cc b/media/filters/audio_file_reader.cc |
index cf295b6f4467f5c0b93da91f4103636f90f6d14b..f2d311fe2560f3cae063bfc10848a7fdbbdfeb25 100644 |
--- a/media/filters/audio_file_reader.cc |
+++ b/media/filters/audio_file_reader.cc |
@@ -163,10 +163,28 @@ int AudioFileReader::Read(AudioBus* audio_bus) { |
if (current_frame + frames_read > audio_bus->frames()) |
frames_read = audio_bus->frames() - current_frame; |
- // Deinterleave each channel and convert to 32bit floating-point |
- // with nominal range -1.0 -> +1.0. |
- audio_bus->FromInterleavedPartial( |
- av_frame->data[0], current_frame, frames_read, bytes_per_sample); |
+ // Deinterleave each channel and convert to 32bit floating-point with |
+ // nominal range -1.0 -> +1.0. If the output is already in float planar |
+ // format, just copy it into the AudioBus. |
+ if (codec_context_->sample_fmt == AV_SAMPLE_FMT_FLT) { |
+ float* decoded_audio_data = reinterpret_cast<float*>(av_frame->data[0]); |
+ int channels = audio_bus->channels(); |
+ for (int ch = 0; ch < channels; ++ch) { |
+ float* bus_data = audio_bus->channel(ch) + current_frame; |
+ for (int i = 0, offset = ch; i < frames_read; |
+ ++i, offset += channels) { |
+ bus_data[i] = decoded_audio_data[offset]; |
+ } |
+ } |
+ } else if (codec_context_->sample_fmt == AV_SAMPLE_FMT_FLTP) { |
+ for (int ch = 0; ch < audio_bus->channels(); ++ch) { |
+ memcpy(audio_bus->channel(ch) + current_frame, |
+ av_frame->extended_data[ch], sizeof(float) * frames_read); |
+ } |
+ } else { |
+ audio_bus->FromInterleavedPartial( |
+ av_frame->data[0], current_frame, frames_read, bytes_per_sample); |
+ } |
current_frame += frames_read; |
} while (packet_temp.size > 0); |