Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: media/filters/vpx_video_decoder.cc

Issue 1476523005: Verify returned frames from media::VideoFrame::Wrap*() methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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->get())
596 memory_pool_->CreateFrameCallback(vpx_image->fb_priv)); 596 video_frame->get()->AddDestructionObserver(
597 memory_pool_->CreateFrameCallback(vpx_image->fb_priv));
mcasas 2016/01/12 17:46:16 Needs {} You can test if (video_frame) directly.
emircan 2016/01/14 23:07:40 Done.
597 598
598 UMA_HISTOGRAM_COUNTS("Media.Vpx.VideoDecoderBuffersInUseByDecoder", 599 UMA_HISTOGRAM_COUNTS("Media.Vpx.VideoDecoderBuffersInUseByDecoder",
599 memory_pool_->NumberOfFrameBuffersInUseByDecoder()); 600 memory_pool_->NumberOfFrameBuffersInUseByDecoder());
600 UMA_HISTOGRAM_COUNTS( 601 UMA_HISTOGRAM_COUNTS(
601 "Media.Vpx.VideoDecoderBuffersInUseByDecoderAndVideoFrame", 602 "Media.Vpx.VideoDecoderBuffersInUseByDecoderAndVideoFrame",
602 memory_pool_->NumberOfFrameBuffersInUseByDecoderAndVideoFrame()); 603 memory_pool_->NumberOfFrameBuffersInUseByDecoderAndVideoFrame());
603 604
604 return true; 605 return true;
605 } 606 }
606 607
607 DCHECK(codec_format == PIXEL_FORMAT_YV12 || 608 DCHECK(codec_format == PIXEL_FORMAT_YV12 ||
608 codec_format == PIXEL_FORMAT_YV12A); 609 codec_format == PIXEL_FORMAT_YV12A);
609 610
610 *video_frame = frame_pool_.CreateFrame( 611 *video_frame = frame_pool_.CreateFrame(
611 codec_format, visible_size, gfx::Rect(visible_size), 612 codec_format, visible_size, gfx::Rect(visible_size),
612 config_.natural_size(), kNoTimestamp()); 613 config_.natural_size(), kNoTimestamp());
614 if (!(*video_frame))
mcasas 2016/01/12 17:46:16 if (!video_frame) ?
emircan 2016/01/14 23:07:40 Done.
615 return false;
613 616
614 libyuv::I420Copy( 617 libyuv::I420Copy(
615 vpx_image->planes[VPX_PLANE_Y], vpx_image->stride[VPX_PLANE_Y], 618 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], 619 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], 620 vpx_image->planes[VPX_PLANE_V], vpx_image->stride[VPX_PLANE_V],
618 (*video_frame)->visible_data(VideoFrame::kYPlane), 621 (*video_frame)->visible_data(VideoFrame::kYPlane),
619 (*video_frame)->stride(VideoFrame::kYPlane), 622 (*video_frame)->stride(VideoFrame::kYPlane),
620 (*video_frame)->visible_data(VideoFrame::kUPlane), 623 (*video_frame)->visible_data(VideoFrame::kUPlane),
621 (*video_frame)->stride(VideoFrame::kUPlane), 624 (*video_frame)->stride(VideoFrame::kUPlane),
622 (*video_frame)->visible_data(VideoFrame::kVPlane), 625 (*video_frame)->visible_data(VideoFrame::kVPlane),
623 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), 626 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(),
624 coded_size.height()); 627 coded_size.height());
625 628
626 return true; 629 return true;
627 } 630 }
628 631
629 } // namespace media 632 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698