Commit fb9bf167 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Chromium LUCI CQ

media/gpu/video_encode_accelerator_tests: Fix ForceKeyFrame test bug

ForceKeyFrame requested after the frames are released specified
times and checks if the first bitstream returned by
VideoEncodeAccelerator is keyframe after requested.
However, releasing frames and producing bitstreams are
asynchronous. This check is wrong. This CL corrects the fix
by seeing if the keyframe exists in a few produced bitstreams
after requested rather than the first bitstream.

Bug: b:176252185
Test: video_encode_accelerator_tests on grunt
Change-Id: I442635a3c1ffefd4fcade9abdd81e74205e931be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2614527Reviewed-by: default avatarDavid Staessens <dstaessens@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842443}
parent 6cd3fb97
......@@ -333,8 +333,14 @@ TEST_F(VideoEncoderTest, ForceKeyFrame) {
// Check if there is no keyframe except the first frame.
EXPECT_EQ(encoder->GetEventCount(VideoEncoder::kKeyFrame), 1u);
encoder->ForceKeyFrame();
// Check if the |middle_frame|+1-th frame is keyframe.
encoder->EncodeUntil(VideoEncoder::kBitstreamReady, middle_frame + 1u);
// Since kFrameReleased and kBitstreamReady events are asynchronous, the
// number of bitstreams being processed is unknown. We check keyframe request
// is applied by seeing if there is a keyframe in a few frames after
// requested. 10 is arbitrarily chosen.
constexpr size_t kKeyFrameRequestWindow = 10u;
encoder->EncodeUntil(VideoEncoder::kBitstreamReady,
std::min(middle_frame + kKeyFrameRequestWindow,
config.num_frames_to_encode));
EXPECT_TRUE(encoder->WaitUntilIdle());
EXPECT_EQ(encoder->GetEventCount(VideoEncoder::kKeyFrame), 2u);
......
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