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/gpu_video_decoder.h" | 5 #include "media/filters/gpu_video_decoder.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 | 415 |
416 PictureBufferMap::iterator it = | 416 PictureBufferMap::iterator it = |
417 assigned_picture_buffers_.find(picture.picture_buffer_id()); | 417 assigned_picture_buffers_.find(picture.picture_buffer_id()); |
418 if (it == assigned_picture_buffers_.end()) { | 418 if (it == assigned_picture_buffers_.end()) { |
419 NOTREACHED() << "Missing picture buffer: " << picture.picture_buffer_id(); | 419 NOTREACHED() << "Missing picture buffer: " << picture.picture_buffer_id(); |
420 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); | 420 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); |
421 return; | 421 return; |
422 } | 422 } |
423 const PictureBuffer& pb = it->second; | 423 const PictureBuffer& pb = it->second; |
424 | 424 |
| 425 // Validate picture size from GPU |
| 426 if (picture.size().IsEmpty() || |
| 427 !gfx::Rect(pb.size()).Contains(gfx::Rect(picture.size()))) { |
| 428 LOG(ERROR) << "Invalid picture size: " << pb.size().ToString() |
| 429 << " from PictureBuffer, but " << picture.size().ToString() |
| 430 << " from GPU"; |
| 431 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 432 return; |
| 433 } |
| 434 |
425 // Update frame's timestamp. | 435 // Update frame's timestamp. |
426 base::TimeDelta timestamp; | 436 base::TimeDelta timestamp; |
| 437 // Some of the VDAs don't support and thus don't provide us with visible |
| 438 // size in picture.size, passing coded size instead, so drop it and use |
| 439 // config information instead. |
427 gfx::Rect visible_rect; | 440 gfx::Rect visible_rect; |
428 gfx::Size natural_size; | 441 gfx::Size natural_size; |
429 GetBufferData(picture.bitstream_buffer_id(), ×tamp, &visible_rect, | 442 GetBufferData(picture.bitstream_buffer_id(), ×tamp, &visible_rect, |
430 &natural_size); | 443 &natural_size); |
431 DCHECK(decoder_texture_target_); | 444 DCHECK(decoder_texture_target_); |
432 | 445 |
433 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTexture( | 446 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTexture( |
434 make_scoped_ptr(new gpu::MailboxHolder( | 447 make_scoped_ptr(new gpu::MailboxHolder( |
435 pb.texture_mailbox(), decoder_texture_target_, 0 /* sync_point */)), | 448 pb.texture_mailbox(), decoder_texture_target_, 0 /* sync_point */)), |
436 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::ReleaseMailbox, | 449 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::ReleaseMailbox, |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 DLOG(ERROR) << "VDA Error: " << error; | 615 DLOG(ERROR) << "VDA Error: " << error; |
603 DestroyVDA(); | 616 DestroyVDA(); |
604 } | 617 } |
605 | 618 |
606 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 619 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
607 const { | 620 const { |
608 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 621 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
609 } | 622 } |
610 | 623 |
611 } // namespace media | 624 } // namespace media |
OLD | NEW |