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

Side by Side Diff: media/filters/ffmpeg_video_decoder.cc

Issue 10534172: Implement ISO BMFF support in Media Source (try 2). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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
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/filters/ffmpeg_video_decoder.h" 5 #include "media/filters/ffmpeg_video_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "media/base/decoder_buffer.h" 12 #include "media/base/decoder_buffer.h"
13 #include "media/base/demuxer_stream.h" 13 #include "media/base/demuxer_stream.h"
14 #include "media/base/limits.h" 14 #include "media/base/limits.h"
15 #include "media/base/media_switches.h" 15 #include "media/base/media_switches.h"
16 #include "media/base/pipeline.h" 16 #include "media/base/pipeline.h"
17 #include "media/base/video_decoder_config.h" 17 #include "media/base/video_decoder_config.h"
18 #include "media/base/video_frame.h" 18 #include "media/base/video_frame.h"
19 #include "media/base/video_util.h" 19 #include "media/base/video_util.h"
20 #include "media/ffmpeg/ffmpeg_common.h" 20 #include "media/ffmpeg/ffmpeg_common.h"
21 #include "media/filters/ffmpeg_glue.h"
21 22
22 namespace media { 23 namespace media {
23 24
24 // Always try to use three threads for video decoding. There is little reason 25 // Always try to use three threads for video decoding. There is little reason
25 // not to since current day CPUs tend to be multi-core and we measured 26 // not to since current day CPUs tend to be multi-core and we measured
26 // performance benefits on older machines such as P4s with hyperthreading. 27 // performance benefits on older machines such as P4s with hyperthreading.
27 // 28 //
28 // Handling decoding on separate threads also frees up the pipeline thread to 29 // Handling decoding on separate threads also frees up the pipeline thread to
29 // continue processing. Although it'd be nice to have the option of a single 30 // continue processing. Although it'd be nice to have the option of a single
30 // decoding thread, FFmpeg treats having one thread the same as having zero 31 // decoding thread, FFmpeg treats having one thread the same as having zero
(...skipping 26 matching lines...) Expand all
57 codec_context_(NULL), 58 codec_context_(NULL),
58 av_frame_(NULL), 59 av_frame_(NULL),
59 frame_rate_numerator_(0), 60 frame_rate_numerator_(0),
60 frame_rate_denominator_(0), 61 frame_rate_denominator_(0),
61 decryptor_(NULL) { 62 decryptor_(NULL) {
62 } 63 }
63 64
64 void FFmpegVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream, 65 void FFmpegVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream,
65 const PipelineStatusCB& status_cb, 66 const PipelineStatusCB& status_cb,
66 const StatisticsCB& statistics_cb) { 67 const StatisticsCB& statistics_cb) {
68 // Ensure FFmpeg has been initialized
69 FFmpegGlue::GetInstance();
70
67 if (!message_loop_) { 71 if (!message_loop_) {
68 message_loop_ = message_loop_factory_cb_.Run(); 72 message_loop_ = message_loop_factory_cb_.Run();
69 message_loop_factory_cb_.Reset(); 73 message_loop_factory_cb_.Reset();
70 74
71 message_loop_->PostTask(FROM_HERE, base::Bind( 75 message_loop_->PostTask(FROM_HERE, base::Bind(
72 &FFmpegVideoDecoder::Initialize, this, 76 &FFmpegVideoDecoder::Initialize, this,
73 stream, status_cb, statistics_cb)); 77 stream, status_cb, statistics_cb));
74 return; 78 return;
75 } 79 }
76 80
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 scoped_refptr<VideoFrame> FFmpegVideoDecoder::AllocateVideoFrame() { 432 scoped_refptr<VideoFrame> FFmpegVideoDecoder::AllocateVideoFrame() {
429 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context_->pix_fmt); 433 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context_->pix_fmt);
430 size_t width = codec_context_->width; 434 size_t width = codec_context_->width;
431 size_t height = codec_context_->height; 435 size_t height = codec_context_->height;
432 436
433 return VideoFrame::CreateFrame(format, width, height, 437 return VideoFrame::CreateFrame(format, width, height,
434 kNoTimestamp(), kNoTimestamp()); 438 kNoTimestamp(), kNoTimestamp());
435 } 439 }
436 440
437 } // namespace media 441 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698