| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/rtc_video_decoder.h" | 5 #include "content/renderer/media/rtc_video_decoder.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 RTCVideoDecoder::BufferData::BufferData() {} | 59 RTCVideoDecoder::BufferData::BufferData() {} |
| 60 | 60 |
| 61 RTCVideoDecoder::BufferData::~BufferData() {} | 61 RTCVideoDecoder::BufferData::~BufferData() {} |
| 62 | 62 |
| 63 RTCVideoDecoder::RTCVideoDecoder(webrtc::VideoCodecType type, | 63 RTCVideoDecoder::RTCVideoDecoder(webrtc::VideoCodecType type, |
| 64 media::GpuVideoAcceleratorFactories* factories) | 64 media::GpuVideoAcceleratorFactories* factories) |
| 65 : vda_error_counter_(0), | 65 : vda_error_counter_(0), |
| 66 video_codec_type_(type), | 66 video_codec_type_(type), |
| 67 factories_(factories), | 67 factories_(factories), |
| 68 decoder_texture_target_(0), | 68 decoder_texture_target_(0), |
| 69 pixel_format_(media::PIXEL_FORMAT_UNKNOWN), | |
| 70 next_picture_buffer_id_(0), | 69 next_picture_buffer_id_(0), |
| 71 state_(UNINITIALIZED), | 70 state_(UNINITIALIZED), |
| 72 decode_complete_callback_(nullptr), | 71 decode_complete_callback_(nullptr), |
| 73 num_shm_buffers_(0), | 72 num_shm_buffers_(0), |
| 74 next_bitstream_buffer_id_(0), | 73 next_bitstream_buffer_id_(0), |
| 75 reset_bitstream_buffer_id_(ID_INVALID), | 74 reset_bitstream_buffer_id_(ID_INVALID), |
| 76 weak_factory_(this) { | 75 weak_factory_(this) { |
| 77 DCHECK(!factories_->GetTaskRunner()->BelongsToCurrentThread()); | 76 DCHECK(!factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 78 } | 77 } |
| 79 | 78 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 state_ = RESETTING; | 304 state_ = RESETTING; |
| 306 factories_->GetTaskRunner()->PostTask( | 305 factories_->GetTaskRunner()->PostTask( |
| 307 FROM_HERE, | 306 FROM_HERE, |
| 308 base::Bind(&RTCVideoDecoder::ResetInternal, | 307 base::Bind(&RTCVideoDecoder::ResetInternal, |
| 309 weak_factory_.GetWeakPtr())); | 308 weak_factory_.GetWeakPtr())); |
| 310 } | 309 } |
| 311 return WEBRTC_VIDEO_CODEC_OK; | 310 return WEBRTC_VIDEO_CODEC_OK; |
| 312 } | 311 } |
| 313 | 312 |
| 314 void RTCVideoDecoder::ProvidePictureBuffers(uint32_t count, | 313 void RTCVideoDecoder::ProvidePictureBuffers(uint32_t count, |
| 315 media::VideoPixelFormat format, | |
| 316 uint32_t textures_per_buffer, | 314 uint32_t textures_per_buffer, |
| 317 const gfx::Size& size, | 315 const gfx::Size& size, |
| 318 uint32_t texture_target) { | 316 uint32_t texture_target) { |
| 319 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 317 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 320 DVLOG(3) << "ProvidePictureBuffers. texture_target=" << texture_target; | 318 DVLOG(3) << "ProvidePictureBuffers. texture_target=" << texture_target; |
| 321 DCHECK_EQ(1u, textures_per_buffer); | 319 DCHECK_EQ(1u, textures_per_buffer); |
| 322 | 320 |
| 323 if (!vda_) | 321 if (!vda_) |
| 324 return; | 322 return; |
| 325 | 323 |
| 326 std::vector<uint32_t> texture_ids; | 324 std::vector<uint32_t> texture_ids; |
| 327 std::vector<gpu::Mailbox> texture_mailboxes; | 325 std::vector<gpu::Mailbox> texture_mailboxes; |
| 328 decoder_texture_target_ = texture_target; | 326 decoder_texture_target_ = texture_target; |
| 329 | |
| 330 if (format == media::PIXEL_FORMAT_UNKNOWN) | |
| 331 format = media::PIXEL_FORMAT_ARGB; | |
| 332 | |
| 333 if ((pixel_format_ != media::PIXEL_FORMAT_UNKNOWN) && | |
| 334 (format != pixel_format_)) { | |
| 335 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | |
| 336 return; | |
| 337 } | |
| 338 | |
| 339 pixel_format_ = format; | |
| 340 if (!factories_->CreateTextures(count, | 327 if (!factories_->CreateTextures(count, |
| 341 size, | 328 size, |
| 342 &texture_ids, | 329 &texture_ids, |
| 343 &texture_mailboxes, | 330 &texture_mailboxes, |
| 344 decoder_texture_target_)) { | 331 decoder_texture_target_)) { |
| 345 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 332 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 346 return; | 333 return; |
| 347 } | 334 } |
| 348 DCHECK_EQ(count, texture_ids.size()); | 335 DCHECK_EQ(count, texture_ids.size()); |
| 349 DCHECK_EQ(count, texture_mailboxes.size()); | 336 DCHECK_EQ(count, texture_mailboxes.size()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 visible_rect = picture.visible_rect(); | 393 visible_rect = picture.visible_rect(); |
| 407 | 394 |
| 408 const media::PictureBuffer& pb = it->second; | 395 const media::PictureBuffer& pb = it->second; |
| 409 if (visible_rect.IsEmpty() || !gfx::Rect(pb.size()).Contains(visible_rect)) { | 396 if (visible_rect.IsEmpty() || !gfx::Rect(pb.size()).Contains(visible_rect)) { |
| 410 LOG(ERROR) << "Invalid picture size: " << visible_rect.ToString() | 397 LOG(ERROR) << "Invalid picture size: " << visible_rect.ToString() |
| 411 << " should fit in " << pb.size().ToString(); | 398 << " should fit in " << pb.size().ToString(); |
| 412 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 399 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 413 return; | 400 return; |
| 414 } | 401 } |
| 415 | 402 |
| 403 media::VideoPixelFormat pixel_format = vda_->GetOutputFormat(); |
| 404 if (pixel_format == media::PIXEL_FORMAT_UNKNOWN) |
| 405 pixel_format = media::PIXEL_FORMAT_ARGB; |
| 406 |
| 416 scoped_refptr<media::VideoFrame> frame = | 407 scoped_refptr<media::VideoFrame> frame = |
| 417 CreateVideoFrame(picture, pb, timestamp, visible_rect, pixel_format_); | 408 CreateVideoFrame(picture, pb, timestamp, visible_rect, pixel_format); |
| 418 if (!frame) { | 409 if (!frame) { |
| 419 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 410 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 420 return; | 411 return; |
| 421 } | 412 } |
| 422 bool inserted = picture_buffers_at_display_ | 413 bool inserted = picture_buffers_at_display_ |
| 423 .insert(std::make_pair(picture.picture_buffer_id(), | 414 .insert(std::make_pair(picture.picture_buffer_id(), |
| 424 pb.texture_ids()[0])) | 415 pb.texture_ids()[0])) |
| 425 .second; | 416 .second; |
| 426 DCHECK(inserted); | 417 DCHECK(inserted); |
| 427 | 418 |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 | 877 |
| 887 void RTCVideoDecoder::TryResetVDAErrorCounter_Locked() { | 878 void RTCVideoDecoder::TryResetVDAErrorCounter_Locked() { |
| 888 lock_.AssertAcquired(); | 879 lock_.AssertAcquired(); |
| 889 | 880 |
| 890 if (vda_error_counter_ == 0) | 881 if (vda_error_counter_ == 0) |
| 891 return; | 882 return; |
| 892 vda_error_counter_ = 0; | 883 vda_error_counter_ = 0; |
| 893 } | 884 } |
| 894 | 885 |
| 895 } // namespace content | 886 } // namespace content |
| OLD | NEW |