Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: media/ffmpeg/ffmpeg_common.cc

Issue 11468018: Add libvpx wrapper to media to support VP9 video decoding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Uncomment VP9 stuff in ffmpeg_common. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 case CODEC_ID_H264: 141 case CODEC_ID_H264:
142 return kCodecH264; 142 return kCodecH264;
143 case CODEC_ID_THEORA: 143 case CODEC_ID_THEORA:
144 return kCodecTheora; 144 return kCodecTheora;
145 case CODEC_ID_MPEG2VIDEO: 145 case CODEC_ID_MPEG2VIDEO:
146 return kCodecMPEG2; 146 return kCodecMPEG2;
147 case CODEC_ID_MPEG4: 147 case CODEC_ID_MPEG4:
148 return kCodecMPEG4; 148 return kCodecMPEG4;
149 case CODEC_ID_VP8: 149 case CODEC_ID_VP8:
150 return kCodecVP8; 150 return kCodecVP8;
151 case AV_CODEC_ID_VP9:
152 return kCodecVP9;
151 default: 153 default:
152 DVLOG(1) << "Unknown video CodecID: " << codec_id; 154 DVLOG(1) << "Unknown video CodecID: " << codec_id;
153 } 155 }
154 return kUnknownVideoCodec; 156 return kUnknownVideoCodec;
155 } 157 }
156 158
157 static CodecID VideoCodecToCodecID(VideoCodec video_codec) { 159 static CodecID VideoCodecToCodecID(VideoCodec video_codec) {
158 switch (video_codec) { 160 switch (video_codec) {
159 case kCodecVC1: 161 case kCodecVC1:
160 return CODEC_ID_VC1; 162 return CODEC_ID_VC1;
161 case kCodecH264: 163 case kCodecH264:
162 return CODEC_ID_H264; 164 return CODEC_ID_H264;
163 case kCodecTheora: 165 case kCodecTheora:
164 return CODEC_ID_THEORA; 166 return CODEC_ID_THEORA;
165 case kCodecMPEG2: 167 case kCodecMPEG2:
166 return CODEC_ID_MPEG2VIDEO; 168 return CODEC_ID_MPEG2VIDEO;
167 case kCodecMPEG4: 169 case kCodecMPEG4:
168 return CODEC_ID_MPEG4; 170 return CODEC_ID_MPEG4;
169 case kCodecVP8: 171 case kCodecVP8:
170 return CODEC_ID_VP8; 172 return CODEC_ID_VP8;
173 case kCodecVP9:
174 return AV_CODEC_ID_VP9;
171 default: 175 default:
172 DVLOG(1) << "Unknown VideoCodec: " << video_codec; 176 DVLOG(1) << "Unknown VideoCodec: " << video_codec;
173 } 177 }
174 return CODEC_ID_NONE; 178 return CODEC_ID_NONE;
175 } 179 }
176 180
177 static VideoCodecProfile ProfileIDToVideoCodecProfile(int profile) { 181 static VideoCodecProfile ProfileIDToVideoCodecProfile(int profile) {
178 // Clear out the CONSTRAINED & INTRA flags which are strict subsets of the 182 // Clear out the CONSTRAINED & INTRA flags which are strict subsets of the
179 // corresponding profiles with which they're used. 183 // corresponding profiles with which they're used.
180 profile &= ~FF_PROFILE_H264_CONSTRAINED; 184 profile &= ~FF_PROFILE_H264_CONSTRAINED;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 gfx::Rect visible_rect(stream->codec->width, stream->codec->height); 307 gfx::Rect visible_rect(stream->codec->width, stream->codec->height);
304 308
305 AVRational aspect_ratio = { 1, 1 }; 309 AVRational aspect_ratio = { 1, 1 };
306 if (stream->sample_aspect_ratio.num) 310 if (stream->sample_aspect_ratio.num)
307 aspect_ratio = stream->sample_aspect_ratio; 311 aspect_ratio = stream->sample_aspect_ratio;
308 else if (stream->codec->sample_aspect_ratio.num) 312 else if (stream->codec->sample_aspect_ratio.num)
309 aspect_ratio = stream->codec->sample_aspect_ratio; 313 aspect_ratio = stream->codec->sample_aspect_ratio;
310 314
311 VideoCodec codec = CodecIDToVideoCodec(stream->codec->codec_id); 315 VideoCodec codec = CodecIDToVideoCodec(stream->codec->codec_id);
312 VideoCodecProfile profile = (codec == kCodecVP8) ? VP8PROFILE_MAIN : 316 VideoCodecProfile profile = (codec == kCodecVP8) ? VP8PROFILE_MAIN :
313 ProfileIDToVideoCodecProfile(stream->codec->profile); 317 (codec == kCodecVP9) ? VP9PROFILE_MAIN :
318 ProfileIDToVideoCodecProfile(stream->codec->profile);
314 gfx::Size natural_size = GetNaturalSize( 319 gfx::Size natural_size = GetNaturalSize(
315 visible_rect.size(), aspect_ratio.num, aspect_ratio.den); 320 visible_rect.size(), aspect_ratio.num, aspect_ratio.den);
316 config->Initialize(codec, 321 config->Initialize(codec,
317 profile, 322 profile,
318 PixelFormatToVideoFormat(stream->codec->pix_fmt), 323 PixelFormatToVideoFormat(stream->codec->pix_fmt),
319 coded_size, visible_rect, natural_size, 324 coded_size, visible_rect, natural_size,
320 stream->codec->extradata, stream->codec->extradata_size, 325 stream->codec->extradata, stream->codec->extradata_size,
321 false, // Not encrypted. 326 false, // Not encrypted.
322 true); 327 true);
323 } 328 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 return PIX_FMT_YUV422P; 438 return PIX_FMT_YUV422P;
434 case VideoFrame::YV12: 439 case VideoFrame::YV12:
435 return PIX_FMT_YUV420P; 440 return PIX_FMT_YUV420P;
436 default: 441 default:
437 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; 442 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format;
438 } 443 }
439 return PIX_FMT_NONE; 444 return PIX_FMT_NONE;
440 } 445 }
441 446
442 } // namespace media 447 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698