| 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 | |
| 298 void AVCodecContextToAudioDecoderConfig( | 272 void AVCodecContextToAudioDecoderConfig( |
| 299 const AVCodecContext* codec_context, | 273 const AVCodecContext* codec_context, |
| 300 AudioDecoderConfig* config) { | 274 AudioDecoderConfig* config) { |
| 301 DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO); | 275 DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO); |
| 302 | 276 |
| 303 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); | 277 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); |
| 304 | 278 |
| 305 SampleFormat sample_format = | 279 SampleFormat sample_format = |
| 306 AVSampleFormatToSampleFormat(codec_context->sample_fmt); | 280 AVSampleFormatToSampleFormat(codec_context->sample_fmt); |
| 307 | 281 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 return PIX_FMT_YUV422P; | 485 return PIX_FMT_YUV422P; |
| 512 case VideoFrame::YV12: | 486 case VideoFrame::YV12: |
| 513 return PIX_FMT_YUV420P; | 487 return PIX_FMT_YUV420P; |
| 514 default: | 488 default: |
| 515 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; | 489 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; |
| 516 } | 490 } |
| 517 return PIX_FMT_NONE; | 491 return PIX_FMT_NONE; |
| 518 } | 492 } |
| 519 | 493 |
| 520 } // namespace media | 494 } // namespace media |
| OLD | NEW |