Commit a83e534e authored by David Staessens's avatar David Staessens Committed by Commit Bot

media/gpu/test: Add multiple outstanding encodes test to video encoder tests.

This CL adds a new test to the video_encode_accelerator_tests that
tests multiple outstanding simultaneous encodes.

Bug: 1045825
Test: ./video_encode_accelerator_tests on hana
Change-Id: Iaf7be2b3292b3efd1f7d830dd2d01bd59790ce7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2251610
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792577}
parent 2e2c71b7
...@@ -396,7 +396,8 @@ void VideoEncoderClient::FlushTask() { ...@@ -396,7 +396,8 @@ void VideoEncoderClient::FlushTask() {
// If the encoder does not support flush, immediately consider flushing done. // If the encoder does not support flush, immediately consider flushing done.
if (!encoder_->IsFlushSupported()) { if (!encoder_->IsFlushSupported()) {
FireEvent(VideoEncoder::EncoderEvent::kFlushing); FireEvent(VideoEncoder::EncoderEvent::kFlushing);
FlushDoneTask(true); if (num_outstanding_encode_requests_ == 0)
FlushDoneTask(true);
return; return;
} }
...@@ -424,9 +425,17 @@ void VideoEncoderClient::EncodeDoneTask(base::TimeDelta timestamp) { ...@@ -424,9 +425,17 @@ void VideoEncoderClient::EncodeDoneTask(base::TimeDelta timestamp) {
DCHECK_NE(VideoEncoderClientState::kIdle, encoder_client_state_); DCHECK_NE(VideoEncoderClientState::kIdle, encoder_client_state_);
DVLOGF(4); DVLOGF(4);
FireEvent(VideoEncoder::EncoderEvent::kFrameReleased);
num_outstanding_encode_requests_--; num_outstanding_encode_requests_--;
FireEvent(VideoEncoder::EncoderEvent::kFrameReleased); // If the encoder does not support flushing, we have to manually call
// FlushDoneTask() when the last outstanding encode has been completed.
if ((encoder_client_state_ == VideoEncoderClientState::kFlushing) &&
!encoder_->IsFlushSupported() &&
(num_outstanding_encode_requests_ == 0)) {
FlushDoneTask(true);
}
// Queue the next frame to be encoded. // Queue the next frame to be encoded.
encoder_client_task_runner_->PostTask( encoder_client_task_runner_->PostTask(
......
...@@ -257,6 +257,21 @@ TEST_F(VideoEncoderTest, DestroyBeforeInitialize) { ...@@ -257,6 +257,21 @@ TEST_F(VideoEncoderTest, DestroyBeforeInitialize) {
EXPECT_NE(video_encoder, nullptr); EXPECT_NE(video_encoder, nullptr);
} }
// Encode video from start to end. Multiple buffer encodes will be queued in the
// encoder, without waiting for the result of the previous encode requests.
TEST_F(VideoEncoderTest, FlushAtEndOfStream_MultipleOutstandingDecodes) {
VideoEncoderClientConfig config(g_env->Video(), g_env->Profile());
config.max_outstanding_encode_requests = 4;
auto encoder = CreateVideoEncoder(g_env->Video(), config);
encoder->Encode();
EXPECT_TRUE(encoder->WaitForFlushDone());
EXPECT_EQ(encoder->GetFlushDoneCount(), 1u);
EXPECT_EQ(encoder->GetFrameReleasedCount(), g_env->Video()->NumFrames());
EXPECT_TRUE(encoder->WaitForBitstreamProcessors());
}
// Encode multiple videos simultaneously from start to finish. // Encode multiple videos simultaneously from start to finish.
TEST_F(VideoEncoderTest, FlushAtEndOfStream_MultipleConcurrentEncodes) { TEST_F(VideoEncoderTest, FlushAtEndOfStream_MultipleConcurrentEncodes) {
// The minimal number of concurrent encoders we expect to be supported. // The minimal number of concurrent encoders we expect to be 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