Commit 93c4034f authored by David Staessens's avatar David Staessens Committed by Commit Bot

media/gpu/test: Fixed missing frames in video decoder tests in allocate mode.

When running the new video decoder tests in allocate mode, sometimes the video
player will not receive the last frame, making the tests fails. This happens
because the WrapVideoFrame method is only supported in import mode, and a
workaround is used in allocate mode.

To fix this issue logic is added to manually wrap frames in a similar way when
using allocate mode. This is also required to run the video decoder performance
tests on allocate-only platforms.

TEST=./video_decode_accelerator_tests on nyan_big

BUG=957808

Change-Id: Ibf29e9f716beef8aaf1a27904e2220399418c209
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1688773
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676259}
parent 08244f71
...@@ -280,33 +280,33 @@ void TestVDAVideoDecoder::PictureReady(const Picture& picture) { ...@@ -280,33 +280,33 @@ void TestVDAVideoDecoder::PictureReady(const Picture& picture) {
ASSERT_NE(timestamp_it, decode_start_timestamps_.end()); ASSERT_NE(timestamp_it, decode_start_timestamps_.end());
video_frame->set_timestamp(timestamp_it->second); video_frame->set_timestamp(timestamp_it->second);
// When using import mode, we wrap the video frame in another video frame that scoped_refptr<VideoFrame> wrapped_video_frame = nullptr;
// calls ReusePictureBufferTask() upon destruction. When the renderer and
// video frame processors are done using the video frame, the associated // Wrap the video frame in another frame that calls ReusePictureBufferTask()
// picture buffer will automatically be flagged for reuse. // upon destruction. When the renderer and video frame processors are done
if (output_mode_ == VideoDecodeAccelerator::Config::OutputMode::IMPORT) { // using the video frame, the associated picture buffer will automatically be
base::OnceClosure reuse_cb = BindToCurrentLoop( // flagged for reuse. WrapVideoFrame() is not supported for texture-based
base::BindOnce(&TestVDAVideoDecoder::ReusePictureBufferTask, weak_this_, // video frames (see http://crbug/362521) so we work around this by creating a
picture.picture_buffer_id())); // new video frame using the same mailbox.
if (!video_frame->HasTextures()) {
scoped_refptr<VideoFrame> wrapped_video_frame = VideoFrame::WrapVideoFrame( wrapped_video_frame = VideoFrame::WrapVideoFrame(
*video_frame, video_frame->format(), picture.visible_rect(), *video_frame, video_frame->format(), picture.visible_rect(),
picture.visible_rect().size()); picture.visible_rect().size());
wrapped_video_frame->AddDestructionObserver(std::move(reuse_cb)); } else {
gpu::MailboxHolder mailbox_holders[media::VideoFrame::kMaxPlanes];
output_cb_.Run(wrapped_video_frame); mailbox_holders[0] = video_frame->mailbox_holder(0);
wrapped_video_frame = VideoFrame::WrapNativeTextures(
video_frame->format(), mailbox_holders, VideoFrame::ReleaseMailboxCB(),
video_frame->coded_size(), video_frame->visible_rect(),
video_frame->natural_size(), video_frame->timestamp());
} }
// Wrapping a video frame inside another video frame is not supported in DCHECK(wrapped_video_frame);
// allocate mode, so we have to render the frame and return the picture buffer base::OnceClosure reuse_cb = BindToCurrentLoop(
// synchronously here. See http://crbug/362521. base::BindOnce(&TestVDAVideoDecoder::ReusePictureBufferTask, weak_this_,
if (output_mode_ == VideoDecodeAccelerator::Config::OutputMode::ALLOCATE) { picture.picture_buffer_id()));
PostTaskAndReply( wrapped_video_frame->AddDestructionObserver(std::move(reuse_cb));
FROM_HERE, base::BindOnce(output_cb_, video_frame), output_cb_.Run(std::move(wrapped_video_frame));
base::BindOnce(&TestVDAVideoDecoder::ReusePictureBufferTask, weak_this_,
picture.picture_buffer_id()));
return;
}
} }
// Called when a picture buffer is ready to be re-used. // Called when a picture buffer is ready to be re-used.
......
...@@ -337,8 +337,6 @@ void VideoDecoderClient::DecodeDoneTask(media::DecodeStatus status) { ...@@ -337,8 +337,6 @@ void VideoDecoderClient::DecodeDoneTask(media::DecodeStatus status) {
void VideoDecoderClient::FrameReadyTask(scoped_refptr<VideoFrame> video_frame) { void VideoDecoderClient::FrameReadyTask(scoped_refptr<VideoFrame> video_frame) {
DCHECK_CALLED_ON_VALID_SEQUENCE(decoder_client_sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(decoder_client_sequence_checker_);
// When using allocate mode the frame will be reused after this function, so
// the frame should be rendered synchronously in this case.
frame_renderer_->RenderFrame(video_frame); frame_renderer_->RenderFrame(video_frame);
// When using allocate mode, direct texture memory access is not supported. // When using allocate mode, direct texture memory access is not supported.
......
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