| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); | 322 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); |
| 323 | 323 |
| 324 SampleFormat sample_format = AVSampleFormatToSampleFormat( | 324 SampleFormat sample_format = AVSampleFormatToSampleFormat( |
| 325 codec_context->sample_fmt, codec_context->codec_id); | 325 codec_context->sample_fmt, codec_context->codec_id); |
| 326 | 326 |
| 327 ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout( | 327 ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout( |
| 328 codec_context->channel_layout, codec_context->channels); | 328 codec_context->channel_layout, codec_context->channels); |
| 329 | 329 |
| 330 int sample_rate = codec_context->sample_rate; | 330 int sample_rate = codec_context->sample_rate; |
| 331 switch (codec) { | 331 switch (codec) { |
| 332 case kCodecOpus: | |
| 333 // |codec_context->sample_fmt| is not set by FFmpeg because Opus decoding | |
| 334 // is not enabled in FFmpeg. It doesn't matter what value is set here, so | |
| 335 // long as it's valid, the true sample format is selected inside the | |
| 336 // decoder. | |
| 337 sample_format = kSampleFormatF32; | |
| 338 | |
| 339 // Always use 48kHz for OPUS. Technically we should match to the highest | |
| 340 // supported hardware sample rate among [8, 12, 16, 24, 48] kHz, but we | |
| 341 // don't know the hardware sample rate at this point and those rates are | |
| 342 // rarely used for output. See the "Input Sample Rate" section of the | |
| 343 // spec: http://tools.ietf.org/html/draft-terriberry-oggopus-01#page-11 | |
| 344 sample_rate = 48000; | |
| 345 break; | |
| 346 | |
| 347 // For AC3/EAC3 we enable only demuxing, but not decoding, so FFmpeg does | 332 // For AC3/EAC3 we enable only demuxing, but not decoding, so FFmpeg does |
| 348 // not fill |sample_fmt|. | 333 // not fill |sample_fmt|. |
| 349 case kCodecAC3: | 334 case kCodecAC3: |
| 350 case kCodecEAC3: | 335 case kCodecEAC3: |
| 351 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 336 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 352 // The spec for AC3/EAC3 audio is ETSI TS 102 366. According to sections | 337 // The spec for AC3/EAC3 audio is ETSI TS 102 366. According to sections |
| 353 // F.3.1 and F.5.1 in that spec the sample_format for AC3/EAC3 must be 16. | 338 // F.3.1 and F.5.1 in that spec the sample_format for AC3/EAC3 must be 16. |
| 354 sample_format = kSampleFormatS16; | 339 sample_format = kSampleFormatS16; |
| 355 #else | 340 #else |
| 356 NOTREACHED(); | 341 NOTREACHED(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 383 codec_context->extradata + codec_context->extradata_size); | 368 codec_context->extradata + codec_context->extradata_size); |
| 384 } | 369 } |
| 385 | 370 |
| 386 config->Initialize(codec, sample_format, channel_layout, sample_rate, | 371 config->Initialize(codec, sample_format, channel_layout, sample_rate, |
| 387 extra_data, encryption_scheme, seek_preroll, | 372 extra_data, encryption_scheme, seek_preroll, |
| 388 codec_context->delay); | 373 codec_context->delay); |
| 389 | 374 |
| 390 // Verify that AudioConfig.bits_per_channel was calculated correctly for | 375 // Verify that AudioConfig.bits_per_channel was calculated correctly for |
| 391 // codecs that have |sample_fmt| set by FFmpeg. | 376 // codecs that have |sample_fmt| set by FFmpeg. |
| 392 switch (codec) { | 377 switch (codec) { |
| 393 case kCodecOpus: | |
| 394 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 378 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 395 case kCodecAC3: | 379 case kCodecAC3: |
| 396 case kCodecEAC3: | 380 case kCodecEAC3: |
| 397 #endif | 381 #endif |
| 398 break; | 382 break; |
| 399 default: | 383 default: |
| 400 DCHECK_EQ(av_get_bytes_per_sample(codec_context->sample_fmt) * 8, | 384 DCHECK_EQ(av_get_bytes_per_sample(codec_context->sample_fmt) * 8, |
| 401 config->bits_per_channel()); | 385 config->bits_per_channel()); |
| 402 break; | 386 break; |
| 403 } | 387 } |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 TEST_COLORSPACE(RESERVED); | 809 TEST_COLORSPACE(RESERVED); |
| 826 TEST_COLORSPACE(FCC); | 810 TEST_COLORSPACE(FCC); |
| 827 TEST_COLORSPACE(BT470BG); | 811 TEST_COLORSPACE(BT470BG); |
| 828 TEST_COLORSPACE(SMPTE170M); | 812 TEST_COLORSPACE(SMPTE170M); |
| 829 TEST_COLORSPACE(SMPTE240M); | 813 TEST_COLORSPACE(SMPTE240M); |
| 830 TEST_COLORSPACE(YCOCG); | 814 TEST_COLORSPACE(YCOCG); |
| 831 TEST_COLORSPACE(BT2020_NCL); | 815 TEST_COLORSPACE(BT2020_NCL); |
| 832 TEST_COLORSPACE(BT2020_CL); | 816 TEST_COLORSPACE(BT2020_CL); |
| 833 | 817 |
| 834 } // namespace media | 818 } // namespace media |
| OLD | NEW |