OLD | NEW |
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/vpx_video_decoder.h" | 5 #include "media/filters/vpx_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/location.h" | 10 #include "base/location.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 VpxVideoDecoder::~VpxVideoDecoder() { | 69 VpxVideoDecoder::~VpxVideoDecoder() { |
70 DCHECK_EQ(kUninitialized, state_); | 70 DCHECK_EQ(kUninitialized, state_); |
71 CloseDecoder(); | 71 CloseDecoder(); |
72 } | 72 } |
73 | 73 |
74 void VpxVideoDecoder::Initialize( | 74 void VpxVideoDecoder::Initialize( |
75 DemuxerStream* stream, | 75 DemuxerStream* stream, |
76 const PipelineStatusCB& status_cb, | 76 const PipelineStatusCB& status_cb, |
77 const StatisticsCB& statistics_cb) { | 77 const StatisticsCB& statistics_cb) { |
78 DCHECK(message_loop_->BelongsToCurrentThread()); | 78 DCHECK(message_loop_->BelongsToCurrentThread()); |
79 DCHECK(!demuxer_stream_) << "Already initialized."; | 79 DCHECK(stream); |
| 80 DCHECK(read_cb_.is_null()); |
| 81 DCHECK(reset_cb_.is_null()); |
| 82 |
80 weak_this_ = weak_factory_.GetWeakPtr(); | 83 weak_this_ = weak_factory_.GetWeakPtr(); |
81 | 84 |
82 if (!stream) { | |
83 status_cb.Run(PIPELINE_ERROR_DECODE); | |
84 return; | |
85 } | |
86 | |
87 demuxer_stream_ = stream; | 85 demuxer_stream_ = stream; |
88 statistics_cb_ = statistics_cb; | 86 statistics_cb_ = statistics_cb; |
89 | 87 |
90 if (!ConfigureDecoder()) { | 88 if (!ConfigureDecoder()) { |
91 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); | 89 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); |
92 return; | 90 return; |
93 } | 91 } |
94 | 92 |
95 // Success! | 93 // Success! |
96 state_ = kNormal; | 94 state_ = kNormal; |
(...skipping 17 matching lines...) Expand all Loading... |
114 if (status != VPX_CODEC_OK) { | 112 if (status != VPX_CODEC_OK) { |
115 LOG(ERROR) << "vpx_codec_dec_init failed, status=" << status; | 113 LOG(ERROR) << "vpx_codec_dec_init failed, status=" << status; |
116 delete context; | 114 delete context; |
117 return NULL; | 115 return NULL; |
118 } | 116 } |
119 return context; | 117 return context; |
120 } | 118 } |
121 | 119 |
122 bool VpxVideoDecoder::ConfigureDecoder() { | 120 bool VpxVideoDecoder::ConfigureDecoder() { |
123 const VideoDecoderConfig& config = demuxer_stream_->video_decoder_config(); | 121 const VideoDecoderConfig& config = demuxer_stream_->video_decoder_config(); |
124 if (!config.IsValidConfig()) { | 122 DCHECK(config.IsValidConfig()); |
125 DLOG(ERROR) << "Invalid video stream config: " | |
126 << config.AsHumanReadableString(); | |
127 return false; | |
128 } | |
129 | 123 |
130 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 124 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
131 bool can_handle = false; | 125 bool can_handle = false; |
132 if (cmd_line->HasSwitch(switches::kEnableVp9Playback) && | 126 if (cmd_line->HasSwitch(switches::kEnableVp9Playback) && |
133 config.codec() == kCodecVP9) { | 127 config.codec() == kCodecVP9) { |
134 can_handle = true; | 128 can_handle = true; |
135 } | 129 } |
136 if (cmd_line->HasSwitch(switches::kEnableVp8AlphaPlayback) && | 130 if (cmd_line->HasSwitch(switches::kEnableVp8AlphaPlayback) && |
137 config.codec() == kCodecVP8 && config.format() == VideoFrame::YV12A) { | 131 config.codec() == kCodecVP8 && config.format() == VideoFrame::YV12A) { |
138 can_handle = true; | 132 can_handle = true; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 *video_frame); | 421 *video_frame); |
428 return; | 422 return; |
429 } | 423 } |
430 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], | 424 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], |
431 vpx_image->stride[VPX_PLANE_Y], | 425 vpx_image->stride[VPX_PLANE_Y], |
432 vpx_image->d_h, | 426 vpx_image->d_h, |
433 *video_frame); | 427 *video_frame); |
434 } | 428 } |
435 | 429 |
436 } // namespace media | 430 } // namespace media |
OLD | NEW |