OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "media/base/audio_decoder_config.h" | 8 #include "media/base/audio_decoder_config.h" |
9 #include "media/base/video_decoder_config.h" | 9 #include "media/base/video_decoder_config.h" |
10 | 10 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 case kCodecMPEG4: | 120 case kCodecMPEG4: |
121 return CODEC_ID_MPEG4; | 121 return CODEC_ID_MPEG4; |
122 case kCodecVP8: | 122 case kCodecVP8: |
123 return CODEC_ID_VP8; | 123 return CODEC_ID_VP8; |
124 default: | 124 default: |
125 NOTREACHED(); | 125 NOTREACHED(); |
126 } | 126 } |
127 return CODEC_ID_NONE; | 127 return CODEC_ID_NONE; |
128 } | 128 } |
129 | 129 |
| 130 static VideoCodecProfile ProfileIDToVideoCodecProfile(int profile) { |
| 131 switch (profile) { |
| 132 case FF_PROFILE_H264_BASELINE: return H264PROFILE_BASELINE; |
| 133 case FF_PROFILE_H264_MAIN: return H264PROFILE_MAIN; |
| 134 case FF_PROFILE_H264_EXTENDED: return H264PROFILE_EXTENDED; |
| 135 case FF_PROFILE_H264_HIGH: return H264PROFILE_HIGH; |
| 136 case FF_PROFILE_H264_HIGH_10: return H264PROFILE_HIGH10PROFILE; |
| 137 case FF_PROFILE_H264_HIGH_422: return H264PROFILE_HIGH422PROFILE; |
| 138 case FF_PROFILE_H264_HIGH_444_PREDICTIVE: |
| 139 return H264PROFILE_HIGH444PREDICTIVEPROFILE; |
| 140 } |
| 141 return VIDEO_CODEC_PROFILE_UNKNOWN; |
| 142 } |
| 143 |
130 void AVCodecContextToAudioDecoderConfig( | 144 void AVCodecContextToAudioDecoderConfig( |
131 const AVCodecContext* codec_context, | 145 const AVCodecContext* codec_context, |
132 AudioDecoderConfig* config) { | 146 AudioDecoderConfig* config) { |
133 DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO); | 147 DCHECK_EQ(codec_context->codec_type, AVMEDIA_TYPE_AUDIO); |
134 | 148 |
135 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); | 149 AudioCodec codec = CodecIDToAudioCodec(codec_context->codec_id); |
136 int bits_per_channel = av_get_bits_per_sample_fmt(codec_context->sample_fmt); | 150 int bits_per_channel = av_get_bits_per_sample_fmt(codec_context->sample_fmt); |
137 ChannelLayout channel_layout = | 151 ChannelLayout channel_layout = |
138 ChannelLayoutToChromeChannelLayout(codec_context->channel_layout, | 152 ChannelLayoutToChromeChannelLayout(codec_context->channel_layout, |
139 codec_context->channels); | 153 codec_context->channels); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // for now, but may not always be true forever. Fix this in the future. | 211 // for now, but may not always be true forever. Fix this in the future. |
198 gfx::Rect visible_rect(stream->codec->width, stream->codec->height); | 212 gfx::Rect visible_rect(stream->codec->width, stream->codec->height); |
199 | 213 |
200 AVRational aspect_ratio = { 1, 1 }; | 214 AVRational aspect_ratio = { 1, 1 }; |
201 if (stream->sample_aspect_ratio.num) | 215 if (stream->sample_aspect_ratio.num) |
202 aspect_ratio = stream->sample_aspect_ratio; | 216 aspect_ratio = stream->sample_aspect_ratio; |
203 else if (stream->codec->sample_aspect_ratio.num) | 217 else if (stream->codec->sample_aspect_ratio.num) |
204 aspect_ratio = stream->codec->sample_aspect_ratio; | 218 aspect_ratio = stream->codec->sample_aspect_ratio; |
205 | 219 |
206 config->Initialize(CodecIDToVideoCodec(stream->codec->codec_id), | 220 config->Initialize(CodecIDToVideoCodec(stream->codec->codec_id), |
| 221 ProfileIDToVideoCodecProfile(stream->codec->profile), |
207 PixelFormatToVideoFormat(stream->codec->pix_fmt), | 222 PixelFormatToVideoFormat(stream->codec->pix_fmt), |
208 coded_size, visible_rect, | 223 coded_size, visible_rect, |
209 stream->r_frame_rate.num, | 224 stream->r_frame_rate.num, |
210 stream->r_frame_rate.den, | 225 stream->r_frame_rate.den, |
211 aspect_ratio.num, | 226 aspect_ratio.num, |
212 aspect_ratio.den, | 227 aspect_ratio.den, |
213 stream->codec->extradata, | 228 stream->codec->extradata, |
214 stream->codec->extradata_size); | 229 stream->codec->extradata_size); |
215 } | 230 } |
216 | 231 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 avcodec_close(stream->codec); | 349 avcodec_close(stream->codec); |
335 } | 350 } |
336 } | 351 } |
337 } | 352 } |
338 | 353 |
339 // Then finally cleanup the format context. | 354 // Then finally cleanup the format context. |
340 av_close_input_file(format_context); | 355 av_close_input_file(format_context); |
341 } | 356 } |
342 | 357 |
343 } // namespace media | 358 } // namespace media |
OLD | NEW |