Chromium Code Reviews| 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 video_frame->get()->AddDestructionObserver( | 595 if (*video_frame) { |
| 596 memory_pool_->CreateFrameCallback(vpx_image->fb_priv)); | 596 video_frame->get()->AddDestructionObserver( |
| 597 memory_pool_->CreateFrameCallback(vpx_image->fb_priv)); | |
| 598 } | |
| 597 | 599 |
| 598 UMA_HISTOGRAM_COUNTS("Media.Vpx.VideoDecoderBuffersInUseByDecoder", | 600 UMA_HISTOGRAM_COUNTS("Media.Vpx.VideoDecoderBuffersInUseByDecoder", |
| 599 memory_pool_->NumberOfFrameBuffersInUseByDecoder()); | 601 memory_pool_->NumberOfFrameBuffersInUseByDecoder()); |
| 600 UMA_HISTOGRAM_COUNTS( | 602 UMA_HISTOGRAM_COUNTS( |
| 601 "Media.Vpx.VideoDecoderBuffersInUseByDecoderAndVideoFrame", | 603 "Media.Vpx.VideoDecoderBuffersInUseByDecoderAndVideoFrame", |
| 602 memory_pool_->NumberOfFrameBuffersInUseByDecoderAndVideoFrame()); | 604 memory_pool_->NumberOfFrameBuffersInUseByDecoderAndVideoFrame()); |
| 603 | 605 |
| 604 return true; | 606 return true; |
|
Pawel Osciak
2016/01/15 01:00:55
Should we be returning true if !*video_frame (and
emircan
2016/01/15 01:18:57
Early return false and not adding to UMAs makes mo
| |
| 605 } | 607 } |
| 606 | 608 |
| 607 DCHECK(codec_format == PIXEL_FORMAT_YV12 || | 609 DCHECK(codec_format == PIXEL_FORMAT_YV12 || |
| 608 codec_format == PIXEL_FORMAT_YV12A); | 610 codec_format == PIXEL_FORMAT_YV12A); |
| 609 | 611 |
| 610 *video_frame = frame_pool_.CreateFrame( | 612 *video_frame = frame_pool_.CreateFrame( |
| 611 codec_format, visible_size, gfx::Rect(visible_size), | 613 codec_format, visible_size, gfx::Rect(visible_size), |
| 612 config_.natural_size(), kNoTimestamp()); | 614 config_.natural_size(), kNoTimestamp()); |
| 615 if (!(*video_frame)) | |
| 616 return false; | |
| 613 | 617 |
| 614 libyuv::I420Copy( | 618 libyuv::I420Copy( |
| 615 vpx_image->planes[VPX_PLANE_Y], vpx_image->stride[VPX_PLANE_Y], | 619 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], | 620 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], | 621 vpx_image->planes[VPX_PLANE_V], vpx_image->stride[VPX_PLANE_V], |
| 618 (*video_frame)->visible_data(VideoFrame::kYPlane), | 622 (*video_frame)->visible_data(VideoFrame::kYPlane), |
| 619 (*video_frame)->stride(VideoFrame::kYPlane), | 623 (*video_frame)->stride(VideoFrame::kYPlane), |
| 620 (*video_frame)->visible_data(VideoFrame::kUPlane), | 624 (*video_frame)->visible_data(VideoFrame::kUPlane), |
| 621 (*video_frame)->stride(VideoFrame::kUPlane), | 625 (*video_frame)->stride(VideoFrame::kUPlane), |
| 622 (*video_frame)->visible_data(VideoFrame::kVPlane), | 626 (*video_frame)->visible_data(VideoFrame::kVPlane), |
| 623 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), | 627 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), |
| 624 coded_size.height()); | 628 coded_size.height()); |
| 625 | 629 |
| 626 return true; | 630 return true; |
| 627 } | 631 } |
| 628 | 632 |
| 629 } // namespace media | 633 } // namespace media |
| OLD | NEW |