OLD | NEW |
---|---|
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/ffmpeg/ffmpeg_common.h" | 5 #include "media/ffmpeg/ffmpeg_common.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); | 279 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); |
280 | 280 |
281 SampleFormat sample_format = | 281 SampleFormat sample_format = |
282 AVSampleFormatToSampleFormat(codec_context->sample_fmt); | 282 AVSampleFormatToSampleFormat(codec_context->sample_fmt); |
283 | 283 |
284 ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout( | 284 ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout( |
285 codec_context->channel_layout, codec_context->channels); | 285 codec_context->channel_layout, codec_context->channels); |
286 | 286 |
287 if (codec == kCodecOpus) { | 287 if (codec == kCodecOpus) { |
288 // |codec_context->sample_fmt| is not set by FFmpeg because Opus decoding is | 288 // |codec_context->sample_fmt| is not set by FFmpeg because Opus decoding is |
289 // not enabled in FFmpeg, so we need to manually set the sample format. | 289 // not enabled in FFmpeg. It doesn't matter what value is set here, so long |
290 // as it's valid, the true sample format is selected inside the decoder. | |
290 sample_format = kSampleFormatS16; | 291 sample_format = kSampleFormatS16; |
acolwell GONE FROM CHROMIUM
2013/12/11 23:30:02
This is probably a separate CL, but... It seems li
DaleCurtis
2013/12/12 00:03:24
Sounds reasonable, but for another CL.
| |
291 } | 292 } |
292 | 293 |
293 base::TimeDelta seek_preroll; | 294 base::TimeDelta seek_preroll; |
294 if (codec_context->seek_preroll > 0) { | 295 if (codec_context->seek_preroll > 0) { |
295 seek_preroll = base::TimeDelta::FromMicroseconds( | 296 seek_preroll = base::TimeDelta::FromMicroseconds( |
296 codec_context->seek_preroll * 1000000.0 / codec_context->sample_rate); | 297 codec_context->seek_preroll * 1000000.0 / codec_context->sample_rate); |
297 } | 298 } |
298 | 299 |
299 base::TimeDelta codec_delay; | 300 base::TimeDelta codec_delay; |
300 if (codec_context->delay > 0) { | 301 if (codec_context->delay > 0) { |
301 codec_delay = base::TimeDelta::FromMicroseconds( | 302 codec_delay = base::TimeDelta::FromMicroseconds( |
302 codec_context->delay * 1000000.0 / codec_context->sample_rate); | 303 codec_context->delay * 1000000.0 / codec_context->sample_rate); |
303 } | 304 } |
304 | 305 |
305 config->Initialize(codec, | 306 config->Initialize(codec, |
306 sample_format, | 307 sample_format, |
307 channel_layout, | 308 channel_layout, |
308 codec_context->sample_rate, | 309 codec_context->sample_rate, |
309 codec_context->extradata, | 310 codec_context->extradata, |
310 codec_context->extradata_size, | 311 codec_context->extradata_size, |
311 is_encrypted, | 312 is_encrypted, |
312 record_stats, | 313 record_stats, |
313 seek_preroll, | 314 seek_preroll, |
314 codec_delay); | 315 codec_delay); |
315 if (codec != kCodecOpus) { | 316 if (codec != kCodecOpus) { |
acolwell GONE FROM CHROMIUM
2013/12/11 23:30:02
nit: Shouldn't this be checking for sample_format
DaleCurtis
2013/12/12 00:03:24
Not unless we make the change you talk about above
acolwell GONE FROM CHROMIUM
2013/12/12 00:53:14
ok. This was meant to go with the comment above.
| |
316 DCHECK_EQ(av_get_bytes_per_sample(codec_context->sample_fmt) * 8, | 317 DCHECK_EQ(av_get_bytes_per_sample(codec_context->sample_fmt) * 8, |
317 config->bits_per_channel()); | 318 config->bits_per_channel()); |
318 } | 319 } |
319 } | 320 } |
320 | 321 |
321 void AVStreamToAudioDecoderConfig( | 322 void AVStreamToAudioDecoderConfig( |
322 const AVStream* stream, | 323 const AVStream* stream, |
323 AudioDecoderConfig* config, | 324 AudioDecoderConfig* config, |
324 bool record_stats) { | 325 bool record_stats) { |
325 bool is_encrypted = false; | 326 bool is_encrypted = false; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 return PIX_FMT_YUVJ420P; | 536 return PIX_FMT_YUVJ420P; |
536 case VideoFrame::YV12A: | 537 case VideoFrame::YV12A: |
537 return PIX_FMT_YUVA420P; | 538 return PIX_FMT_YUVA420P; |
538 default: | 539 default: |
539 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; | 540 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; |
540 } | 541 } |
541 return PIX_FMT_NONE; | 542 return PIX_FMT_NONE; |
542 } | 543 } |
543 | 544 |
544 } // namespace media | 545 } // namespace media |
OLD | NEW |