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 "media/base/decoder_buffer.h" | 9 #include "media/base/decoder_buffer.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 case kSampleFormatPlanarS16: | 262 case kSampleFormatPlanarS16: |
263 return AV_SAMPLE_FMT_S16P; | 263 return AV_SAMPLE_FMT_S16P; |
264 case kSampleFormatPlanarF32: | 264 case kSampleFormatPlanarF32: |
265 return AV_SAMPLE_FMT_FLTP; | 265 return AV_SAMPLE_FMT_FLTP; |
266 default: | 266 default: |
267 DVLOG(1) << "Unknown SampleFormat: " << sample_format; | 267 DVLOG(1) << "Unknown SampleFormat: " << sample_format; |
268 } | 268 } |
269 return AV_SAMPLE_FMT_NONE; | 269 return AV_SAMPLE_FMT_NONE; |
270 } | 270 } |
271 | 271 |
| 272 // Converts a channel count into a channel layout. Layouts chosen based on the |
| 273 // Vorbis / Opus channel layout. |
| 274 static ChannelLayout GuessChannelLayout(int channels) { |
| 275 switch (channels) { |
| 276 case 1: |
| 277 return CHANNEL_LAYOUT_MONO; |
| 278 case 2: |
| 279 return CHANNEL_LAYOUT_STEREO; |
| 280 case 3: |
| 281 return CHANNEL_LAYOUT_SURROUND; |
| 282 case 4: |
| 283 return CHANNEL_LAYOUT_QUAD; |
| 284 case 5: |
| 285 return CHANNEL_LAYOUT_5_0; |
| 286 case 6: |
| 287 return CHANNEL_LAYOUT_5_1; |
| 288 case 7: |
| 289 return CHANNEL_LAYOUT_6_1; |
| 290 case 8: |
| 291 return CHANNEL_LAYOUT_7_1; |
| 292 default: |
| 293 DVLOG(1) << "Unsupported channel count: " << channels; |
| 294 } |
| 295 return CHANNEL_LAYOUT_UNSUPPORTED; |
| 296 } |
| 297 |
272 void AVCodecContextToAudioDecoderConfig( | 298 void AVCodecContextToAudioDecoderConfig( |
273 const AVCodecContext* codec_context, | 299 const AVCodecContext* codec_context, |
274 AudioDecoderConfig* config) { | 300 AudioDecoderConfig* config) { |
275 DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO); | 301 DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO); |
276 | 302 |
277 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); | 303 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); |
278 | 304 |
279 SampleFormat sample_format = | 305 SampleFormat sample_format = |
280 AVSampleFormatToSampleFormat(codec_context->sample_fmt); | 306 AVSampleFormatToSampleFormat(codec_context->sample_fmt); |
281 | 307 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 return PIX_FMT_YUV422P; | 511 return PIX_FMT_YUV422P; |
486 case VideoFrame::YV12: | 512 case VideoFrame::YV12: |
487 return PIX_FMT_YUV420P; | 513 return PIX_FMT_YUV420P; |
488 default: | 514 default: |
489 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; | 515 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; |
490 } | 516 } |
491 return PIX_FMT_NONE; | 517 return PIX_FMT_NONE; |
492 } | 518 } |
493 | 519 |
494 } // namespace media | 520 } // namespace media |
OLD | NEW |