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

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

Issue 10832087: Remove VideoDecoderConfig.frame_rate_xxx() & VideoFrame:Get/SetDuration() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address more CR comments. Created 8 years, 4 months 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_util_unittest.cc ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('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/logging.h" 7 #include "base/logging.h"
8 8
9 namespace media { 9 namespace media {
10 10
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 else if (stream->codec->sample_aspect_ratio.num) 247 else if (stream->codec->sample_aspect_ratio.num)
248 aspect_ratio = stream->codec->sample_aspect_ratio; 248 aspect_ratio = stream->codec->sample_aspect_ratio;
249 249
250 VideoCodec codec = CodecIDToVideoCodec(stream->codec->codec_id); 250 VideoCodec codec = CodecIDToVideoCodec(stream->codec->codec_id);
251 VideoCodecProfile profile = (codec == kCodecVP8) ? VP8PROFILE_MAIN : 251 VideoCodecProfile profile = (codec == kCodecVP8) ? VP8PROFILE_MAIN :
252 ProfileIDToVideoCodecProfile(stream->codec->profile); 252 ProfileIDToVideoCodecProfile(stream->codec->profile);
253 config->Initialize(codec, 253 config->Initialize(codec,
254 profile, 254 profile,
255 PixelFormatToVideoFormat(stream->codec->pix_fmt), 255 PixelFormatToVideoFormat(stream->codec->pix_fmt),
256 coded_size, visible_rect, 256 coded_size, visible_rect,
257 stream->r_frame_rate.num,
258 stream->r_frame_rate.den,
259 aspect_ratio.num, 257 aspect_ratio.num,
260 aspect_ratio.den, 258 aspect_ratio.den,
261 stream->codec->extradata, 259 stream->codec->extradata,
262 stream->codec->extradata_size, 260 stream->codec->extradata_size,
263 true); 261 true);
264 } 262 }
265 263
266 void VideoDecoderConfigToAVCodecContext( 264 void VideoDecoderConfigToAVCodecContext(
267 const VideoDecoderConfig& config, 265 const VideoDecoderConfig& config,
268 AVCodecContext* codec_context) { 266 AVCodecContext* codec_context) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 case VideoFrame::YV16: 347 case VideoFrame::YV16:
350 return PIX_FMT_YUV422P; 348 return PIX_FMT_YUV422P;
351 case VideoFrame::YV12: 349 case VideoFrame::YV12:
352 return PIX_FMT_YUV420P; 350 return PIX_FMT_YUV420P;
353 default: 351 default:
354 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; 352 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format;
355 } 353 }
356 return PIX_FMT_NONE; 354 return PIX_FMT_NONE;
357 } 355 }
358 356
359 base::TimeDelta GetFrameDuration(const VideoDecoderConfig& config) {
360 AVRational time_base = {
361 config.frame_rate_denominator(),
362 config.frame_rate_numerator()
363 };
364 return ConvertFromTimeBase(time_base, 1);
365 }
366
367 void DestroyAVFormatContext(AVFormatContext* format_context) { 357 void DestroyAVFormatContext(AVFormatContext* format_context) {
368 DCHECK(format_context); 358 DCHECK(format_context);
369 359
370 // Iterate each stream and destroy each one of them. 360 // Iterate each stream and destroy each one of them.
371 if (format_context->streams) { 361 if (format_context->streams) {
372 int streams = format_context->nb_streams; 362 int streams = format_context->nb_streams;
373 for (int i = 0; i < streams; ++i) { 363 for (int i = 0; i < streams; ++i) {
374 AVStream* stream = format_context->streams[i]; 364 AVStream* stream = format_context->streams[i];
375 365
376 // The conditions for calling avcodec_close(): 366 // The conditions for calling avcodec_close():
377 // 1. AVStream is alive. 367 // 1. AVStream is alive.
378 // 2. AVCodecContext in AVStream is alive. 368 // 2. AVCodecContext in AVStream is alive.
379 // 3. AVCodec in AVCodecContext is alive. 369 // 3. AVCodec in AVCodecContext is alive.
380 // Notice that closing a codec context without prior avcodec_open2() will 370 // Notice that closing a codec context without prior avcodec_open2() will
381 // result in a crash in FFmpeg. 371 // result in a crash in FFmpeg.
382 if (stream && stream->codec && stream->codec->codec) { 372 if (stream && stream->codec && stream->codec->codec) {
383 stream->discard = AVDISCARD_ALL; 373 stream->discard = AVDISCARD_ALL;
384 avcodec_close(stream->codec); 374 avcodec_close(stream->codec);
385 } 375 }
386 } 376 }
387 } 377 }
388 378
389 // Then finally cleanup the format context. 379 // Then finally cleanup the format context.
390 avformat_close_input(&format_context); 380 avformat_close_input(&format_context);
391 } 381 }
392 382
393 } // namespace media 383 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_util_unittest.cc ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698