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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 197 } |
198 | 198 |
199 void VpxVideoDecoder::MemoryPool::OnVideoFrameDestroyed( | 199 void VpxVideoDecoder::MemoryPool::OnVideoFrameDestroyed( |
200 VP9FrameBuffer* frame_buffer) { | 200 VP9FrameBuffer* frame_buffer) { |
201 --frame_buffer->ref_cnt; | 201 --frame_buffer->ref_cnt; |
202 } | 202 } |
203 | 203 |
204 VpxVideoDecoder::VpxVideoDecoder( | 204 VpxVideoDecoder::VpxVideoDecoder( |
205 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) | 205 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) |
206 : task_runner_(task_runner), | 206 : task_runner_(task_runner), |
207 weak_factory_(this), | |
208 state_(kUninitialized), | 207 state_(kUninitialized), |
209 vpx_codec_(NULL), | 208 vpx_codec_(NULL), |
210 vpx_codec_alpha_(NULL) { | 209 vpx_codec_alpha_(NULL) {} |
211 } | |
212 | 210 |
213 VpxVideoDecoder::~VpxVideoDecoder() { | 211 VpxVideoDecoder::~VpxVideoDecoder() { |
214 DCHECK_EQ(kUninitialized, state_); | 212 DCHECK_EQ(kUninitialized, state_); |
215 CloseDecoder(); | 213 CloseDecoder(); |
216 } | 214 } |
217 | 215 |
218 void VpxVideoDecoder::Initialize(const VideoDecoderConfig& config, | 216 void VpxVideoDecoder::Initialize(const VideoDecoderConfig& config, |
219 const PipelineStatusCB& status_cb) { | 217 const PipelineStatusCB& status_cb) { |
220 DCHECK(task_runner_->BelongsToCurrentThread()); | 218 DCHECK(task_runner_->BelongsToCurrentThread()); |
221 DCHECK(config.IsValidConfig()); | 219 DCHECK(config.IsValidConfig()); |
222 DCHECK(!config.is_encrypted()); | 220 DCHECK(!config.is_encrypted()); |
223 DCHECK(decode_cb_.is_null()); | 221 DCHECK(decode_cb_.is_null()); |
224 DCHECK(reset_cb_.is_null()); | 222 DCHECK(reset_cb_.is_null()); |
225 | 223 |
226 weak_this_ = weak_factory_.GetWeakPtr(); | |
227 | |
228 if (!ConfigureDecoder(config)) { | 224 if (!ConfigureDecoder(config)) { |
229 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); | 225 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); |
230 return; | 226 return; |
231 } | 227 } |
232 | 228 |
233 // Success! | 229 // Success! |
234 config_ = config; | 230 config_ = config; |
235 state_ = kNormal; | 231 state_ = kNormal; |
236 status_cb.Run(PIPELINE_OK); | 232 status_cb.Run(PIPELINE_OK); |
237 } | 233 } |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); | 523 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); |
528 return; | 524 return; |
529 } | 525 } |
530 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], | 526 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], |
531 vpx_image->stride[VPX_PLANE_Y], | 527 vpx_image->stride[VPX_PLANE_Y], |
532 vpx_image->d_h, | 528 vpx_image->d_h, |
533 video_frame->get()); | 529 video_frame->get()); |
534 } | 530 } |
535 | 531 |
536 } // namespace media | 532 } // namespace media |
OLD | NEW |