 Chromium Code Reviews
 Chromium Code Reviews Issue 8686010:
  <video> decode in hardware!  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 8686010:
  <video> decode in hardware!  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| 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; | |
| 
scherkus (not reviewing)
2011/12/06 00:27:44
let's drop the returns to the next line
 
Ami GONE FROM CHROMIUM
2011/12/07 00:03:04
What, you think vertical space grows on trees???
D
 | |
| 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 | 
| 217 void VideoDecoderConfigToAVCodecContext( | 232 void VideoDecoderConfigToAVCodecContext( | 
| 218 const VideoDecoderConfig& config, | 233 const VideoDecoderConfig& config, | 
| 219 AVCodecContext* codec_context) { | 234 AVCodecContext* codec_context) { | 
| 220 codec_context->codec_type = AVMEDIA_TYPE_VIDEO; | 235 codec_context->codec_type = AVMEDIA_TYPE_VIDEO; | 
| 221 codec_context->codec_id = VideoCodecToCodecID(config.codec()); | 236 codec_context->codec_id = VideoCodecToCodecID(config.codec()); | 
| 222 codec_context->coded_width = config.coded_size().width(); | 237 codec_context->coded_width = config.coded_size().width(); | 
| 223 codec_context->coded_height = config.coded_size().height(); | 238 codec_context->coded_height = config.coded_size().height(); | 
| 224 codec_context->pix_fmt = VideoFormatToPixelFormat(config.format()); | 239 codec_context->pix_fmt = VideoFormatToPixelFormat(config.format()); | 
| 
scherkus (not reviewing)
2011/12/06 00:27:44
set profile here?
 
Ami GONE FROM CHROMIUM
2011/12/07 00:03:04
Done.
 | |
| 225 | 240 | 
| 226 if (config.extra_data()) { | 241 if (config.extra_data()) { | 
| 227 codec_context->extradata_size = config.extra_data_size(); | 242 codec_context->extradata_size = config.extra_data_size(); | 
| 228 codec_context->extradata = reinterpret_cast<uint8_t*>( | 243 codec_context->extradata = reinterpret_cast<uint8_t*>( | 
| 229 av_malloc(config.extra_data_size() + FF_INPUT_BUFFER_PADDING_SIZE)); | 244 av_malloc(config.extra_data_size() + FF_INPUT_BUFFER_PADDING_SIZE)); | 
| 230 memcpy(codec_context->extradata, config.extra_data(), | 245 memcpy(codec_context->extradata, config.extra_data(), | 
| 231 config.extra_data_size()); | 246 config.extra_data_size()); | 
| 232 memset(codec_context->extradata + config.extra_data_size(), '\0', | 247 memset(codec_context->extradata + config.extra_data_size(), '\0', | 
| 233 FF_INPUT_BUFFER_PADDING_SIZE); | 248 FF_INPUT_BUFFER_PADDING_SIZE); | 
| 234 } else { | 249 } else { | 
| (...skipping 99 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 |