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

Side by Side Diff: media/filters/audio_file_reader.cc

Issue 111153003: FFmpeg fixups for M33 roll. Now with more Opus! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DEPS update. Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/ffmpeg/ffmpeg_unittest.cc ('k') | media/filters/ffmpeg_audio_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/filters/audio_file_reader.h" 5 #include "media/filters/audio_file_reader.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "media/base/audio_bus.h" 9 #include "media/base/audio_bus.h"
10 #include "media/ffmpeg/ffmpeg_common.h" 10 #include "media/ffmpeg/ffmpeg_common.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 "AudioFileReader::Read() : reader is not opened!"; 125 "AudioFileReader::Read() : reader is not opened!";
126 126
127 DCHECK_EQ(audio_bus->channels(), channels()); 127 DCHECK_EQ(audio_bus->channels(), channels());
128 if (audio_bus->channels() != channels()) 128 if (audio_bus->channels() != channels())
129 return 0; 129 return 0;
130 130
131 size_t bytes_per_sample = av_get_bytes_per_sample(codec_context_->sample_fmt); 131 size_t bytes_per_sample = av_get_bytes_per_sample(codec_context_->sample_fmt);
132 132
133 // Holds decoded audio. 133 // Holds decoded audio.
134 scoped_ptr_malloc<AVFrame, ScopedPtrAVFreeFrame> av_frame( 134 scoped_ptr_malloc<AVFrame, ScopedPtrAVFreeFrame> av_frame(
135 avcodec_alloc_frame()); 135 av_frame_alloc());
136 136
137 // Read until we hit EOF or we've read the requested number of frames. 137 // Read until we hit EOF or we've read the requested number of frames.
138 AVPacket packet; 138 AVPacket packet;
139 int current_frame = 0; 139 int current_frame = 0;
140 bool continue_decoding = true; 140 bool continue_decoding = true;
141 141
142 while (current_frame < audio_bus->frames() && continue_decoding && 142 while (current_frame < audio_bus->frames() && continue_decoding &&
143 av_read_frame(glue_->format_context(), &packet) >= 0 && 143 av_read_frame(glue_->format_context(), &packet) >= 0 &&
144 av_dup_packet(&packet) >= 0) { 144 av_dup_packet(&packet) >= 0) {
145 // Skip packets from other streams. 145 // Skip packets from other streams.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // Zero any remaining frames. 237 // Zero any remaining frames.
238 audio_bus->ZeroFramesPartial( 238 audio_bus->ZeroFramesPartial(
239 current_frame, audio_bus->frames() - current_frame); 239 current_frame, audio_bus->frames() - current_frame);
240 240
241 // Returns the actual number of sample-frames decoded. 241 // Returns the actual number of sample-frames decoded.
242 // Ideally this represents the "true" exact length of the file. 242 // Ideally this represents the "true" exact length of the file.
243 return current_frame; 243 return current_frame;
244 } 244 }
245 245
246 } // namespace media 246 } // namespace media
OLDNEW
« no previous file with comments | « media/ffmpeg/ffmpeg_unittest.cc ('k') | media/filters/ffmpeg_audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698