Chromium Code Reviews| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 case CODEC_ID_FLAC: | 76 case CODEC_ID_FLAC: |
| 77 return kCodecFLAC; | 77 return kCodecFLAC; |
| 78 case CODEC_ID_AMR_NB: | 78 case CODEC_ID_AMR_NB: |
| 79 return kCodecAMR_NB; | 79 return kCodecAMR_NB; |
| 80 case CODEC_ID_AMR_WB: | 80 case CODEC_ID_AMR_WB: |
| 81 return kCodecAMR_WB; | 81 return kCodecAMR_WB; |
| 82 case CODEC_ID_GSM_MS: | 82 case CODEC_ID_GSM_MS: |
| 83 return kCodecGSM_MS; | 83 return kCodecGSM_MS; |
| 84 case CODEC_ID_PCM_MULAW: | 84 case CODEC_ID_PCM_MULAW: |
| 85 return kCodecPCM_MULAW; | 85 return kCodecPCM_MULAW; |
| 86 case CODEC_ID_OPUS: | |
| 87 return kCodecOpus; | |
| 86 default: | 88 default: |
| 87 DVLOG(1) << "Unknown audio CodecID: " << codec_id; | 89 DVLOG(1) << "Unknown audio CodecID: " << codec_id; |
| 88 } | 90 } |
| 89 return kUnknownAudioCodec; | 91 return kUnknownAudioCodec; |
| 90 } | 92 } |
| 91 | 93 |
| 92 static CodecID AudioCodecToCodecID(AudioCodec audio_codec, | 94 static CodecID AudioCodecToCodecID(AudioCodec audio_codec, |
| 93 int bits_per_channel) { | 95 int bits_per_channel) { |
| 94 switch (audio_codec) { | 96 switch (audio_codec) { |
| 95 case kCodecAAC: | 97 case kCodecAAC: |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 117 case kCodecFLAC: | 119 case kCodecFLAC: |
| 118 return CODEC_ID_FLAC; | 120 return CODEC_ID_FLAC; |
| 119 case kCodecAMR_NB: | 121 case kCodecAMR_NB: |
| 120 return CODEC_ID_AMR_NB; | 122 return CODEC_ID_AMR_NB; |
| 121 case kCodecAMR_WB: | 123 case kCodecAMR_WB: |
| 122 return CODEC_ID_AMR_WB; | 124 return CODEC_ID_AMR_WB; |
| 123 case kCodecGSM_MS: | 125 case kCodecGSM_MS: |
| 124 return CODEC_ID_GSM_MS; | 126 return CODEC_ID_GSM_MS; |
| 125 case kCodecPCM_MULAW: | 127 case kCodecPCM_MULAW: |
| 126 return CODEC_ID_PCM_MULAW; | 128 return CODEC_ID_PCM_MULAW; |
| 129 case kCodecOpus: | |
| 130 return CODEC_ID_OPUS; | |
| 127 default: | 131 default: |
| 128 DVLOG(1) << "Unknown AudioCodec: " << audio_codec; | 132 DVLOG(1) << "Unknown AudioCodec: " << audio_codec; |
| 129 } | 133 } |
| 130 return CODEC_ID_NONE; | 134 return CODEC_ID_NONE; |
| 131 } | 135 } |
| 132 | 136 |
| 133 VideoCodec CodecIDToVideoCodec(CodecID codec_id) { | 137 VideoCodec CodecIDToVideoCodec(CodecID codec_id) { |
| 134 switch (codec_id) { | 138 switch (codec_id) { |
| 135 case CODEC_ID_VC1: | 139 case CODEC_ID_VC1: |
| 136 return kCodecVC1; | 140 return kCodecVC1; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 return FF_PROFILE_UNKNOWN; | 222 return FF_PROFILE_UNKNOWN; |
| 219 } | 223 } |
| 220 | 224 |
| 221 void AVCodecContextToAudioDecoderConfig( | 225 void AVCodecContextToAudioDecoderConfig( |
| 222 const AVCodecContext* codec_context, | 226 const AVCodecContext* codec_context, |
| 223 AudioDecoderConfig* config) { | 227 AudioDecoderConfig* config) { |
| 224 DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO); | 228 DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO); |
| 225 | 229 |
| 226 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); | 230 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); |
| 227 int bytes_per_channel = av_get_bytes_per_sample(codec_context->sample_fmt); | 231 int bytes_per_channel = av_get_bytes_per_sample(codec_context->sample_fmt); |
| 232 | |
| 233 AVSampleFormat sample_format = codec_context->sample_fmt; | |
|
DaleCurtis
2012/12/15 01:13:22
I meant you should do this above line 231 and repl
Tom Finegan
2012/12/15 01:24:33
Done.
| |
| 234 if (codec == kCodecOpus) { | |
| 235 // TODO(tomfinegan): |sample_fmt| in |codec_context| is -1... because | |
| 236 // libopusdec.c isn't built into ffmpegsumo...? Maybe it's not *that* big | |
| 237 // a deal since libopus will produce either float or S16 samples, and | |
| 238 // OpusAudioDecoder is the only provider of Opus support. | |
| 239 sample_format = AV_SAMPLE_FMT_S16; | |
| 240 bytes_per_channel = av_get_bytes_per_sample(sample_format); | |
| 241 } | |
| 242 | |
| 228 ChannelLayout channel_layout = | 243 ChannelLayout channel_layout = |
| 229 ChannelLayoutToChromeChannelLayout(codec_context->channel_layout, | 244 ChannelLayoutToChromeChannelLayout(codec_context->channel_layout, |
| 230 codec_context->channels); | 245 codec_context->channels); |
| 231 int samples_per_second = codec_context->sample_rate; | 246 int samples_per_second = codec_context->sample_rate; |
| 232 | 247 |
| 233 config->Initialize(codec, | 248 config->Initialize(codec, |
| 234 bytes_per_channel << 3, | 249 bytes_per_channel << 3, |
| 235 channel_layout, | 250 channel_layout, |
| 236 samples_per_second, | 251 samples_per_second, |
| 237 codec_context->extradata, | 252 codec_context->extradata, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 return PIX_FMT_YUV422P; | 436 return PIX_FMT_YUV422P; |
| 422 case VideoFrame::YV12: | 437 case VideoFrame::YV12: |
| 423 return PIX_FMT_YUV420P; | 438 return PIX_FMT_YUV420P; |
| 424 default: | 439 default: |
| 425 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; | 440 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; |
| 426 } | 441 } |
| 427 return PIX_FMT_NONE; | 442 return PIX_FMT_NONE; |
| 428 } | 443 } |
| 429 | 444 |
| 430 } // namespace media | 445 } // namespace media |
| OLD | NEW |