Commit 2682e578 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu: Check if VideoFrame is not nullptr in VideoFrameMapper

VideoFrameMapper assumes a given VideoFrame on Map() is not nullptr. This
causes a test crash if the VideoFrame is nullptr. We shall handle the case
as error rather than crash.

Bug: 1020776
Test: VD test on atlas
Change-Id: Ifa49a405cf33e16f2df0e5e5079e7df253a5bb1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1911062Reviewed-by: default avatarDavid Staessens <dstaessens@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714799}
parent 16f27b21
......@@ -101,6 +101,11 @@ GenericDmaBufVideoFrameMapper::GenericDmaBufVideoFrameMapper(
scoped_refptr<VideoFrame> GenericDmaBufVideoFrameMapper::Map(
scoped_refptr<const VideoFrame> video_frame) const {
if (!video_frame) {
LOG(ERROR) << "Video frame is nullptr";
return nullptr;
}
if (video_frame->storage_type() != VideoFrame::StorageType::STORAGE_DMABUFS) {
VLOGF(1) << "VideoFrame's storage type is not DMABUF: "
<< video_frame->storage_type();
......
......@@ -22,6 +22,11 @@ GpuMemoryBufferVideoFrameMapper::GpuMemoryBufferVideoFrameMapper(
scoped_refptr<VideoFrame> GpuMemoryBufferVideoFrameMapper::Map(
scoped_refptr<const VideoFrame> video_frame) const {
if (!video_frame) {
LOG(ERROR) << "Video frame is nullptr";
return nullptr;
}
if (video_frame->storage_type() !=
VideoFrame::StorageType::STORAGE_GPU_MEMORY_BUFFER) {
VLOGF(1) << "VideoFrame's storage type is not GPU_MEMORY_BUFFER: "
......
......@@ -132,6 +132,11 @@ void VideoFrameValidator::ProcessVideoFrame(
size_t frame_index) {
DCHECK_CALLED_ON_VALID_SEQUENCE(validator_sequence_checker_);
if (!video_frame) {
LOG(ERROR) << "Video frame is nullptr";
return;
}
base::AutoLock auto_lock(frame_validator_lock_);
num_frames_validating_++;
......
......@@ -32,6 +32,7 @@ scoped_refptr<VideoFrame> CreateMappedVideoFrame(
const gfx::Rect& visible_rect,
const base::TimeDelta timestamp,
std::unique_ptr<ScopedVAImage> va_image) {
DCHECK(va_image);
// ScopedVAImage manages the resource of mapped data. That is, ScopedVAImage's
// dtor releases the mapped resource.
const size_t num_planes = VideoFrame::NumPlanes(format);
......@@ -118,6 +119,11 @@ VaapiDmaBufVideoFrameMapper::~VaapiDmaBufVideoFrameMapper() {}
scoped_refptr<VideoFrame> VaapiDmaBufVideoFrameMapper::Map(
scoped_refptr<const VideoFrame> video_frame) const {
DCHECK(vaapi_wrapper_);
if (!video_frame) {
LOG(ERROR) << "Video frame is nullptr";
return nullptr;
}
if (!video_frame->HasDmaBufs()) {
return nullptr;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment