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

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

Issue 854006: Revert 41386 - Removed custom FFmpegLock. Removed ffmpeg headers from third_p... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « media/ffmpeg/ffmpeg_common.cc ('k') | media/filters/ffmpeg_demuxer.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/ffmpeg_audio_decoder.h" 5 #include "media/filters/ffmpeg_audio_decoder.h"
6 6
7 #include "media/base/callback.h" 7 #include "media/base/callback.h"
8 #include "media/base/data_buffer.h" 8 #include "media/base/data_buffer.h"
9 #include "media/base/limits.h" 9 #include "media/base/limits.h"
10 #include "media/ffmpeg/ffmpeg_common.h" 10 #include "media/ffmpeg/ffmpeg_common.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 bps == 0 || 54 bps == 0 ||
55 static_cast<size_t>(bps) > Limits::kMaxBPS || 55 static_cast<size_t>(bps) > Limits::kMaxBPS ||
56 codec_context_->sample_rate == 0 || 56 codec_context_->sample_rate == 0 ||
57 (static_cast<size_t>(codec_context_->sample_rate) > 57 (static_cast<size_t>(codec_context_->sample_rate) >
58 Limits::kMaxSampleRate)) { 58 Limits::kMaxSampleRate)) {
59 return; 59 return;
60 } 60 }
61 61
62 // Serialize calls to avcodec_open(). 62 // Serialize calls to avcodec_open().
63 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); 63 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
64 if (!codec || avcodec_open(codec_context_, codec) < 0) { 64 {
65 return; 65 AutoLock auto_lock(FFmpegLock::get()->lock());
66 if (!codec || avcodec_open(codec_context_, codec) < 0) {
67 return;
68 }
66 } 69 }
67 70
68 // When calling avcodec_find_decoder(), |codec_context_| might be altered by 71 // When calling avcodec_find_decoder(), |codec_context_| might be altered by
69 // the decoder to give more accurate values of the output format of the 72 // the decoder to give more accurate values of the output format of the
70 // decoder. So set the media format after a decoder is allocated. 73 // decoder. So set the media format after a decoder is allocated.
71 // TODO(hclam): Reuse the information provided by the demuxer for now, we may 74 // TODO(hclam): Reuse the information provided by the demuxer for now, we may
72 // need to wait until the first buffer is decoded to know the correct 75 // need to wait until the first buffer is decoded to know the correct
73 // information. 76 // information.
74 media_format_.SetAsInteger(MediaFormat::kChannels, codec_context_->channels); 77 media_format_.SetAsInteger(MediaFormat::kChannels, codec_context_->channels);
75 media_format_.SetAsInteger(MediaFormat::kSampleBits, 78 media_format_.SetAsInteger(MediaFormat::kSampleBits,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 base::TimeDelta FFmpegAudioDecoder::CalculateDuration(size_t size) { 192 base::TimeDelta FFmpegAudioDecoder::CalculateDuration(size_t size) {
190 int64 denominator = codec_context_->channels * 193 int64 denominator = codec_context_->channels *
191 av_get_bits_per_sample_format(codec_context_->sample_fmt) / 8 * 194 av_get_bits_per_sample_format(codec_context_->sample_fmt) / 8 *
192 codec_context_->sample_rate; 195 codec_context_->sample_rate;
193 double microseconds = size / 196 double microseconds = size /
194 (denominator / static_cast<double>(base::Time::kMicrosecondsPerSecond)); 197 (denominator / static_cast<double>(base::Time::kMicrosecondsPerSecond));
195 return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)); 198 return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds));
196 } 199 }
197 200
198 } // namespace 201 } // namespace
OLDNEW
« no previous file with comments | « media/ffmpeg/ffmpeg_common.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698