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

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

Issue 11578046: Revert 174311 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « media/base/video_decoder_config.h ('k') | media/filters/vpx_video_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "media/base/video_util.h" 11 #include "media/base/video_util.h"
12 12
13 // TODO(tomfinegan): Remove this once FFmpeg rolls for M25. The VP9 patch is in
14 // tree, but this is required until the roll happens.
15 #define AV_CODEC_ID_VP9 170
16
17 namespace media { 13 namespace media {
18 14
19 // Why FF_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are 15 // Why FF_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are
20 // padded. Check here to ensure FFmpeg only receives data padded to its 16 // padded. Check here to ensure FFmpeg only receives data padded to its
21 // specifications. 17 // specifications.
22 COMPILE_ASSERT(DecoderBuffer::kPaddingSize >= FF_INPUT_BUFFER_PADDING_SIZE, 18 COMPILE_ASSERT(DecoderBuffer::kPaddingSize >= FF_INPUT_BUFFER_PADDING_SIZE,
23 decoder_buffer_padding_size_does_not_fit_ffmpeg_requirement); 19 decoder_buffer_padding_size_does_not_fit_ffmpeg_requirement);
24 20
25 // Alignment requirement by FFmpeg for input and output buffers. This need to 21 // Alignment requirement by FFmpeg for input and output buffers. This need to
26 // be updated to match FFmpeg when it changes. 22 // be updated to match FFmpeg when it changes.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return kCodecH264; 142 return kCodecH264;
147 case CODEC_ID_THEORA: 143 case CODEC_ID_THEORA:
148 return kCodecTheora; 144 return kCodecTheora;
149 case CODEC_ID_MPEG2VIDEO: 145 case CODEC_ID_MPEG2VIDEO:
150 return kCodecMPEG2; 146 return kCodecMPEG2;
151 case CODEC_ID_MPEG4: 147 case CODEC_ID_MPEG4:
152 return kCodecMPEG4; 148 return kCodecMPEG4;
153 case CODEC_ID_VP8: 149 case CODEC_ID_VP8:
154 return kCodecVP8; 150 return kCodecVP8;
155 default: 151 default:
156 if (codec_id == AV_CODEC_ID_VP9) {
157 // TODO(tomfinegan): Remove this once FFmpeg rolls for M25, and
158 // AV_CODEC_ID_VP9 is part of CodecID.
159 return kCodecVP9;
160 }
161 DVLOG(1) << "Unknown video CodecID: " << codec_id; 152 DVLOG(1) << "Unknown video CodecID: " << codec_id;
162 } 153 }
163 return kUnknownVideoCodec; 154 return kUnknownVideoCodec;
164 } 155 }
165 156
166 static CodecID VideoCodecToCodecID(VideoCodec video_codec) { 157 static CodecID VideoCodecToCodecID(VideoCodec video_codec) {
167 switch (video_codec) { 158 switch (video_codec) {
168 case kCodecVC1: 159 case kCodecVC1:
169 return CODEC_ID_VC1; 160 return CODEC_ID_VC1;
170 case kCodecH264: 161 case kCodecH264:
171 return CODEC_ID_H264; 162 return CODEC_ID_H264;
172 case kCodecTheora: 163 case kCodecTheora:
173 return CODEC_ID_THEORA; 164 return CODEC_ID_THEORA;
174 case kCodecMPEG2: 165 case kCodecMPEG2:
175 return CODEC_ID_MPEG2VIDEO; 166 return CODEC_ID_MPEG2VIDEO;
176 case kCodecMPEG4: 167 case kCodecMPEG4:
177 return CODEC_ID_MPEG4; 168 return CODEC_ID_MPEG4;
178 case kCodecVP8: 169 case kCodecVP8:
179 return CODEC_ID_VP8; 170 return CODEC_ID_VP8;
180 case kCodecVP9:
181 // TODO(tomfinegan): Remove this cast once FFmpeg rolls for M25, and the
182 // local define for AV_CODEC_ID_VP9 is removed.
183 return static_cast<CodecID>(AV_CODEC_ID_VP9);
184 default: 171 default:
185 DVLOG(1) << "Unknown VideoCodec: " << video_codec; 172 DVLOG(1) << "Unknown VideoCodec: " << video_codec;
186 } 173 }
187 return CODEC_ID_NONE; 174 return CODEC_ID_NONE;
188 } 175 }
189 176
190 static VideoCodecProfile ProfileIDToVideoCodecProfile(int profile) { 177 static VideoCodecProfile ProfileIDToVideoCodecProfile(int profile) {
191 // Clear out the CONSTRAINED & INTRA flags which are strict subsets of the 178 // Clear out the CONSTRAINED & INTRA flags which are strict subsets of the
192 // corresponding profiles with which they're used. 179 // corresponding profiles with which they're used.
193 profile &= ~FF_PROFILE_H264_CONSTRAINED; 180 profile &= ~FF_PROFILE_H264_CONSTRAINED;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 // for now, but may not always be true forever. Fix this in the future. 304 // for now, but may not always be true forever. Fix this in the future.
318 gfx::Rect visible_rect(stream->codec->width, stream->codec->height); 305 gfx::Rect visible_rect(stream->codec->width, stream->codec->height);
319 306
320 AVRational aspect_ratio = { 1, 1 }; 307 AVRational aspect_ratio = { 1, 1 };
321 if (stream->sample_aspect_ratio.num) 308 if (stream->sample_aspect_ratio.num)
322 aspect_ratio = stream->sample_aspect_ratio; 309 aspect_ratio = stream->sample_aspect_ratio;
323 else if (stream->codec->sample_aspect_ratio.num) 310 else if (stream->codec->sample_aspect_ratio.num)
324 aspect_ratio = stream->codec->sample_aspect_ratio; 311 aspect_ratio = stream->codec->sample_aspect_ratio;
325 312
326 VideoCodec codec = CodecIDToVideoCodec(stream->codec->codec_id); 313 VideoCodec codec = CodecIDToVideoCodec(stream->codec->codec_id);
327 314 VideoCodecProfile profile = (codec == kCodecVP8) ? VP8PROFILE_MAIN :
328 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN; 315 ProfileIDToVideoCodecProfile(stream->codec->profile);
329 if (codec == kCodecVP8)
330 profile = VP8PROFILE_MAIN;
331 else if (codec == kCodecVP9)
332 profile = VP9PROFILE_MAIN;
333 else
334 profile = ProfileIDToVideoCodecProfile(stream->codec->profile);
335
336 gfx::Size natural_size = GetNaturalSize( 316 gfx::Size natural_size = GetNaturalSize(
337 visible_rect.size(), aspect_ratio.num, aspect_ratio.den); 317 visible_rect.size(), aspect_ratio.num, aspect_ratio.den);
338
339 VideoFrame::Format format = PixelFormatToVideoFormat(stream->codec->pix_fmt);
340 if (codec == kCodecVP9) {
341 // TODO(tomfinegan): libavcodec doesn't know about VP9.
342 format = VideoFrame::YV12;
343 coded_size = natural_size;
344 }
345
346 config->Initialize(codec, 318 config->Initialize(codec,
347 profile, 319 profile,
348 format, 320 PixelFormatToVideoFormat(stream->codec->pix_fmt),
349 coded_size, visible_rect, natural_size, 321 coded_size, visible_rect, natural_size,
350 stream->codec->extradata, stream->codec->extradata_size, 322 stream->codec->extradata, stream->codec->extradata_size,
351 false, // Not encrypted. 323 false, // Not encrypted.
352 true); 324 true);
353 } 325 }
354 326
355 void VideoDecoderConfigToAVCodecContext( 327 void VideoDecoderConfigToAVCodecContext(
356 const VideoDecoderConfig& config, 328 const VideoDecoderConfig& config,
357 AVCodecContext* codec_context) { 329 AVCodecContext* codec_context) {
358 codec_context->codec_type = AVMEDIA_TYPE_VIDEO; 330 codec_context->codec_type = AVMEDIA_TYPE_VIDEO;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 return PIX_FMT_YUV422P; 435 return PIX_FMT_YUV422P;
464 case VideoFrame::YV12: 436 case VideoFrame::YV12:
465 return PIX_FMT_YUV420P; 437 return PIX_FMT_YUV420P;
466 default: 438 default:
467 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; 439 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format;
468 } 440 }
469 return PIX_FMT_NONE; 441 return PIX_FMT_NONE;
470 } 442 }
471 443
472 } // namespace media 444 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_decoder_config.h ('k') | media/filters/vpx_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698