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

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

Issue 8686010: <video> decode in hardware! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing OVERRIDEs Created 9 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) 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/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/message_loop.h" 8 #include "base/message_loop.h"
9 #include "media/base/demuxer_stream.h" 9 #include "media/base/demuxer_stream.h"
10 #include "media/base/filter_host.h" 10 #include "media/base/filter_host.h"
11 #include "media/base/limits.h" 11 #include "media/base/limits.h"
12 #include "media/base/video_decoder_config.h" 12 #include "media/base/video_decoder_config.h"
13 #include "media/base/video_frame.h" 13 #include "media/base/video_frame.h"
14 #include "media/ffmpeg/ffmpeg_common.h" 14 #include "media/ffmpeg/ffmpeg_common.h"
15 #include "media/video/ffmpeg_video_decode_engine.h" 15 #include "media/video/ffmpeg_video_decode_engine.h"
16 16
17 namespace media { 17 namespace media {
18 18
19 FFmpegVideoDecoder::FFmpegVideoDecoder(MessageLoop* message_loop) 19 FFmpegVideoDecoder::FFmpegVideoDecoder(MessageLoop* message_loop)
20 : message_loop_(message_loop), 20 : message_loop_(message_loop),
21 state_(kUninitialized), 21 state_(kUninitialized),
22 decode_engine_(new FFmpegVideoDecodeEngine()) { 22 decode_engine_(new FFmpegVideoDecodeEngine()) {
23 } 23 }
24 24
25 FFmpegVideoDecoder::~FFmpegVideoDecoder() {} 25 FFmpegVideoDecoder::~FFmpegVideoDecoder() {}
26 26
27 void FFmpegVideoDecoder::Initialize(DemuxerStream* demuxer_stream, 27 void FFmpegVideoDecoder::Initialize(DemuxerStream* demuxer_stream,
28 const base::Closure& callback, 28 const PipelineStatusCB& callback,
29 const StatisticsCallback& stats_callback) { 29 const StatisticsCallback& stats_callback) {
30 if (MessageLoop::current() != message_loop_) { 30 if (MessageLoop::current() != message_loop_) {
31 message_loop_->PostTask(FROM_HERE, base::Bind( 31 message_loop_->PostTask(FROM_HERE, base::Bind(
32 &FFmpegVideoDecoder::Initialize, this, 32 &FFmpegVideoDecoder::Initialize, this,
33 make_scoped_refptr(demuxer_stream), callback, stats_callback)); 33 make_scoped_refptr(demuxer_stream), callback, stats_callback));
34 return; 34 return;
35 } 35 }
36 36
37 DCHECK(!demuxer_stream_); 37 DCHECK(!demuxer_stream_);
38 38
39 if (!demuxer_stream) { 39 if (!demuxer_stream) {
40 host()->SetError(PIPELINE_ERROR_DECODE); 40 callback.Run(PIPELINE_ERROR_DECODE);
scherkus (not reviewing) 2011/12/06 00:27:44 \o/
Ami GONE FROM CHROMIUM 2011/12/07 00:03:04 Done.
41 callback.Run();
42 return; 41 return;
43 } 42 }
44 43
45 demuxer_stream_ = demuxer_stream; 44 demuxer_stream_ = demuxer_stream;
46 statistics_callback_ = stats_callback; 45 statistics_callback_ = stats_callback;
47 46
48 const VideoDecoderConfig& config = demuxer_stream->video_decoder_config(); 47 const VideoDecoderConfig& config = demuxer_stream->video_decoder_config();
49 48
50 // TODO(scherkus): this check should go in PipelineImpl prior to creating 49 // TODO(scherkus): this check should go in PipelineImpl prior to creating
51 // decoder objects. 50 // decoder objects.
52 if (!config.IsValidConfig()) { 51 if (!config.IsValidConfig()) {
53 DLOG(ERROR) << "Invalid video stream -" 52 DLOG(ERROR) << "Invalid video stream - " << config.AsHumanReadableString();
54 << " codec: " << config.codec() 53 callback.Run(PIPELINE_ERROR_DECODE);
55 << " format: " << config.format()
56 << " coded size: [" << config.coded_size().width()
57 << "," << config.coded_size().height() << "]"
58 << " visible rect: [" << config.visible_rect().x()
59 << "," << config.visible_rect().y()
60 << "," << config.visible_rect().width()
61 << "," << config.visible_rect().height() << "]"
62 << " natural size: [" << config.natural_size().width()
63 << "," << config.natural_size().height() << "]"
64 << " frame rate: " << config.frame_rate_numerator()
65 << "/" << config.frame_rate_denominator()
66 << " aspect ratio: " << config.aspect_ratio_numerator()
67 << "/" << config.aspect_ratio_denominator();
68
69 host()->SetError(PIPELINE_ERROR_DECODE);
70 callback.Run();
71 return; 54 return;
72 } 55 }
73 56
74 pts_stream_.Initialize(GetFrameDuration(config)); 57 pts_stream_.Initialize(GetFrameDuration(config));
75 natural_size_ = config.natural_size(); 58 natural_size_ = config.natural_size();
76 59
77 if (!decode_engine_->Initialize(config)) { 60 if (!decode_engine_->Initialize(config)) {
78 host()->SetError(PIPELINE_ERROR_DECODE); 61 callback.Run(PIPELINE_ERROR_DECODE);
79 callback.Run();
80 return; 62 return;
81 } 63 }
82 64
83 state_ = kNormal; 65 state_ = kNormal;
84 callback.Run(); 66 callback.Run(PIPELINE_OK);
85 } 67 }
86 68
87 void FFmpegVideoDecoder::Stop(const base::Closure& callback) { 69 void FFmpegVideoDecoder::Stop(const base::Closure& callback) {
88 if (MessageLoop::current() != message_loop_) { 70 if (MessageLoop::current() != message_loop_) {
89 message_loop_->PostTask(FROM_HERE, base::Bind( 71 message_loop_->PostTask(FROM_HERE, base::Bind(
90 &FFmpegVideoDecoder::Stop, this, callback)); 72 &FFmpegVideoDecoder::Stop, this, callback));
91 return; 73 return;
92 } 74 }
93 75
94 decode_engine_->Uninitialize(); 76 decode_engine_->Uninitialize();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 240
259 void FFmpegVideoDecoder::DeliverFrame( 241 void FFmpegVideoDecoder::DeliverFrame(
260 const scoped_refptr<VideoFrame>& video_frame) { 242 const scoped_refptr<VideoFrame>& video_frame) {
261 // Reset the callback before running to protect against reentrancy. 243 // Reset the callback before running to protect against reentrancy.
262 ReadCB read_cb = read_cb_; 244 ReadCB read_cb = read_cb_;
263 read_cb_.Reset(); 245 read_cb_.Reset();
264 read_cb.Run(video_frame); 246 read_cb.Run(video_frame);
265 } 247 }
266 248
267 } // namespace media 249 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698