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

Unified Diff: media/filters/audio_file_reader.cc

Issue 11280301: Roll FFMpeg for M26. Fix ffmpeg float audio decoding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DCHECK. Roll DEPS for fix. Created 8 years 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/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);

Powered by Google App Engine
This is Rietveld 408576698