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

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

Issue 8341033: Remove DemuxerStream::GetAVStream() once and for all. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: now with cmath Created 9 years, 1 month 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 <deque> 7 #include <deque>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 if (!demuxer_stream) { 51 if (!demuxer_stream) {
52 host()->SetError(PIPELINE_ERROR_DECODE); 52 host()->SetError(PIPELINE_ERROR_DECODE);
53 callback.Run(); 53 callback.Run();
54 return; 54 return;
55 } 55 }
56 56
57 demuxer_stream_ = demuxer_stream; 57 demuxer_stream_ = demuxer_stream;
58 initialize_callback_ = callback; 58 initialize_callback_ = callback;
59 statistics_callback_ = stats_callback; 59 statistics_callback_ = stats_callback;
60 60
61 AVStream* av_stream = demuxer_stream->GetAVStream(); 61 const VideoDecoderConfig& config = demuxer_stream->video_decoder_config();
62 if (!av_stream) {
63 OnInitializeComplete(false);
64 return;
65 }
66 62
67 pts_stream_.Initialize(GetFrameDuration(av_stream)); 63 pts_stream_.Initialize(GetFrameDuration(config));
68 64
69 gfx::Size coded_size( 65 natural_size_ = config.natural_size();
70 av_stream->codec->coded_width, av_stream->codec->coded_height);
71 // TODO(vrk): This assumes decoded frame data starts at (0, 0), which is true
72 // for now, but may not always be true forever. Fix this in the future.
73 gfx::Rect visible_rect(
74 av_stream->codec->width, av_stream->codec->height);
75
76 natural_size_ = GetNaturalSize(av_stream);
77 if (natural_size_.width() > Limits::kMaxDimension || 66 if (natural_size_.width() > Limits::kMaxDimension ||
78 natural_size_.height() > Limits::kMaxDimension || 67 natural_size_.height() > Limits::kMaxDimension ||
79 natural_size_.GetArea() > Limits::kMaxCanvas) { 68 natural_size_.GetArea() > Limits::kMaxCanvas) {
80 OnInitializeComplete(false); 69 OnInitializeComplete(false);
81 return; 70 return;
82 } 71 }
83 72
84 VideoDecoderConfig config(CodecIDToVideoCodec(av_stream->codec->codec_id),
85 PixelFormatToVideoFormat(av_stream->codec->pix_fmt),
86 coded_size, visible_rect,
87 av_stream->r_frame_rate.num,
88 av_stream->r_frame_rate.den,
89 av_stream->codec->extradata,
90 av_stream->codec->extradata_size);
91
92 state_ = kInitializing; 73 state_ = kInitializing;
93 decode_engine_->Initialize(message_loop_, this, NULL, config); 74 decode_engine_->Initialize(message_loop_, this, NULL, config);
94 } 75 }
95 76
96 void FFmpegVideoDecoder::OnInitializeComplete(bool success) { 77 void FFmpegVideoDecoder::OnInitializeComplete(bool success) {
97 DCHECK_EQ(MessageLoop::current(), message_loop_); 78 DCHECK_EQ(MessageLoop::current(), message_loop_);
98 DCHECK(!initialize_callback_.is_null()); 79 DCHECK(!initialize_callback_.is_null());
99 80
100 if (success) { 81 if (success) {
101 state_ = kNormal; 82 state_ = kNormal;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 decode_engine_->ProduceVideoFrame(video_frame); 318 decode_engine_->ProduceVideoFrame(video_frame);
338 } 319 }
339 } 320 }
340 321
341 void FFmpegVideoDecoder::SetVideoDecodeEngineForTest( 322 void FFmpegVideoDecoder::SetVideoDecodeEngineForTest(
342 VideoDecodeEngine* engine) { 323 VideoDecodeEngine* engine) {
343 decode_engine_.reset(engine); 324 decode_engine_.reset(engine);
344 } 325 }
345 326
346 } // namespace media 327 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | media/filters/ffmpeg_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698