| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 state_(kUninitialized), | 207 state_(kUninitialized), |
| 208 vpx_codec_(NULL), | 208 vpx_codec_(NULL), |
| 209 vpx_codec_alpha_(NULL) {} | 209 vpx_codec_alpha_(NULL) {} |
| 210 | 210 |
| 211 VpxVideoDecoder::~VpxVideoDecoder() { | 211 VpxVideoDecoder::~VpxVideoDecoder() { |
| 212 DCHECK_EQ(kUninitialized, state_); | 212 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 213 CloseDecoder(); | 213 CloseDecoder(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void VpxVideoDecoder::Initialize(const VideoDecoderConfig& config, | 216 void VpxVideoDecoder::Initialize(const VideoDecoderConfig& config, |
| 217 bool low_delay, | 217 bool low_delay, |
| 218 const PipelineStatusCB& status_cb, | 218 const PipelineStatusCB& status_cb, |
| 219 const OutputCB& output_cb) { | 219 const OutputCB& output_cb) { |
| 220 DCHECK(task_runner_->BelongsToCurrentThread()); | 220 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 221 DCHECK(config.IsValidConfig()); | 221 DCHECK(config.IsValidConfig()); |
| 222 DCHECK(!config.is_encrypted()); | 222 DCHECK(!config.is_encrypted()); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 } | 331 } |
| 332 | 332 |
| 333 void VpxVideoDecoder::Reset(const base::Closure& closure) { | 333 void VpxVideoDecoder::Reset(const base::Closure& closure) { |
| 334 DCHECK(task_runner_->BelongsToCurrentThread()); | 334 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 335 DCHECK(decode_cb_.is_null()); | 335 DCHECK(decode_cb_.is_null()); |
| 336 | 336 |
| 337 state_ = kNormal; | 337 state_ = kNormal; |
| 338 task_runner_->PostTask(FROM_HERE, closure); | 338 task_runner_->PostTask(FROM_HERE, closure); |
| 339 } | 339 } |
| 340 | 340 |
| 341 void VpxVideoDecoder::Stop() { | |
| 342 DCHECK(task_runner_->BelongsToCurrentThread()); | |
| 343 | |
| 344 state_ = kUninitialized; | |
| 345 } | |
| 346 | |
| 347 void VpxVideoDecoder::DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer) { | 341 void VpxVideoDecoder::DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer) { |
| 348 DCHECK(task_runner_->BelongsToCurrentThread()); | 342 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 349 DCHECK_NE(state_, kUninitialized); | 343 DCHECK_NE(state_, kUninitialized); |
| 350 DCHECK_NE(state_, kDecodeFinished); | 344 DCHECK_NE(state_, kDecodeFinished); |
| 351 DCHECK_NE(state_, kError); | 345 DCHECK_NE(state_, kError); |
| 352 DCHECK(!decode_cb_.is_null()); | 346 DCHECK(!decode_cb_.is_null()); |
| 353 DCHECK(buffer); | 347 DCHECK(buffer); |
| 354 | 348 |
| 355 // Transition to kDecodeFinished on the first end of stream buffer. | 349 // Transition to kDecodeFinished on the first end of stream buffer. |
| 356 if (state_ == kNormal && buffer->end_of_stream()) { | 350 if (state_ == kNormal && buffer->end_of_stream()) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); | 501 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); |
| 508 return; | 502 return; |
| 509 } | 503 } |
| 510 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], | 504 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], |
| 511 vpx_image->stride[VPX_PLANE_Y], | 505 vpx_image->stride[VPX_PLANE_Y], |
| 512 vpx_image->d_h, | 506 vpx_image->d_h, |
| 513 video_frame->get()); | 507 video_frame->get()); |
| 514 } | 508 } |
| 515 | 509 |
| 516 } // namespace media | 510 } // namespace media |
| OLD | NEW |