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_util.h" | 10 #include "media/base/video_util.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 ChannelLayoutToChromeChannelLayout(codec_context->channel_layout, | 215 ChannelLayoutToChromeChannelLayout(codec_context->channel_layout, |
216 codec_context->channels); | 216 codec_context->channels); |
217 int samples_per_second = codec_context->sample_rate; | 217 int samples_per_second = codec_context->sample_rate; |
218 | 218 |
219 config->Initialize(codec, | 219 config->Initialize(codec, |
220 bytes_per_channel << 3, | 220 bytes_per_channel << 3, |
221 channel_layout, | 221 channel_layout, |
222 samples_per_second, | 222 samples_per_second, |
223 codec_context->extradata, | 223 codec_context->extradata, |
224 codec_context->extradata_size, | 224 codec_context->extradata_size, |
| 225 false, // Not encrypted. |
225 true); | 226 true); |
226 } | 227 } |
227 | 228 |
228 void AudioDecoderConfigToAVCodecContext(const AudioDecoderConfig& config, | 229 void AudioDecoderConfigToAVCodecContext(const AudioDecoderConfig& config, |
229 AVCodecContext* codec_context) { | 230 AVCodecContext* codec_context) { |
230 codec_context->codec_type = AVMEDIA_TYPE_AUDIO; | 231 codec_context->codec_type = AVMEDIA_TYPE_AUDIO; |
231 codec_context->codec_id = AudioCodecToCodecID(config.codec(), | 232 codec_context->codec_id = AudioCodecToCodecID(config.codec(), |
232 config.bits_per_channel()); | 233 config.bits_per_channel()); |
233 | 234 |
234 switch (config.bits_per_channel()) { | 235 switch (config.bits_per_channel()) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 VideoCodec codec = CodecIDToVideoCodec(stream->codec->codec_id); | 285 VideoCodec codec = CodecIDToVideoCodec(stream->codec->codec_id); |
285 VideoCodecProfile profile = (codec == kCodecVP8) ? VP8PROFILE_MAIN : | 286 VideoCodecProfile profile = (codec == kCodecVP8) ? VP8PROFILE_MAIN : |
286 ProfileIDToVideoCodecProfile(stream->codec->profile); | 287 ProfileIDToVideoCodecProfile(stream->codec->profile); |
287 gfx::Size natural_size = GetNaturalSize( | 288 gfx::Size natural_size = GetNaturalSize( |
288 visible_rect.size(), aspect_ratio.num, aspect_ratio.den); | 289 visible_rect.size(), aspect_ratio.num, aspect_ratio.den); |
289 config->Initialize(codec, | 290 config->Initialize(codec, |
290 profile, | 291 profile, |
291 PixelFormatToVideoFormat(stream->codec->pix_fmt), | 292 PixelFormatToVideoFormat(stream->codec->pix_fmt), |
292 coded_size, visible_rect, natural_size, | 293 coded_size, visible_rect, natural_size, |
293 stream->codec->extradata, stream->codec->extradata_size, | 294 stream->codec->extradata, stream->codec->extradata_size, |
294 false, | 295 false, // Not encrypted. |
295 true); | 296 true); |
296 } | 297 } |
297 | 298 |
298 void VideoDecoderConfigToAVCodecContext( | 299 void VideoDecoderConfigToAVCodecContext( |
299 const VideoDecoderConfig& config, | 300 const VideoDecoderConfig& config, |
300 AVCodecContext* codec_context) { | 301 AVCodecContext* codec_context) { |
301 codec_context->codec_type = AVMEDIA_TYPE_VIDEO; | 302 codec_context->codec_type = AVMEDIA_TYPE_VIDEO; |
302 codec_context->codec_id = VideoCodecToCodecID(config.codec()); | 303 codec_context->codec_id = VideoCodecToCodecID(config.codec()); |
303 codec_context->profile = VideoCodecProfileToProfileID(config.profile()); | 304 codec_context->profile = VideoCodecProfileToProfileID(config.profile()); |
304 codec_context->coded_width = config.coded_size().width(); | 305 codec_context->coded_width = config.coded_size().width(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 avcodec_close(stream->codec); | 409 avcodec_close(stream->codec); |
409 } | 410 } |
410 } | 411 } |
411 } | 412 } |
412 | 413 |
413 // Then finally cleanup the format context. | 414 // Then finally cleanup the format context. |
414 avformat_close_input(&format_context); | 415 avformat_close_input(&format_context); |
415 } | 416 } |
416 | 417 |
417 } // namespace media | 418 } // namespace media |
OLD | NEW |