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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 *video_frame = VideoFrame::WrapExternalYuvData( | 585 *video_frame = VideoFrame::WrapExternalYuvData( |
586 codec_format, | 586 codec_format, |
587 coded_size, gfx::Rect(visible_size), config_.natural_size(), | 587 coded_size, gfx::Rect(visible_size), config_.natural_size(), |
588 vpx_image->stride[VPX_PLANE_Y], | 588 vpx_image->stride[VPX_PLANE_Y], |
589 vpx_image->stride[VPX_PLANE_U], | 589 vpx_image->stride[VPX_PLANE_U], |
590 vpx_image->stride[VPX_PLANE_V], | 590 vpx_image->stride[VPX_PLANE_V], |
591 vpx_image->planes[VPX_PLANE_Y], | 591 vpx_image->planes[VPX_PLANE_Y], |
592 vpx_image->planes[VPX_PLANE_U], | 592 vpx_image->planes[VPX_PLANE_U], |
593 vpx_image->planes[VPX_PLANE_V], | 593 vpx_image->planes[VPX_PLANE_V], |
594 kNoTimestamp()); | 594 kNoTimestamp()); |
| 595 if (!(*video_frame)) |
| 596 return false; |
| 597 |
595 video_frame->get()->AddDestructionObserver( | 598 video_frame->get()->AddDestructionObserver( |
596 memory_pool_->CreateFrameCallback(vpx_image->fb_priv)); | 599 memory_pool_->CreateFrameCallback(vpx_image->fb_priv)); |
597 | 600 |
598 UMA_HISTOGRAM_COUNTS("Media.Vpx.VideoDecoderBuffersInUseByDecoder", | 601 UMA_HISTOGRAM_COUNTS("Media.Vpx.VideoDecoderBuffersInUseByDecoder", |
599 memory_pool_->NumberOfFrameBuffersInUseByDecoder()); | 602 memory_pool_->NumberOfFrameBuffersInUseByDecoder()); |
600 UMA_HISTOGRAM_COUNTS( | 603 UMA_HISTOGRAM_COUNTS( |
601 "Media.Vpx.VideoDecoderBuffersInUseByDecoderAndVideoFrame", | 604 "Media.Vpx.VideoDecoderBuffersInUseByDecoderAndVideoFrame", |
602 memory_pool_->NumberOfFrameBuffersInUseByDecoderAndVideoFrame()); | 605 memory_pool_->NumberOfFrameBuffersInUseByDecoderAndVideoFrame()); |
603 | 606 |
604 return true; | 607 return true; |
605 } | 608 } |
606 | 609 |
607 DCHECK(codec_format == PIXEL_FORMAT_YV12 || | 610 DCHECK(codec_format == PIXEL_FORMAT_YV12 || |
608 codec_format == PIXEL_FORMAT_YV12A); | 611 codec_format == PIXEL_FORMAT_YV12A); |
609 | 612 |
610 *video_frame = frame_pool_.CreateFrame( | 613 *video_frame = frame_pool_.CreateFrame( |
611 codec_format, visible_size, gfx::Rect(visible_size), | 614 codec_format, visible_size, gfx::Rect(visible_size), |
612 config_.natural_size(), kNoTimestamp()); | 615 config_.natural_size(), kNoTimestamp()); |
| 616 if (!(*video_frame)) |
| 617 return false; |
613 | 618 |
614 libyuv::I420Copy( | 619 libyuv::I420Copy( |
615 vpx_image->planes[VPX_PLANE_Y], vpx_image->stride[VPX_PLANE_Y], | 620 vpx_image->planes[VPX_PLANE_Y], vpx_image->stride[VPX_PLANE_Y], |
616 vpx_image->planes[VPX_PLANE_U], vpx_image->stride[VPX_PLANE_U], | 621 vpx_image->planes[VPX_PLANE_U], vpx_image->stride[VPX_PLANE_U], |
617 vpx_image->planes[VPX_PLANE_V], vpx_image->stride[VPX_PLANE_V], | 622 vpx_image->planes[VPX_PLANE_V], vpx_image->stride[VPX_PLANE_V], |
618 (*video_frame)->visible_data(VideoFrame::kYPlane), | 623 (*video_frame)->visible_data(VideoFrame::kYPlane), |
619 (*video_frame)->stride(VideoFrame::kYPlane), | 624 (*video_frame)->stride(VideoFrame::kYPlane), |
620 (*video_frame)->visible_data(VideoFrame::kUPlane), | 625 (*video_frame)->visible_data(VideoFrame::kUPlane), |
621 (*video_frame)->stride(VideoFrame::kUPlane), | 626 (*video_frame)->stride(VideoFrame::kUPlane), |
622 (*video_frame)->visible_data(VideoFrame::kVPlane), | 627 (*video_frame)->visible_data(VideoFrame::kVPlane), |
623 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), | 628 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), |
624 coded_size.height()); | 629 coded_size.height()); |
625 | 630 |
626 return true; | 631 return true; |
627 } | 632 } |
628 | 633 |
629 } // namespace media | 634 } // namespace media |
OLD | NEW |